diff options
Diffstat (limited to 'sapi/aolserver/aolserver.c')
| -rw-r--r-- | sapi/aolserver/aolserver.c | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/sapi/aolserver/aolserver.c b/sapi/aolserver/aolserver.c index 9df215ecd6..bc583e78ad 100644 --- a/sapi/aolserver/aolserver.c +++ b/sapi/aolserver/aolserver.c @@ -101,12 +101,12 @@ php_ns_sapi_ub_write(const char *str, uint str_length) sent += n; str_length -= n; } - + return sent; } /* - * php_ns_sapi_header_handler() sets a HTTP reply header to be + * php_ns_sapi_header_handler() sets a HTTP reply header to be * sent to the client. */ @@ -135,7 +135,7 @@ php_ns_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct } sapi_free_header(sapi_header); - + return 0; } @@ -150,9 +150,9 @@ php_ns_sapi_send_headers(sapi_headers_struct *sapi_headers) if(SG(sapi_headers).send_default_content_type) { Ns_ConnSetRequiredHeaders(NSG(conn), "text/html", 0); } - + Ns_ConnFlushHeaders(NSG(conn), SG(sapi_headers).http_response_code); - + return SAPI_HEADER_SENT_SUCCESSFULLY; } @@ -168,9 +168,9 @@ php_ns_sapi_read_post(char *buf, uint count_bytes) uint total_read = 0; max_read = MIN(NSG(data_avail), count_bytes); - + total_read = Ns_ConnRead(NSG(conn), buf, max_read); - + if(total_read == NS_ERROR) { total_read = -1; } else { @@ -180,16 +180,16 @@ php_ns_sapi_read_post(char *buf, uint count_bytes) return total_read; } -/* +/* * php_ns_sapi_read_cookies() returns the Cookie header from * the HTTP request header */ - + static char *php_ns_sapi_read_cookies(void) { int i; char *http_cookie = NULL; - + i = Ns_SetIFind(NSG(conn->headers), "cookie"); if(i != -1) { http_cookie = Ns_SetValue(NSG(conn->headers), i); @@ -203,7 +203,7 @@ static void php_info_aolserver(ZEND_MODULE_INFO_FUNC_ARGS) char buf[512]; int uptime = Ns_InfoUptime(); int i; - + php_info_print_table_start(); php_info_print_table_row(2, "SAPI module version", "$Id$"); php_info_print_table_row(2, "Build date", Ns_InfoBuildDate()); @@ -215,7 +215,7 @@ static void php_info_aolserver(ZEND_MODULE_INFO_FUNC_ARGS) php_info_print_table_row(2, "Server platform", Ns_InfoPlatform()); snprintf(buf, 511, "%s/%s", Ns_InfoServerName(), Ns_InfoServerVersion()); php_info_print_table_row(2, "Server version", buf); - snprintf(buf, 511, "%d day(s), %02d:%02d:%02d", + snprintf(buf, 511, "%d day(s), %02d:%02d:%02d", uptime / 86400, (uptime / 3600) % 24, (uptime / 60) % 60, @@ -268,11 +268,11 @@ PHP_FUNCTION(getallheaders) int i; array_init(return_value); - + for (i = 0; i < Ns_SetSize(NSG(conn->headers)); i++) { char *key = Ns_SetKey(NSG(conn->headers), i); char *value = Ns_SetValue(NSG(conn->headers), i); - + add_assoc_string(return_value, key, value); } } @@ -314,7 +314,7 @@ php_ns_sapi_register_variables(zval *track_vars_array) char c; snprintf(buf, NS_BUF_SIZE, "HTTP_%s", key); - + for(p = buf + 5; (c = *p); p++) { c = toupper(c); if(c < 'A' || c > 'Z') { @@ -325,7 +325,7 @@ php_ns_sapi_register_variables(zval *track_vars_array) ADD_STRINGX(buf, value); } - + snprintf(buf, NS_BUF_SIZE, "%s/%s", Ns_InfoServerName(), Ns_InfoServerVersion()); ADD_STRING("SERVER_SOFTWARE"); snprintf(buf, NS_BUF_SIZE, "HTTP/%1.1f", NSG(conn)->request->version); @@ -335,7 +335,7 @@ php_ns_sapi_register_variables(zval *track_vars_array) if(NSG(conn)->request->query) ADD_STRINGX("QUERY_STRING", NSG(conn)->request->query); - + ADD_STRINGX("SERVER_BUILDDATE", Ns_InfoBuildDate()); ADD_STRINGX("REMOTE_ADDR", Ns_ConnPeer(NSG(conn))); @@ -410,12 +410,12 @@ php_ns_module_main(void) file_handle.filename = SG(request_info).path_translated; file_handle.free_filename = 0; file_handle.opened_path = NULL; - + php_ns_config(global_context, 0); if (php_request_startup() == FAILURE) { return NS_ERROR; } - + php_execute_script(&file_handle); php_request_shutdown(NULL); @@ -427,7 +427,7 @@ php_ns_module_main(void) * and fills it with data provided by the web server */ -static void +static void php_ns_request_ctor(void) { char *server; @@ -435,15 +435,15 @@ php_ns_request_ctor(void) char *root; int index; char *tmp; - + server = Ns_ConnServer(NSG(conn)); - + #define safe_strdup(x) ((x)?strdup((x)):NULL) SG(request_info).query_string = safe_strdup(NSG(conn->request->query)); Ns_DStringInit(&ds); Ns_UrlToFile(&ds, server, NSG(conn->request->url)); - + /* path_translated is the absolute path to the file */ SG(request_info).path_translated = safe_strdup(Ns_DStringValue(&ds)); Ns_DStringFree(&ds); @@ -454,7 +454,7 @@ php_ns_request_ctor(void) else SG(request_info).proto_num = 1000; SG(request_info).content_length = Ns_ConnContentLength(NSG(conn)); index = Ns_SetIFind(NSG(conn)->headers, "content-type"); - SG(request_info).content_type = index == -1 ? NULL : + SG(request_info).content_type = index == -1 ? NULL : Ns_SetValue(NSG(conn)->headers, index); SG(sapi_headers).http_response_code = 200; @@ -473,7 +473,7 @@ php_ns_request_ctor(void) /* * php_ns_request_dtor() destroys all data associated with - * the per-request structure + * the per-request structure */ static void @@ -494,15 +494,15 @@ static int php_ns_request_handler(void *context, Ns_Conn *conn) { int status = NS_OK; - + NSG(conn) = conn; - + SG(server_context) = global_context; php_ns_request_ctor(); - + status = php_ns_module_main(); - + php_ns_request_dtor(); return status; @@ -514,7 +514,7 @@ php_ns_request_handler(void *context, Ns_Conn *conn) * It understands the "map" and "php_value" command. */ -static void +static void php_ns_config(php_ns_context *ctx, char global) { int i; @@ -534,10 +534,10 @@ php_ns_config(php_ns_context *ctx, char global) 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) + /* + * 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")) { @@ -548,25 +548,25 @@ php_ns_config(php_ns_context *ctx, char global) val = strchr(value, ' '); if (val) { char *new_key; - + new_key = estrndup(value, val - value); - - do { - val++; + + 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, + 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 } - + } } - + /* * php_ns_server_shutdown() performs the last steps before the * server exits. Shutdowns basic services and frees memory @@ -576,7 +576,7 @@ static void php_ns_server_shutdown(void *context) { php_ns_context *ctx = (php_ns_context *) context; - + ctx->sapi_module->shutdown(ctx->sapi_module); sapi_shutdown(); tsrm_shutdown(); @@ -596,20 +596,20 @@ php_ns_server_shutdown(void *context) int Ns_ModuleInit(char *server, char *module) { php_ns_context *ctx; - + tsrm_startup(1, 1, 0, NULL); sapi_startup(&aolserver_sapi_module); sapi_module.startup(&aolserver_sapi_module); - + /* TSRM is used to allocate a per-thread structure */ ts_allocate_id(&ns_globals_id, sizeof(ns_globals_struct), NULL, NULL); - + /* the context contains data valid for all threads */ ctx = malloc(sizeof *ctx); ctx->sapi_module = &aolserver_sapi_module; ctx->ns_server = strdup(server); ctx->ns_module = strdup(module); - + /* read the configuration */ php_ns_config(ctx, 1); |
