From: Stephen D. <sd...@gm...> - 2005-06-10 16:49:28
|
For future reference, you can hande this by using the Ns_ObjvObj option/arg type which just gives you back the underlying Tcl object.=20 You can then handle it however you like. On 6/10/05, Vlad Seryakov <vl...@cr...> wrote: > yes, parsing should check for nulls an dlimits, just to see if idea is > coorrect. obkv parsing will not work here because i will need change on > the fly TclObjvString and TclObjvByteArray. >=20 > if (objc > param && !strcmp(Tcl_GetString(objv[param]),"-binary")) { > binary =3D 1; > param++; > } > if (objc > param && Tcl_GetIntFromObj(interp, objv[param++], > &status) !=3D TCL_OK) { > return TCL_ERROR; > } > if (objc > param) { > type =3D Tcl_GetString(objv[param++]); > } > if (objc > param) { > if (binary !=3D 0) { > data =3D Tcl_GetByteArrayFromObj(objv[param], &len); > } else { > data =3D Tcl_GetStringFromObj(objv[param], &len); > } > } >=20 >=20 > Zoran Vasiljevic wrote: > > > > Am 10.06.2005 um 17:50 schrieb Vlad Seryakov: > > > >> Second try :-))) > > > > > > You'd get (probably) a sigsegv if somebody says: > > > > ns_return -binary 200 > > > > Yes, this arg parsing can be a PITA. Therefore I like > > Stephens tclobjv code :-) > > Unfortunately, it won't do the boolean flags, but we've > > discussed that already many times. > > > > I'd still strenghten out the parsing with objc checking. > > > > Zoran > > > >> > >> int > >> NsTclReturnObjCmd(ClientData arg, Tcl_Interp *interp, int objc, > >> Tcl_Obj *CONST objv[]) > >> { > >> Ns_Conn *conn; > >> unsigned char *data =3D 0, *type =3D 0; > >> int result, param =3D 1, status =3D 0, len =3D 0, binary =3D 0; > >> > >> if (!strcmp(Tcl_GetString(objv[param]),"-binary")) { > >> binary =3D 1; > >> param++; > >> } > >> if (Tcl_GetIntFromObj(interp, objv[param++], &status) !=3D TCL_OK)= { > >> return TCL_ERROR; > >> } > >> type =3D Tcl_GetString(objv[param++]); > >> if (binary !=3D 0) { > >> data =3D Tcl_GetByteArrayFromObj(objv[param], &len); > >> } else { > >> data =3D Tcl_GetStringFromObj(objv[param], &len); > >> } > >> if (data =3D=3D NULL || type =3D=3D NULL || status =3D=3D 0) { > >> Tcl_WrongNumArgs(interp, 1, objv, "?-binary? status type > >> string"); > >> return TCL_ERROR; > >> } > >> if (GetConn(arg, interp, &conn) !=3D TCL_OK) { > >> return TCL_ERROR; > >> } > >> if(binary !=3D 0) { > >> result =3D Ns_ConnReturnData(conn, status, data, len, type); > >> } else { > >> result =3D Ns_ConnReturnCharData(conn, status, data, len, type)= ; > >> } > >> return Result(interp, result); > >> } > >> > >> > >> Zoran Vasiljevic wrote: > >> > >>> Am 10.06.2005 um 17:23 schrieb Vlad Seryakov: > >>> > >>>> How about this, i tested it : > >>>> > >>>> int > >>>> NsTclReturnObjCmd(ClientData arg, Tcl_Interp *interp, int objc, > >>>> Tcl_Obj *CONST objv[]) > >>>> > >>>> > >>> Hm... I would say, if somebody wanted to do: > >>> ns_return 200 text/plain -binary > >>> you'd have a problem, right? > >>> Zoran > >>> ------------------------------------------------------- > >>> This SF.Net email is sponsored by: NEC IT Guy Games. How far can > >>> you shotput > >>> a projector? How fast can you ride your desk chair down the office > >>> luge track? > >>> If you want to score the big prize, get to know the little guy. > >>> Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=3D2= 0 > >>> _______________________________________________ > >>> naviserver-devel mailing list > >>> nav...@li... > >>> https://lists.sourceforge.net/lists/listinfo/naviserver-devel > >>> > >> > >> -- > >> Vlad Seryakov > >> 571 262-8608 office > >> vl...@cr... > >> http://www.crystalballinc.com/vlad/ > >> > >> > >> ------------------------------------------------------- > >> This SF.Net email is sponsored by: NEC IT Guy Games. How far can you > >> shotput > >> a projector? How fast can you ride your desk chair down the office > >> luge track? > >> If you want to score the big prize, get to know the little guy. Play > >> to win an NEC 61" plasma display: http://www.necitguy.com/?r=3D20 > >> _______________________________________________ > >> naviserver-devel mailing list > >> nav...@li... > >> https://lists.sourceforge.net/lists/listinfo/naviserver-devel > >> > > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by: NEC IT Guy Games. How far can you > > shotput > > a projector? How fast can you ride your desk chair down the office luge > > track? > > If you want to score the big prize, get to know the little guy. Play t= o > > win an NEC 61" plasma display: http://www.necitguy.com/?r=3D20 > > _______________________________________________ > > naviserver-devel mailing list > > nav...@li... > > https://lists.sourceforge.net/lists/listinfo/naviserver-devel >=20 > -- > Vlad Seryakov > 571 262-8608 office > vl...@cr... > http://www.crystalballinc.com/vlad/ >=20 >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by: NEC IT Guy Games. How far can you sho= tput > a projector? How fast can you ride your desk chair down the office luge t= rack? > If you want to score the big prize, get to know the little guy. > Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=3D20 > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > |