void
NsConfUpdate(void)
{
    int stacksize;
    Ns_DString ds;
    
    Ns_DStringInit(&ds);
    Ns_HomePath(&ds, "modules", "tcl", NULL);
    nsconf.tcl.sharedlibrary = Ns_DStringExport(&ds);

    nsconf.shutdowntimeout = NsParamInt("shutdowntimeout", SHUTDOWNTIMEOUT);
    nsconf.sched.maxelapsed = NsParamInt("schedmaxelapsed", SCHED_MAXELAPSED);
    nsconf.backlog = NsParamInt("listenbacklog", LISTEN_BACKLOG);
    nsconf.http.major = (unsigned) NsParamInt("httpmajor", HTTP_MAJOR);
    nsconf.http.minor = (unsigned) NsParamInt("httpmajor", HTTP_MINOR);
    nsconf.tcl.lockoninit = NsParamBool("tclinitlock", TCL_INITLCK);

    if (!Ns_ConfigGetInt(NS_CONFIG_THREADS, "stacksize", &stacksize)) {
    	stacksize = NsParamInt("stacksize", THREAD_STACKSIZE);
    }
    Ns_ThreadStackSize(stacksize);

    NsLogConf();
    NsEnableDNSCache();
    NsUpdateEncodings();
    NsUpdateMimeTypes();
}
int
NsParamInt(char *key, int def)
{
    int i;

    if (!Ns_ConfigGetInt(NS_CONFIG_PARAMETERS, key, &i) || i < 0) {
	i = def;
    }
    return i;
}
Exemple #3
0
int
NsTclConfigCmd(ClientData dummy, Tcl_Interp *interp, int argc, char **argv)
{
    char *value;
    int   i;
    int   fHasDefault = NS_FALSE;
    int	  defaultIndex = 0;

    if (argc < 3 || argc > 5) {
        Tcl_AppendResult(interp, "wrong # args:  should be \"",
            argv[0], " ?-exact | -bool | -int? section key ?default?\"", NULL);
        return TCL_ERROR;
    }

    if (argv[1][0] == '-') {
	if (argc == 5) {
	    fHasDefault = NS_TRUE;
	    defaultIndex = 4;
	}
    } else if (argc == 4) {
	fHasDefault = NS_TRUE;
	defaultIndex = 3;
    }
   
    if (STREQ(argv[1], "-exact")) {
        value = Ns_ConfigGetValueExact(argv[2], argv[3]);

	if (value == NULL && fHasDefault) {
	    value = argv[defaultIndex];
	}
    } else if (STREQ(argv[1], "-int")) {
        if (Ns_ConfigGetInt(argv[2], argv[3], &i)) {
            Tcl_SetObjResult(interp, Tcl_NewIntObj(i));
            return TCL_OK;
        } else if (fHasDefault) {
	    if (Tcl_GetInt(interp, argv[defaultIndex], &i) != TCL_OK) {
		return TCL_ERROR;
	    }
            Tcl_SetObjResult(interp, Tcl_NewIntObj(i));
	    return TCL_OK;
	}
        value = NULL;
    } else if (STREQ(argv[1], "-bool")) {
        int             iValue;

        if (Ns_ConfigGetBool(argv[2], argv[3], &iValue) == NS_FALSE) {
	    if (fHasDefault) {
		if (   Tcl_GetBoolean(interp, argv[defaultIndex], &iValue)
		    != TCL_OK) {
		    return TCL_ERROR;
		}

		value = (iValue) ? "1" : "0";
		
	    } else {
		value = NULL;
	    }
        } else {
	    value = (iValue) ? "1" : "0";
        }
    } else if (argc == 3 || argc == 4) {
        value = Ns_ConfigGetValue(argv[1], argv[2]);

	if (value == NULL && fHasDefault) {
	    value = argv[defaultIndex];
	}
    } else {
        Tcl_AppendResult(interp, "wrong # args:  should be \"",
            argv[0], " ?-exact | -bool | -int? section key ?default?\"", NULL);
        return TCL_ERROR;
    }
    if (value != NULL) {
	Tcl_SetResult(interp, value, TCL_STATIC);
    }
    return TCL_OK;
}