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 { > /* |