rem: if (Tcl_GetIndexFromObj(interp, lobjv[i], wopt, "when", 1,
add: if (Tcl_GetIndexFromObj(interp, lobjv[i], wopt, "when", 0,
context: static Ns_OpProc AdpRequest;static Ns_FilterProc ProcFilter;static Proc *NewProc(char *name, char *args);static Ns_Callback FreeProc;static void AppendConnId(Tcl_DString *dsPtr, Ns_Conn *conn);static void RegisterFilterObj(NsInterp *itPtr, int when, int objc,			      Tcl_Obj *CONST objv[]);static int GetNumArgs(Tcl_Interp *interp, Proc *procPtr);/* *---------------------------------------------------------------------- * * Ns_TclRequest -- * *	Dummy up a direct call to TclProcRequest for a connection. * * Results: *	See TclDoOp. * * Side effects: *	None.  * *---------------------------------------------------------------------- */intNs_TclRequest(Ns_Conn *conn, char *name){    Proc proc;    proc.name = name;    proc.args = NULL;    proc.nargs = 0;    return ProcRequest(&proc, conn);}/* *---------------------------------------------------------------------- * * NsTclRegisterProcObjCmd -- * *	Implements ns_register_proc as obj command.  * * Results: *	Tcl result.  * * Side effects: *	See docs.  * *---------------------------------------------------------------------- */intNsTclRegisterProcObjCmd(ClientData arg, Tcl_Interp *interp, int objc, 				Tcl_Obj *CONST objv[], int adp){    int         flags, idx;    Proc       *procPtr;    NsInterp   *itPtr = arg;    char       *server, *method, *url, *name, *args;    if (objc < 4 || objc > 7) {badargs:        Tcl_WrongNumArgs(interp, 1, objv, "?-noinherit? method url proc ?args?");        return TCL_ERROR;    }    if (STREQ(Tcl_GetString(objv[1]), "-noinherit")) {	if (objc < 5) {	    goto badargs;	}	flags = NS_OP_NOINHERIT;	idx = 2;    } else {	if (objc == 7) {	    goto badargs;	}	flags = 0;	idx = 1;    }    server = itPtr->servPtr->server;    method = Tcl_GetString(objv[idx++]);    url = Tcl_GetString(objv[idx++]);    name = Tcl_GetString(objv[idx++]);    args = (idx < objc ? Tcl_GetString(objv[idx]) : NULL);    procPtr = NewProc(name, args);    Ns_RegisterRequest(server, method, url, ProcRequest, FreeProc,			procPtr, flags);    return TCL_OK;}/* *---------------------------------------------------------------------- * * NsTclRegisterAdpObjCmd -- * *	Implements ns_register_adp as obj command. * * Results: *	Tcl result.  * * Side effects: *	See docs.  * *---------------------------------------------------------------------- */intNsTclRegisterAdpObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]){    NsInterp   *itPtr = arg;    char       *server, *method, *url, *file;    if (objc != 4 && objc != 5) {badargs:        Tcl_WrongNumArgs(interp, 1, objv, "?-noinherit? method url file");        return TCL_ERROR;    }    if (objc == 5 && !STREQ(Tcl_GetString(objv[1]), "-noinherit")) {	goto badargs;    }    server = itPtr->servPtr->server;    method = Tcl_GetString(objv[objc-3]);    url = Tcl_GetString(objv[objc-2]);    file = ns_strdup(Tcl_GetString(objv[objc-1]));    Ns_RegisterRequest(server, method, url, AdpRequest, ns_free,			file, objc == 5 ? NS_OP_NOINHERIT : 0);    return TCL_OK;}/* *---------------------------------------------------------------------- * * NsTclUnRegisterObjCmd -- * *	Implements ns_unregister_proc and ns_unregister_adp commands. * * Results: *	Tcl result.  * * Side effects: *	See docs.  * *---------------------------------------------------------------------- */intNsTclUnRegisterObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]){    NsInterp *itPtr = arg;    char *server = itPtr->servPtr->server;        if (objc != 3 && objc != 4) {        Tcl_WrongNumArgs(interp, 1, objv, "?-noinherit? method url");        return TCL_ERROR;    }    if (objc == 4 && !STREQ(Tcl_GetString(objv[1]), "-noinherit")) {	Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "unknown flag \"", 		Tcl_GetString(objv[1]),		"\": should be -noinherit", NULL);	return TCL_ERROR;    }    Ns_UnRegisterRequest(server, Tcl_GetString(objv[objc-2]), Tcl_GetString(objv[objc-1]), 			objc == 3 ? 1 : 0);    return TCL_OK;}/* *---------------------------------------------------------------------- * * NsTclRegisterFilterObjCmd -- * *	Implements ns_register_filter.  * * Results: *	Tcl result.  * * Side effects: *	See docs.  * *---------------------------------------------------------------------- */intNsTclRegisterFilterObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]){    NsInterp *itPtr = arg;    int       lobjc;    Tcl_Obj **lobjv;    int       when, i;    static CONST char *wopt[] = {        "prequeue", "preauth", "postauth", "trace", NULL    };    enum {        PQIdx, PRIdx, POIdx, TRIdx,    } widx;    if (objc < 2) {        Tcl_WrongNumArgs(interp, 1, objv, "option ?args?");        return TCL_ERROR;    }    if (objc != 5 && objc != 6) {        Tcl_WrongNumArgs(interp, 1, objv, "when method url script ?arg?");        return TCL_ERROR;    }    if (Tcl_ListObjGetElements(interp, objv[1], &lobjc, &lobjv) != TCL_OK) {	return TCL_ERROR;    }    when = 0;    for (i = 0; i < lobjc; ++i) {    	if (Tcl_GetIndexFromObj(interp, lobjv[i], wopt, "when", 1,                (int *) &widx) != TCL_OK) {            return TCL_ERROR;    	}	switch (widx) {	case PQIdx:            when |= NS_FILTER_PRE_QUEUE;	    break;	case PRIdx:            when |= NS_FILTER_PRE_AUTH;	    break;	case POIdx:            when |= NS_FILTER_POST_AUTH;	    break;	case TRIdx:            when |= NS_FILTER_TRACE;	    break;	}    }    if (when == 0) {	Tcl_SetResult(interp, "blank filter when specification", TCL_STATIC);	return TCL_ERROR;    }    RegisterFilterObj(itPtr, when, objc - 2, objv + 2);    return TCL_OK;}/* *---------------------------------------------------------------------- * * NsTclRegisterTraceObjCmd -- * *	Implements ns_register_trace as obj command. * * Results: *	Tcl result.  * * Side effects: *	See docs.  * *---------------------------------------------------------------------- */intNsTclRegisterTraceObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]){    NsInterp *itPtr = arg;    if (objc != 4 && objc != 5) {        Tcl_WrongNumArgs(interp, 1, objv, "method urlPattern script ?arg?");        return TCL_ERROR;    }    RegisterFilterObj(itPtr, NS_FILTER_VOID_TRACE, objc - 1, objv + 1);    return TCL_OK;}/* *---------------------------------------------------------------------- * * AdpRequest -- * *	Ns_OpProc for registered ADP's. * * Results: *	See Ns_AdpRequest. * * Side effects: *	None.  * *---------------------------------------------------------------------- */static intAdpRequest(void *arg, Ns_Conn *conn){    return Ns_AdpRequest(conn, (char *) arg);}