diff -u mod_ngobjweb.OLD/ChangeLog mod_ngobjweb/ChangeLog --- mod_ngobjweb.OLD/ChangeLog 2003-07-04 16:34:50.000000000 +0200 +++ mod_ngobjweb/ChangeLog 2003-07-15 12:23:51.038999130 +0200 @@ -1,3 +1,8 @@ +2003-07-15 Thomas Woerner + + * port to apache 2.x + * thanks to Ricardo Cerqueira for testing + 2003-02-05 Helge Hess * globals.c: disable HEAVY_LOG per default diff -u mod_ngobjweb.OLD/common.h mod_ngobjweb/common.h --- mod_ngobjweb.OLD/common.h 2003-07-04 16:33:18.000000000 +0200 +++ mod_ngobjweb/common.h 2003-07-15 13:52:18.627537224 +0200 @@ -8,6 +8,8 @@ #include #include #include +#include +#include /* Apache includes */ @@ -17,6 +19,40 @@ #include #include +#if MODULE_MAGIC_NUMBER_MAJOR >= 20010224 +/* apache ap version 2 */ +#include "apr.h" +#include "apr_buckets.h" +#include "apr_strings.h" +#include "apr_portable.h" +#include "apr_optional.h" +#include "apr_lib.h" +#include "ap_config.h" +#include "ap_listen.h" +#else +/* for compatibility */ +#define AP_VERSION_1 + +#define apr_array_header_t array_header +#define apr_inet_addr inet_addr +#define apr_isalnum isalnum +#define apr_isspace isspace +#define apr_palloc ap_palloc +#define apr_pcalloc ap_pcalloc +#define apr_pool_t pool +#define apr_table_elts ap_table_elts +#define apr_table_entry_t table_entry +#define apr_table_get ap_table_get +#define apr_table_make ap_make_table +#define apr_table_set ap_table_set +#define apr_table_t table +#define apr_sleep sleep +#define apr_snprintf snprintf + +#define ap_log_error(file, line, level, status, vars...) \ + ap_log_error(file, line, level, ## vars) +#endif + #include "NGBufferedDescriptor.h" module ngobjweb_module; @@ -40,7 +76,7 @@ extern void * _sendSNSQuery(request_rec *_rq, const char *_line, const char *_cookie, - int *_domain, int *_len, + int *_domain, size_t *_len, const char *_appName, ngobjweb_dir_config *_cfg); @@ -49,7 +85,7 @@ extern char NGScanResponseLine(NGBufferedDescriptor *_in, char *_version, int *_status, char *_text); -extern table *NGScanHeaders(pool *_pool, NGBufferedDescriptor *_in); +extern apr_table_t *NGScanHeaders(apr_pool_t *_pool, NGBufferedDescriptor *_in); /* handlers */ @@ -71,7 +107,7 @@ /* configuration */ -extern void *ngobjweb_create_dir_config(pool *p, char *dummy); -extern void *ngobjweb_merge_dir_configs(pool *p, void *basev, void *addv); +extern void *ngobjweb_create_dir_config(apr_pool_t *p, char *dummy); +extern void *ngobjweb_merge_dir_configs(apr_pool_t *p, void *basev, void *addv); #endif /* __NGObjWeb_Adaptors_apache_H__ */ diff -u mod_ngobjweb.OLD/config.c mod_ngobjweb/config.c --- mod_ngobjweb.OLD/config.c 2003-07-04 16:33:18.000000000 +0200 +++ mod_ngobjweb/config.c 2003-07-15 13:52:51.213858431 +0200 @@ -72,10 +72,10 @@ return NULL; } -void *ngobjweb_create_dir_config(pool *p, char *dummy) { +void *ngobjweb_create_dir_config(apr_pool_t *p, char *dummy) { ngobjweb_dir_config *new; - new = ap_palloc(p, sizeof(ngobjweb_dir_config)); + new = apr_palloc(p, sizeof(ngobjweb_dir_config)); new->snsPort = NULL; new->snsPortDomain = AF_UNIX; new->appPort = NULL; @@ -91,7 +91,7 @@ return new; } -void *ngobjweb_merge_dir_configs(pool *p, void *basev, void *addv) { +void *ngobjweb_merge_dir_configs(apr_pool_t *p, void *basev, void *addv) { ngobjweb_dir_config *base; ngobjweb_dir_config *add; ngobjweb_dir_config *new; @@ -100,10 +100,10 @@ add = (ngobjweb_dir_config *)addv; if (add == NULL) add = base; - if ((new = ap_palloc(p, sizeof(ngobjweb_dir_config))) == NULL) { - fprintf(stderr, "%s: couldn't allocate memory of size %i\n", + if ((new = apr_palloc(p, sizeof(ngobjweb_dir_config))) == NULL) { + fprintf(stderr, "%s: couldn't allocate memory of size %ld\n", __PRETTY_FUNCTION__, - sizeof(ngobjweb_dir_config)); + (long int) sizeof(ngobjweb_dir_config)); return NULL; } diff -u mod_ngobjweb.OLD/GNUmakefile mod_ngobjweb/GNUmakefile --- mod_ngobjweb.OLD/GNUmakefile 2003-07-04 16:33:18.000000000 +0200 +++ mod_ngobjweb/GNUmakefile 2003-07-15 13:00:03.325920392 +0200 @@ -4,9 +4,9 @@ # config -#APACHE = /HOME/helge/apache-marvin-7134 -#APXS = $(APACHE)/bin/apxs -#HTTPD = $(APACHE)/bin/httpd +APACHE = /usr +APXS = $(APACHE)/sbin/apxs +HTTPD = $(APACHE)/sbin/httpd ifneq ($(apxs),no) ifneq ($(apxs),yes) @@ -22,12 +22,9 @@ APXS= endif -HTTPD = /usr/sbin/httpd - -#APACHE_VERSION = $(shell ./apversion.sh -v ${HTTPD}) -#APACHE_SSL = $(shell ./apversion.sh -iseapi "${HTTPD}") -APACHE_VERSION = 1.3.26 -APACHE_SSL = +APACHE_VERSION = $(shell ./apversion.sh -v ${HTTPD} | head -n 1) +#APACHE_SSL = $(shell ./apversion.sh -iseapi ${HTTPD}) +APACHE_SSL = ifneq ($(APXS),) ifneq ($(shared),no) @@ -46,7 +43,7 @@ endif else # no apxs available -APXS_CFLAGS="-fpic -DSHARED_MODULE -O2 -m486 -mcpu=i486 -march=i486 -DEAPI_MM -fPIC -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHARD_SERVER_LIMIT=2048 -DDYNAMIC_MODULE_LIMIT=128 -DLINUX=22 -DMOD_SSL=208103 -DEAPI -DUSE_EXPAT" +APXS_CFLAGS="-DSHARED_MODULE -O2 -DEAPI_MM -fPIC -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHARD_SERVER_LIMIT=2048 -DDYNAMIC_MODULE_LIMIT=128 -DLINUX=22 -DMOD_SSL=208103 -DEAPI -DUSE_EXPAT" endif @@ -56,8 +53,8 @@ LD = gcc SHARED_LIBEXT = .so -CFLAGS = -Wall -g -I. $(APXS_CFLAGS) $(APXS_INCLUDE_DIRS) -LDFLAGS = $(APXS_LDFLAGS) +CFLAGS = -Wall -I. -fPIC $(APXS_CFLAGS) $(APXS_INCLUDE_DIRS) +LDFLAGS = $(APXS_LDFLAGS) -shared -fPIC # adaptor @@ -81,7 +78,7 @@ all : $(product) clean : - rm -f *.o $(product) *.so + rm -f *.o $(product) *.so *~ apache-dir : $(MKDIRS) $(GNUSTEP_INSTALLATION_DIR) diff -u mod_ngobjweb.OLD/handler.c mod_ngobjweb/handler.c --- mod_ngobjweb.OLD/handler.c 2003-07-04 16:33:18.000000000 +0200 +++ mod_ngobjweb/handler.c 2003-07-15 13:48:35.164358313 +0200 @@ -7,7 +7,7 @@ extern int HEAVY_LOG; #if WITH_LOGGING -static void _logTable(const char *text, table *table); +static void _logTable(const char *text, apr_table_t *table); #endif static ngobjweb_dir_config *_getConfig(request_rec *r) { @@ -18,7 +18,7 @@ return NULL; } if (r->per_dir_config == NULL) { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server, "missing directory config in request ..."); return NULL; } @@ -60,7 +60,7 @@ int readBytes, toBeRead; void *requestBody; - clen = ap_table_get(r->headers_in, "content-length"); + clen = apr_table_get(r->headers_in, "content-length"); contentLength = clen ? atoi(clen) : 0; *requestContentLength = contentLength; @@ -70,15 +70,19 @@ /* read content */ if (HEAVY_LOG) { - ap_log_error(__FILE__, __LINE__, APLOG_INFO, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server, "going to read %i bytes from browser ...", contentLength); } - requestBody = ap_palloc(r->pool, contentLength + 2); + requestBody = apr_palloc(r->pool, contentLength + 2); ptr = requestBody; for (toBeRead = contentLength; toBeRead > 0;) { +#ifdef AP_VERSION_1 readBytes = ap_bread(r->connection->client, ptr, toBeRead); +#else + readBytes = ap_get_client_block(r, ptr, toBeRead); +#endif toBeRead -= readBytes; ptr += readBytes; if (readBytes == 0) break; @@ -86,7 +90,7 @@ ptr = NULL; if (toBeRead > 0) { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server, "couldn't read complete HTTP req body from browser " "(read %i of %i bytes)", (contentLength - toBeRead), contentLength); @@ -97,29 +101,29 @@ } static void -_copyHeadersToRequest(request_rec *r, table *headers, int *contentLength) +_copyHeadersToRequest(request_rec *r, apr_table_t *headers, int *contentLength) { - array_header *array; - table_entry *entries; + const apr_array_header_t *array; + apr_table_entry_t *entries; int i; const char *value; if (headers == NULL) return; - value = ap_table_get(headers, "content-type"); + value = apr_table_get(headers, "content-type"); if (value) r->content_type = value; - value = ap_table_get(headers, "content-encoding"); + value = apr_table_get(headers, "content-encoding"); if (value) r->content_encoding = value; - value = ap_table_get(headers, "content-length"); + value = apr_table_get(headers, "content-length"); *contentLength = value ? atoi(value) : 0; - array = ap_table_elts(headers); - entries = (table_entry *)array->elts; + array = apr_table_elts(headers); + entries = (apr_table_entry_t *)array->elts; for (i = 0; i < array->nelts; i++) { - table_entry *entry = &(entries[i]); + apr_table_entry_t *entry = &(entries[i]); - ap_table_set(r->headers_out, entry->key, entry->val); + apr_table_set(r->headers_out, entry->key, entry->val); } // _logTable("out", r->headers_out); } @@ -131,7 +135,7 @@ if (!HEAVY_LOG) return; - sprintf(buf, " => address len=%i domain=%i<", addressLen, domain); + apr_snprintf(buf, sizeof(buf), " => address len=%li domain=%i<", (long int) addressLen, domain); switch (domain) { case AF_INET: strcat(buf, "inet"); break; case AF_UNIX: strcat(buf, "unix"); break; @@ -145,19 +149,17 @@ strcat(buf, "\""); } else if (domain == AF_INET) { - unsigned int ia; char *ptr = NULL; int port; char sport[256]; - ia = (unsigned int)&(((struct sockaddr_in *)address)->sin_addr.s_addr); - ptr = inet_ntoa(*((struct in_addr *)ia)); + ptr = inet_ntoa(((struct sockaddr_in *)address)->sin_addr); port = ntohs(((struct sockaddr_in *)address)->sin_port); - sprintf(sport, "host=\"%s\" port=%i", ptr, port); + apr_snprintf(sport, sizeof(sport), "host=\"%s\" port=%i", ptr, port); strcat(buf, sport); } - ap_log_error(__FILE__, __LINE__, APLOG_INFO, r->server, buf); + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server, buf); } static int _connectInstance(request_rec *r, @@ -175,11 +177,11 @@ char *pdelay = NULL; /* pblock_findval("delay", _paras) */ int delay = pdelay ? atoi(pdelay) : 3; // default: 3s - ap_log_error(__FILE__, __LINE__, APLOG_INFO, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server, "sleeping %is ..", delay); - sleep(delay); + apr_sleep(delay); - ap_log_error(__FILE__, __LINE__, APLOG_INFO, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server, "retry connect .."); result = connect(appFd, address, addressLen); @@ -191,7 +193,7 @@ } if (isConnected == 0) { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server, "connect to application instance failed, tried %i times.", tryCount); close(appFd); @@ -201,17 +203,17 @@ } static int _writeInHeaders(NGBufferedDescriptor *toApp, request_rec *r) { - array_header *array; - table_entry *entries; + const apr_array_header_t *array; + apr_table_entry_t *entries; int i; if (r->headers_in == NULL) return 1; - array = ap_table_elts(r->headers_in); - entries = (table_entry *)array->elts; + array = apr_table_elts(r->headers_in); + entries = (apr_table_entry_t *)array->elts; for (i = 0; i < array->nelts; i++) { - table_entry *entry = &(entries[i]); + apr_table_entry_t *entry = &(entries[i]); if (!NGBufferedDescriptor_writeHttpHeader(toApp, entry->key, entry->val)) { @@ -241,6 +243,11 @@ requestContentLength = 0; requestBody = NULL; +#ifndef AP_VERSION_1 + if (strcmp(r->handler, "ngobjweb-adaptor") != 0) + return DECLINED; +#endif + if (uri == NULL) return DECLINED; if (uri[0] != '/') return DECLINED; if (strstr(uri, "WebServerResources")) return DECLINED; @@ -250,7 +257,7 @@ if ((cfg = _getConfig(r))) { if (cfg->appPrefix) { if (HEAVY_LOG) { - ap_log_error(__FILE__, __LINE__, APLOG_INFO, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server, "using prefix '%s'\n", cfg->appPrefix); } uri += strlen(cfg->appPrefix); @@ -277,13 +284,13 @@ if (cfg->snsPort) { address = _sendSNSQuery(r, r->the_request, - ap_table_get(r->headers_in, "cookie"), + apr_table_get(r->headers_in, "cookie"), &domain, &addressLen, appName, cfg); if (address == NULL) { /* did not find an appropriate application server */ - ap_log_error(__FILE__, __LINE__, APLOG_ERR, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server, "didn't find SKYRiXgreen server using SNS ..."); return DECLINED; } @@ -293,7 +300,7 @@ if (cfg->appPortDomain == AF_UNIX) { addressLen = sizeof(struct sockaddr_un); - address = ap_palloc(r->pool, sizeof(struct sockaddr_un)); + address = apr_palloc(r->pool, sizeof(struct sockaddr_un)); memset(address, 0, sizeof(struct sockaddr_un)); ((struct sockaddr_un *)address)->sun_family = AF_UNIX; @@ -309,38 +316,38 @@ host = "127.0.0.1"; port = atoi(cfg->appPort); - //ap_log_error(__FILE__, __LINE__, APLOG_INFO, r->server, + //ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server, // "appPort: '%s', cfg 0x%08X", cfg->appPort, cfg); addressLen = sizeof(struct sockaddr_in); - address = ap_palloc(r->pool, sizeof(struct sockaddr_in)); + address = apr_palloc(r->pool, sizeof(struct sockaddr_in)); memset(address, 0, sizeof(struct sockaddr_in)); snsi = (struct sockaddr_in *)address; - snsi->sin_addr.s_addr = inet_addr(host); + snsi->sin_addr.s_addr = apr_inet_addr(host); snsi->sin_family = AF_INET; snsi->sin_port = htons((short)(port & 0xFFFF)); if (snsi->sin_addr.s_addr == -1) { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server, "couldn't convert snsd IP address: %s", host); } if (HEAVY_LOG && 0) { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server, "connect IP address: %s", host); } } } else { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server, "neither SNS port nor app port are set for request ..."); return 500; } if (addressLen > 10000) { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, r->server, - "suspect instance port length (%i) ...", addressLen); + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server, + "suspect instance port length (%li) ...", (long int) addressLen); return 500; } @@ -349,7 +356,7 @@ /* setup connection to application server */ if ((appFd = socket(domain, SOCK_STREAM, 0)) < 0) { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server, "could not create socket in domain %i.", domain); return DECLINED; } @@ -360,7 +367,7 @@ toApp = NGBufferedDescriptor_newWithOwnedDescriptorAndSize(appFd, 512); if (toApp == NULL) { close(appFd); - ap_log_error(__FILE__, __LINE__, APLOG_ERR, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server, "could not alloc socket buffer for " "application server connection"); return 500; @@ -369,7 +376,7 @@ /* write request to application server */ if (HEAVY_LOG) - ap_log_error(__FILE__, __LINE__, APLOG_INFO, r->server, "transfer reqline"); + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server, "transfer reqline"); { char *reqLine; @@ -378,7 +385,7 @@ reqLine = r->the_request; toGo = reqLine ? strlen(reqLine) : 0; - ap_log_error(__FILE__, __LINE__, APLOG_INFO, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server, "req is %s(len=%i)", reqLine, toGo); if (!NGBufferedDescriptor_safeWrite(toApp, reqLine, @@ -396,7 +403,7 @@ if (writeError == 0) { if (HEAVY_LOG) - ap_log_error(__FILE__, __LINE__, APLOG_INFO, r->server, "transfer hdrs"); + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server, "transfer hdrs"); /* extended adaptor headers */ { @@ -434,7 +441,11 @@ } } +#ifdef AP_VERSION_1 if ((value = r->connection->ap_auth_type)) { +#else + if ((value = r->ap_auth_type)) { +#endif if (!NGBufferedDescriptor_writeHttpHeader(toApp, "x-webobjects-auth-type", value)) { @@ -443,7 +454,11 @@ } } +#ifdef AP_VERSION_1 if ((value = r->connection->user)) { +#else + if ((value = r->user)) { +#endif if (!NGBufferedDescriptor_writeHttpHeader(toApp, "x-webobjects-remote-user", value)) { @@ -469,7 +484,7 @@ goto writeErrorHandler; } - sprintf(tmp, "%i", r->server->port); + apr_snprintf(tmp, sizeof(tmp), "%i", r->server->port); if (!NGBufferedDescriptor_writeHttpHeader(toApp, "x-webobjects-server-port", tmp)) { @@ -477,7 +492,7 @@ goto writeErrorHandler; } - sprintf(tmp, "%s://%s:%i", + apr_snprintf(tmp, sizeof(tmp), "%s://%s:%i", ap_http_method(r), r->server->server_hostname, r->server->port); @@ -515,7 +530,7 @@ if (writeError == 1) { if (toApp) NGBufferedDescriptor_free(toApp); - ap_log_error(__FILE__, __LINE__, APLOG_ERR, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server, "socket write error during transfer of HTTP header section"); return 500; } @@ -527,7 +542,7 @@ requestBody, requestContentLength)) { if (toApp) NGBufferedDescriptor_free(toApp); - ap_log_error(__FILE__, __LINE__, APLOG_ERR, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server, "couldn't transfer HTTP req body to app server (%i bytes)", contentLength); return 500; @@ -536,7 +551,7 @@ } else { if (HEAVY_LOG) { - ap_log_error(__FILE__, __LINE__, APLOG_INFO, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server, "no content in request to transfer"); } } @@ -545,7 +560,7 @@ if (!NGScanResponseLine(toApp, NULL, &statusCode, NULL)) { if (toApp) NGBufferedDescriptor_free(toApp); - ap_log_error(__FILE__, __LINE__, APLOG_ERR, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server, "error during reading of response line .."); return 500; } @@ -554,18 +569,20 @@ /* process response headers */ { - table *headers = NULL; + apr_table_t *headers = NULL; if (HEAVY_LOG) - ap_log_error(__FILE__, __LINE__, APLOG_INFO, r->server, "scan headers"); + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server, "scan headers"); if ((headers = NGScanHeaders(r->pool, toApp)) == NULL) { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server, "error during parsing of response headers .."); } _copyHeadersToRequest(r, headers, &contentLength); +#ifdef AP_VERSION_1 ap_send_http_header(r); +#endif } /* send response content */ @@ -574,8 +591,8 @@ if (contentLength > 0) { void *buffer = NULL; - if ((buffer = ap_pcalloc(r->pool, contentLength + 1)) == NULL) { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, r->server, + if ((buffer = apr_pcalloc(r->pool, contentLength + 1)) == NULL) { + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, r->server, "could not allocate response buffer (size=%i)", contentLength); } @@ -591,7 +608,7 @@ toApp = NULL; } - ap_log_error(__FILE__, __LINE__, APLOG_INFO, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server, "send response (size=%i)", contentLength); // send response to client @@ -615,7 +632,7 @@ while (result > 0); if (HEAVY_LOG && (writeCount > 0)) { - ap_log_error(__FILE__, __LINE__, APLOG_INFO, r->server, + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, r->server, "write %i bytes (without content-length header)", writeCount); } @@ -645,7 +662,7 @@ r->method, r->protocol, r->the_request, - ap_table_get(r->headers_in, "content-length"), + apr_table_get(r->headers_in, "content-length"), r->content_type, r->handler ); @@ -656,9 +673,9 @@ _logTable(" in", r->headers_in); } -static void _logTable(const char *text, table *table) { - array_header *array; - table_entry *entries; +static void _logTable(const char *text, apr_table_t *table) { + apr_array_header_t *array; + apr_table_entry_t *entries; int i; if (table == NULL) { @@ -666,8 +683,8 @@ return; } - array = ap_table_elts(table); - entries = (table_entry *)array->elts; + array = apr_table_elts(table); + entries = (apr_table_entry_t *)array->elts; if (array->nelts == 0) { fprintf(stderr, "%s: empty\n", text); @@ -675,7 +692,7 @@ } for (i = 0; i < array->nelts; i++) { - table_entry *entry = &(entries[i]); + apr_table_entry_t *entry = &(entries[i]); fprintf(stderr, "%s: %s: %s\n", text, entry->key, entry->val); } diff -u mod_ngobjweb.OLD/NGBufferedDescriptor.c mod_ngobjweb/NGBufferedDescriptor.c --- mod_ngobjweb.OLD/NGBufferedDescriptor.c 2003-07-04 16:33:18.000000000 +0200 +++ mod_ngobjweb/NGBufferedDescriptor.c 2003-07-15 10:42:25.258963413 +0200 @@ -2,6 +2,7 @@ #include #include +#include #include "NGBufferedDescriptor.h" // returns the number of bytes which where read from the buffer diff -u mod_ngobjweb.OLD/ngobjweb_module.c mod_ngobjweb/ngobjweb_module.c --- mod_ngobjweb.OLD/ngobjweb_module.c 2003-07-04 16:33:18.000000000 +0200 +++ mod_ngobjweb/ngobjweb_module.c 2003-07-15 13:46:07.286857759 +0200 @@ -2,11 +2,6 @@ #include "common.h" -static handler_rec ngobjweb_handlers[] = { - { "ngobjweb-adaptor", ngobjweb_handler }, - { NULL } -}; - static command_rec ngobjweb_cmds[] = { { "SetSNSPort", @@ -43,22 +38,13 @@ { NULL } }; +#ifdef AP_VERSION_1 +static handler_rec ngobjweb_handlers[] = { + { "ngobjweb-adaptor", ngobjweb_handler }, + { NULL } +}; + static void ngobjweb_init(server_rec *_server, pool *_pool) { -#if 0 -#if 0 - int port = 7777; - sns = calloc(sizeof(struct sockaddr_in), 1); - ((struct sockaddr_in *)sns)->sin_family = AF_INET; - ((struct sockaddr_in *)sns)->sin_port = htons((short)(port & 0xffff)); -#else - char *psns = NULL; - sns = calloc(sizeof(struct sockaddr_un), 1); - ((struct sockaddr_un *)sns)->sun_family = AF_UNIX; - strncpy(((struct sockaddr_un *)sns)->sun_path, - psns ? psns : "/tmp/.snsd", - sizeof(((struct sockaddr_un *)sns)->sun_path) - 1); -#endif -#endif } module ngobjweb_module = { @@ -79,3 +65,19 @@ NULL, /* logger */ NULL /* header parser */ }; +#else +static void ngobjweb_register_hooks(apr_pool_t *p) { + ap_hook_handler(ngobjweb_handler, NULL, NULL, APR_HOOK_LAST); +} + +module AP_MODULE_DECLARE_DATA ngobjweb_module = { + STANDARD20_MODULE_STUFF, + ngobjweb_create_dir_config, /* create per-directory config structures */ + ngobjweb_merge_dir_configs, /* merge per-directory config structures */ + NULL, /* create per-server config structures */ + NULL, /* merge per-server config structures */ + ngobjweb_cmds, /* command handlers */ + ngobjweb_register_hooks /* register hooks */ +}; +#endif + diff -u mod_ngobjweb.OLD/README mod_ngobjweb/README --- mod_ngobjweb.OLD/README 2003-07-04 16:34:03.000000000 +0200 +++ mod_ngobjweb/README 2003-07-15 13:59:00.409240412 +0200 @@ -14,9 +14,13 @@ SetAppPort SNSUseHTTP (experimental) -Loading the Module ------------------- -LoadModule ngobjweb_module /opt/skyrix/system/Adaptors/apache/ngobjweb_1.3.28.so +Loading the Module with apache 1.3.x +------------------------------------ +LoadModule ngobjweb_module modules/ngobjweb_1.3.x.so + +Loading the Module with apache 2.0.x +------------------------------------ +LoadModule ngobjweb_module modules/ngobjweb_2.0.x.so Example Apache Config --------------------- diff -u mod_ngobjweb.OLD/scanhttp.c mod_ngobjweb/scanhttp.c --- mod_ngobjweb.OLD/scanhttp.c 2003-07-04 16:33:18.000000000 +0200 +++ mod_ngobjweb/scanhttp.c 2003-07-15 10:49:12.241806961 +0200 @@ -19,7 +19,7 @@ { c = NGBufferedDescriptor_readChar(_in); i = 0; - while ((c > 0) && !isspace(c) && (i < 16)) { + while ((c > 0) && !apr_isspace(c) && (i < 16)) { if (_version) _version[i] = c; i++; c = NGBufferedDescriptor_readChar(_in); @@ -29,7 +29,7 @@ } // skip spaces - while ((c > 0) && isspace(c)) + while ((c > 0) && apr_isspace(c)) c = NGBufferedDescriptor_readChar(_in); if (c < 1) return 0; // read error @@ -37,7 +37,7 @@ { char buf[10]; i = 0; - while ((c > 0) && !isspace(c) && (c != '\r') && (c != '\n') && (i < 6)) { + while ((c > 0) && !apr_isspace(c) && (c != '\r') && (c != '\n') && (i < 6)) { buf[i] = c; i++; c = NGBufferedDescriptor_readChar(_in); @@ -47,7 +47,7 @@ } // skip spaces - while ((c > 0) && isspace(c)) + while ((c > 0) && apr_isspace(c)) c = NGBufferedDescriptor_readChar(_in); if (c < 1) return 0; // read error @@ -61,7 +61,7 @@ // scan reason { i = 0; - while ((c > 0) && !isspace(c) && (c != '\r') && (c != '\n') && (i < 6)) { + while ((c > 0) && !apr_isspace(c) && (c != '\r') && (c != '\n') && (i < 6)) { if (_text) _text[i] = c; i++; c = NGBufferedDescriptor_readChar(_in); @@ -79,12 +79,12 @@ return 1; } -table *NGScanHeaders(pool *_pool, NGBufferedDescriptor *_in) { - table *headers = NULL; +apr_table_t *NGScanHeaders(apr_pool_t *_pool, NGBufferedDescriptor *_in) { + apr_table_t *headers = NULL; if (_in == NULL) return NULL; - headers = ap_make_table(_pool, 64); + headers = apr_table_make(_pool, 64); if (headers) { unsigned char name[256]; unsigned char value[8000]; @@ -123,7 +123,7 @@ // skip spaces following separator c = NGBufferedDescriptor_readChar(_in); - while ((c > 0) && (isspace(c))) + while ((c > 0) && (apr_isspace(c))) c = NGBufferedDescriptor_readChar(_in); // scan value @@ -148,7 +148,7 @@ break; // store value - ap_table_set(headers, name, value); + apr_table_set(headers, name, value); } } return headers; diff -u mod_ngobjweb.OLD/sns.c mod_ngobjweb/sns.c --- mod_ngobjweb.OLD/sns.c 2003-07-04 16:33:18.000000000 +0200 +++ mod_ngobjweb/sns.c 2003-07-15 13:13:10.960672741 +0200 @@ -15,7 +15,7 @@ static inline int _isPlistBreakChar(unsigned char c) { - if (!isalnum(c)) return 1; + if (!apr_isalnum(c)) return 1; switch (c) { case '_': case '@': case '#': case '$': @@ -43,7 +43,7 @@ return; } if (_cfg == NULL) { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, _rq->server, "SNS: missing directory config for request .."); return; } @@ -53,7 +53,7 @@ char *end, *pos; if (_cfg->snsPortDomain == AF_UNIX) { - result = ap_palloc(_rq->pool, sizeof(struct sockaddr_un)); + result = apr_palloc(_rq->pool, sizeof(struct sockaddr_un)); memset(result, 0, sizeof(struct sockaddr_un)); ((struct sockaddr_un *)result)->sun_family = AF_UNIX; @@ -71,7 +71,7 @@ /* contains a ':' */ port = strtol((pos + 1), &end, 10); - host = ap_palloc(_rq->pool, (pos - socket) + 3); + host = apr_palloc(_rq->pool, (pos - socket) + 3); strncpy(host, socket, (pos - socket)); host[pos - socket] = '\0'; } @@ -80,26 +80,26 @@ port = strtol(socket, &end, 10); } - result = ap_palloc(_rq->pool, sizeof(struct sockaddr_in)); + result = apr_palloc(_rq->pool, sizeof(struct sockaddr_in)); memset(result, 0, sizeof(struct sockaddr_in)); snsi = (struct sockaddr_in *)result; - snsi->sin_addr.s_addr = inet_addr(host); + snsi->sin_addr.s_addr = apr_inet_addr(host); snsi->sin_family = AF_INET; snsi->sin_port = htons((short)(port & 0xFFFF)); if (snsi->sin_addr.s_addr == -1) { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, _rq->server, "SNS: couldn't convert snsd IP address: %s", host); } if (HEAVY_LOG && 0) { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, _rq->server, "SNS: connect IP address: %s", host); } } else { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, _rq->server, "SNS: unknown socket domain %i for SNS server " "(address=%s) !!!", _cfg->snsPortDomain, _cfg->snsPort); @@ -111,7 +111,7 @@ static void _logSNSConnect(request_rec *_rq, struct sockaddr *sns) { if (sns == NULL) { - ap_log_error(__FILE__, __LINE__, APLOG_INFO, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, _rq->server, "found no SNS socket address ..."); return; } @@ -119,7 +119,7 @@ struct sockaddr_in *snsi = (struct sockaddr_in *)sns; if (HEAVY_LOG) { - ap_log_error(__FILE__, __LINE__, APLOG_INFO, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, _rq->server, "SNS: connecting INET socket (family=%d, ip=%s:%i) ...", sns->sa_family, inet_ntoa(snsi->sin_addr), @@ -128,13 +128,13 @@ } else if (sns->sa_family == AF_UNIX) { if (HEAVY_LOG) { - ap_log_error(__FILE__, __LINE__, APLOG_INFO, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, _rq->server, "SNS: connect UNIX socket (family=%d) ...", sns->sa_family); } } else { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, _rq->server, "SNS: unknown socket address family: %d.", sns->sa_family); } @@ -142,7 +142,7 @@ void *_sendSNSQuery(request_rec *_rq, const char *_line, const char *_cookie, - int *_domain, int *_len, + int *_domain, size_t *_len, const char *_appName, ngobjweb_dir_config *_cfg) { @@ -172,7 +172,7 @@ fd = socket(sns->sa_family, SOCK_STREAM, 0); if (fd < 0) { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, _rq->server, "SNS: could not setup socket to SNS: %s.", strerror(errno)); return NULL; @@ -183,7 +183,7 @@ ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_un)) != 0) { if (HEAVY_LOG) { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, _rq->server, "could not connect sns daemon %s: %s.", sns->sa_family == AF_UNIX ? ((struct sockaddr_un *)sns)->sun_path @@ -196,7 +196,7 @@ toSNS = NGBufferedDescriptor_newWithOwnedDescriptorAndSize(fd, 1024); if (toSNS == NULL) { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, _rq->server, "could not allocate buffered descriptor."); close(fd); return NULL; @@ -209,7 +209,7 @@ int len = strlen(_line); if (HEAVY_LOG) { - ap_log_error(__FILE__, __LINE__, APLOG_INFO, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, _rq->server, "SNS: line %s cookie '%s'", _line, _cookie); } @@ -246,7 +246,7 @@ // send cookie len = strlen(_cookie); if (len > 2000) { - ap_log_error(__FILE__, __LINE__, APLOG_INFO, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, _rq->server, "WARNING: cookie length > 2000 bytes (%i bytes): %s", len, _cookie); } @@ -267,7 +267,7 @@ } if (HEAVY_LOG) { - ap_log_error(__FILE__, __LINE__, APLOG_INFO, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, _rq->server, "SNS: reading response .."); } @@ -277,7 +277,7 @@ int domain; int size; - buffer = ap_palloc(_rq->pool, 1000); + buffer = apr_palloc(_rq->pool, 1000); memset(buffer, 0, 1000); if (!NGBufferedDescriptor_safeRead(toSNS, &domain, sizeof(domain))) { @@ -285,7 +285,7 @@ goto finish; } if (HEAVY_LOG) { - ap_log_error(__FILE__, __LINE__, APLOG_INFO, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, _rq->server, "SNS: domain: %i ..", domain); } @@ -294,12 +294,12 @@ goto finish; } if (HEAVY_LOG) { - ap_log_error(__FILE__, __LINE__, APLOG_INFO, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, _rq->server, "SNS: size: %i ..", size); } if (size > 1024) { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, _rq->server, "SNS: size of returned address is too big (%i bytes) !", size); goto finish; @@ -311,7 +311,7 @@ } if (HEAVY_LOG) { - ap_log_error(__FILE__, __LINE__, APLOG_INFO, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_INFO, 0, _rq->server, "SNS: got address in domain %i, size is %i bytes !", domain, size); } @@ -327,7 +327,7 @@ } finish: if (failed) { - ap_log_error(__FILE__, __LINE__, APLOG_ERR, _rq->server, + ap_log_error(__FILE__, __LINE__, APLOG_ERR, 0, _rq->server, "SNS: lookup request failed (code=%i) !", failed); } if (toSNS) {