rem: connPtr = (Conn *) conn = itPtr->conn;
context: NsTclConnObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj **objv){    NsInterp     *itPtr = arg;    Ns_Conn      *conn;    Conn         *connPtr;    Ns_Set       *form;    Ns_Request   *request;    Tcl_Encoding  encoding;    Tcl_Channel   chan;    Tcl_Obj	 *result;    int		  idx, off, len;    static CONST char *opts[] = {	 "authpassword", "authuser", "close", "content", "contentlength",	 "copy", "driver", "encoding", "files", "flags", "form",	 "headers", "host", "id", "isconnected", "location", "method",	 "outputheaders", "peeraddr", "peerport", "port", "protocol",	 "query", "request", "server", "sock", "start", "status",	 "url", "urlc", "urlv", "version", NULL,    };    enum ISubCmdIdx {	 CAuthPasswordIdx, CAuthUserIdx, CCloseIdx, CContentIdx,	 CContentLengthIdx, CCopyIdx, CDriverIdx, CEncodingIdx,	 CFilesIdx, CFlagsIdx, CFormIdx, CHeadersIdx, CHostIdx,	 CIdIdx, CIsConnectedIdx, CLocationIdx, CMethodIdx,	 COutputHeadersIdx, CPeerAddrIdx, CPeerPortIdx, CPortIdx,	 CProtocolIdx, CQueryIdx, CRequestIdx, CServerIdx, CSockIdx,	 CStartIdx, CStatusIdx, CUrlIdx, CUrlcIdx, CUrlvIdx,	 CVersionIdx,    } opt;    if (objc < 2) {	Tcl_WrongNumArgs(interp, 1, objv, "option");        return TCL_ERROR;    }    if (Tcl_GetIndexFromObj(interp, objv[1], opts, "option", 0,			    (int *) &opt) != TCL_OK) {	return TCL_ERROR;    }    /*     * Only the "isconnected" option operates without a conn.     */    if (itPtr->conn == NULL && opt != CIsConnectedIdx) {	Tcl_SetResult(interp, "no current connection", TCL_STATIC);        return TCL_ERROR;    }    connPtr = (Conn *) conn = itPtr->conn;    request = connPtr->request;    result  = Tcl_GetObjResult(interp);    switch (opt) {	case CIsConnectedIdx:	    Tcl_SetBooleanObj(result, connPtr ? 0 : 1);	    break;			case CUrlvIdx:	    if (objc == 2 || (objc == 3 && NsIsIdConn(Tcl_GetString(objv[2])))) {		for (idx = 0; idx < request->urlc; idx++) {		    Tcl_AppendElement(interp, request->urlv[idx]);		}	    } else if (Tcl_GetIntFromObj(interp, objv[2], &idx) != TCL_OK) {		return TCL_ERROR;	    } else if (idx >= 0 && idx < request->urlc) {		Tcl_SetResult(interp, request->urlv[idx], TCL_STATIC);	    }	    break;	case CAuthUserIdx:	    Tcl_SetResult(interp, connPtr->authUser, TCL_STATIC);	    break;	    	case CAuthPasswordIdx:	    Tcl_SetResult(interp, connPtr->authPasswd, TCL_STATIC);	    break;	case CContentIdx:	    Tcl_SetResult(interp, Ns_ConnContent(conn), TCL_STATIC);	    break;	    	case CContentLengthIdx:	    Tcl_SetIntObj(result, conn->contentLength);	    break;	case CEncodingIdx:	    if (objc > 2) {		encoding = Ns_GetEncoding(Tcl_GetString(objv[2]));		if (encoding == NULL) {		    Tcl_AppendResult(interp, "no such encoding: ",			Tcl_GetString(objv[2]), NULL);		    return TCL_ERROR;		}		connPtr->encoding = encoding;	    }	    if (connPtr->encoding != NULL) {		Tcl_SetResult(interp, (char *) Tcl_GetEncodingName(connPtr->encoding),			      TCL_STATIC);	    }	    break;		case CPeerAddrIdx:	    Tcl_SetResult(interp, Ns_ConnPeer(conn), TCL_STATIC);	    break;		case CPeerPortIdx:	    Tcl_SetIntObj(result, Ns_ConnPeerPort(conn));	    break;	case CHeadersIdx:	    if (itPtr->nsconn.flags & CONN_TCLHDRS) {		Tcl_SetResult(interp, itPtr->nsconn.hdrs, TCL_STATIC);	    } else {		Ns_TclEnterSet(interp, connPtr->headers, NS_TCL_SET_STATIC);		strcpy(itPtr->nsconn.hdrs, Tcl_GetStringResult(interp));		itPtr->nsconn.flags |= CONN_TCLHDRS;	    }	    break;		case COutputHeadersIdx:	    if (itPtr->nsconn.flags & CONN_TCLOUTHDRS) {		Tcl_SetResult(interp, itPtr->nsconn.outhdrs, TCL_STATIC);	    } else {		Ns_TclEnterSet(interp, connPtr->outputheaders, NS_TCL_SET_STATIC);		strcpy(itPtr->nsconn.outhdrs, Tcl_GetStringResult(interp));		itPtr->nsconn.flags |= CONN_TCLOUTHDRS;	    }	    break;		case CFormIdx:	    if (itPtr->nsconn.flags & CONN_TCLFORM) {		Tcl_SetResult(interp, itPtr->nsconn.form, TCL_STATIC);	    } else {		form = Ns_ConnGetQuery(conn);		if (form == NULL) {		    itPtr->nsconn.form[0] = '\0';		} else {		    Ns_TclEnterSet(interp, form, NS_TCL_SET_STATIC);		    strcpy(itPtr->nsconn.form, Tcl_GetStringResult(interp));		}		itPtr->nsconn.flags |= CONN_TCLFORM;	    }	    break;	case CFilesIdx:	    Tcl_SetResult(interp, connPtr->files.string, TCL_STATIC);	    break;	case CCopyIdx:	    if (objc != 5) {		Tcl_WrongNumArgs(interp, 1, objv, "copy off len chan");		return TCL_ERROR;	    }	    if (Tcl_GetIntFromObj(interp, objv[2], &off) != TCL_OK ||		Tcl_GetIntFromObj(interp, objv[3], &len) != TCL_OK ||		GetChan(interp, Tcl_GetString(objv[4]), &chan) != TCL_OK) {		return TCL_ERROR;	    }	    if (off < 0 || off > connPtr->reqPtr->length) {		Tcl_AppendResult(interp, "invalid offset: ", Tcl_GetString(objv[2]), NULL);		return TCL_ERROR;	    }	    if (len < 0 || len > (connPtr->reqPtr->length - off)) {		Tcl_AppendResult(interp, "invalid length: ", Tcl_GetString(objv[3]), NULL);		return TCL_ERROR;	    }	    if (Tcl_WriteChars(chan, connPtr->reqPtr->content + off, len) != len) {		Tcl_AppendResult(interp, "could not write ", Tcl_GetString(objv[3]), " bytes to ",		    Tcl_GetString(objv[4]), ": ", Tcl_PosixError(interp), NULL);		return TCL_ERROR;	    }	    break;	case CRequestIdx:	    Tcl_SetResult(interp, request->line, TCL_STATIC);	    break;	case CMethodIdx:	    Tcl_SetResult(interp, request->method, TCL_STATIC);	    break;	case CProtocolIdx:	    Tcl_SetResult(interp, request->protocol, TCL_STATIC);	    break;	case CHostIdx:	    Tcl_SetResult(interp, request->host, TCL_STATIC);	    break;		case CPortIdx:	    Tcl_SetIntObj(result, request->port);	    break;	case CUrlIdx:	    Tcl_SetResult(interp, request->url, TCL_STATIC);	    break;		case CQueryIdx:	    Tcl_SetResult(interp, request->query, TCL_STATIC);	    break;		case CUrlcIdx:	    Tcl_SetIntObj(result, request->urlc);	    break;		case CVersionIdx:	    Tcl_SetDoubleObj(result, request->version);	    break;	case CLocationIdx:	    Tcl_SetResult(interp, Ns_ConnLocation(conn), TCL_STATIC);	    break;	case CDriverIdx:	    Tcl_SetResult(interp, Ns_ConnDriverName(conn), TCL_STATIC);	    break;    	case CServerIdx:	    Tcl_SetResult(interp, Ns_ConnServer(conn), TCL_STATIC);	    break;	case CStatusIdx:	    Tcl_SetIntObj(result, Ns_ConnResponseStatus(conn));	    break;	case CSockIdx:	    Tcl_SetIntObj(result, Ns_ConnSock(conn));	    break;		case CIdIdx:	    Tcl_SetIntObj(result, Ns_ConnId(conn));	    break;		case CFlagsIdx:	    Tcl_SetIntObj(result, connPtr->flags);	    break;	case CStartIdx:	    Tcl_SetLongObj(result, connPtr->startTime);	    break;	case CCloseIdx:	    if (Ns_ConnClose(conn) != NS_OK) {		Tcl_SetResult(interp, "could not close connection", TCL_STATIC);		return TCL_ERROR;	    }	    break;	        }    return TCL_OK;}