in src/generic/modwebsh_ap.c [282:375]
int Web_InterpClassCfg_AP(ClientData clientData,
Tcl_Interp * interp, int objc, Tcl_Obj * CONST objv[])
{
Tcl_HashEntry *entry;
char *id;
WebInterpClass *webInterpClass = NULL;
int index;
static TCLCONST char *classParams[] = {
"maxttl",
"maxidletime",
"maxrequests",
NULL
};
enum params
{
CLASS_TTL,
CLASS_IDLETIME,
CLASS_REQUESTS
};
websh_server_conf *conf = (websh_server_conf *) clientData;
WebAssertObjc(objc < 3 || objc > 4, 1, "id parameter ?value?");
id = Tcl_GetString(objv[1]);
Tcl_MutexLock(&(conf->webshPoolLock));
/* see if we have that id */
entry = Tcl_FindHashEntry(conf->webshPool, id);
if (entry != NULL) {
webInterpClass = (WebInterpClass *) Tcl_GetHashValue(entry);
}
if (webInterpClass == NULL) {
struct stat statPtr;
int isnew = 0;
Tcl_Stat(id, &statPtr);
webInterpClass = createWebInterpClass(conf, id, statPtr.st_mtime);
entry = Tcl_CreateHashEntry(conf->webshPool, id, &isnew);
Tcl_SetHashValue(entry, (ClientData) webInterpClass);
}
if (Tcl_GetIndexFromObj(interp, objv[2], classParams, "parameter", 0,
&index) != TCL_OK) {
Tcl_MutexUnlock(&(conf->webshPoolLock));
return TCL_ERROR;
}
switch ((enum params) index) {
case CLASS_TTL:{
long maxttl = webInterpClass->maxttl;
if (objc == 4)
if (Tcl_GetLongFromObj
(interp, objv[3], &(webInterpClass->maxttl)) != TCL_OK) {
Tcl_MutexUnlock(&(conf->webshPoolLock));
return TCL_ERROR;
}
Tcl_SetObjResult(interp, Tcl_NewLongObj(maxttl));
break;
}
case CLASS_IDLETIME:{
long maxidletime = webInterpClass->maxidletime;
if (objc == 4)
if (Tcl_GetLongFromObj
(interp, objv[3],
&(webInterpClass->maxidletime)) != TCL_OK) {
Tcl_MutexUnlock(&(conf->webshPoolLock));
return TCL_ERROR;
}
Tcl_SetObjResult(interp, Tcl_NewLongObj(maxidletime));
break;
}
case CLASS_REQUESTS:{
long maxrequests = webInterpClass->maxrequests;
if (objc == 4)
if (Tcl_GetLongFromObj
(interp, objv[3],
&(webInterpClass->maxrequests)) != TCL_OK) {
Tcl_MutexUnlock(&(conf->webshPoolLock));
return TCL_ERROR;
}
Tcl_SetObjResult(interp, Tcl_NewLongObj(maxrequests));
break;
}
}
Tcl_MutexUnlock(&(conf->webshPoolLock));
return TCL_OK;
}