int Web_InterpCfg_AP()

in src/generic/modwebsh_ap.c [190:276]


int Web_InterpCfg_AP(ClientData clientData,
		  Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[])
{

    int index;

    static TCLCONST char *interpParams[] = {
	"numrequests",
	"starttime",
	"lastusedtime",
	"retire",
	NULL
    };

    enum params
    {
      INTERP_REQUESTS,
      INTERP_START,
      INTERP_LASTUSED,
      INTERP_RETIRE
    };

    WebInterp *webInterp = (WebInterp *) clientData;

    WebAssertObjc(objc > 3, 1, "?key ?value??");


    if (objc == 1) {
	/* return interpreter class name */
	Tcl_SetResult(interp, webInterp->interpClass->filename, TCL_VOLATILE);
	return TCL_OK;
    }

    if (Tcl_GetIndexFromObj(interp, objv[1], interpParams, "parameter", 0,
			    &index) != TCL_OK) {
	return TCL_ERROR;
    }

    switch ((enum params) index) {
    case INTERP_REQUESTS:{
	    long numrequests = webInterp->numrequests;
	    if (objc == 3)
		if (Tcl_GetLongFromObj
		    (interp, objv[2], &(webInterp->numrequests)) != TCL_OK) {
		    return TCL_ERROR;
		}
	    Tcl_SetObjResult(interp, Tcl_NewLongObj(numrequests));
	    break;
	}
    case INTERP_START:{
	    long starttime = webInterp->starttime;
	    if (objc == 3)
		if (Tcl_GetLongFromObj
		    (interp, objv[2], &(webInterp->starttime)) != TCL_OK) {
		    return TCL_ERROR;
		}
	    Tcl_SetObjResult(interp, Tcl_NewLongObj(starttime));
	    break;
	}
    case INTERP_LASTUSED:{
	    long lastusedtime = webInterp->lastusedtime;
	    if (objc == 3)
		if (Tcl_GetLongFromObj
		    (interp, objv[2], &(webInterp->lastusedtime)) != TCL_OK) {
		    return TCL_ERROR;
		}
	    Tcl_SetObjResult(interp, Tcl_NewLongObj(lastusedtime));
	    break;
	}
    case INTERP_RETIRE:{
	    int expire = (webInterp->state == WIP_EXPIREDINUSE);
	    if (objc == 3) {
		int retire = 0;
		if (Tcl_GetBooleanFromObj(interp, objv[2], &retire) != TCL_OK) {
		    return TCL_ERROR;
		}
		if (retire)
		    webInterp->state = WIP_EXPIREDINUSE;
		else
		    webInterp->state = WIP_INUSE;
	    }
	    Tcl_SetObjResult(interp, Tcl_NewIntObj(expire));
	    break;
	}
    }
    return TCL_OK;
}