mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-04-24 16:02:04 +00:00
* GSWAdaptors/common/GSWAppConnectSocket.c
* GSWAdaptors/common/GSWUtil.c make the old Apache Adaptor work on OpenBSD * GSWAdaptors/Apache/mod_gsweb.c * GSWAdaptors/Apache/GNUmakefile-Apache[1|2]x remove all #ifdef Apache2, and remove old GNUmakefiles git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@36705 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
720585fe82
commit
37f0c6a624
6 changed files with 46 additions and 509 deletions
|
@ -1,3 +1,12 @@
|
|||
2013-06-06: Sebastian Reitenbach <sebastia@l00-bugdead-prods.de>
|
||||
* GSWAdaptors/common/GSWAppConnectSocket.c
|
||||
* GSWAdaptors/common/GSWUtil.c
|
||||
make the old Apache Adaptor work on OpenBSD
|
||||
* GSWAdaptors/Apache/mod_gsweb.c
|
||||
* GSWAdaptors/Apache/GNUmakefile-Apache[1|2]x
|
||||
remove all #ifdef Apache2, and remove old GNUmakefiles
|
||||
|
||||
|
||||
2013-06-02: David Wetzel <dave@turbocat.de>
|
||||
* GSWeb/GSWMessage.m
|
||||
Remove warning
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
# Makefile for Apache 1.x GNUstepWeb module
|
||||
# Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
|
||||
#
|
||||
# Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
# Date: July 1999
|
||||
#
|
||||
# This file is part of the GNUstep Web Library.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
# The result of this is mod_gsweb.so.
|
||||
# Newt, run
|
||||
# apxs -i -a -n gsweb mod_gsweb.so
|
||||
#
|
||||
|
||||
#Solaris, Linux, FreeBSD
|
||||
|
||||
OSNAME := "$(shell uname)"
|
||||
APXS := "$(shell which apxs)"
|
||||
|
||||
ifeq ("",$(strip $(APXS)))
|
||||
ifeq ("FreeBSD",$(strip $(OSNAME)))
|
||||
APXS = /usr/local/sbin/apxs
|
||||
else
|
||||
APXS = /usr/apache/sbin/apxs
|
||||
endif
|
||||
else
|
||||
ifneq (,$(findstring no apxs,$(APXS)))
|
||||
APXS = "/usr/apache/sbin/apxs"
|
||||
endif
|
||||
endif
|
||||
|
||||
APACHEHEADERS := -I/usr/apache/include -I/usr/include/apache -I/usr/local/include/apache -I/usr/lib/apache/include -I/usr/local/include -I/usr/local/apache/include
|
||||
|
||||
APXS := $(APXS) -lPropList -L/usr/local/lib -L/usr/pkg/lib -L/usr/X11R6/lib
|
||||
|
||||
SRCROOT = ..
|
||||
DSTROOT = .
|
||||
OBJROOT = .
|
||||
|
||||
# Directory
|
||||
SERVERAPI = Apache
|
||||
|
||||
ADAPTOR = mod_gsweb.so
|
||||
|
||||
LOADBALANCING = roundrobin
|
||||
ADAPTORLIB = $(OBJROOT)/libAdaptor.a
|
||||
COMMON = $(SRCROOT)/common
|
||||
|
||||
INCLUDE = -I$(COMMON) $(APACHEHEADERS) -I/usr/X11R6/include
|
||||
|
||||
CFLAGS = -O2 $(RC_CFLAGS) $(INCLUDE) -D$(SERVERAPI) -DREENTRANT -DEAPI
|
||||
|
||||
all:: $(ADAPTOR)
|
||||
|
||||
include $(COMMON)/common.make
|
||||
|
||||
OFILES = $(COMMONOBJS) $(OBJROOT)/mod_gsweb.o
|
||||
|
||||
install: $(ADAPTOR)
|
||||
-cp -f $(ADAPTOR) $(DSTROOT)
|
||||
|
||||
$(ADAPTOR):: $(OFILES)
|
||||
$(APXS) -c $(OTHER_LDFLAGS) -o $@ $(OFILES)
|
||||
|
||||
$(OBJROOT)/mod_gsweb.o: $(SRCROOT)/$(SERVERAPI)/mod_gsweb.c
|
||||
$(CC) $(CFLAGS) -c -o $*.o $<
|
||||
|
||||
clean:
|
||||
rm -f $(COMMONOBJS) $(OFILES) $(ADAPTOR) $(ADAPTORLIB) core
|
|
@ -1,104 +0,0 @@
|
|||
# Makefile for Apache 2.x GNUstepWeb module
|
||||
# Copyright (C) 1999-2002 Free Software Foundation, Inc.
|
||||
#
|
||||
# Written by: Manuel Guesdon <mguesdon@orange-concept.com>
|
||||
# Date: Jully 1999
|
||||
# Dec 2002
|
||||
#
|
||||
# This file is part of the GNUstep Web Library.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
# The result of this is mod_gsweb.so.
|
||||
# Newt, run
|
||||
# apxs -i -a -n gsweb mod_gsweb.so
|
||||
#
|
||||
|
||||
#Solaris, Linux, FreeBSD
|
||||
|
||||
OSNAME := "$(shell uname)"
|
||||
APXS := "$(shell which apxs2)"
|
||||
|
||||
ifeq ("no apxs",$(findstring no apxs,$(APXS)))
|
||||
APXS := "$(shell which apxs)"
|
||||
endif
|
||||
|
||||
ifeq ("",$(strip $(APXS)))
|
||||
ifeq ("FreeBSD",$(strip $(OSNAME)))
|
||||
APXS = /usr/local/sbin/apxs
|
||||
else
|
||||
APXS = /usr/apache/sbin/apxs
|
||||
endif
|
||||
else
|
||||
ifneq (,$(findstring no apxs,$(APXS)))
|
||||
APXS = "/usr/apache/sbin/apxs"
|
||||
endif
|
||||
endif
|
||||
|
||||
APACHE_LIBEXECDIR := $(shell $(APXS) -q LIBEXECDIR)
|
||||
APACHEHEADERS := -I$(shell $(APXS) -q INCLUDEDIR)
|
||||
APACHE_CFLAGS := $(shell $(APXS) -q CFLAGS)
|
||||
APACHE_CC := $(shell $(APXS) -q CC)
|
||||
|
||||
SRCROOT = ..
|
||||
DSTROOT = .
|
||||
OBJROOT = .
|
||||
|
||||
# Directory
|
||||
SERVERAPI = Apache2
|
||||
SERVERAPIROOT = Apache
|
||||
|
||||
ADAPTOR = $(DSTROOT)/mod_gsweb.so
|
||||
|
||||
LOADBALANCING = roundrobin
|
||||
COMMON = $(SRCROOT)/common
|
||||
|
||||
INCLUDE = -I. -I$(COMMON) $(APACHEHEADERS) -I/usr/X11R6/include
|
||||
|
||||
CFLAGS = $(APACHE_CFLAGS) -fpic $(RC_CFLAGS) $(INCLUDE) -D$(SERVERAPI) -DREENTRANT -DEAPI
|
||||
|
||||
include $(COMMON)/common.make
|
||||
OFILES = $(COMMONOBJS) $(OBJROOT)/mod_gsweb.o
|
||||
|
||||
CC = $(APACHE_CC)
|
||||
AR = ar
|
||||
LD = $(CC)
|
||||
RANLIB = ranlib
|
||||
|
||||
LDFLAGS = -rdynamic
|
||||
LIBS = -ldl -lcrypt -lm -lPropList
|
||||
LDSHARED = $(LD) -shared $(CFLAGS)
|
||||
INSTALL = /usr/bin/install -c
|
||||
INSTALL_PROGRAM = $(INSTALL)
|
||||
|
||||
|
||||
|
||||
$(ADAPTOR): $(OFILES)
|
||||
$(LDSHARED) -o $(ADAPTOR) $(OFILES) \
|
||||
$(LIBGSWEBARG) $(LIBS)
|
||||
|
||||
$(OBJROOT)/mod_gsweb.o: $(SRCROOT)/$(SERVERAPIROOT)/mod_gsweb.c
|
||||
|
||||
all:: $(ADAPTOR)
|
||||
|
||||
clean:
|
||||
rm -f $(COMMONOBJS) $(OFILES) $(ADAPTOR) $(ADAPTORLIB) core
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -66,46 +66,6 @@ typedef struct _GSWeb_Config
|
|||
} GSWeb_Config;
|
||||
|
||||
|
||||
#ifdef Apache2
|
||||
/*
|
||||
* Declare ourselves so the configuration routines can find and know us.
|
||||
* We'll fill it in at the end of the module.
|
||||
*/
|
||||
module AP_MODULE_DECLARE_DATA gsweb_module;
|
||||
|
||||
#include <ap_compat.h>
|
||||
#include <apr_pools.h>
|
||||
#include <apr_strings.h>
|
||||
#include <apr_tables.h>
|
||||
|
||||
#define ap_soft_timeout(s, r) ;
|
||||
#define ap_hard_timeout(s, r) ;
|
||||
#define ap_kill_timeout(r) ;
|
||||
|
||||
typedef apr_pool_t pool;
|
||||
typedef apr_array_header_t array_header;
|
||||
typedef apr_table_t table;
|
||||
typedef apr_table_entry_t table_entry;
|
||||
|
||||
|
||||
#ifndef ap_palloc
|
||||
#define ap_palloc apr_palloc
|
||||
#endif
|
||||
#ifndef ap_pstrdup
|
||||
#define ap_pstrdup apr_pstrdup
|
||||
#endif
|
||||
#ifndef ap_table_elts
|
||||
#define ap_table_elts apr_table_elts
|
||||
#endif
|
||||
#ifndef ap_table_add
|
||||
#define ap_table_add apr_table_add
|
||||
#endif
|
||||
|
||||
#ifndef ap_http_method
|
||||
#define ap_http_method ap_run_http_scheme
|
||||
#endif
|
||||
|
||||
#else
|
||||
//TODO: remove ??
|
||||
struct table
|
||||
{
|
||||
|
@ -119,15 +79,6 @@ struct table
|
|||
void *creator;
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
// 1.x/2.x Compatibility
|
||||
#ifdef Apache2
|
||||
#define APR_PSPRINTF apr_psprintf
|
||||
#else
|
||||
#define APR_PSPRINTF ap_psprintf
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
static CONST char *GSWeb_SetDocRoot(cmd_parms *p_pCmdParams,
|
||||
|
@ -153,30 +104,11 @@ GSWeb_GetServerConfig(server_rec *p_pServerRec)
|
|||
}
|
||||
|
||||
|
||||
#ifdef Apache2
|
||||
static int GSWeb_PostConfig(apr_pool_t *p, apr_pool_t *plog,
|
||||
apr_pool_t *ptemp, server_rec *s)
|
||||
{
|
||||
char buffer[256]="mod_gsweb/"
|
||||
GSWEB_SERVER_ADAPTOR_VERSION_MAJOR_STRING
|
||||
"." GSWEB_SERVER_ADAPTOR_VERSION_MINOR_STRING
|
||||
"rev";
|
||||
RevisionStringToRevisionValue(buffer+strlen(buffer),moduleRevision);
|
||||
ap_add_version_component(p, buffer);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
//--------------------------------------------------------------------
|
||||
// Init
|
||||
#ifdef Apache2
|
||||
static void
|
||||
GSWeb_ChildInit(apr_pool_t *p,
|
||||
server_rec *p_pServerRec)
|
||||
#else
|
||||
static void
|
||||
GSWeb_Init(server_rec *p_pServerRec,
|
||||
pool *p)
|
||||
#endif
|
||||
{
|
||||
GSWDict *pDict=GSWDict_New(0);
|
||||
GSWeb_Config *pConfig=NULL;
|
||||
|
@ -363,11 +295,7 @@ copyHeaders(request_rec *p_pRequestRec,
|
|||
// Add server headers
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_ServerSoftware,
|
||||
#ifdef Apache2
|
||||
ap_get_server_version()
|
||||
#else
|
||||
SERVER_VERSION
|
||||
#endif
|
||||
);
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_RequestScheme,
|
||||
|
@ -379,7 +307,7 @@ copyHeaders(request_rec *p_pRequestRec,
|
|||
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_ProtocolNum,
|
||||
APR_PSPRINTF(p_pRequestRec->pool,
|
||||
ap_psprintf(p_pRequestRec->pool,
|
||||
"%u",
|
||||
p_pRequestRec->proto_num));
|
||||
|
||||
|
@ -396,7 +324,7 @@ copyHeaders(request_rec *p_pRequestRec,
|
|||
else
|
||||
serverPort=(unsigned)pServerRec->port;
|
||||
};
|
||||
pszPort = APR_PSPRINTF(p_pRequestRec->pool,
|
||||
pszPort = ap_psprintf(p_pRequestRec->pool,
|
||||
"%u",
|
||||
(unsigned int)serverPort);
|
||||
};
|
||||
|
@ -404,19 +332,11 @@ copyHeaders(request_rec *p_pRequestRec,
|
|||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_ServerPort,
|
||||
pszPort);
|
||||
#ifdef Apache2
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_RemoteHost,
|
||||
(CONST char *)ap_get_remote_host(pConnection,
|
||||
p_pRequestRec->per_dir_config,
|
||||
REMOTE_NAME,NULL));
|
||||
#else /* Apache 1.x */
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_RemoteHost,
|
||||
(CONST char *)ap_get_remote_host(pConnection,
|
||||
p_pRequestRec->per_dir_config,
|
||||
REMOTE_NAME));
|
||||
#endif
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_RemoteAddress,
|
||||
pConnection->remote_ip);
|
||||
|
@ -430,22 +350,15 @@ copyHeaders(request_rec *p_pRequestRec,
|
|||
g_szServerInfo_ScriptFileName,
|
||||
p_pRequestRec->filename);
|
||||
#if 0
|
||||
pszPort = APR_PSPRINTF(p_pRequestRec->pool,
|
||||
pszPort = ap_psprintf(p_pRequestRec->pool,
|
||||
"%u",
|
||||
#ifdef Apache2
|
||||
pConnection->remote_addr->port
|
||||
#else
|
||||
ntohs(pConnection->remote_addr.sin_port)
|
||||
#endif
|
||||
);
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_RemotePort,
|
||||
pszPort);
|
||||
#endif
|
||||
|
||||
#ifdef Apache2
|
||||
//TODO
|
||||
#else
|
||||
if (pConnection->user)
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_RemoteUser,
|
||||
|
@ -454,7 +367,6 @@ copyHeaders(request_rec *p_pRequestRec,
|
|||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_AuthType,//"auth_type",
|
||||
pConnection->ap_auth_type);
|
||||
#endif
|
||||
pszRemoteLogName = (char *)ap_get_remote_logname(p_pRequestRec);
|
||||
if (pszRemoteLogName)
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
|
@ -480,9 +392,6 @@ getHeader(GSWDictElem *p_pElem,
|
|||
{
|
||||
pRequestRec->content_type = (char *)ap_pstrdup(pRequestRec->pool,
|
||||
(char *)p_pElem->pValue);//TODOVERIFY: strdup or not ?
|
||||
#ifdef Apache2
|
||||
ap_set_content_type(pRequestRec, (char *)p_pElem->pValue);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
ap_table_add(pRequestRec->headers_out,p_pElem->pszKey,
|
||||
|
@ -507,45 +416,11 @@ sendResponse(request_rec *p_pRequestRec,
|
|||
|
||||
p_pHTTPResponse->pStats->_prepareSendResponseTS=GSWTime_now();
|
||||
|
||||
// Add Headers for processing time information
|
||||
#ifdef Apache2
|
||||
if (GSWConfig_AddTimeHeaders())
|
||||
{
|
||||
GSWDebugLog(pServerRec,"Start addTimeHeaders");
|
||||
/*
|
||||
char *pszBuffer= malloc(100);
|
||||
GSWTime newTS=GSWTime_now();
|
||||
GSWTime requestTS=GSWTime_makeFromAPRTime(p_pRequestRec->request_time);
|
||||
long duration=newTS-requestTS;
|
||||
strcpy(pszBuffer,"gswadaptor-requestdate: ");
|
||||
GSWTime_format(pszBuffer+strlen(pszBuffer),requestTS);
|
||||
GSWHTTPResponse_AddHeader(p_pHTTPResponse,
|
||||
pszBuffer);
|
||||
strcpy(pszBuffer,"gswadaptor-sendresponsedate: ");
|
||||
GSWTime_format(pszBuffer+strlen(pszBuffer),newTS);
|
||||
GSWHTTPResponse_AddHeader(p_pHTTPResponse,
|
||||
pszBuffer);
|
||||
sprintf(pszBuffer,"gswadaptor-processduration: %0.3fs",
|
||||
GSWTime_floatSec(duration));
|
||||
free(pszBuffer);
|
||||
pszBuffer=NULL;
|
||||
*/
|
||||
// caller should free the returned string
|
||||
char* pszBuffer=GSWStats_formatStats(p_pHTTPResponse->pStats,
|
||||
"gswadaptor-stats: ",
|
||||
pServerRec);
|
||||
|
||||
GSWHTTPResponse_AddHeader(p_pHTTPResponse,
|
||||
pszBuffer);
|
||||
free(pszBuffer);
|
||||
GSWDebugLog(pServerRec,"Stop addTimeHeaders");
|
||||
};
|
||||
#endif
|
||||
// Process Headers
|
||||
GSWDict_PerformForAllElem(p_pHTTPResponse->pHeaders,getHeader,p_pRequestRec);
|
||||
|
||||
GSWDebugLog(pServerRec,"status message=[%s]",p_pHTTPResponse->pszStatusMessage);
|
||||
p_pRequestRec->status_line = APR_PSPRINTF(p_pRequestRec->pool,"%u %s",
|
||||
p_pRequestRec->status_line = ap_psprintf(p_pRequestRec->pool,"%u %s",
|
||||
p_pHTTPResponse->uStatus,
|
||||
p_pHTTPResponse->pszStatusMessage);
|
||||
|
||||
|
@ -556,9 +431,6 @@ sendResponse(request_rec *p_pRequestRec,
|
|||
if (!p_pRequestRec->content_type)
|
||||
{
|
||||
p_pRequestRec->content_type = g_szContentType_TextHtml;
|
||||
#ifdef Apache2
|
||||
ap_set_content_type(p_pRequestRec, g_szContentType_TextHtml);
|
||||
#endif
|
||||
};
|
||||
GSWDebugLog(pServerRec,"p_pRequestRec->content_type=%s",p_pRequestRec->content_type);
|
||||
|
||||
|
@ -570,9 +442,7 @@ sendResponse(request_rec *p_pRequestRec,
|
|||
p_pHTTPResponse->pStats->_beginSendResponseTS=GSWTime_now();
|
||||
|
||||
// send Headers
|
||||
#ifndef Apache2 // No more needed in Apache2 (?)
|
||||
ap_send_http_header(p_pRequestRec);
|
||||
#endif
|
||||
|
||||
// If not headers only
|
||||
if (!p_pRequestRec->header_only)
|
||||
|
@ -748,11 +618,7 @@ GSWeb_Handler(request_rec *p_pRequestRec)
|
|||
{
|
||||
long iReadLength=0;
|
||||
|
||||
#ifdef Apache2
|
||||
apr_size_t iRemainingLength = pRequest->uContentLength;
|
||||
#else
|
||||
size_t iRemainingLength = pRequest->uContentLength;
|
||||
#endif
|
||||
char *pszBuffer = malloc(pRequest->uContentLength);
|
||||
char *pszData = pszBuffer;
|
||||
|
||||
|
@ -845,120 +711,6 @@ GSWeb_Handler(request_rec *p_pRequestRec)
|
|||
return iRetVal;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifdef Apache2
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* */
|
||||
/* Which functions are responsible for which hooks in the server. */
|
||||
/* */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Each function our module provides to handle a particular hook is
|
||||
* specified here. The functions are registered using
|
||||
* ap_hook_foo(name, predecessors, successors, position)
|
||||
* where foo is the name of the hook.
|
||||
*
|
||||
* The args are as follows:
|
||||
* name -> the name of the function to call.
|
||||
* predecessors -> a list of modules whose calls to this hook must be
|
||||
* invoked before this module.
|
||||
* successors -> a list of modules whose calls to this hook must be
|
||||
* invoked after this module.
|
||||
* position -> The relative position of this module. One of
|
||||
* APR_HOOK_FIRST, APR_HOOK_MIDDLE, or APR_HOOK_LAST.
|
||||
* Most modules will use APR_HOOK_MIDDLE. If multiple
|
||||
* modules use the same relative position, Apache will
|
||||
* determine which to call first.
|
||||
* If your module relies on another module to run first,
|
||||
* or another module running after yours, use the
|
||||
* predecessors and/or successors.
|
||||
*
|
||||
* The number in brackets indicates the order in which the routine is called
|
||||
* during request processing. Note that not all routines are necessarily
|
||||
* called (such as if a resource doesn't have access restrictions).
|
||||
* The actual delivery of content to the browser [9] is not handled by
|
||||
* a hook; see the handler declarations below.
|
||||
*/
|
||||
static void
|
||||
GSWeb_register_hooks(apr_pool_t *p)
|
||||
{
|
||||
/* ap_hook_pre_config(GSWeb_PreConfig, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
*/
|
||||
ap_hook_post_config(GSWeb_PostConfig, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
/*
|
||||
ap_hook_open_logs(GSWeb_OpenLogs, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
*/
|
||||
ap_hook_child_init(GSWeb_ChildInit, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
ap_hook_handler(GSWeb_Handler, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
/* ap_hook_quick_handler(GSWeb_QuickHandler, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
ap_hook_pre_connection(GSWeb_PreConnection, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
ap_hook_process_connection(GSWeb_ProcessConnection, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
// [1] post read_request handling
|
||||
ap_hook_post_read_request(GSWeb_PostReadRequest, NULL, NULL,APR_HOOK_MIDDLE);
|
||||
ap_hook_log_transaction(GSWeb_Logger, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
#if 0
|
||||
ap_hook_http_method(GSWeb_HttpMethod, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
ap_hook_default_port(GSWeb_DefaultPort, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
#endif
|
||||
ap_hook_translate_name(GSWeb_Translation, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
ap_hook_header_parser(GSWeb_header_ParserHandler, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
ap_hook_check_user_id(GSWeb_CheckUserId, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
ap_hook_fixups(GSWeb_FixerUpper, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
ap_hook_type_checker(GSWeb_TypeChecker, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
ap_hook_access_checker(GSWeb_AccessChecker, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
ap_hook_auth_checker(GSWeb_AuthChecker, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
ap_hook_insert_filter(GSWeb_InsertFilter, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
*/
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* */
|
||||
/* All of the routines have been declared now. Here's the list of */
|
||||
/* directives specific to our module, and information about where they */
|
||||
/* may appear and how the command parser should pass them to us for */
|
||||
/* processing. Note that care must be taken to ensure that there are NO */
|
||||
/* collisions of directive names between modules. */
|
||||
/* */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/*
|
||||
* List of directives specific to our module.
|
||||
*/
|
||||
static const command_rec GSWeb_Commands[] =
|
||||
{
|
||||
AP_INIT_TAKE1
|
||||
(
|
||||
GSWEB_CONF__ALIAS, /* directive name */
|
||||
GSWeb_SetScriptAlias, /* config action routine */
|
||||
NULL, /* argument to include in call */
|
||||
RSRC_CONF, /* where available */
|
||||
"ScriptAlias for GSWeb" /* directive description */
|
||||
),
|
||||
AP_INIT_TAKE1
|
||||
(
|
||||
GSWEB_CONF__CONFIG_FILE_PATH, /* directive name */
|
||||
GSWeb_SetConfig, /* config action routine */
|
||||
NULL, /* argument to include in call */
|
||||
RSRC_CONF, /* where available */
|
||||
"Configuration File Path for GSWeb" /* directive description */
|
||||
),
|
||||
{NULL}
|
||||
};
|
||||
|
||||
module AP_MODULE_DECLARE_DATA gsweb_module =
|
||||
{
|
||||
STANDARD20_MODULE_STUFF,
|
||||
NULL,//x_create_dir_config, /* per-directory config creator */
|
||||
NULL,//x_merge_dir_config, /* dir config merger */
|
||||
GSWeb_CreateServerConfig, /* server config creator */
|
||||
NULL,//x_merge_server_config, /* server config merger */
|
||||
GSWeb_Commands, /* command table */
|
||||
GSWeb_register_hooks, /* set up other request processing hooks */
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Module definitions
|
||||
|
||||
|
@ -1024,4 +776,3 @@ module gsweb_module =
|
|||
NULL
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -84,10 +84,10 @@ AppConnectHandle GSWApp_Open(GSWAppRequest* p_pAppRequest,void* p_pLogServerData
|
|||
{
|
||||
int iSocketDescr = 0;
|
||||
struct sockaddr_in sin;
|
||||
memset(&sin,0,sizeof(sin));
|
||||
memset(&sin,0,sizeof(struct sockaddr_in));
|
||||
sin.sin_family = pHost->h_addrtype;
|
||||
sin.sin_port = htons(p_pAppRequest->iPort);
|
||||
memcpy(&sin.sin_addr,pHost->h_addr_list[0],pHost->h_length);
|
||||
sin.sin_addr=*(struct in_addr*)pHost->h_addr_list[0];
|
||||
GSWDebugLog(p_pLogServerData,
|
||||
"Try contacting %s on port %d...",
|
||||
p_pAppRequest->pszHost,
|
||||
|
@ -105,7 +105,7 @@ AppConnectHandle GSWApp_Open(GSWAppRequest* p_pAppRequest,void* p_pLogServerData
|
|||
}
|
||||
else
|
||||
{
|
||||
if (connect(iSocketDescr,(struct sockaddr*)&sin,sizeof(sin))<0)
|
||||
if (connect(iSocketDescr,(struct sockaddr*)&sin,sizeof(struct sockaddr_in))<0)
|
||||
{
|
||||
GSWLog(__FILE__, __LINE__, GSW_ERROR,
|
||||
p_pLogServerData,
|
||||
|
|
|
@ -446,74 +446,35 @@ hstrerror(int herr)
|
|||
static PSTHostent
|
||||
GSWUtil_CopyHostent(PSTHostent p_pHost)
|
||||
{
|
||||
PSTHostent pNewHost=NULL;
|
||||
int iSize=(ROUND_UP(sizeof(struct hostent),
|
||||
sizeof(void *)))+strlen(p_pHost->h_name)+1;
|
||||
int iAliasNb=0;
|
||||
int iAddressesNb = 0;
|
||||
char **ppszAliasOrAddress=NULL;
|
||||
char **ppszNewHostAliasOrAddress=NULL;
|
||||
void *pTmp=NULL;
|
||||
|
||||
// Aliases
|
||||
for (ppszAliasOrAddress=p_pHost->h_aliases;
|
||||
ppszAliasOrAddress && *ppszAliasOrAddress;
|
||||
ppszAliasOrAddress++)
|
||||
{
|
||||
iSize+=strlen(*ppszAliasOrAddress)+1;
|
||||
iAliasNb++;
|
||||
};
|
||||
int i = 0, alias_index = 0;
|
||||
|
||||
// Aliases Pointers Null Terminated List
|
||||
iSize=ROUND_UP(iSize,sizeof(char *));
|
||||
iSize+=(iAliasNb+1)*sizeof(char *);
|
||||
|
||||
for (ppszAliasOrAddress=p_pHost->h_addr_list;
|
||||
ppszAliasOrAddress && *ppszAliasOrAddress;
|
||||
ppszAliasOrAddress++)
|
||||
iAddressesNb++;
|
||||
|
||||
iSize+=iAddressesNb*(sizeof(char *)+p_pHost->h_length+1);
|
||||
|
||||
pNewHost=malloc(ROUND_UP(iSize,sizeof(char *)));
|
||||
pTmp=pNewHost;
|
||||
pNewHost->h_addrtype = p_pHost->h_addrtype;
|
||||
pNewHost->h_length = p_pHost->h_length;
|
||||
|
||||
pTmp+=ROUND_UP(sizeof(struct hostent),sizeof(void *));
|
||||
pNewHost->h_aliases = (char **)pTmp;
|
||||
pTmp+=(iAliasNb+1)*sizeof(char *);
|
||||
pNewHost->h_addr_list = (char **)pTmp;
|
||||
pTmp+=(iAddressesNb+1)*sizeof(char *);
|
||||
|
||||
pNewHost->h_name = pTmp;
|
||||
strcpy(pNewHost->h_name,p_pHost->h_name);
|
||||
pTmp+=strlen(pNewHost->h_name)+1;
|
||||
|
||||
// Copy Aliases
|
||||
for (ppszAliasOrAddress=p_pHost->h_aliases,
|
||||
ppszNewHostAliasOrAddress=pNewHost->h_aliases;
|
||||
ppszAliasOrAddress && *ppszAliasOrAddress;
|
||||
ppszAliasOrAddress++,ppszNewHostAliasOrAddress++)
|
||||
while (p_pHost->h_aliases[alias_index] != NULL)
|
||||
{
|
||||
*ppszNewHostAliasOrAddress = (char *)pTmp;
|
||||
strcpy((char *)pTmp,*ppszAliasOrAddress);
|
||||
pTmp+=strlen(*ppszAliasOrAddress) + 1;
|
||||
};
|
||||
*ppszNewHostAliasOrAddress=NULL;
|
||||
|
||||
pTmp=(void *)ROUND_UP(pTmp,pNewHost->h_length);
|
||||
for (ppszAliasOrAddress=p_pHost->h_addr_list,
|
||||
ppszNewHostAliasOrAddress=pNewHost->h_addr_list;
|
||||
ppszAliasOrAddress && *ppszAliasOrAddress;
|
||||
ppszAliasOrAddress++,ppszNewHostAliasOrAddress++)
|
||||
++alias_index;
|
||||
}
|
||||
struct hostent *pNewHost = (struct hostent*) malloc (sizeof(struct hostent));
|
||||
bzero(pNewHost, sizeof(struct hostent));
|
||||
pNewHost->h_name = (char *) strdup(p_pHost->h_name);
|
||||
pNewHost->h_aliases = (char **) malloc ((alias_index + 1) * sizeof(char *));
|
||||
if (alias_index)
|
||||
{
|
||||
*ppszNewHostAliasOrAddress=(char *)pTmp;
|
||||
memcpy(*ppszNewHostAliasOrAddress,*ppszAliasOrAddress,
|
||||
pNewHost->h_length);
|
||||
pTmp+=pNewHost->h_length;
|
||||
};
|
||||
*ppszNewHostAliasOrAddress=NULL;
|
||||
for (i=0; i<alias_index; i++)
|
||||
{
|
||||
pNewHost->h_aliases[i] = (char *) strdup(p_pHost->h_aliases[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pNewHost->h_aliases[0] = NULL;
|
||||
}
|
||||
pNewHost->h_aliases[alias_index] = 0;
|
||||
pNewHost->h_addrtype = AF_INET;
|
||||
pNewHost->h_length = sizeof(struct in_addr);
|
||||
pNewHost->h_addr_list = (char **) malloc (2 * sizeof(char *));
|
||||
pNewHost->h_addr_list[0] = (char *) malloc(sizeof(struct in_addr));
|
||||
memset(pNewHost->h_addr_list[0], 0, sizeof(struct in_addr));
|
||||
memcpy(pNewHost->h_addr_list[0], p_pHost->h_addr_list[0], sizeof(struct in_addr));
|
||||
pNewHost->h_addr_list[1] = 0;
|
||||
return pNewHost;
|
||||
};
|
||||
|
||||
|
@ -524,10 +485,10 @@ GSWUtil_HostLookup(CONST char *p_pszHost,
|
|||
{
|
||||
PSTHostent pHost=NULL;
|
||||
struct in_addr hostaddr;
|
||||
struct hostent stTmpHost;
|
||||
int error=0;
|
||||
|
||||
#if defined(HAS_REENTRANT_GETHOSTENT)
|
||||
struct hostent stTmpHost;
|
||||
char szBuffer[BUFLEN];
|
||||
|
||||
pHost = &stTmpHost; /* point to struct on the stack */
|
||||
|
@ -583,9 +544,11 @@ GSWUtil_HostLookup(CONST char *p_pszHost,
|
|||
#endif // SOLARIS
|
||||
};
|
||||
#else // !HAS_REENTRANT_GETHOSTENT
|
||||
pHost = &stTmpHost;
|
||||
if (isdigit(*p_pszHost))
|
||||
{
|
||||
pHost = gethostbyaddr((char *)&hostaddr.s_addr, sizeof(hostaddr.s_addr),
|
||||
in_addr_t address = inet_addr(p_pszHost);
|
||||
pHost = gethostbyaddr(&address, sizeof(in_addr_t),
|
||||
AF_INET);
|
||||
error = (pHost) ? 0 : h_errno;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue