char * Ns_ConfigGetPath(char *server, char *module, ...) { va_list ap; char *s; Ns_DString ds; Ns_Set *set; Ns_DStringInit(&ds); Ns_DStringAppend(&ds, "ns"); if (server != NULL) { Ns_DStringVarAppend(&ds, "/server/", server, NULL); } if (module != NULL) { Ns_DStringVarAppend(&ds, "/module/", module, NULL); } va_start(ap, module); while ((s = va_arg(ap, char *)) != NULL) { Ns_DStringAppend(&ds, "/"); while (*s != '\0' && ISSLASH(*s)) { ++s; } Ns_DStringAppend(&ds, s); while (ISSLASH(ds.string[ds.length - 1])) { ds.string[--ds.length] = '\0'; } } va_end(ap); set = Ns_ConfigGetSection(ds.string); Ns_DStringFree(&ds); return (set ? Ns_SetName(set) : NULL); }
void NsUpdateMimeTypes(void) { Ns_Set *set; int i; set = Ns_ConfigGetSection("ns/mimetypes"); if (set == NULL) { return; } defaultType = Ns_SetIGet(set, "default"); if (defaultType == NULL) { defaultType = TYPE_DEFAULT; } noextType = Ns_SetIGet(set, "noextension"); if (noextType == NULL) { noextType = defaultType; } for (i=0; i < Ns_SetSize(set); i++) { AddType(Ns_SetKey(set, i), Ns_SetValue(set, i)); } }
static void php_ns_config(php_ns_context *ctx, char global) { int i; char *path; Ns_Set *set; path = Ns_ConfigGetPath(ctx->ns_server, ctx->ns_module, NULL); set = Ns_ConfigGetSection(path); for (i = 0; set && i < Ns_SetSize(set); i++) { char *key = Ns_SetKey(set, i); char *value = Ns_SetValue(set, i); if (global && !strcasecmp(key, "map")) { Ns_Log(Notice, "Registering PHP for \"%s\"", value); Ns_RegisterRequest(ctx->ns_server, "GET", value, php_ns_request_handler, NULL, ctx, 0); Ns_RegisterRequest(ctx->ns_server, "POST", value, php_ns_request_handler, NULL, ctx, 0); Ns_RegisterRequest(ctx->ns_server, "HEAD", value, php_ns_request_handler, NULL, ctx, 0); /* * Deactivated for now. The ini system will cause random crashes when * accessed from here (since there are no locks to protect the global * known_directives) */ } else if (!global && !strcasecmp(key, "php_value")) { Ns_Log(Notice, "php_value has been deactivated temporarily. Please use a php.ini file to pass directives to PHP. Thanks."); #if 0 char *val; val = strchr(value, ' '); if (val) { char *new_key; new_key = estrndup(value, val - value); do { val++; } while(*val == ' '); Ns_Log(Debug, "PHP configuration option '%s=%s'", new_key, val); zend_alter_ini_entry(new_key, strlen(new_key) + 1, val, strlen(val) + 1, PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE); efree(new_key); } #endif } } }
int NsTclConfigSectionCmd(ClientData dummy, Tcl_Interp *interp, int argc, char **argv) { Ns_Set *set; if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " key\"", NULL); return TCL_ERROR; } set = Ns_ConfigGetSection(argv[1]); if (set == NULL) { Tcl_SetResult(interp, "", TCL_STATIC); } else { Ns_TclEnterSet(interp, set, NS_TCL_SET_STATIC); } return TCL_OK; }