From: Stephen D. <sd...@gm...> - 2005-06-10 00:08:29
|
Before you cvs commit, you must make test. Two tests are broken...=20 We're strugeling for tests, but tclresp.c is one file that does have a reasonably complete set. Can you add some for the new commands?=20 Also, the cut 'n paste comment for Ns_ObjvByteArray is no longer correct. I was wondering, is ns_returnbinary necessary? What if ns_return was modified to check the type of it's data arg, and if it's byterray, send using Ns_ConnReturnData. Would this work? On 6/8/05, Vlad Seryakov <ser...@us...> wrote: > Update of /cvsroot/naviserver/naviserver/nsd > In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15813/nsd >=20 > Modified Files: > tclobjv.c tclresp.c > Log Message: > Added -binary flag to ns_respond to return binary data without encoding c= onversion >=20 >=20 > Index: tclobjv.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvsroot/naviserver/naviserver/nsd/tclobjv.c,v > retrieving revision 1.7 > retrieving revision 1.8 > diff -C2 -d -r1.7 -r1.8 > *** tclobjv.c 15 May 2005 07:47:21 -0000 1.7 > --- tclobjv.c 8 Jun 2005 20:27:12 -0000 1.8 > *************** > *** 310,313 **** > --- 310,352 ---- > *---------------------------------------------------------------------= - > * > + * Ns_ObjvByteArray -- > + * > + * Consume exactly one argument, returning a pointer to it's > + * cstring into *spec->dest. > + * > + * If spec->arg is !=3D NULL it is assumed to be a pointer to an > + * int and the returned string length will be left in it. > + * > + * Results: > + * TCL_OK or TCL_ERROR. > + * > + * Side effects: > + * None. > + * > + *---------------------------------------------------------------------= - > + */ > + > + int > + Ns_ObjvByteArray(Ns_ObjvSpec *spec, Tcl_Interp *interp, int *objcPtr, > + Tcl_Obj *CONST objv[]) > + { > + unsigned char **dest =3D spec->dest; > + > + if (*objcPtr > 0) { > + if (spec->arg =3D=3D NULL) { > + *dest =3D Tcl_GetByteArrayFromObj(objv[0],0); > + } else { > + *dest =3D Tcl_GetByteArrayFromObj(objv[0], (int *) spec->ar= g); > + } > + *objcPtr -=3D 1; > + return TCL_OK; > + } > + return TCL_ERROR; > + } > + > + > + /* > + *---------------------------------------------------------------------= - > + * > * Ns_ObjvObj -- > * >=20 > Index: tclresp.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvsroot/naviserver/naviserver/nsd/tclresp.c,v > retrieving revision 1.4 > retrieving revision 1.5 > diff -C2 -d -r1.4 -r1.5 > *** tclresp.c 8 Jun 2005 20:13:12 -0000 1.4 > --- tclresp.c 8 Jun 2005 20:27:12 -0000 1.5 > *************** > *** 252,256 **** > Ns_Conn *conn; > int status =3D 200, length =3D -1; > ! char *type =3D "*/*", *setid =3D NULL; > char *string =3D NULL, *filename =3D NULL, *chanid =3D NULL; > Ns_Set *set =3D NULL; > --- 252,256 ---- > Ns_Conn *conn; > int status =3D 200, length =3D -1; > ! char *type =3D "*/*", *setid =3D NULL, *binary =3D NULL; > char *string =3D NULL, *filename =3D NULL, *chanid =3D NULL; > Ns_Set *set =3D NULL; > *************** > *** 259,269 **** >=20 > Ns_ObjvSpec opts[] =3D { > ! {"-status", Ns_ObjvInt, &status, NULL}, > ! {"-type", Ns_ObjvString, &type, NULL}, > ! {"-length", Ns_ObjvInt, &length, NULL}, > ! {"-headers", Ns_ObjvString, &setid, NULL}, > ! {"-string", Ns_ObjvString, &string, NULL}, > ! {"-file", Ns_ObjvString, &filename, NULL}, > ! {"-fileid", Ns_ObjvString, &chanid, NULL}, > {NULL, NULL, NULL, NULL} > }; > --- 259,270 ---- >=20 > Ns_ObjvSpec opts[] =3D { > ! {"-status", Ns_ObjvInt, &status, NULL}, > ! {"-type", Ns_ObjvString, &type, NULL}, > ! {"-length", Ns_ObjvInt, &length, NULL}, > ! {"-headers", Ns_ObjvString, &setid, NULL}, > ! {"-string", Ns_ObjvString, &string, NULL}, > ! {"-file", Ns_ObjvString, &filename, NULL}, > ! {"-fileid", Ns_ObjvString, &chanid, NULL}, > ! {"-binary", Ns_ObjvByteArray, &binary, &length}, > {NULL, NULL, NULL, NULL} > }; > *************** > *** 277,282 **** > return TCL_ERROR; > } > ! if ((string !=3D NULL) + (filename !=3D NULL) + (chanid !=3D NULL) = !=3D 1) { > ! Tcl_SetResult(interp, "must specify only one of -string, -file = " > "or -fileid", TCL_STATIC); > return TCL_ERROR; > --- 278,283 ---- > return TCL_ERROR; > } > ! if ((binary !=3D NULL) + (string !=3D NULL) + (filename !=3D NULL) = + (chanid !=3D NULL) !=3D 1) { > ! Tcl_SetResult(interp, "must specify only one of -string, -file,= -binary " > "or -fileid", TCL_STATIC); > return TCL_ERROR; > *************** > *** 313,316 **** > --- 314,324 ---- > retval =3D Ns_ConnReturnFile(conn, status, type, filename); >=20 > + } else if (binary !=3D NULL) { > + /* > + * We'll be returning a binary data > + */ > + > + retval =3D Ns_ConnReturnData(conn, status, binary, length, type= ); > + > } else { > /* |
From: Zoran V. <zv...@ar...> - 2005-06-10 16:03:23
|
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 = 0, *type = 0; > int result, param = 1, status = 0, len = 0, binary = 0; > > if (!strcmp(Tcl_GetString(objv[param]),"-binary")) { > binary = 1; > param++; > } > if (Tcl_GetIntFromObj(interp, objv[param++], &status) != TCL_OK) { > return TCL_ERROR; > } > type = Tcl_GetString(objv[param++]); > if (binary != 0) { > data = Tcl_GetByteArrayFromObj(objv[param], &len); > } else { > data = Tcl_GetStringFromObj(objv[param], &len); > } > if (data == NULL || type == NULL || status == 0) { > Tcl_WrongNumArgs(interp, 1, objv, "?-binary? status type > string"); > return TCL_ERROR; > } > if (GetConn(arg, interp, &conn) != TCL_OK) { > return TCL_ERROR; > } > if(binary != 0) { > result = Ns_ConnReturnData(conn, status, data, len, type); > } else { > result = 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=20 >> _______________________________________________ >> 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=20 > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > |
From: Stephen D. <sd...@gm...> - 2005-06-10 16:50:10
|
On 6/10/05, Zoran Vasiljevic <zv...@ar...> wrote: >=20 > Am 10.06.2005 um 17:50 schrieb Vlad Seryakov: >=20 > > Second try :-))) >=20 > You'd get (probably) a sigsegv if somebody says: >=20 > ns_return -binary 200 >=20 > 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. Yes it will! ns_parseargs doesn't expose this, but it's avaialble to C cod= e. > I'd still strenghten out the parsing with objc checking. >=20 > Zoran >=20 > > > > 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=3D20 > >> _______________________________________________ > >> 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 > > >=20 >=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 > |
From: Vlad S. <vl...@cr...> - 2005-06-10 16:20:01
|
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. if (objc > param && !strcmp(Tcl_GetString(objv[param]),"-binary")) { binary = 1; param++; } if (objc > param && Tcl_GetIntFromObj(interp, objv[param++], &status) != TCL_OK) { return TCL_ERROR; } if (objc > param) { type = Tcl_GetString(objv[param++]); } if (objc > param) { if (binary != 0) { data = Tcl_GetByteArrayFromObj(objv[param], &len); } else { data = Tcl_GetStringFromObj(objv[param], &len); } } 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 = 0, *type = 0; >> int result, param = 1, status = 0, len = 0, binary = 0; >> >> if (!strcmp(Tcl_GetString(objv[param]),"-binary")) { >> binary = 1; >> param++; >> } >> if (Tcl_GetIntFromObj(interp, objv[param++], &status) != TCL_OK) { >> return TCL_ERROR; >> } >> type = Tcl_GetString(objv[param++]); >> if (binary != 0) { >> data = Tcl_GetByteArrayFromObj(objv[param], &len); >> } else { >> data = Tcl_GetStringFromObj(objv[param], &len); >> } >> if (data == NULL || type == NULL || status == 0) { >> Tcl_WrongNumArgs(interp, 1, objv, "?-binary? status type >> string"); >> return TCL_ERROR; >> } >> if (GetConn(arg, interp, &conn) != TCL_OK) { >> return TCL_ERROR; >> } >> if(binary != 0) { >> result = Ns_ConnReturnData(conn, status, data, len, type); >> } else { >> result = 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=20 >>> _______________________________________________ >>> 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=20 >> _______________________________________________ >> 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 to > win an NEC 61" plasma display: http://www.necitguy.com/?r=20 > _______________________________________________ > 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/ |
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 > |
From: Vlad S. <vl...@cr...> - 2005-06-10 00:31:45
|
I have no failed tests Tests running in interp: /home/vlad/src/naviserver/nsd/nsd Tests located in: /home/vlad/src/naviserver/tests Tests running in: /home/vlad/src/naviserver/tests Temporary files stored in /home/vlad/src/naviserver/tests Test files sourced into current interpreter Running tests that match: * Skipping test files that match: l.*.test Only running test files that match: *.test Tests began at Thu Jun 09 08:30:29 PM EDT 2005 http.test ns_addrbyhost.test ns_adp_compress.test [09/Jun/2005:20:30:29][5516.3073625008][-conn:test::0] Notice: encoding: loaded: iso8859-1 ns_conn_host.test ns_hashpath.test ns_hostbyaddr.test ns_hrefs.test ns_nsv.test ns_pagepath.test ns_parseargs.test ns_serverpath.test ns_urlencode.test tclresp.test Tests ended at Thu Jun 09 08:30:30 PM EDT 2005 all.tcl: Total 193 Passed 193 Skipped 0 Failed 0 Sourced 13 Test Files. Stephen Deasey wrote: > Before you cvs commit, you must make test. Two tests are broken... > We're strugeling for tests, but tclresp.c is one file that does have a > reasonably complete set. Can you add some for the new commands? > Also, the cut 'n paste comment for Ns_ObjvByteArray is no longer > correct. > > I was wondering, is ns_returnbinary necessary? What if ns_return was > modified to check the type of it's data arg, and if it's byterray, > send using Ns_ConnReturnData. Would this work? > > > > > On 6/8/05, Vlad Seryakov <ser...@us...> wrote: > >>Update of /cvsroot/naviserver/naviserver/nsd >>In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15813/nsd >> >>Modified Files: >> tclobjv.c tclresp.c >>Log Message: >>Added -binary flag to ns_respond to return binary data without encoding conversion >> >> >>Index: tclobjv.c >>=================================================================== >>RCS file: /cvsroot/naviserver/naviserver/nsd/tclobjv.c,v >>retrieving revision 1.7 >>retrieving revision 1.8 >>diff -C2 -d -r1.7 -r1.8 >>*** tclobjv.c 15 May 2005 07:47:21 -0000 1.7 >>--- tclobjv.c 8 Jun 2005 20:27:12 -0000 1.8 >>*************** >>*** 310,313 **** >>--- 310,352 ---- >> *---------------------------------------------------------------------- >> * >>+ * Ns_ObjvByteArray -- >>+ * >>+ * Consume exactly one argument, returning a pointer to it's >>+ * cstring into *spec->dest. >>+ * >>+ * If spec->arg is != NULL it is assumed to be a pointer to an >>+ * int and the returned string length will be left in it. >>+ * >>+ * Results: >>+ * TCL_OK or TCL_ERROR. >>+ * >>+ * Side effects: >>+ * None. >>+ * >>+ *---------------------------------------------------------------------- >>+ */ >>+ >>+ int >>+ Ns_ObjvByteArray(Ns_ObjvSpec *spec, Tcl_Interp *interp, int *objcPtr, >>+ Tcl_Obj *CONST objv[]) >>+ { >>+ unsigned char **dest = spec->dest; >>+ >>+ if (*objcPtr > 0) { >>+ if (spec->arg == NULL) { >>+ *dest = Tcl_GetByteArrayFromObj(objv[0],0); >>+ } else { >>+ *dest = Tcl_GetByteArrayFromObj(objv[0], (int *) spec->arg); >>+ } >>+ *objcPtr -= 1; >>+ return TCL_OK; >>+ } >>+ return TCL_ERROR; >>+ } >>+ >>+ >>+ /* >>+ *---------------------------------------------------------------------- >>+ * >> * Ns_ObjvObj -- >> * >> >>Index: tclresp.c >>=================================================================== >>RCS file: /cvsroot/naviserver/naviserver/nsd/tclresp.c,v >>retrieving revision 1.4 >>retrieving revision 1.5 >>diff -C2 -d -r1.4 -r1.5 >>*** tclresp.c 8 Jun 2005 20:13:12 -0000 1.4 >>--- tclresp.c 8 Jun 2005 20:27:12 -0000 1.5 >>*************** >>*** 252,256 **** >> Ns_Conn *conn; >> int status = 200, length = -1; >>! char *type = "*/*", *setid = NULL; >> char *string = NULL, *filename = NULL, *chanid = NULL; >> Ns_Set *set = NULL; >>--- 252,256 ---- >> Ns_Conn *conn; >> int status = 200, length = -1; >>! char *type = "*/*", *setid = NULL, *binary = NULL; >> char *string = NULL, *filename = NULL, *chanid = NULL; >> Ns_Set *set = NULL; >>*************** >>*** 259,269 **** >> >> Ns_ObjvSpec opts[] = { >>! {"-status", Ns_ObjvInt, &status, NULL}, >>! {"-type", Ns_ObjvString, &type, NULL}, >>! {"-length", Ns_ObjvInt, &length, NULL}, >>! {"-headers", Ns_ObjvString, &setid, NULL}, >>! {"-string", Ns_ObjvString, &string, NULL}, >>! {"-file", Ns_ObjvString, &filename, NULL}, >>! {"-fileid", Ns_ObjvString, &chanid, NULL}, >> {NULL, NULL, NULL, NULL} >> }; >>--- 259,270 ---- >> >> Ns_ObjvSpec opts[] = { >>! {"-status", Ns_ObjvInt, &status, NULL}, >>! {"-type", Ns_ObjvString, &type, NULL}, >>! {"-length", Ns_ObjvInt, &length, NULL}, >>! {"-headers", Ns_ObjvString, &setid, NULL}, >>! {"-string", Ns_ObjvString, &string, NULL}, >>! {"-file", Ns_ObjvString, &filename, NULL}, >>! {"-fileid", Ns_ObjvString, &chanid, NULL}, >>! {"-binary", Ns_ObjvByteArray, &binary, &length}, >> {NULL, NULL, NULL, NULL} >> }; >>*************** >>*** 277,282 **** >> return TCL_ERROR; >> } >>! if ((string != NULL) + (filename != NULL) + (chanid != NULL) != 1) { >>! Tcl_SetResult(interp, "must specify only one of -string, -file " >> "or -fileid", TCL_STATIC); >> return TCL_ERROR; >>--- 278,283 ---- >> return TCL_ERROR; >> } >>! if ((binary != NULL) + (string != NULL) + (filename != NULL) + (chanid != NULL) != 1) { >>! Tcl_SetResult(interp, "must specify only one of -string, -file, -binary " >> "or -fileid", TCL_STATIC); >> return TCL_ERROR; >>*************** >>*** 313,316 **** >>--- 314,324 ---- >> retval = Ns_ConnReturnFile(conn, status, type, filename); >> >>+ } else if (binary != NULL) { >>+ /* >>+ * We'll be returning a binary data >>+ */ >>+ >>+ retval = Ns_ConnReturnData(conn, status, binary, length, type); >>+ >> } else { >> /* > > > > ------------------------------------------------------- > 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 > _______________________________________________ > 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/ |
From: Stephen D. <sd...@gm...> - 2005-06-10 06:46:19
|
On 6/9/05, Vlad Seryakov <vl...@cr...> wrote: > I have no failed tests >=20 > Tests running in interp: /home/vlad/src/naviserver/nsd/nsd > Tests located in: /home/vlad/src/naviserver/tests > Tests running in: /home/vlad/src/naviserver/tests > Temporary files stored in /home/vlad/src/naviserver/tests > Test files sourced into current interpreter > Running tests that match: * > Skipping test files that match: l.*.test > Only running test files that match: *.test > Tests began at Thu Jun 09 08:30:29 PM EDT 2005 > http.test > ns_addrbyhost.test > ns_adp_compress.test > [09/Jun/2005:20:30:29][5516.3073625008][-conn:test::0] Notice: encoding: > loaded: iso8859-1 > ns_conn_host.test > ns_hashpath.test > ns_hostbyaddr.test > ns_hrefs.test > ns_nsv.test > ns_pagepath.test > ns_parseargs.test > ns_serverpath.test > ns_urlencode.test > tclresp.test >=20 > Tests ended at Thu Jun 09 08:30:30 PM EDT 2005 > all.tcl: Total 193 Passed 193 Skipped 0 Failed 0 > Sourced 13 Test Files. The test server is linking against some other libnsd.so you have installed on the machine, so you're not testing what you think you're testing... Unfortunately LD_LIBRARY_PATH isn't enough to fix this as the lib locations are embeded into the binaries with rpath. I'm not sure what the best way to fix this is yet, but as a temporary measure you can configure your test server with --prefix=3D/tmp/nsdtest, i.e. something other than the installed nsd. |
From: Vlad S. <vl...@cr...> - 2005-06-10 13:53:54
|
Yes, i see. fixed Stephen Deasey wrote: > On 6/9/05, Vlad Seryakov <vl...@cr...> wrote: > >>I have no failed tests >> >>Tests running in interp: /home/vlad/src/naviserver/nsd/nsd >>Tests located in: /home/vlad/src/naviserver/tests >>Tests running in: /home/vlad/src/naviserver/tests >>Temporary files stored in /home/vlad/src/naviserver/tests >>Test files sourced into current interpreter >>Running tests that match: * >>Skipping test files that match: l.*.test >>Only running test files that match: *.test >>Tests began at Thu Jun 09 08:30:29 PM EDT 2005 >>http.test >>ns_addrbyhost.test >>ns_adp_compress.test >>[09/Jun/2005:20:30:29][5516.3073625008][-conn:test::0] Notice: encoding: >>loaded: iso8859-1 >>ns_conn_host.test >>ns_hashpath.test >>ns_hostbyaddr.test >>ns_hrefs.test >>ns_nsv.test >>ns_pagepath.test >>ns_parseargs.test >>ns_serverpath.test >>ns_urlencode.test >>tclresp.test >> >>Tests ended at Thu Jun 09 08:30:30 PM EDT 2005 >>all.tcl: Total 193 Passed 193 Skipped 0 Failed 0 >>Sourced 13 Test Files. > > > > The test server is linking against some other libnsd.so you have > installed on the machine, so you're not testing what you think you're > testing... > > Unfortunately LD_LIBRARY_PATH isn't enough to fix this as the lib > locations are embeded into the binaries with rpath. I'm not sure what > the best way to fix this is yet, but as a temporary measure you can > configure your test server with --prefix=/tmp/nsdtest, i.e. something > other than the installed nsd. > > > ------------------------------------------------------- > 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 > _______________________________________________ > 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/ |
From: Vlad S. <vl...@cr...> - 2005-06-10 00:33:48
|
ns_respond now supports binary so ns_returnbinary is redundant, but i think Tcl_GetByteArray works with string and byte array, just Tcl_GetByteArray does not do eny encoding/converting to/From utf. Stephen Deasey wrote: > Before you cvs commit, you must make test. Two tests are broken... > We're strugeling for tests, but tclresp.c is one file that does have a > reasonably complete set. Can you add some for the new commands? > Also, the cut 'n paste comment for Ns_ObjvByteArray is no longer > correct. > > I was wondering, is ns_returnbinary necessary? What if ns_return was > modified to check the type of it's data arg, and if it's byterray, > send using Ns_ConnReturnData. Would this work? > > > > > On 6/8/05, Vlad Seryakov <ser...@us...> wrote: > >>Update of /cvsroot/naviserver/naviserver/nsd >>In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15813/nsd >> >>Modified Files: >> tclobjv.c tclresp.c >>Log Message: >>Added -binary flag to ns_respond to return binary data without encoding conversion >> >> >>Index: tclobjv.c >>=================================================================== >>RCS file: /cvsroot/naviserver/naviserver/nsd/tclobjv.c,v >>retrieving revision 1.7 >>retrieving revision 1.8 >>diff -C2 -d -r1.7 -r1.8 >>*** tclobjv.c 15 May 2005 07:47:21 -0000 1.7 >>--- tclobjv.c 8 Jun 2005 20:27:12 -0000 1.8 >>*************** >>*** 310,313 **** >>--- 310,352 ---- >> *---------------------------------------------------------------------- >> * >>+ * Ns_ObjvByteArray -- >>+ * >>+ * Consume exactly one argument, returning a pointer to it's >>+ * cstring into *spec->dest. >>+ * >>+ * If spec->arg is != NULL it is assumed to be a pointer to an >>+ * int and the returned string length will be left in it. >>+ * >>+ * Results: >>+ * TCL_OK or TCL_ERROR. >>+ * >>+ * Side effects: >>+ * None. >>+ * >>+ *---------------------------------------------------------------------- >>+ */ >>+ >>+ int >>+ Ns_ObjvByteArray(Ns_ObjvSpec *spec, Tcl_Interp *interp, int *objcPtr, >>+ Tcl_Obj *CONST objv[]) >>+ { >>+ unsigned char **dest = spec->dest; >>+ >>+ if (*objcPtr > 0) { >>+ if (spec->arg == NULL) { >>+ *dest = Tcl_GetByteArrayFromObj(objv[0],0); >>+ } else { >>+ *dest = Tcl_GetByteArrayFromObj(objv[0], (int *) spec->arg); >>+ } >>+ *objcPtr -= 1; >>+ return TCL_OK; >>+ } >>+ return TCL_ERROR; >>+ } >>+ >>+ >>+ /* >>+ *---------------------------------------------------------------------- >>+ * >> * Ns_ObjvObj -- >> * >> >>Index: tclresp.c >>=================================================================== >>RCS file: /cvsroot/naviserver/naviserver/nsd/tclresp.c,v >>retrieving revision 1.4 >>retrieving revision 1.5 >>diff -C2 -d -r1.4 -r1.5 >>*** tclresp.c 8 Jun 2005 20:13:12 -0000 1.4 >>--- tclresp.c 8 Jun 2005 20:27:12 -0000 1.5 >>*************** >>*** 252,256 **** >> Ns_Conn *conn; >> int status = 200, length = -1; >>! char *type = "*/*", *setid = NULL; >> char *string = NULL, *filename = NULL, *chanid = NULL; >> Ns_Set *set = NULL; >>--- 252,256 ---- >> Ns_Conn *conn; >> int status = 200, length = -1; >>! char *type = "*/*", *setid = NULL, *binary = NULL; >> char *string = NULL, *filename = NULL, *chanid = NULL; >> Ns_Set *set = NULL; >>*************** >>*** 259,269 **** >> >> Ns_ObjvSpec opts[] = { >>! {"-status", Ns_ObjvInt, &status, NULL}, >>! {"-type", Ns_ObjvString, &type, NULL}, >>! {"-length", Ns_ObjvInt, &length, NULL}, >>! {"-headers", Ns_ObjvString, &setid, NULL}, >>! {"-string", Ns_ObjvString, &string, NULL}, >>! {"-file", Ns_ObjvString, &filename, NULL}, >>! {"-fileid", Ns_ObjvString, &chanid, NULL}, >> {NULL, NULL, NULL, NULL} >> }; >>--- 259,270 ---- >> >> Ns_ObjvSpec opts[] = { >>! {"-status", Ns_ObjvInt, &status, NULL}, >>! {"-type", Ns_ObjvString, &type, NULL}, >>! {"-length", Ns_ObjvInt, &length, NULL}, >>! {"-headers", Ns_ObjvString, &setid, NULL}, >>! {"-string", Ns_ObjvString, &string, NULL}, >>! {"-file", Ns_ObjvString, &filename, NULL}, >>! {"-fileid", Ns_ObjvString, &chanid, NULL}, >>! {"-binary", Ns_ObjvByteArray, &binary, &length}, >> {NULL, NULL, NULL, NULL} >> }; >>*************** >>*** 277,282 **** >> return TCL_ERROR; >> } >>! if ((string != NULL) + (filename != NULL) + (chanid != NULL) != 1) { >>! Tcl_SetResult(interp, "must specify only one of -string, -file " >> "or -fileid", TCL_STATIC); >> return TCL_ERROR; >>--- 278,283 ---- >> return TCL_ERROR; >> } >>! if ((binary != NULL) + (string != NULL) + (filename != NULL) + (chanid != NULL) != 1) { >>! Tcl_SetResult(interp, "must specify only one of -string, -file, -binary " >> "or -fileid", TCL_STATIC); >> return TCL_ERROR; >>*************** >>*** 313,316 **** >>--- 314,324 ---- >> retval = Ns_ConnReturnFile(conn, status, type, filename); >> >>+ } else if (binary != NULL) { >>+ /* >>+ * We'll be returning a binary data >>+ */ >>+ >>+ retval = Ns_ConnReturnData(conn, status, binary, length, type); >>+ >> } else { >> /* > > > > ------------------------------------------------------- > 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 > _______________________________________________ > 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/ |
From: Stephen D. <sd...@gm...> - 2005-06-10 06:52:28
|
I think it's fine to also alow ns_return to handle binary data, I'm just wondering if it should be with the extra command ns_returnbinary? It looks like you can simple check the type of the Tcl object passed to ns_return for "bytearray". That's the only case it makes sense to write the bytes directly. The advantage over ns_returnbinary is that in many cases the uses doesn't have to know what's going on. e.g. a command which creates a png graph would be returned as a byte array, and if passed to ns_return everything should just work. On 6/9/05, Vlad Seryakov <vl...@cr...> wrote: > ns_respond now supports binary so ns_returnbinary is redundant, but i > think Tcl_GetByteArray works with string and byte array, just > Tcl_GetByteArray does not do eny encoding/converting to/From utf. >=20 > Stephen Deasey wrote: > > Before you cvs commit, you must make test. Two tests are broken... > > We're strugeling for tests, but tclresp.c is one file that does have a > > reasonably complete set. Can you add some for the new commands? > > Also, the cut 'n paste comment for Ns_ObjvByteArray is no longer > > correct. > > > > I was wondering, is ns_returnbinary necessary? What if ns_return was > > modified to check the type of it's data arg, and if it's byterray, > > send using Ns_ConnReturnData. Would this work? |
From: Vlad S. <vl...@cr...> - 2005-06-10 13:44:45
|
* Tcl_GetByteArrayFromObj -- * * Attempt to get the array of bytes from the Tcl object. If the * object is not already a ByteArray object, an attempt will be * made to convert it to one. So, if i call ns_return from Tcl and pass data parameter, it will be always type of String. ByteArrays are created from Tcl by binary command only, other commands work with String types, so i need to tell ns_return to treat data as bytearray. Tcl string can contain binary data but it is still String and that check will never work for binary data. Stephen Deasey wrote: > I think it's fine to also alow ns_return to handle binary data, I'm > just wondering if it should be with the extra command ns_returnbinary? > > It looks like you can simple check the type of the Tcl object passed > to ns_return for "bytearray". That's the only case it makes sense to > write the bytes directly. > > The advantage over ns_returnbinary is that in many cases the uses > doesn't have to know what's going on. e.g. a command which creates a > png graph would be returned as a byte array, and if passed to > ns_return everything should just work. > > > > On 6/9/05, Vlad Seryakov <vl...@cr...> wrote: > >>ns_respond now supports binary so ns_returnbinary is redundant, but i >>think Tcl_GetByteArray works with string and byte array, just >>Tcl_GetByteArray does not do eny encoding/converting to/From utf. >> >>Stephen Deasey wrote: >> >>>Before you cvs commit, you must make test. Two tests are broken... >>>We're strugeling for tests, but tclresp.c is one file that does have a >>>reasonably complete set. Can you add some for the new commands? >>>Also, the cut 'n paste comment for Ns_ObjvByteArray is no longer >>>correct. >>> >>>I was wondering, is ns_returnbinary necessary? What if ns_return was >>>modified to check the type of it's data arg, and if it's byterray, >>>send using Ns_ConnReturnData. Would this work? > > > > ------------------------------------------------------- > 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 > _______________________________________________ > 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/ |
From: Zoran V. <zv...@ar...> - 2005-06-10 14:44:36
|
Am 10.06.2005 um 15:41 schrieb Vlad Seryakov: > * Tcl_GetByteArrayFromObj -- > * > * Attempt to get the array of bytes from the Tcl object. If the > * object is not already a ByteArray object, an attempt will be > * made to convert it to one. > > So, if i call ns_return from Tcl and pass data parameter, it will > be always type of String. ByteArrays are created from Tcl by binary > command only, other commands work with String types, so i need to > tell ns_return to treat data as bytearray. Tcl string > can contain binary data but it is still String and that check will > never work for binary data. > I'm afraid you are right. I also have my own (binary-aware) ns_return somewhere in my toolbox but never thought it would be of general interest. OTOH, the "ns_return -binary" would look nicer but I do not know if we'd be backwardly-compatible (guess not). Zoran |
From: Vlad S. <vl...@cr...> - 2005-06-10 15:07:49
|
I thought about ns_return -binary as well. first -binary flag is optional so it will be compatible with the old API. Let me try this. Zoran Vasiljevic wrote: > > Am 10.06.2005 um 15:41 schrieb Vlad Seryakov: > >> * Tcl_GetByteArrayFromObj -- >> * >> * Attempt to get the array of bytes from the Tcl object. If the >> * object is not already a ByteArray object, an attempt will be >> * made to convert it to one. >> >> So, if i call ns_return from Tcl and pass data parameter, it will be >> always type of String. ByteArrays are created from Tcl by binary >> command only, other commands work with String types, so i need to >> tell ns_return to treat data as bytearray. Tcl string >> can contain binary data but it is still String and that check will >> never work for binary data. >> > > I'm afraid you are right. I also have my own (binary-aware) ns_return > somewhere > in my toolbox but never thought it would be of general interest. > > OTOH, the "ns_return -binary" would look nicer but I do not > know if we'd be backwardly-compatible (guess not). > > 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=20 > _______________________________________________ > 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/ |
From: Vlad S. <vl...@cr...> - 2005-06-10 15:24:06
|
How about this, i tested it : int NsTclReturnObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Ns_Conn *conn; unsigned char *data = 0, *type = 0; int i, result, status = 0, len = 0, binary = 0; for (i = 1;i < objc;i++) { if (!strcmp(Tcl_GetString(objv[i]),"-binary")) { binary = 1; } else if (status == 0) { if (Tcl_GetIntFromObj(interp, objv[i], &status) != TCL_OK) { return TCL_ERROR; } } else if (type == NULL) { type = Tcl_GetString(objv[i]); } else if (data == NULL) { if (binary != 0) { data = Tcl_GetByteArrayFromObj(objv[i], &len); } else { data = Tcl_GetStringFromObj(objv[i], &len); } } } if (data == NULL || type == NULL || status == 0) { Tcl_WrongNumArgs(interp, 1, objv, "?-binary? status type string"); return TCL_ERROR; } if (GetConn(arg, interp, &conn) != TCL_OK) { return TCL_ERROR; } if(binary != 0) { result = Ns_ConnReturnData(conn, status, data, len, type); } else { result = Ns_ConnReturnCharData(conn, status, data, len, type); } return Result(interp, result); } Vlad Seryakov wrote: > I thought about ns_return -binary as well. first -binary flag is > optional so it will be compatible with the old API. Let me try this. > > Zoran Vasiljevic wrote: > >> >> Am 10.06.2005 um 15:41 schrieb Vlad Seryakov: >> >>> * Tcl_GetByteArrayFromObj -- >>> * >>> * Attempt to get the array of bytes from the Tcl object. If the >>> * object is not already a ByteArray object, an attempt will be >>> * made to convert it to one. >>> >>> So, if i call ns_return from Tcl and pass data parameter, it will be >>> always type of String. ByteArrays are created from Tcl by binary >>> command only, other commands work with String types, so i need to >>> tell ns_return to treat data as bytearray. Tcl string >>> can contain binary data but it is still String and that check will >>> never work for binary data. >>> >> >> I'm afraid you are right. I also have my own (binary-aware) ns_return >> somewhere >> in my toolbox but never thought it would be of general interest. >> >> OTOH, the "ns_return -binary" would look nicer but I do not >> know if we'd be backwardly-compatible (guess not). >> >> 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=20 >> _______________________________________________ >> 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/ |
From: Zoran V. <zv...@ar...> - 2005-06-10 15:40:29
|
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 |
From: Vlad S. <vl...@cr...> - 2005-06-10 15:51:49
|
Second try :-))) int NsTclReturnObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Ns_Conn *conn; unsigned char *data = 0, *type = 0; int result, param = 1, status = 0, len = 0, binary = 0; if (!strcmp(Tcl_GetString(objv[param]),"-binary")) { binary = 1; param++; } if (Tcl_GetIntFromObj(interp, objv[param++], &status) != TCL_OK) { return TCL_ERROR; } type = Tcl_GetString(objv[param++]); if (binary != 0) { data = Tcl_GetByteArrayFromObj(objv[param], &len); } else { data = Tcl_GetStringFromObj(objv[param], &len); } if (data == NULL || type == NULL || status == 0) { Tcl_WrongNumArgs(interp, 1, objv, "?-binary? status type string"); return TCL_ERROR; } if (GetConn(arg, interp, &conn) != TCL_OK) { return TCL_ERROR; } if(binary != 0) { result = Ns_ConnReturnData(conn, status, data, len, type); } else { result = 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=20 > _______________________________________________ > 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/ |
From: Stephen D. <sd...@gm...> - 2005-06-10 15:42:31
|
On 6/10/05, Vlad Seryakov <vl...@cr...> wrote: > I thought about ns_return -binary as well. first -binary flag is > optional so it will be compatible with the old API. Let me try this. >=20 > Zoran Vasiljevic wrote: > > > > Am 10.06.2005 um 15:41 schrieb Vlad Seryakov: > > > >> * Tcl_GetByteArrayFromObj -- > >> * > >> * Attempt to get the array of bytes from the Tcl object. If the > >> * object is not already a ByteArray object, an attempt will be > >> * made to convert it to one. > >> > >> So, if i call ns_return from Tcl and pass data parameter, it will be > >> always type of String. ByteArrays are created from Tcl by binary > >> command only, other commands work with String types, so i need to > >> tell ns_return to treat data as bytearray. Tcl string > >> can contain binary data but it is still String and that check will > >> never work for binary data. > >> > > > > I'm afraid you are right. I also have my own (binary-aware) ns_return > > somewhere > > in my toolbox but never thought it would be of general interest. > > > > OTOH, the "ns_return -binary" would look nicer but I do not > > know if we'd be backwardly-compatible (guess not). The *only* thing a Tcl string can contain is valid UTF8. If you're putting something other than UTF8 in there, you've got big problems... Now, sending a UTF8 string directly to the client as a bytearray is effectively the same as sedinding it in the UTF8 encoding, i.e. the client will recieve exactly what was in memory for that string, because no transcoding to some other character set will be occur.=20 There is API for setting the encoding on a per connection basis. The only way to pass a buffer of arbitrary (non-UTF8) bytes to a command is as a bytearray object. You can create these with the [binary] command, by opening a file with -translation binary, or from some extension such as the image example I gave above. That being the case, you should be able to check the type of the object given to ns_return, and act accordingly It's for these reasons that ns_returnbinary and ns_return -binary are fundamentaly broken. |
From: Zoran V. <zv...@ar...> - 2005-06-10 15:56:34
|
Am 10.06.2005 um 17:42 schrieb Stephen Deasey: > That being the > case, you should be able to check the type of the object given to > ns_return, and act accordingly > And what if it shimmers away? You read-in the file with "-translation binary" put the resulting data in the nsv_array, and get it back from there later on? Now, you'd get a string-type and you need to convert it to binary-array back. Who will do that? Normally, if I'd to write the content back, I need to open the file for writing and set it again to "-translation binary" in order to get the correct content back. I'm not sure if it is enough to rely on the object type. Zoran |
From: Stephen D. <sd...@gm...> - 2005-06-10 16:55:29
|
On 6/10/05, Zoran Vasiljevic <zv...@ar...> wrote: >=20 > Am 10.06.2005 um 17:42 schrieb Stephen Deasey: >=20 > > That being the > > case, you should be able to check the type of the object given to > > ns_return, and act accordingly > > >=20 > And what if it shimmers away? >=20 > You read-in the file with "-translation binary" put the resulting data > in the nsv_array, and get it back from there later on? You've just passed arbitrary bytes to an API which expects UTF8.=20 Expect your server to crash... > Now, you'd get a string-type and you need to convert it to binary-array > back. Who will do that? > Normally, if I'd to write the content back, I need to open the file > for writing and set it again to "-translation binary" in order to get > the correct content back. >=20 > I'm not sure if it is enough to rely on the object type. It doesn't make sense to shimmer arbitrary bytes to UTF8 strings. The bytes will be mangled to make the string valid UTF8, but what use it that? |
From: Zoran V. <zv...@ar...> - 2005-06-10 17:05:58
|
Am 10.06.2005 um 18:55 schrieb Stephen Deasey: > > You've just passed arbitrary bytes to an API which expects UTF8. > Expect your server to crash... > > Hm.... set chan [open /the/file.img] fconfigure $chan -translation binary set datain [read $chan] close $file nsv_set Images file.img $datain # set dataout [nsv_set Images file.img] set chan [open /the/fileout.img w] fconfigure $chan -translation binary puts -nonewline $chan $dataout close $file Crash ? Zoran |
From: Vlad S. <vl...@cr...> - 2005-06-10 17:12:42
|
All that encoding also depends on how your server configured, does it use non-standard encoding or everything in UTF. Eastern websites usually support many languages and there all encoding/translation goes, so being able to explicitly handle binary data is important. Zoran Vasiljevic wrote: > > Am 10.06.2005 um 18:55 schrieb Stephen Deasey: > >> >> You've just passed arbitrary bytes to an API which expects UTF8. >> Expect your server to crash... >> >> > > Hm.... > > set chan [open /the/file.img] > fconfigure $chan -translation binary > set datain [read $chan] > close $file > nsv_set Images file.img $datain > # > set dataout [nsv_set Images file.img] > set chan [open /the/fileout.img w] > fconfigure $chan -translation binary > puts -nonewline $chan $dataout > close $file > > Crash ? > > 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=20 > _______________________________________________ > 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/ |
From: Vlad S. <vl...@cr...> - 2005-06-10 15:57:24
|
The problem is, there is no Public API to check object for ByteArray type. You have to include tclInt.h for this which is not public. Stephen Deasey wrote: > On 6/10/05, Vlad Seryakov <vl...@cr...> wrote: > >>I thought about ns_return -binary as well. first -binary flag is >>optional so it will be compatible with the old API. Let me try this. >> >>Zoran Vasiljevic wrote: >> >>>Am 10.06.2005 um 15:41 schrieb Vlad Seryakov: >>> >>> >>>>* Tcl_GetByteArrayFromObj -- >>>>* >>>>* Attempt to get the array of bytes from the Tcl object. If the >>>>* object is not already a ByteArray object, an attempt will be >>>>* made to convert it to one. >>>> >>>>So, if i call ns_return from Tcl and pass data parameter, it will be >>>>always type of String. ByteArrays are created from Tcl by binary >>>>command only, other commands work with String types, so i need to >>>>tell ns_return to treat data as bytearray. Tcl string >>>>can contain binary data but it is still String and that check will >>>>never work for binary data. >>>> >>> >>>I'm afraid you are right. I also have my own (binary-aware) ns_return >>>somewhere >>>in my toolbox but never thought it would be of general interest. >>> >>>OTOH, the "ns_return -binary" would look nicer but I do not >>>know if we'd be backwardly-compatible (guess not). > > > > The *only* thing a Tcl string can contain is valid UTF8. If you're > putting something other than UTF8 in there, you've got big problems... > > Now, sending a UTF8 string directly to the client as a bytearray is > effectively the same as sedinding it in the UTF8 encoding, i.e. the > client will recieve exactly what was in memory for that string, > because no transcoding to some other character set will be occur. > There is API for setting the encoding on a per connection basis. > > The only way to pass a buffer of arbitrary (non-UTF8) bytes to a > command is as a bytearray object. You can create these with the > [binary] command, by opening a file with -translation binary, or from > some extension such as the image example I gave above. That being the > case, you should be able to check the type of the object given to > ns_return, and act accordingly > > It's for these reasons that ns_returnbinary and ns_return -binary are > fundamentaly broken. > > > ------------------------------------------------------- > 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 > _______________________________________________ > 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/ |
From: Stephen D. <sd...@gm...> - 2005-06-10 16:51:59
|
Tcl_ObjType byteArrayType =3D Tcl_GetObjType("bytearray"); On 6/10/05, Vlad Seryakov <vl...@cr...> wrote: > The problem is, there is no Public API to check object for ByteArray > type. You have to include tclInt.h for this which is not public. >=20 > Stephen Deasey wrote: > > On 6/10/05, Vlad Seryakov <vl...@cr...> wrote: > > > >>I thought about ns_return -binary as well. first -binary flag is > >>optional so it will be compatible with the old API. Let me try this. > >> > >>Zoran Vasiljevic wrote: > >> > >>>Am 10.06.2005 um 15:41 schrieb Vlad Seryakov: > >>> > >>> > >>>>* Tcl_GetByteArrayFromObj -- > >>>>* > >>>>* Attempt to get the array of bytes from the Tcl object. If the > >>>>* object is not already a ByteArray object, an attempt will be > >>>>* made to convert it to one. > >>>> > >>>>So, if i call ns_return from Tcl and pass data parameter, it will be > >>>>always type of String. ByteArrays are created from Tcl by binary > >>>>command only, other commands work with String types, so i need to > >>>>tell ns_return to treat data as bytearray. Tcl string > >>>>can contain binary data but it is still String and that check will > >>>>never work for binary data. > >>>> > >>> > >>>I'm afraid you are right. I also have my own (binary-aware) ns_return > >>>somewhere > >>>in my toolbox but never thought it would be of general interest. > >>> > >>>OTOH, the "ns_return -binary" would look nicer but I do not > >>>know if we'd be backwardly-compatible (guess not). > > > > > > > > The *only* thing a Tcl string can contain is valid UTF8. If you're > > putting something other than UTF8 in there, you've got big problems... > > > > Now, sending a UTF8 string directly to the client as a bytearray is > > effectively the same as sedinding it in the UTF8 encoding, i.e. the > > client will recieve exactly what was in memory for that string, > > because no transcoding to some other character set will be occur. > > There is API for setting the encoding on a per connection basis. > > > > The only way to pass a buffer of arbitrary (non-UTF8) bytes to a > > command is as a bytearray object. You can create these with the > > [binary] command, by opening a file with -translation binary, or from > > some extension such as the image example I gave above. That being the > > case, you should be able to check the type of the object given to > > ns_return, and act accordingly > > > > It's for these reasons that ns_returnbinary and ns_return -binary are > > fundamentaly broken. > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by: NEC IT Guy Games. How far can you s= hotput > > 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 > > _______________________________________________ > > 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 > |
From: Vlad S. <vl...@cr...> - 2005-06-10 17:02:22
|
This is i missed, never thought it is available Stephen Deasey wrote: > Tcl_ObjType byteArrayType = Tcl_GetObjType("bytearray"); > > > On 6/10/05, Vlad Seryakov <vl...@cr...> wrote: > >>The problem is, there is no Public API to check object for ByteArray >>type. You have to include tclInt.h for this which is not public. >> >>Stephen Deasey wrote: >> >>>On 6/10/05, Vlad Seryakov <vl...@cr...> wrote: >>> >>> >>>>I thought about ns_return -binary as well. first -binary flag is >>>>optional so it will be compatible with the old API. Let me try this. >>>> >>>>Zoran Vasiljevic wrote: >>>> >>>> >>>>>Am 10.06.2005 um 15:41 schrieb Vlad Seryakov: >>>>> >>>>> >>>>> >>>>>>* Tcl_GetByteArrayFromObj -- >>>>>>* >>>>>>* Attempt to get the array of bytes from the Tcl object. If the >>>>>>* object is not already a ByteArray object, an attempt will be >>>>>>* made to convert it to one. >>>>>> >>>>>>So, if i call ns_return from Tcl and pass data parameter, it will be >>>>>>always type of String. ByteArrays are created from Tcl by binary >>>>>>command only, other commands work with String types, so i need to >>>>>>tell ns_return to treat data as bytearray. Tcl string >>>>>>can contain binary data but it is still String and that check will >>>>>>never work for binary data. >>>>>> >>>>> >>>>>I'm afraid you are right. I also have my own (binary-aware) ns_return >>>>>somewhere >>>>>in my toolbox but never thought it would be of general interest. >>>>> >>>>>OTOH, the "ns_return -binary" would look nicer but I do not >>>>>know if we'd be backwardly-compatible (guess not). >>> >>> >>> >>>The *only* thing a Tcl string can contain is valid UTF8. If you're >>>putting something other than UTF8 in there, you've got big problems... >>> >>>Now, sending a UTF8 string directly to the client as a bytearray is >>>effectively the same as sedinding it in the UTF8 encoding, i.e. the >>>client will recieve exactly what was in memory for that string, >>>because no transcoding to some other character set will be occur. >>>There is API for setting the encoding on a per connection basis. >>> >>>The only way to pass a buffer of arbitrary (non-UTF8) bytes to a >>>command is as a bytearray object. You can create these with the >>>[binary] command, by opening a file with -translation binary, or from >>>some extension such as the image example I gave above. That being the >>>case, you should be able to check the type of the object given to >>>ns_return, and act accordingly >>> >>>It's for these reasons that ns_returnbinary and ns_return -binary are >>>fundamentaly broken. >>> >>> >>>------------------------------------------------------- >>>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 >>>_______________________________________________ >>>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=20 >>_______________________________________________ >>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 to win an NEC 61" plasma display: http://www.necitguy.com/?r > _______________________________________________ > 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/ |