rem: } else if (STREQ(argv[1], "isconnected")) { Tcl_SetResult(interp, (connPtr == NULL) ? "0" : "1", TCL_STATIC); return TCL_OK;
context: NsTclConnCmd(ClientData dummy, Tcl_Interp *interp, int argc, char **argv){    Ns_Conn    *conn;    Conn       *connPtr;    Ns_Request *request;    Ns_Set     *form;    /*     * Assumed that all ns_conn commands just take the secondary command     * name and no additional arguments.     *     * Urlv takes an extra undocumented argument, so it's hacked here.     */    if (argc >= 2 && STREQ(argv[1], "urlv")) {	return UrlVHackCmd(dummy, interp, argc, argv);    }    if (argc == 3) {	/*	 * They must have specified a conn ID.  Make sure it's a valid	 * conn ID.  If not, it's an error.	 */		if (NsIsIdConn(argv[2]) == NS_FALSE) {	    Tcl_AppendResult(interp, "bad connid: \"", argv[2], "\"", NULL);	    return TCL_ERROR;	}    } else if (argc > 3 || argc < 2) {        Tcl_AppendResult(interp, "wrong # of args: should be \"",                         argv[0], " cmd ", NULL);        return TCL_ERROR;    }    connPtr = (Conn *) Ns_GetConn();    if (connPtr == NULL) {        Tcl_AppendResult(interp, "no current connection", NULL);        return TCL_ERROR;    }    if (!connPtr->tclInit) {        Ns_TclEnterSet(interp, connPtr->headers, 0);        strcpy(connPtr->tclHdrs, interp->result);        Ns_TclEnterSet(interp, connPtr->outputheaders, 0);        strcpy(connPtr->tclOutputHdrs, interp->result);	Tcl_ResetResult(interp);	connPtr->tclInit = 1;    }    conn = (Ns_Conn *) connPtr;    request = connPtr->request;        if (STREQ(argv[1], "authuser")) {        Tcl_SetResult(interp, connPtr->authUser, TCL_STATIC);    } else if (STREQ(argv[1], "authpassword")) {        Tcl_SetResult(interp, connPtr->authPasswd, TCL_STATIC);    } else if (STREQ(argv[1], "contentlength")) {        sprintf(interp->result, "%u", (unsigned) conn->contentLength);    } else if (STREQ(argv[1], "peeraddr")) {        Tcl_SetResult(interp, Ns_ConnPeer(conn), TCL_STATIC);    } else if (STREQ(argv[1], "peerport")) {	sprintf(interp->result, "%d", Ns_ConnPeerPort(conn));    } else if (STREQ(argv[1], "headers")) {        Tcl_SetResult(interp, connPtr->tclHdrs, TCL_STATIC);    } else if (STREQ(argv[1], "outputheaders")) {        Tcl_SetResult(interp, connPtr->tclOutputHdrs, TCL_STATIC);    } else if (STREQ(argv[1], "form")) {    	if (!connPtr->tclFormInit) {            form = Ns_ConnGetQuery(conn);            if (form != NULL) {                Ns_TclEnterSet(interp, Ns_SetCopy(form), 1);        	strcpy(connPtr->tclForm, interp->result);	    }	    connPtr->tclFormInit = 1;	}        Tcl_SetResult(interp, connPtr->tclForm, TCL_STATIC);    } else if (STREQ(argv[1], "request")) {        Tcl_SetResult(interp, request->line, TCL_STATIC);    } else if (STREQ(argv[1], "method")) {        Tcl_SetResult(interp, request->method, TCL_STATIC);    } else if (STREQ(argv[1], "protocol")) {        Tcl_SetResult(interp, request->protocol, TCL_STATIC);    } else if (STREQ(argv[1], "host")) {        Tcl_SetResult(interp, request->host, TCL_STATIC);    } else if (STREQ(argv[1], "port")) {        sprintf(interp->result, "%d", request->port);    } else if (STREQ(argv[1], "url")) {        Tcl_SetResult(interp, request->url, TCL_STATIC);    } else if (STREQ(argv[1], "query")) {        Tcl_SetResult(interp, request->query, TCL_STATIC);    } else if (STREQ(argv[1], "urlc")) {        sprintf(interp->result, "%d", request->urlc);    } else if (STREQ(argv[1], "version")) {        sprintf(interp->result, "%1.1f", request->version);        return TCL_OK;    } else if (STREQ(argv[1], "location")) {        Tcl_SetResult(interp, Ns_ConnLocation(conn), TCL_STATIC);    } else if (STREQ(argv[1], "driver")) {	Tcl_AppendResult(interp, Ns_ConnDriverName(conn), NULL);	return TCL_OK;    } else if (STREQ(argv[1], "server")) {        Tcl_SetResult(interp, Ns_ConnServer(conn), TCL_STATIC);    } else if (STREQ(argv[1], "status")) {        sprintf(interp->result, "%d", Ns_ConnResponseStatus(conn));    } else if (STREQ(argv[1], "sock")) {	sprintf(interp->result, "%d", Ns_ConnSock(conn));    } else if (STREQ(argv[1], "id")) {	sprintf(interp->result, "%d", Ns_ConnId(conn));    } else if (STREQ(argv[1], "flags")) {	sprintf(interp->result, "%d", connPtr->flags);    } else if (STREQ(argv[1], "start")) {	sprintf(interp->result, "%d", (int) connPtr->startTime);    } else if (STREQ(argv[1], "close")) {        if (Ns_ConnClose(conn) != NS_OK) {            Tcl_SetResult(interp, "could not close connection", TCL_STATIC);            return TCL_ERROR;        }    } else if (STREQ(argv[1], "isconnected")) {	Tcl_SetResult(interp, (connPtr == NULL) ? "0" : "1", TCL_STATIC);	return TCL_OK;    } else {        Tcl_AppendResult(interp, "unknown command \"", argv[1],			 "\":  should be "                         "authpassword, "                         "authuser, "                         "content, "                         "contentlength, "                         "driver, "                         "flags, "                         "form, "                         "headers, "                         "host, "                         "location, "                         "method, "                         "outputheaders, "                         "peeraddr, "			 "peerport, "                         "port, "                         "protocol, "                         "url, "                         "query, "                         "server, "			 "sock, "                         "start, "                         "status, "                         "urlc, "                         "urlv, "                         "close, "                         "isconnected, "                         "or version", NULL);        return TCL_ERROR;    }    return TCL_OK;}