* GSWAdaptors/Apache/mod_gsweb.c (sendResponse): Add cast.

* GSWAdaptors/Apache/GNUmakefile-Apache1x: Update copyright and
        correct ADAPTOR variable.
        * GSWAdaptors/Doc/ConfigurationFile.html: Updated formatting.
        * GSWAdaptors/common/GSWAppConnectNSSocket.c (GSWApp_Open,
        GSWAppSendBlock, GSWApp_ReceiveLine, GSWApp_ReceiveBlock): Correct
        usage of GSWLog by addeding requiered parameter.
        * GSWAdaptors/common/GSWApp.[hc]: Updated copyright notice and
        applied some formatting.
        * GSWAdaptors/common/GSWAppConnect.h: Ditto.
        * GSWAdaptors/common/GSWAppConnectNSSocket.c: Ditto.
        * GSWAdaptors/common/GSWAppConnectSocket.c: Ditto.
        * GSWAdaptors/common/GSWAppRequest.[hc]: Ditto.
        * GSWAdaptors/common/GSWAppRequestStruct.h: Ditto.
        * GSWAdaptors/common/GSWConfig.[hc]: Ditto.
        * GSWAdaptors/common/GSWDict.[hc]: Ditto.
        * GSWAdaptors/common/GSWHTTPHeaders.[hc]: Ditto.
        * GSWAdaptors/common/GSWHTTPRequest.[hc]: Ditto.
        * GSWAdaptors/common/GSWHTTPResponse.[hc]: Ditto.
        * GSWAdaptors/common/GSWList.[hc]: Ditto.
        * GSWAdaptors/common/GSWLoadBalancing.[hc]: Ditto.
        * GSWAdaptors/common/GSWPropList.[hc]: Ditto.
        * GSWAdaptors/common/GSWString.[hc]: Ditto.
        * GSWAdaptors/common/GSWTemplates.[hc]: Ditto.
        * GSWAdaptors/common/GSWURLUtils.[hc]: Ditto.
        * GSWAdaptors/common/GSWUtils.[hc]: Ditto.
        * GSWAdaptors/common/common.make: Ditto.
        * GSWAdaptors/common/config.[hc]: Ditto.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@16089 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
ayers 2003-02-28 18:37:43 +00:00
parent ef9aeb9211
commit 2e0c8afdee
40 changed files with 3998 additions and 3409 deletions

View file

@ -1,3 +1,34 @@
2003-02-28 David Ayers <d.ayers@inode.at>
* GSWAdaptors/Apache/mod_gsweb.c (sendResponse): Add cast.
* GSWAdaptors/Apache/GNUmakefile-Apache1x: Update copyright and
correct ADAPTOR variable.
* GSWAdaptors/Doc/ConfigurationFile.html: Updated formatting.
* GSWAdaptors/common/GSWAppConnectNSSocket.c (GSWApp_Open,
GSWAppSendBlock, GSWApp_ReceiveLine, GSWApp_ReceiveBlock): Correct
usage of GSWLog by addeding requiered parameter.
* GSWAdaptors/common/GSWApp.[hc]: Updated copyright notice and
applied some formatting.
* GSWAdaptors/common/GSWAppConnect.h: Ditto.
* GSWAdaptors/common/GSWAppConnectNSSocket.c: Ditto.
* GSWAdaptors/common/GSWAppConnectSocket.c: Ditto.
* GSWAdaptors/common/GSWAppRequest.[hc]: Ditto.
* GSWAdaptors/common/GSWAppRequestStruct.h: Ditto.
* GSWAdaptors/common/GSWConfig.[hc]: Ditto.
* GSWAdaptors/common/GSWDict.[hc]: Ditto.
* GSWAdaptors/common/GSWHTTPHeaders.[hc]: Ditto.
* GSWAdaptors/common/GSWHTTPRequest.[hc]: Ditto.
* GSWAdaptors/common/GSWHTTPResponse.[hc]: Ditto.
* GSWAdaptors/common/GSWList.[hc]: Ditto.
* GSWAdaptors/common/GSWLoadBalancing.[hc]: Ditto.
* GSWAdaptors/common/GSWPropList.[hc]: Ditto.
* GSWAdaptors/common/GSWString.[hc]: Ditto.
* GSWAdaptors/common/GSWTemplates.[hc]: Ditto.
* GSWAdaptors/common/GSWURLUtils.[hc]: Ditto.
* GSWAdaptors/common/GSWUtils.[hc]: Ditto.
* GSWAdaptors/common/common.make: Ditto.
* GSWAdaptors/common/config.[hc]: Ditto.
2003-02-20 Mirko Viviani <mirko.viviani@rccr.cremona.it>
* GSWAdaptors/common/GSWUtil.c|.h (strcasestr): removed CONST from

View file

@ -1,8 +1,8 @@
# Makefile for Apache 1.x GNUstepWeb module
# Copyright (C) 1999 Free Software Foundation, Inc.
# Makefile for Apache 1.x GNUstepWeb module
# Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
#
# Written by: Manuel Guesdon <mguesdon@sbuilders.com>
# Date: Jully 1999
# Date: July 1999
#
# This file is part of the GNUstep Web Library.
#
@ -53,7 +53,7 @@ OBJROOT = .
# Directory
SERVERAPI = Apache
ADAPTOR = $(DSTROOT)/mod_gsweb.so
ADAPTOR = mod_gsweb.so
LOADBALANCING = roundrobin
ADAPTORLIB = $(OBJROOT)/libAdaptor.a

View file

@ -2,7 +2,7 @@
Copyright (C) 1999 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -59,9 +59,9 @@ module GSWeb_Module;
typedef struct _GSWeb_Config
{
const char* pszGSWeb; // default = GSWeb
const char* pszConfigPath; // path to GSWeb.conf
// const char* pszRoot; // normally htdocs/GSWeb
const char *pszGSWeb; // default = GSWeb
const char *pszConfigPath; // path to GSWeb.conf
// const char *pszRoot; // normally htdocs/GSWeb
} GSWeb_Config;
#ifdef Apache2
@ -89,10 +89,10 @@ typedef apr_table_entry_t table_entry;
struct table
{
/* This has to be first to promote backwards compatibility with
* older modules which cast a table * to an array_header *...
* they should use the table_elts() function for most of the
* cases they do this for.
*/
* older modules which cast a table * to an array_header *...
* they should use the table_elts() function for most of the
* cases they do this for.
*/
array_header a;
#ifdef MAKE_TABLE_PROFILE
void *creator;
@ -100,63 +100,84 @@ struct table
};
#endif
//static CONST char* GSWeb_SetDocRoot(cmd_parms* p_pCmdParams,void* p_pUnused,char *p_pszArg);
static CONST char* GSWeb_SetScriptAlias(cmd_parms *p_pCmdParams, void *p_pUnused, char *p_pszArg);
static CONST char *GSWeb_SetConfig(cmd_parms *p_pCmdParams, void *p_pUnused, char *p_pszArg);
static int GSWeb_Handler(request_rec* p_pRequestRec);
/*
static CONST char *GSWeb_SetDocRoot(cmd_parms *p_pCmdParams,
void *p_pUnused,
char *p_pszArg);
*/
static CONST char *GSWeb_SetScriptAlias(cmd_parms *p_pCmdParams,
void *p_pUnused,
char *p_pszArg);
static CONST char *GSWeb_SetConfig(cmd_parms *p_pCmdParams,
void *p_pUnused,
char *p_pszArg);
static int GSWeb_Handler(request_rec *p_pRequestRec);
/*
* Locate our server configuration record for the current request.
*/
static GSWeb_Config *GSWeb_GetServerConfig(server_rec* p_pServerRec)
static GSWeb_Config *
GSWeb_GetServerConfig(server_rec *p_pServerRec)
{
return (GSWeb_Config*) ap_get_module_config(p_pServerRec->module_config, &GSWeb_Module);
return (GSWeb_Config *)ap_get_module_config(p_pServerRec->module_config,
&GSWeb_Module);
}
//--------------------------------------------------------------------
// Init
#ifdef Apache2
static void GSWeb_ChildInit(apr_pool_t *p,server_rec* p_pServerRec)
static void
GSWeb_ChildInit(apr_pool_t *p,
server_rec *p_pServerRec)
#else
static void GSWeb_Init(server_rec* p_pServerRec, pool *p)
static void
GSWeb_Init(server_rec *p_pServerRec,
pool *p)
#endif
{
GSWDict* pDict=GSWDict_New(0);
GSWeb_Config* pConfig=NULL;
GSWDict *pDict=GSWDict_New(0);
GSWeb_Config *pConfig=NULL;
pConfig=GSWeb_GetServerConfig(p_pServerRec);
GSWLog_Init(NULL,GSW_INFO);
GSWLog(GSW_INFO,p_pServerRec,
"GSWeb Init Start Config. Handler: " GSWEB_HANDLER);
"GSWeb Init Start Config. Handler: " GSWEB_HANDLER);
GSWLog(GSW_DEBUG,p_pServerRec,
"GSWeb_Init: pConfig->pszGSWeb=%s",
pConfig->pszGSWeb);
"GSWeb_Init: pConfig->pszGSWeb=%s",
pConfig->pszGSWeb);
if (pConfig && pConfig->pszConfigPath)
GSWDict_AddStringDup(pDict,
g_szGSWeb_Conf_ConfigFilePath,
pConfig->pszConfigPath);
/* if (pConfig && pConfig->pszRoot)
GSWDict_AddStringDup(pDict,
g_szGSWeb_Conf_DocRoot,
pConfig->pszRoot);*/
GSWDict_AddStringDup(pDict,
g_szGSWeb_Conf_ConfigFilePath,
pConfig->pszConfigPath);
/*
if (pConfig && pConfig->pszRoot)
GSWDict_AddStringDup(pDict,
g_szGSWeb_Conf_DocRoot,
pConfig->pszRoot);
*/
GSWLog(GSW_INFO,p_pServerRec,
"GSWeb Init LB Init. Handler: " GSWEB_HANDLER);
"GSWeb Init LB Init. Handler: " GSWEB_HANDLER);
GSWConfig_Init(pDict,p_pServerRec);
GSWLog(GSW_INFO,p_pServerRec,
"GSWeb Init. Handler: " GSWEB_HANDLER);
"GSWeb Init. Handler: " GSWEB_HANDLER);
GSWDict_Free(pDict);
};
//--------------------------------------------------------------------
// Create Config
static void* GSWeb_CreateServerConfig(pool* p_pPool,
server_rec* p_pServerRec)
static void *
GSWeb_CreateServerConfig(pool *p_pPool,
server_rec *p_pServerRec)
{
GSWeb_Config *pConfig = (GSWeb_Config*)ap_palloc(p_pPool,sizeof(GSWeb_Config));
GSWeb_Config *pConfig = (GSWeb_Config *)ap_palloc(p_pPool,
sizeof(GSWeb_Config));
pConfig->pszGSWeb = g_szGSWeb_Prefix;
GSWLog(GSW_DEBUG,p_pServerRec,"GSWeb_CreateServerConfig: pConfig->pszGSWeb=%s",
GSWLog(GSW_DEBUG,p_pServerRec,
"GSWeb_CreateServerConfig: pConfig->pszGSWeb=%s",
pConfig->pszGSWeb);
pConfig->pszConfigPath = NULL;
// pConfig->pszRoot = NULL;
@ -165,24 +186,31 @@ static void* GSWeb_CreateServerConfig(pool* p_pPool,
/*
//--------------------------------------------------------------------
// Set Param: DocRoot
static CONST char* GSWeb_SetDocRoot(cmd_parms* p_pCmdParams,void* p_pUnused,char *p_pszArg)
static CONST char *
GSWeb_SetDocRoot(cmd_parms *p_pCmdParams,
void *p_pUnused,
char *p_pszArg)
{
server_rec* pServerRec = p_pCmdParams->server;
GSWeb_Config* pConfig = NULL;
GSWLog(GSW_DEBUG,pServerRec,"Start GSWeb_SetDocRoot");
pConfig=(GSWeb_Config *)ap_get_module_config(pServerRec->module_config,
&GSWeb_Module);
pConfig->pszRoot = p_pszArg;
server_rec *pServerRec = p_pCmdParams->server;
GSWeb_Config *pConfig = NULL;
GSWLog(GSW_DEBUG,pServerRec,"Start GSWeb_SetDocRoot");
return NULL;
pConfig=(GSWeb_Config *)ap_get_module_config(pServerRec->module_config,
&GSWeb_Module);
pConfig->pszRoot = p_pszArg;
GSWLog(GSW_DEBUG,pServerRec,"Start GSWeb_SetDocRoot");
return NULL;
};
*/
//--------------------------------------------------------------------
// Set Param: ScriptAlias
static CONST char* GSWeb_SetScriptAlias(cmd_parms *p_pCmdParams, void *p_pUnused, char *p_pszArg)
static CONST char *
GSWeb_SetScriptAlias(cmd_parms *p_pCmdParams,
void *p_pUnused,
char *p_pszArg)
{
server_rec* pServerRec = p_pCmdParams->server;
GSWeb_Config* pConfig = NULL;
server_rec *pServerRec = p_pCmdParams->server;
GSWeb_Config *pConfig = NULL;
GSWLog(GSW_DEBUG,pServerRec,"Start GSWeb_SetScriptAlias");
pConfig=GSWeb_GetServerConfig(pServerRec);
pConfig->pszGSWeb = p_pszArg;
@ -192,10 +220,14 @@ static CONST char* GSWeb_SetScriptAlias(cmd_parms *p_pCmdParams, void *p_pUnused
//--------------------------------------------------------------------
// Set Param: ConfigFile
static CONST char *GSWeb_SetConfig(cmd_parms *p_pCmdParams, void *p_pUnused, char *p_pszArg)
static CONST char *
GSWeb_SetConfig(cmd_parms *p_pCmdParams,
void *p_pUnused,
char *p_pszArg)
{
server_rec* pServerRec = p_pCmdParams->server;
GSWeb_Config* pConfig = NULL;
server_rec *pServerRec = p_pCmdParams->server;
GSWeb_Config *pConfig = NULL;
GSWLog(GSW_DEBUG,pServerRec,"Start GSWeb_SetConfig");
pConfig=GSWeb_GetServerConfig(pServerRec);
GSWLog(GSW_DEBUG,pServerRec,"pConfig=%p",pConfig);
@ -208,61 +240,67 @@ static CONST char *GSWeb_SetConfig(cmd_parms *p_pCmdParams, void *p_pUnused, cha
//--------------------------------------------------------------------
// Translate
int GSWeb_Translation(request_rec* p_pRequestRec)
int
GSWeb_Translation(request_rec *p_pRequestRec)
{
int iRetValue=OK;
GSWeb_Config* pConfig=NULL;
GSWURLComponents stURL;
int iRetValue=OK;
GSWeb_Config *pConfig=NULL;
GSWURLComponents stURL;
memset(&stURL,0,sizeof(stURL));
GSWLog(GSW_DEBUG,p_pRequestRec->server,"Start GSWeb_Translation");
pConfig=GSWeb_GetServerConfig(p_pRequestRec->server);
// Is this for us ?
if (strncmp(pConfig->pszGSWeb,
p_pRequestRec->uri,
strlen(pConfig->pszGSWeb))==0)
p_pRequestRec->uri,
strlen(pConfig->pszGSWeb))==0)
{
GSWURLError eError=GSWParseURL(&stURL,p_pRequestRec->uri,
p_pRequestRec->server);
if (eError!=GSWURLError_OK)
{
GSWURLError eError=GSWParseURL(&stURL,p_pRequestRec->uri,
p_pRequestRec->server);
if (eError!=GSWURLError_OK)
{
GSWLog(GSW_ERROR,p_pRequestRec->server,"GSWeb_Translation Declined (Error %d)",(int)eError);
iRetValue=DECLINED;
}
else
{
GSWLog(GSW_DEBUG,
p_pRequestRec->server,
"GSWeb_Translation Handler p_pRequestRec->handler=%s pool=%p handler=%s pConfig->pszGSWeb=%s",
p_pRequestRec->handler,
p_pRequestRec->pool,
g_szGSWeb_Handler,
pConfig->pszGSWeb);
p_pRequestRec->handler=(char*)ap_pstrdup(p_pRequestRec->pool,g_szGSWeb_Handler);
iRetValue=OK;
};
}
else
{
GSWLog(GSW_DEBUG,p_pRequestRec->server,"GSWeb_Translation Declined");
GSWLog(GSW_ERROR,p_pRequestRec->server,
"GSWeb_Translation Declined (Error %d)",(int)eError);
iRetValue=DECLINED;
}
else
{
GSWLog(GSW_DEBUG,
p_pRequestRec->server,
"GSWeb_Translation Handler p_pRequestRec->handler=%s pool=%p handler=%s pConfig->pszGSWeb=%s",
p_pRequestRec->handler,
p_pRequestRec->pool,
g_szGSWeb_Handler,
pConfig->pszGSWeb);
p_pRequestRec->handler=(char *)ap_pstrdup(p_pRequestRec->pool,
g_szGSWeb_Handler);
iRetValue=OK;
};
}
else
{
GSWLog(GSW_DEBUG,p_pRequestRec->server,"GSWeb_Translation Declined");
iRetValue=DECLINED;
};
GSWLog(GSW_DEBUG,p_pRequestRec->server,
"Stop GSWeb_Translation return %d",
iRetValue);
"Stop GSWeb_Translation return %d",
iRetValue);
return iRetValue;
};
//--------------------------------------------------------------------
static void copyHeaders(request_rec* p_pRequestRec,GSWHTTPRequest* p_pGSWHTTPRequest)
static void
copyHeaders(request_rec *p_pRequestRec,
GSWHTTPRequest *p_pGSWHTTPRequest)
{
server_rec* pServerRec = p_pRequestRec->server;
conn_rec* pConnection = p_pRequestRec->connection;
server_rec *pServerRec = p_pRequestRec->server;
conn_rec *pConnection = p_pRequestRec->connection;
const array_header *headers_arr=ap_table_elts(p_pRequestRec->headers_in);
table_entry *headers=NULL;
table_entry *headers=NULL;
int i;
char szPort[40]="";
CONST char* pszRemoteLogName=NULL;
char szPort[40]="";
CONST char *pszRemoteLogName=NULL;
GSWLog(GSW_DEBUG,pServerRec,"Start copyHeaders");
// copy p_pRequestRec headers
@ -270,7 +308,8 @@ static void copyHeaders(request_rec* p_pRequestRec,GSWHTTPRequest* p_pGSWHTTPReq
for (i=0;i<headers_arr->nelts;i++)
{
if (headers[i].key)
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,headers[i].key,headers[i].val);
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
headers[i].key,headers[i].val);
};
// Add server headers
@ -296,18 +335,22 @@ static void copyHeaders(request_rec* p_pRequestRec,GSWHTTPRequest* p_pGSWHTTPReq
#ifdef Apache2
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
g_szServerInfo_RemoteHost,
(CONST char*)ap_get_remote_host(pConnection,p_pRequestRec->per_dir_config,REMOTE_NAME,NULL));
(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));
(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);
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
g_szServerInfo_DocumentRoot,
(char*)ap_document_root(p_pRequestRec));
(char *)ap_document_root(p_pRequestRec));
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
g_szServerInfo_ServerAdmin,
pServerRec->server_admin);
@ -339,7 +382,7 @@ static void copyHeaders(request_rec* p_pRequestRec,GSWHTTPRequest* p_pGSWHTTPReq
g_szServerInfo_AuthType,//"auth_type",
pConnection->ap_auth_type);
#endif
pszRemoteLogName = (char*)ap_get_remote_logname(p_pRequestRec);
pszRemoteLogName = (char *)ap_get_remote_logname(p_pRequestRec);
if (pszRemoteLogName)
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
g_szServerInfo_RemoteIdent,
@ -349,40 +392,47 @@ static void copyHeaders(request_rec* p_pRequestRec,GSWHTTPRequest* p_pGSWHTTPReq
//--------------------------------------------------------------------
// callback finction to copy an header into p_pRequest
static void getHeader(GSWDictElem* p_pElem,void* p_pRequestRec)
static void
getHeader(GSWDictElem *p_pElem,
void *p_pRequestRec)
{
request_rec* pRequestRec = (request_rec*)p_pRequestRec;
request_rec *pRequestRec = (request_rec *)p_pRequestRec;
if (!pRequestRec->content_type && strcasecmp(p_pElem->pszKey,g_szHeader_ContentType)==0)
pRequestRec->content_type = (char*)ap_pstrdup(pRequestRec->pool,(char*)p_pElem->pValue);
if (!pRequestRec->content_type &&
strcasecmp(p_pElem->pszKey,g_szHeader_ContentType)==0)
pRequestRec->content_type = (char *)ap_pstrdup(pRequestRec->pool,
(char *)p_pElem->pValue);
else
ap_table_add(pRequestRec->headers_out,p_pElem->pszKey,(char*)p_pElem->pValue);
ap_table_add(pRequestRec->headers_out,p_pElem->pszKey,
(char *)p_pElem->pValue);
};
//--------------------------------------------------------------------
// send response
static void sendResponse(request_rec* p_pRequestRec,GSWHTTPResponse* p_pHTTPResponse)
static void
sendResponse(request_rec *p_pRequestRec,
GSWHTTPResponse *p_pHTTPResponse)
{
char szStatusBuffer[512]="";
server_rec* pServerRec = p_pRequestRec->server;
char szStatusBuffer[512]="";
server_rec *pServerRec = p_pRequestRec->server;
GSWLog(GSW_DEBUG,pServerRec,"Start sendResponse");
// Process Headers
GSWDict_PerformForAllElem(p_pHTTPResponse->pHeaders,getHeader,p_pRequestRec);
ap_snprintf(szStatusBuffer,sizeof(szStatusBuffer),"%u %s",
p_pHTTPResponse->uStatus,
p_pHTTPResponse->pszStatusMessage);
p_pHTTPResponse->uStatus,
p_pHTTPResponse->pszStatusMessage);
p_pRequestRec->status_line = szStatusBuffer;
p_pRequestRec->status = p_pHTTPResponse->uStatus;
// Set content type if none
if (!p_pRequestRec->content_type)
p_pRequestRec->content_type = g_szContentType_TextHtml;
p_pRequestRec->content_type = g_szContentType_TextHtml;
// Set content length
ap_set_content_length(p_pRequestRec, p_pHTTPResponse->uContentLength);
ap_set_content_length(p_pRequestRec, (uintmax_t)p_pHTTPResponse->uContentLength);
// Now Send response...
@ -391,20 +441,25 @@ static void sendResponse(request_rec* p_pRequestRec,GSWHTTPResponse* p_pHTTPResp
// If not headers only
if (!p_pRequestRec->header_only)
{
ap_soft_timeout("Send GSWeb response",p_pRequestRec);
ap_rwrite(p_pHTTPResponse->pContent,p_pHTTPResponse->uContentLength,p_pRequestRec);
ap_kill_timeout(p_pRequestRec);
};
{
ap_soft_timeout("Send GSWeb response",p_pRequestRec);
ap_rwrite(p_pHTTPResponse->pContent,p_pHTTPResponse->uContentLength,
p_pRequestRec);
ap_kill_timeout(p_pRequestRec);
};
GSWLog(GSW_DEBUG,pServerRec,"Stop sendResponse");
};
//--------------------------------------------------------------------
// die/send response
static int dieSendResponse(request_rec* p_pRequestRec,GSWHTTPResponse** p_ppHTTPResponse,BOOL p_fDecline)
static int
dieSendResponse(request_rec *p_pRequestRec,
GSWHTTPResponse **p_ppHTTPResponse,
BOOL p_fDecline)
{
server_rec* pServerRec = p_pRequestRec->server;
void* pLogServerData=pServerRec;
server_rec *pServerRec = p_pRequestRec->server;
void *pLogServerData=pServerRec;
GSWLog(GSW_DEBUG,pLogServerData,"Start dieSendResponse");
sendResponse(p_pRequestRec,*p_ppHTTPResponse);
GSWHTTPResponse_Free(*p_ppHTTPResponse,pLogServerData);
@ -415,14 +470,19 @@ static int dieSendResponse(request_rec* p_pRequestRec,GSWHTTPResponse** p_ppHTTP
//--------------------------------------------------------------------
// die with a message
static int dieWithMessage(request_rec* p_pRequestRec,CONST char* p_pszMessage,BOOL p_fDecline)
static int
dieWithMessage(request_rec *p_pRequestRec,
CONST char *p_pszMessage,
BOOL p_fDecline)
{
int iReturn=0;
GSWHTTPResponse* pResponse=NULL;
server_rec* pServerRec = p_pRequestRec->server;
GSWHTTPResponse *pResponse=NULL;
server_rec *pServerRec = p_pRequestRec->server;
GSWLog(GSW_DEBUG,pServerRec,"Start dieWithMessage");
GSWLog(GSW_ERROR,pServerRec,"Send Error Response: %s",p_pszMessage);
pResponse = GSWHTTPResponse_BuildErrorResponse(NULL,p_pszMessage,p_pRequestRec->server);
pResponse = GSWHTTPResponse_BuildErrorResponse(NULL,p_pszMessage,
p_pRequestRec->server);
iReturn=dieSendResponse(p_pRequestRec,&pResponse,p_fDecline);
GSWLog(GSW_DEBUG,pServerRec,"Stop dieWithMessage");
return iReturn;
@ -430,16 +490,17 @@ static int dieWithMessage(request_rec* p_pRequestRec,CONST char* p_pszMessage,BO
//--------------------------------------------------------------------
// GSWeb Request Handler
static int GSWeb_Handler(request_rec* p_pRequestRec)
static int
GSWeb_Handler(request_rec *p_pRequestRec)
{
int iRetVal=OK;
GSWURLComponents stURLComponents;
GSWHTTPResponse* pResponse = NULL;
GSWURLError eError=GSWURLError_OK;
CONST char* pszURLError=NULL;
server_rec* pServerRec = p_pRequestRec->server;
void* pLogServerData=pServerRec;
GSWeb_Config* pConfig=NULL;
int iRetVal=OK;
GSWURLComponents stURLComponents;
GSWHTTPResponse *pResponse = NULL;
GSWURLError eError=GSWURLError_OK;
CONST char *pszURLError=NULL;
server_rec *pServerRec = p_pRequestRec->server;
void *pLogServerData=pServerRec;
GSWeb_Config *pConfig=NULL;
memset(&stURLComponents,0,sizeof(stURLComponents));
GSWLog(GSW_DEBUG,pLogServerData,"Start GSWeb_Handler");
@ -448,9 +509,9 @@ static int GSWeb_Handler(request_rec* p_pRequestRec)
// Log the request
GSWLog(GSW_INFO,
pLogServerData,
"GNUstepWeb New request: %s",
p_pRequestRec->uri);
pLogServerData,
"GNUstepWeb New request: %s",
p_pRequestRec->uri);
// Is this for us ?
if (strncmp(pConfig->pszGSWeb,
@ -480,20 +541,22 @@ static int GSWeb_Handler(request_rec* p_pRequestRec)
if (iRetVal==0) // OK Continue
{
// Build the GSWHTTPRequest with the method
GSWHTTPRequest* pRequest=NULL;
CONST char* pszRequestError=NULL;
GSWHTTPRequest *pRequest=NULL;
CONST char *pszRequestError=NULL;
pRequest=GSWHTTPRequest_New(p_pRequestRec->method,NULL,pLogServerData);
pRequest=GSWHTTPRequest_New(p_pRequestRec->method,NULL,
pLogServerData);
// validate the method
pszRequestError=GSWHTTPRequest_ValidateMethod(pRequest,pLogServerData);
pszRequestError=GSWHTTPRequest_ValidateMethod(pRequest,
pLogServerData);
if (pszRequestError)
{
iRetVal=dieWithMessage(p_pRequestRec,pszRequestError,NO);
}
else
{
CONST char* pszDocRoot=NULL;
CONST char *pszDocRoot=NULL;
// copy headers
copyHeaders(p_pRequestRec,pRequest);
@ -506,19 +569,22 @@ static int GSWeb_Handler(request_rec* p_pRequestRec)
{
int iReadLength=0;
int iRemainingLength = pRequest->uContentLength;
char* pszBuffer = malloc(pRequest->uContentLength);
char* pszData = pszBuffer;
char *pszBuffer = malloc(pRequest->uContentLength);
char *pszData = pszBuffer;
while (iRemainingLength>0)
{
ap_soft_timeout("reading GSWeb request",p_pRequestRec);
iReadLength=ap_get_client_block(p_pRequestRec,pszData,iRemainingLength);
ap_soft_timeout("reading GSWeb request",
p_pRequestRec);
iReadLength=ap_get_client_block(p_pRequestRec,
pszData,
iRemainingLength);
ap_kill_timeout(p_pRequestRec);
pszData += iReadLength;
iRemainingLength-=iReadLength;
};
GSWLog(GSW_INFO,pLogServerData,"pszBuffer(%p)=%.*s",
(void*)pszBuffer,
(void *)pszBuffer,
(int)pRequest->uContentLength,
pszBuffer);
pRequest->pContent = pszBuffer;
@ -526,25 +592,28 @@ static int GSWeb_Handler(request_rec* p_pRequestRec)
else if (pRequest->eMethod==ERequestMethod_Get)
{
// Get the QueryString
stURLComponents.stQueryString.pszStart = p_pRequestRec->args;
stURLComponents.stQueryString.iLength = p_pRequestRec->args ? strlen(p_pRequestRec->args) : 0;
stURLComponents.stQueryString.pszStart =
p_pRequestRec->args;
stURLComponents.stQueryString.iLength =
p_pRequestRec->args ? strlen(p_pRequestRec->args) : 0;
};
// get the document root
/* if (pConfig && pConfig->pszRoot)
pszDocRoot = pConfig->pszRoot;
else*/
pszDocRoot=(char*)ap_document_root(p_pRequestRec);
pszDocRoot=(char *)ap_document_root(p_pRequestRec);
// Build the response (Beware: tr_handleRequest free pRequest)
// Build the response
// (Beware: tr_handleRequest free pRequest)
ap_soft_timeout("Call GSWeb Application",p_pRequestRec);
pRequest->pServerHandle = p_pRequestRec;
pResponse=GSWAppRequest_HandleRequest(&pRequest,
&stURLComponents,
p_pRequestRec->protocol,
pszDocRoot,
g_szGSWeb_StatusResponseAppName, //AppTest name
pLogServerData);
&stURLComponents,
p_pRequestRec->protocol,
pszDocRoot,
g_szGSWeb_StatusResponseAppName, //AppTest name
pLogServerData);
ap_kill_timeout(p_pRequestRec);
// Send the response (if any)
@ -602,7 +671,8 @@ static int GSWeb_Handler(request_rec* p_pRequestRec)
* 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)
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);
@ -645,21 +715,23 @@ static void GSWeb_register_hooks(apr_pool_t *p)
*/
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}
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 =
@ -667,10 +739,10 @@ 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 */
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 */
GSWeb_Commands, /* command table */
GSWeb_register_hooks, /* set up other request processing hooks */
};
#else
@ -682,23 +754,23 @@ module AP_MODULE_DECLARE_DATA GSWeb_Module =
static command_rec GSWeb_Commands[] =
{
{
GSWEB_CONF__ALIAS, // Command keyword
GSWeb_SetScriptAlias, // Function
NULL, // Fixed Arg
RSRC_CONF, // Type
TAKE1, // Args Descr
"ScriptAlias for GSWeb"
GSWEB_CONF__ALIAS, // Command keyword
GSWeb_SetScriptAlias, // Function
NULL, // Fixed Arg
RSRC_CONF, // Type
TAKE1, // Args Descr
"ScriptAlias for GSWeb"
},
{
GSWEB_CONF__CONFIG_FILE_PATH, // Command keyword
GSWeb_SetConfig, // Function
NULL, // Fixed Arg
RSRC_CONF, // Type
TAKE1, // Args Descr
"Configuration File Path for GSWeb"
GSWEB_CONF__CONFIG_FILE_PATH, // Command keyword
GSWeb_SetConfig, // Function
NULL, // Fixed Arg
RSRC_CONF, // Type
TAKE1, // Args Descr
"Configuration File Path for GSWeb"
},
{
NULL
NULL
}
};
@ -723,14 +795,14 @@ handler_rec GSWeb_Handlers[] =
module GSWeb_Module =
{
STANDARD_MODULE_STUFF,
GSWeb_Init, // Init
NULL, // Create DirectoryConfig
NULL, // Merge DirectoryConfig
GSWeb_CreateServerConfig, // Create ServerConfig
NULL, // Merge ServerConfig
GSWeb_Commands, // Commands List
GSWeb_Handlers, // Handlers List
GSWeb_Translation, // Fn to Translatie Filename/URI
GSWeb_Init, // Init
NULL, // Create DirectoryConfig
NULL, // Merge DirectoryConfig
GSWeb_CreateServerConfig, // Create ServerConfig
NULL, // Merge ServerConfig
GSWeb_Commands, // Commands List
GSWeb_Handlers, // Handlers List
GSWeb_Translation, // Fn to Translatie Filename/URI
NULL,
NULL,
NULL,

View file

@ -1,96 +1,102 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>Adaptor Configuration File</title>
</head>
<head>
<title>Adaptor Configuration File</title>
</head>
<body>
<body>
Configuration file path is specified with Apache directive (/etc/httpd/conf/gsweb.conf is an exemple): <br>
<PRE>GSWeb_ConfigFilePath /etc/httpd/conf/gsweb.conf</PRE><br>
<PRE>GSWeb_ConfigFilePath /etc/httpd/conf/gsweb.conf</PRE><br>
The format is GNUstep/OpenStep property list.<br>
Here is an exemple with all the possible options:<br>
<PRE>
{
//Global Parameters
canDumpStatus=YES; //YES if server can display status (URL: /GSWeb/status)
GSWExtensionsFrameworkWebServerResources="/GSW/GSWExtensions/WebServerResources"; //URL of GSWExtensions Framework WebServerResources directory
{
//Global Parameters
canDumpStatus = YES; //YES if server can display status (URL: /GSWeb/status)
GSWExtensionsFrameworkWebServerResources =
"/GSW/GSWExtensions/WebServerResources"; // URL of GSWExtensions
// Framework
// WebServerResources directory
//List of applications
applications= {
//The 1st application: MyApp
MyApp = {
//List of its instances
instances = {
//First Instance
1 = {
host=145.146.147.20; //Host of this instance
port=9001; //Port of this instance
parameters= { //Unused
transport=socket;
};
};
};
};
//The 2nd application: AnotherOne
AnotherOne = {
//URL of GSWExtensions Framework WebServerResources directory. It overides Global parameter
GSWExtensionsFrameworkWebServerResources="/GSW/GSWExtensions/WebServerResources";
//YES to say that this application can be listed when the adaptor don't find an application
canDump = YES;
//Unused for the moment
applicationHeaders = {
header1=1264;
header2=4567;
};
//Instances
instances = {
//1st instance
1 = {
host=145.146.147.20;
port=9002;
parameters= {
transport=socket;
};
};
};
};
MyAppVoid = {
//Here we have 3 instances
instances = {
1 = {
host=145.146.147.20;
port=9001;
parameters= {
transport=socket;
};
};
2 = {
host=145.146.147.21;
port=9002;
parameters= {
transport=socket;
};
};
5 ={
host=145.146.147.22;
port=9003;
parameters= {
transport=socket;
};
};
};
};
};
};
//List of applications
applications = {
//The 1st application: MyApp
MyApp = {
//List of its instances
instances = {
//First Instance
1 = {
host = 145.146.147.20; //Host of this instance
port = 9001; //Port of this instance
parameters = { //Unused
transport=socket;
};
};
};
};
//The 2nd application: AnotherOne
AnotherOne = {
// URL of GSWExtensions Framework WebServerResources directory.
// It overides Global parameter
GSWExtensionsFrameworkWebServerResources =
"/GSW/GSWExtensions/WebServerResources";
// YES to say that this application can be listed when the
// adaptor don't find an application
canDump = YES;
//Unused for the moment
applicationHeaders = {
header1 = 1264;
header2 = 4567;
};
//Instances
instances = {
//1st instance
1 = {
host = 145.146.147.20;
port = 9002;
parameters = {
transport = socket;
};
};
};
};
MyAppVoid = {
// Here we have 3 instances
instances = {
1 = {
host = 145.146.147.20;
port = 9001;
parameters = {
transport = socket;
};
};
2 = {
host = 145.146.147.21;
port = 9002;
parameters = {
transport=socket;
};
};
5 = {
host = 145.146.147.22;
port = 9003;
parameters = {
transport=socket;
};
};
};
};
};
};
</PRE>
</body>
</body>
</html>

View file

@ -1,8 +1,8 @@
/* GSWApp.c - GSWeb: Adaptors: GSWApp & GSWAppInstance
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: March 2000
Date: March 2000
This file is part of the GNUstep Web Library.
@ -38,117 +38,132 @@
#include "GSWUtil.h"
#include "GSWApp.h"
void GSWApp_InternFreeNotValidInstances(GSWDictElem* p_pElem,void* p_pData);
void GSWApp_InternClearInstances(GSWDictElem* p_pElem,void* p_pData);
void GSWAppInstance_InternClear(GSWDictElem* p_pElem,void* p_pData);
void GSWApp_InternFreeNotValidInstances(GSWDictElem *p_pElem,void *p_pData);
void GSWApp_InternClearInstances(GSWDictElem *p_pElem,void *p_pData);
void GSWAppInstance_InternClear(GSWDictElem *p_pElem,void *p_pData);
//====================================================================
//--------------------------------------------------------------------
GSWApp* GSWApp_New()
GSWApp *
GSWApp_New()
{
GSWApp* pApp=(GSWApp*)calloc(1,sizeof(GSWApp));
GSWApp *pApp=(GSWApp *)calloc(1,sizeof(GSWApp));
memset(pApp,0,sizeof(GSWApp));
pApp->iUsageCounter++;
return pApp;
};
//--------------------------------------------------------------------
void GSWApp_Free(GSWApp* p_pApp)
void
GSWApp_Free(GSWApp *p_pApp)
{
if (!p_pApp)
GSWLog(GSW_CRITICAL,NULL,"No App to free");
GSWLog(GSW_CRITICAL,NULL,"No App to free");
else
{
p_pApp->iUsageCounter--;
if (p_pApp->iUsageCounter<0)
GSWLog(GSW_CRITICAL,NULL,
"App seems to have been freed too much times");
if (p_pApp->iUsageCounter<=0)
{
p_pApp->iUsageCounter--;
if (p_pApp->iUsageCounter<0)
GSWLog(GSW_CRITICAL,NULL,"App seems to have been freed too much times");
if (p_pApp->iUsageCounter<=0)
{
if (p_pApp->pszName)
free(p_pApp->pszName);
if (p_pApp->pszGSWExtensionsFrameworkWebServerResources)
free(p_pApp->pszGSWExtensionsFrameworkWebServerResources);
if (p_pApp->pszAdaptorTemplatesPath)
free(p_pApp->pszAdaptorTemplatesPath);
GSWDict_FreeElements(&p_pApp->stInstancesDict);
GSWDict_FreeElements(&p_pApp->stHeadersDict);
free(p_pApp);
};
if (p_pApp->pszName)
free(p_pApp->pszName);
if (p_pApp->pszGSWExtensionsFrameworkWebServerResources)
free(p_pApp->pszGSWExtensionsFrameworkWebServerResources);
if (p_pApp->pszAdaptorTemplatesPath)
free(p_pApp->pszAdaptorTemplatesPath);
GSWDict_FreeElements(&p_pApp->stInstancesDict);
GSWDict_FreeElements(&p_pApp->stHeadersDict);
free(p_pApp);
};
};
};
//--------------------------------------------------------------------
void GSWApp_AddInstance(GSWApp* p_pApp,CONST char* p_pszInstanceNum,GSWAppInstance* p_pInstance)
void
GSWApp_AddInstance(GSWApp *p_pApp,
CONST char *p_pszInstanceNum,
GSWAppInstance *p_pInstance)
{
if (!p_pApp)
{
GSWLog(GSW_CRITICAL,NULL,"No App to add instance");
}
{
GSWLog(GSW_CRITICAL,NULL,"No App to add instance");
}
else if (!p_pInstance)
{
GSWLog(GSW_CRITICAL,NULL,"No instance to add");
}
{
GSWLog(GSW_CRITICAL,NULL,"No instance to add");
}
else
{
if (p_pInstance->pApp!=p_pApp)
{
if (p_pInstance->pApp!=p_pApp)
{
GSWLog(GSW_CRITICAL,NULL,"Trying to add instance to another app");
if (p_pInstance->pApp)
p_pInstance->pApp->iUsageCounter--;
p_pInstance->pApp=p_pApp;
p_pInstance->pApp->iUsageCounter++;
};
GSWDict_Add(&p_pApp->stInstancesDict,p_pszInstanceNum,p_pInstance,FALSE);//NotOwner
GSWLog(GSW_CRITICAL,NULL,"Trying to add instance to another app");
if (p_pInstance->pApp)
p_pInstance->pApp->iUsageCounter--;
p_pInstance->pApp=p_pApp;
p_pInstance->pApp->iUsageCounter++;
};
GSWDict_Add(&p_pApp->stInstancesDict,p_pszInstanceNum,
p_pInstance,FALSE);//NotOwner
};
};
//--------------------------------------------------------------------
void GSWApp_InternFreeNotValidInstances(GSWDictElem* p_pElem,void* p_pData)
void
GSWApp_InternFreeNotValidInstances(GSWDictElem *p_pElem,
void *p_pData)
{
GSWDict* pInstancesDict=(GSWDict*)p_pData;
GSWAppInstance* pInstance=(GSWAppInstance*)p_pElem->pValue;
GSWDict *pInstancesDict=(GSWDict *)p_pData;
GSWAppInstance *pInstance=(GSWAppInstance *)p_pElem->pValue;
if (!pInstance->fValid)
{
GSWDict_RemoveKey(pInstancesDict,p_pElem->pszKey);
if (GSWAppInstance_FreeIFND(pInstance))
pInstance=NULL;
};
{
GSWDict_RemoveKey(pInstancesDict,p_pElem->pszKey);
if (GSWAppInstance_FreeIFND(pInstance))
pInstance=NULL;
};
};
//--------------------------------------------------------------------
void GSWApp_FreeNotValidInstances(GSWApp* p_pApp)
void
GSWApp_FreeNotValidInstances(GSWApp *p_pApp)
{
GSWDict_PerformForAllElem(&p_pApp->stInstancesDict,
GSWApp_InternFreeNotValidInstances,
&p_pApp->stInstancesDict);
GSWApp_InternFreeNotValidInstances,
&p_pApp->stInstancesDict);
};
//--------------------------------------------------------------------
void GSWApp_InternClearInstances(GSWDictElem* p_pElem,void* p_pData)
void
GSWApp_InternClearInstances(GSWDictElem *p_pElem,
void *p_pData)
{
GSWApp* pApp=(GSWApp*)(p_pElem->pValue);
GSWApp *pApp=(GSWApp *)(p_pElem->pValue);
GSWDict_PerformForAllElem(&pApp->stInstancesDict,
GSWAppInstance_InternClear,
NULL);
GSWAppInstance_InternClear,
NULL);
};
//--------------------------------------------------------------------
void GSWApp_AppsClearInstances(GSWDict* p_pAppsDict)
void
GSWApp_AppsClearInstances(GSWDict *p_pAppsDict)
{
GSWDict_PerformForAllElem(p_pAppsDict,
GSWApp_InternClearInstances,
NULL);
GSWApp_InternClearInstances,
NULL);
};
//====================================================================
//--------------------------------------------------------------------
GSWAppInstance* GSWAppInstance_New(GSWApp* p_pApp)
GSWAppInstance *
GSWAppInstance_New(GSWApp *p_pApp)
{
GSWAppInstance* pInstance=(GSWAppInstance*)calloc(1,sizeof(GSWAppInstance));
GSWAppInstance *pInstance=(GSWAppInstance*)calloc(1,sizeof(GSWAppInstance));
memset(pInstance,0,sizeof(GSWAppInstance));
if (!p_pApp)
GSWLog(GSW_CRITICAL,NULL,"Intance %p created without App",
pInstance);
GSWLog(GSW_CRITICAL,NULL,"Intance %p created without App",
pInstance);
pInstance->pApp=p_pApp;
return pInstance;
};
@ -156,128 +171,153 @@ GSWAppInstance* GSWAppInstance_New(GSWApp* p_pApp)
//--------------------------------------------------------------------
void GSWAppInstance_Free(GSWAppInstance* p_pInstance)
void
GSWAppInstance_Free(GSWAppInstance *p_pInstance)
{
if (p_pInstance)
{
if (p_pInstance->pszHostName)
free(p_pInstance->pszHostName);
if (p_pInstance->pApp)
{
if (p_pInstance->pszHostName)
free(p_pInstance->pszHostName);
if (p_pInstance->pApp)
{
char szBuffer[128]="";
sprintf(szBuffer,"%d",p_pInstance->iInstance);
if (GSWDict_ValueForKey(&p_pInstance->pApp->stInstancesDict,szBuffer)==p_pInstance)
GSWDict_RemoveKey(&p_pInstance->pApp->stInstancesDict,szBuffer);
p_pInstance->pApp->iUsageCounter--;
};
free(p_pInstance);
};
char szBuffer[128]="";
sprintf(szBuffer,"%d",p_pInstance->iInstance);
if (GSWDict_ValueForKey(&p_pInstance->pApp->stInstancesDict,
szBuffer)==p_pInstance)
GSWDict_RemoveKey(&p_pInstance->pApp->stInstancesDict,szBuffer);
p_pInstance->pApp->iUsageCounter--;
};
free(p_pInstance);
};
};
//--------------------------------------------------------------------
BOOL GSWAppInstance_FreeIFND(GSWAppInstance* p_pInstance)
BOOL
GSWAppInstance_FreeIFND(GSWAppInstance *p_pInstance)
{
if (p_pInstance->uOpenedRequestsNb==0)
{
GSWAppInstance_Free(p_pInstance);
return TRUE;
}
{
GSWAppInstance_Free(p_pInstance);
return TRUE;
}
else
return FALSE;
return FALSE;
};
//--------------------------------------------------------------------
void GSWAppInstance_InternClear(GSWDictElem* p_pElem,void* p_pData)
void
GSWAppInstance_InternClear(GSWDictElem *p_pElem,void *p_pData)
{
GSWAppInstance* pInstance=(GSWAppInstance*)(p_pElem->pValue);
GSWAppInstance *pInstance=(GSWAppInstance*)(p_pElem->pValue);
pInstance->fValid=FALSE;
};
//--------------------------------------------------------------------
//--------------------------------------------------------------------
void GSWAppInfo_Init()
void
GSWAppInfo_Init()
{
if (_gswAppInfoDict == NULL) {
_gswAppInfoDict = GSWDict_New(50); // allows 50 different instances of apps
}
if (_gswAppInfoDict == NULL)
{
_gswAppInfoDict = GSWDict_New(50);
// allows 50 different instances of apps
}
}
//--------------------------------------------------------------------
char* GSWAppInfo_MakeDictKeyName(char* pszName, int iInstance)
char *
GSWAppInfo_MakeDictKeyName(char *pszName, int iInstance)
{
char *name = NULL;
if (name = calloc(1,50)) {
if (pszName) {
strncpy(name, pszName,45);
name[45]=0;
}
sprintf(name + strlen(name), "%d", iInstance);
char *name = NULL;
if (name = calloc(1,50))
{
if (pszName)
{
strncpy(name, pszName,45);
name[45]=0;
}
return name;
sprintf(name + strlen(name), "%d", iInstance);
}
return name;
}
//--------------------------------------------------------------------
GSWAppInfo* GSWAppInfo_Find(char* pszName, int iInstance)
GSWAppInfo *
GSWAppInfo_Find(char *pszName, int iInstance)
{
char *name;
GSWAppInfo* newInfo = NULL;
char *name;
GSWAppInfo *newInfo = NULL;
if (_gswAppInfoDict == NULL) {
GSWAppInfo_Init();
return NULL;
}
if (_gswAppInfoDict == NULL)
{
GSWAppInfo_Init();
return NULL;
}
name = GSWAppInfo_MakeDictKeyName(pszName, iInstance);
if (name) {
newInfo = GSWDict_ValueForKey(_gswAppInfoDict, name);
free(name); name = NULL;
}
name = GSWAppInfo_MakeDictKeyName(pszName, iInstance);
if (name)
{
newInfo = GSWDict_ValueForKey(_gswAppInfoDict, name);
free(name);
name = NULL;
}
return newInfo;
return newInfo;
}
//--------------------------------------------------------------------
void GSWAppInfo_Add(GSWAppInfo* appInfoDict, CONST char* keyName)
void
GSWAppInfo_Add(GSWAppInfo *appInfoDict, CONST char *keyName)
{
if (appInfoDict) {
GSWDict_Add(_gswAppInfoDict, keyName, appInfoDict, TRUE);
}
if (appInfoDict)
{
GSWDict_Add(_gswAppInfoDict, keyName, appInfoDict, TRUE);
}
}
//--------------------------------------------------------------------
void GSWAppInfo_Set(char* pszName, int iInstance, BOOL isRefused)
void
GSWAppInfo_Set(char *pszName, int iInstance, BOOL isRefused)
{
char *name;
GSWAppInfo* newInfo = GSWAppInfo_Find(pszName, iInstance);
time_t curTime = (time_t)0;
BOOL addDict = FALSE;
char *name;
GSWAppInfo *newInfo = GSWAppInfo_Find(pszName, iInstance);
time_t curTime = (time_t)0;
BOOL addDict = FALSE;
if (newInfo == NULL) {
newInfo=(GSWAppInfo*)calloc(1,sizeof(GSWAppInfo));
addDict = TRUE;
if (newInfo == NULL)
{
newInfo=(GSWAppInfo*)calloc(1,sizeof(GSWAppInfo));
addDict = TRUE;
}
if (newInfo && (name = GSWAppInfo_MakeDictKeyName(pszName, iInstance) ))
{
newInfo->isRefused = isRefused;
time(&curTime);
newInfo->timeNextRetryTime = curTime + 10; // + 10 sec
if (addDict == TRUE)
{
GSWAppInfo_Add(newInfo, name);
}
if (newInfo && (name = GSWAppInfo_MakeDictKeyName(pszName, iInstance) )) {
newInfo->isRefused = isRefused;
time(&curTime);
newInfo->timeNextRetryTime = curTime + 10; // + 10 sec
if (addDict == TRUE) {
GSWAppInfo_Add(newInfo, name);
}
free(name); name = NULL;
} else {
if (newInfo) {
free(newInfo); newInfo = NULL;
}
free(name);
name = NULL;
}
else
{
if (newInfo)
{
free(newInfo);
newInfo = NULL;
}
}
}
//--------------------------------------------------------------------
void GSWAppInfo_Remove(GSWAppInfo* _appInfo)
void
GSWAppInfo_Remove(GSWAppInfo *_appInfo)
{
}

View file

@ -1,8 +1,8 @@
/* GSWApp.h - GSWeb: Adaptors: GSWApp & GSWAppInstance
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: March 2000
Date: March 2000
This file is part of the GNUstep Web Library.
@ -26,38 +26,40 @@
typedef struct _GSWApp
{
int iUsageCounter;
char* pszName;
int iIndex;//Current Instance Index
int iUsageCounter;
char *pszName;
int iIndex;//Current Instance Index
GSWDict stInstancesDict;
GSWDict stHeadersDict;
char* pszGSWExtensionsFrameworkWebServerResources;
BOOL fCanDump;
char* pszAdaptorTemplatesPath;
char *pszGSWExtensionsFrameworkWebServerResources;
BOOL fCanDump;
char *pszAdaptorTemplatesPath;
} GSWApp;
typedef struct _GSWAppInstance
{
GSWApp* pApp;
int iInstance;
char* pszHostName;
int iPort;
time_t timeNextRetryTime; // Timer
GSWApp *pApp;
int iInstance;
char *pszHostName;
int iPort;
time_t timeNextRetryTime; // Timer
unsigned int uOpenedRequestsNb;
BOOL fValid;
BOOL fValid;
} GSWAppInstance;
//--------------------------------------------------------------------
GSWApp* GSWApp_New();
void GSWApp_Free(GSWApp* p_pApp);
void GSWApp_FreeNotValidInstances(GSWApp* p_pApp);
void GSWApp_AppsClearInstances(GSWDict* p_pAppsDict);
void GSWApp_AddInstance(GSWApp* p_pApp,CONST char* p_pszInstanceNum,GSWAppInstance* p_pInstance);
GSWApp *GSWApp_New();
void GSWApp_Free(GSWApp *p_pApp);
void GSWApp_FreeNotValidInstances(GSWApp *p_pApp);
void GSWApp_AppsClearInstances(GSWDict *p_pAppsDict);
void GSWApp_AddInstance(GSWApp *p_pApp,
CONST char *p_pszInstanceNum,
GSWAppInstance *p_pInstance);
//--------------------------------------------------------------------
GSWAppInstance* GSWAppInstance_New(GSWApp* p_pApp);
void GSWAppInstance_Free(GSWAppInstance* p_pInstance);
BOOL GSWAppInstance_FreeIFND(GSWAppInstance* p_pInstance);
GSWAppInstance *GSWAppInstance_New(GSWApp *p_pApp);
void GSWAppInstance_Free(GSWAppInstance *p_pInstance);
BOOL GSWAppInstance_FreeIFND(GSWAppInstance *p_pInstance);
//---------------------------------------------------------------------
typedef struct _GSWAppInfo
@ -66,13 +68,13 @@ typedef struct _GSWAppInfo
time_t timeNextRetryTime; // next try to look, if it is not refused
} GSWAppInfo;
static GSWDict* _gswAppInfoDict = NULL;
static GSWDict *_gswAppInfoDict = NULL;
void GSWAppInfo_Init();
GSWAppInfo* GSWAppInfo_Find(char* pszName, int iInstance);
void GSWAppInfo_Add(GSWAppInfo* appInfoDict, CONST char* keyName);
void GSWAppInfo_Set(char* pszName, int iInstance, BOOL isRefused);
void GSWAppInfo_Remove(GSWAppInfo* _appInfo);
GSWAppInfo *GSWAppInfo_Find(char *pszName,int iInstance);
void GSWAppInfo_Add(GSWAppInfo *appInfoDict, CONST char *keyName);
void GSWAppInfo_Set(char *pszName, int iInstance, BOOL isRefused);
void GSWAppInfo_Remove(GSWAppInfo *_appInfo);
#endif // _GSWApp_h__

View file

@ -1,8 +1,8 @@
/* GSWAppConnect.h - GSWeb: GSWeb App Connect
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -26,33 +26,33 @@
typedef struct _STAppConnectHandle
{
void* foo;
void *foo;
} STAppConnectHandle;
typedef STAppConnectHandle* AppConnectHandle;
typedef STAppConnectHandle *AppConnectHandle;
AppConnectHandle GSWApp_Open(GSWAppRequest* p_pAppRequest,
void* p_pLogServerData);
AppConnectHandle GSWApp_Open(GSWAppRequest *p_pAppRequest,
void *p_pLogServerData);
void GSWApp_Close(AppConnectHandle p_handle,
void* p_pLogServerData);
void *p_pLogServerData);
int GSWApp_SendBlock(AppConnectHandle p_handle,
CONST char* p_pszBuffer,
int p_iSize,
void* p_pLogServerData);
CONST char *p_pszBuffer,
int p_iSize,
void *p_pLogServerData);
int GSWApp_ReceiveBlock(AppConnectHandle p_handle,
char* p_pszBuffer,
int p_iBufferSize,
void* p_pLogServerData);
char *p_pszBuffer,
int p_iBufferSize,
void *p_pLogServerData);
int GSWApp_SendLine(AppConnectHandle p_handle,
CONST char* p_pszBuffer,
void* p_pLogServerData);
CONST char *p_pszBuffer,
void *p_pLogServerData);
int GSWApp_ReceiveLine(AppConnectHandle p_handle,
char* p_pszBuffer,
int p_iBufferSize,
void* p_pLogServerData);
char *p_pszBuffer,
int p_iBufferSize,
void *p_pLogServerData);
#endif // _GSWAppConnect_h__

View file

@ -1,8 +1,8 @@
/* GSWAppConnectNSSocket.c - GSWeb: Adaptors: App Connection by Netscape Sockets
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -41,180 +41,195 @@
typedef SYS_NETFD AppConnectNSSocketHandle;
AppConnectHandle GSWApp_Open(GSWAppRequest* p_pAppRequest,
void* p_pLogServerData)
AppConnectHandle
GSWApp_Open(GSWAppRequest *p_pAppRequest,
void *p_pLogServerData)
{
AppConnectHandle handle=NULL;
if (!p_pAppRequest)
{
}
{
}
else
{
struct hostent *pHost=hl_find(p_pAppRequest->pszHost);
if (!pHost)
{
struct hostent* pHost=hl_find(p_pAppRequest->pszHost);
if (!pHost)
{
GSWLog(GSW_ERROR, "gethostbyname(%s) returns no host",p_pAppRequest->pszHost);
}
else if (pHost->h_addrtype!=AF_INET)
{
GSWLog(GSW_ERROR,"Host %s has bad address type",p_pAppRequest->pszHost);
}
else
{
AppConnectNSSocketHandle nshandle=NULL;
struct sockaddr_in sin;
memset(&sin,0,sizeof(sin));
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);
GSWLog(GSW_ERROR, p_pLogServerData,
"gethostbyname(%s) returns no host",
p_pAppRequest->pszHost);
}
else if (pHost->h_addrtype!=AF_INET)
{
GSWLog(GSW_ERROR, p_pLogServerData, "Host %s has bad address type",
p_pAppRequest->pszHost);
}
else
{
AppConnectNSSocketHandle nshandle=NULL;
struct sockaddr_in sin;
memset(&sin,0,sizeof(sin));
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);
GSWLog(GSW_INFO, "Try contacting %s on port %d...",
p_pAppRequest->pszHost,
p_pAppRequest->iPort);
nshandle = net_socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if (nshandle<0)
{
GSWLog(GSW_ERROR,"Can't Create socket to %s:%d. Error=%d (%s)",
p_pAppRequest->pszHost,
p_pAppRequest->iPort,
errno,
strerror(errno));
}
else
{
if (net_connect(nshandle,(struct sockaddr*)&sin,sizeof(sin))<0)
{
GSWLog(GSW_ERROR,"Can't connect to %s:%d. Error=%d (%s)",
p_pAppRequest->pszHost,
p_pAppRequest->iPort,
errno,
strerror(errno));
net_close(nshandle);
};
};
handle=(AppConnectHandle)nshandle;
GSWLog(GSW_INFO, p_pLogServerData, "Try contacting %s on port %d...",
p_pAppRequest->pszHost,
p_pAppRequest->iPort);
nshandle = net_socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if (nshandle<0)
{
GSWLog(GSW_ERROR, p_pLogServerData,
"Can't Create socket to %s:%d. Error=%d (%s)",
p_pAppRequest->pszHost,
p_pAppRequest->iPort,
errno,
strerror(errno));
}
else
{
if (net_connect(nshandle,(struct sockaddr *)&sin,sizeof(sin))<0)
{
GSWLog(GSW_ERROR, p_pLogServerData,
"Can't connect to %s:%d. Error=%d (%s)",
p_pAppRequest->pszHost,
p_pAppRequest->iPort,
errno,
strerror(errno));
net_close(nshandle);
};
};
handle=(AppConnectHandle)nshandle;
};
};
return handle;
};
void GSWApp_Close(AppConnectHandle p_handle,
void* p_pLogServerData)
void
GSWApp_Close(AppConnectHandle p_handle,
void *p_pLogServerData)
{
if (p_handle)
{
AppConnectNSSocketHandle handle=(AppConnectNSSocketHandle)p_handle;
if (handle && handle>(AppConnectNSSocketHandle)1)
net_close(handle);
};
{
AppConnectNSSocketHandle handle=(AppConnectNSSocketHandle)p_handle;
if (handle && handle>(AppConnectNSSocketHandle)1)
net_close(handle);
};
};
int GSWApp_SendLine(AppConnectHandle p_handle,
CONST char* p_pszBuffer,
void* p_pLogServerData)
int
GSWApp_SendLine(AppConnectHandle p_handle,
CONST char *p_pszBuffer,
void *p_pLogServerData)
{
int iRetValue=-1;
if (p_handle)
iRetValue=sendbytes(p_handle,p_pszBuffer,strlen(p_pszBuffer));
iRetValue=sendbytes(p_handle,p_pszBuffer,strlen(p_pszBuffer));
return iRetValue;
}
int GSWApp_SendBlock(AppConnectHandle p_handle,
CONST char* p_pszBuffer,
int p_iSize,
void* p_pLogServerData)
int
GSWApp_SendBlock(AppConnectHandle p_handle,
CONST char *p_pszBuffer,
int p_iSize,
void *p_pLogServerData)
{
int iRetValue=-1;
if (p_handle)
{
AppConnectNSSocketHandle handle=(AppConnectNSSocketHandle)p_handle;
int iSent=0;
int iRemainingSize = p_iSize;
while (iRemainingSize>0 && iSent>=0)
{
AppConnectNSSocketHandle handle=(AppConnectNSSocketHandle)p_handle;
int iSent=0;
int iRemainingSize = p_iSize;
while (iRemainingSize>0 && iSent>=0)
{
iSent=net_write(handle,(char*)p_pszBuffer,iRemainingSize);
if (iSent<0)
GSWLog(GSW_ERROR,"send failed. Error=%d (%s)",
errno,
strerror(errno));
else
{
p_pszBuffer+=iSent;
iRemainingSize-=iSent;
};
};
iRetValue=(iRemainingSize>0) ? -1 : 0;
};
return iRetValue;
}
int GSWApp_ReceiveLine(AppConnectHandle p_handle,
char* p_pszBuffer,
int p_iBufferSize,
void* p_pLogServerData)
{
int iRetValue=-1;
if (p_handle)
{
AppConnectNSSocketHandle handle=(AppConnectNSSocketHandle)p_handle;
char c=0;
int iReaden=0;
int i = 0;
BOOL fOk=TRUE;
while (c!='\n' && i<p_iBufferSize-1 && fOk)
{
iReaden=net_read(handle,&c,1,APP_CONNECT_TIMEOUT);
if (iReaden<1)
{
GSWLog(GSW_ERROR,"GSWApp_ReceiveLine. Error=%d (%s)",
errno,
strerror(errno));
iRetValue=0; //??
fOk=FALSE;
}
else
p_pszBuffer[i++] = c;
};
if (i>0)
{
p_pszBuffer[i] = '\0';
iRetValue=DeleteTrailingCRNL(p_pszBuffer);
}
iSent=net_write(handle,(char *)p_pszBuffer,iRemainingSize);
if (iSent<0)
GSWLog(GSW_ERROR, p_pLogServerData,
"send failed. Error=%d (%s)",
errno,
strerror(errno));
else
iRetValue=0; //??
{
p_pszBuffer+=iSent;
iRemainingSize-=iSent;
};
};
iRetValue=(iRemainingSize>0) ? -1 : 0;
};
return iRetValue;
};
}
int GSWApp_ReceiveBlock(AppConnectHandle p_handle,
char* p_pszBuffer,
int p_iBufferSize,
void* p_pLogServerData)
int
GSWApp_ReceiveLine(AppConnectHandle p_handle,
char *p_pszBuffer,
int p_iBufferSize,
void *p_pLogServerData)
{
int iRetValue=-1;
if (p_handle)
{
AppConnectNSSocketHandle handle=(AppConnectNSSocketHandle)p_handle;
char c=0;
int iReaden=0;
int i = 0;
BOOL fOk=TRUE;
while (c!='\n' && i<p_iBufferSize-1 && fOk)
{
AppConnectNSSocketHandle handle=(AppConnectNSSocketHandle)p_handle;
int iReceived=0;
int iRemainingSize=p_iBufferSize;
BOOL fOk=TRUE;
while (iRemainingSize>0 && fOk)
{
iReceived=net_read(handle,p_pszBuffer,iRemainingSize,APP_CONNECT_TIMEOUT);
if (iReceived<0)
{
GSWLog(GSW_ERROR,"GSWApp_ReceiveBlock failed. Error=%d %s",
errno,
strerror(errno));
fOk=FALSE;
}
else
{
p_pszBuffer+=iReceived;
iRemainingSize-=iReceived;
};
};
iRetValue=p_iBufferSize-iRemainingSize;
iReaden=net_read(handle,&c,1,APP_CONNECT_TIMEOUT);
if (iReaden<1)
{
GSWLog(GSW_ERROR, p_pLogServerData,
"GSWApp_ReceiveLine. Error=%d (%s)",
errno,
strerror(errno));
iRetValue=0; //??
fOk=FALSE;
}
else
p_pszBuffer[i++] = c;
};
if (i>0)
{
p_pszBuffer[i] = '\0';
iRetValue=DeleteTrailingCRNL(p_pszBuffer);
}
else
iRetValue=0; //??
};
return iRetValue;
};
int
GSWApp_ReceiveBlock(AppConnectHandle p_handle,
char *p_pszBuffer,
int p_iBufferSize,
void *p_pLogServerData)
{
int iRetValue=-1;
if (p_handle)
{
AppConnectNSSocketHandle handle=(AppConnectNSSocketHandle)p_handle;
int iReceived=0;
int iRemainingSize=p_iBufferSize;
BOOL fOk=TRUE;
while (iRemainingSize>0 && fOk)
{
iReceived=net_read(handle,p_pszBuffer,
iRemainingSize,APP_CONNECT_TIMEOUT);
if (iReceived<0)
{
GSWLog(GSW_ERROR, p_pLogServerData,
"GSWApp_ReceiveBlock failed. Error=%d %s",
errno,
strerror(errno));
fOk=FALSE;
}
else
{
p_pszBuffer+=iReceived;
iRemainingSize-=iReceived;
};
};
iRetValue=p_iBufferSize-iRemainingSize;
};
return iRetValue;
};

View file

@ -1,8 +1,8 @@
/* GSWAppConnectSocket.c - GSWeb: Adaptors: App Connection by Socket
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.

View file

@ -1,8 +1,8 @@
/* GSWAppRequest.c - GSWeb: Adaptors: App Request
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -60,156 +60,180 @@ Connection closed by foreign host.
*/
//--------------------------------------------------------------------
GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequest,
GSWURLComponents* p_pURLComponents,
GSWAppRequest* p_pAppRequest,
CONST char* p_pszHTTPVersion,
void* p_pLogServerData)
GSWHTTPResponse *
GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest **p_ppHTTPRequest,
GSWURLComponents *p_pURLComponents,
GSWAppRequest *p_pAppRequest,
CONST char *p_pszHTTPVersion,
void *p_pLogServerData)
{
GSWHTTPResponse* pHTTPResponse=NULL;
BOOL fAppFound=FALSE;
BOOL fAppNotResponding=FALSE;
int iAttemptsRemaining=APP_CONNECT_RETRIES_NB;
GSWHTTPResponse *pHTTPResponse=NULL;
BOOL fAppFound=FALSE;
BOOL fAppNotResponding=FALSE;
int iAttemptsRemaining=APP_CONNECT_RETRIES_NB;
AppConnectHandle hConnect=NULL;
char *appName = NULL;
int appInstance = 0;
char *appName = NULL;
int appInstance = 0;
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWAppRequest_SendAppRequestToApp");
if (p_pAppRequest->iInstance>0) //-1 or 0 mean any instance
fAppFound = GSWLoadBalancing_FindInstance(p_pAppRequest,p_pLogServerData, p_pURLComponents);
fAppFound = GSWLoadBalancing_FindInstance(p_pAppRequest,
p_pLogServerData,
p_pURLComponents);
else
fAppFound = GSWLoadBalancing_FindApp(p_pAppRequest,p_pLogServerData, p_pURLComponents);
fAppFound = GSWLoadBalancing_FindApp(p_pAppRequest,
p_pLogServerData,
p_pURLComponents);
if (!fAppFound)
{
GSWLog(GSW_WARNING,p_pLogServerData,"App not found");
//TODO
// Call AppStart daemon
};
{
GSWLog(GSW_WARNING,p_pLogServerData,"App not found");
//TODO
// Call AppStart daemon
};
while (!pHTTPResponse && fAppFound && iAttemptsRemaining-->0)
{
fAppNotResponding=FALSE;
GSWLog(GSW_INFO,p_pLogServerData,"Trying to contact %s:%d on %s(%d)",
p_pAppRequest->pszName,
p_pAppRequest->iInstance,
p_pAppRequest->pszHost,
p_pAppRequest->iPort);
hConnect = GSWApp_Open(p_pAppRequest,p_pLogServerData);
{
fAppNotResponding=FALSE;
GSWLog(GSW_INFO,p_pLogServerData,"Trying to contact %s:%d on %s(%d)",
p_pAppRequest->pszName,
p_pAppRequest->iInstance,
p_pAppRequest->pszHost,
p_pAppRequest->iPort);
hConnect = GSWApp_Open(p_pAppRequest,p_pLogServerData);
if (hConnect)
{
if (p_pAppRequest->eType==EAppType_LoadBalanced)
GSWLoadBalancing_StartAppRequest(p_pAppRequest,p_pLogServerData);
{
if (p_pAppRequest->eType==EAppType_LoadBalanced)
GSWLoadBalancing_StartAppRequest(p_pAppRequest,
p_pLogServerData);
GSWLog(GSW_INFO,p_pLogServerData,"%s:%d on %s(%d) connected",
p_pAppRequest->pszName,
p_pAppRequest->iInstance,
p_pAppRequest->pszHost,
p_pAppRequest->iPort);
GSWLog(GSW_INFO,p_pLogServerData,"%s:%d on %s(%d) connected",
p_pAppRequest->pszName,
p_pAppRequest->iInstance,
p_pAppRequest->pszHost,
p_pAppRequest->iPort);
GSWHTTPRequest_HTTPToAppRequest(*p_ppHTTPRequest,
p_pAppRequest,
p_pURLComponents,
p_pszHTTPVersion,
p_pLogServerData);
if (GSWHTTPRequest_SendRequest(*p_ppHTTPRequest,
hConnect,
p_pLogServerData) != 0)
{
GSWLog(GSW_ERROR,p_pLogServerData,"Failed to send request");
GSWApp_Close(hConnect,p_pLogServerData);
hConnect=NULL;
fAppNotResponding=TRUE;
}
else
{
GSWLog(GSW_INFO,p_pLogServerData,
"Request %s sent, awaiting response",
(*p_ppHTTPRequest)->pszRequest);
appName = strdup(p_pAppRequest->pszName);
appInstance = p_pAppRequest->iInstance;
p_pAppRequest->pRequest = NULL;
pHTTPResponse = GSWHTTPResponse_GetResponse(hConnect,p_pLogServerData);
p_pAppRequest->pResponse = pHTTPResponse;
if (p_pAppRequest->eType == EAppType_LoadBalanced)
GSWLoadBalancing_StopAppRequest(p_pAppRequest,p_pLogServerData);
GSWApp_Close(hConnect,p_pLogServerData);
hConnect=NULL;
glbResponsesNb++;
if (pHTTPResponse)
{
char *value = GSWDict_ValueForKey(pHTTPResponse->pHeaders,"x-gsweb-refusing-redirection");
if (value && (strncmp(value,"YES",3)==0)) {
// refuseNewSessions == YES in app
GSWLog(GSW_INFO,p_pLogServerData,"### This app (%s / %d) is refusing all new sessions ###", appName, appInstance);
GSWAppInfo_Set(appName, appInstance, TRUE);
}
GSWLog(GSW_INFO,p_pLogServerData,
"received: %d %s",
pHTTPResponse->uStatus,
pHTTPResponse->pszStatusMessage);
};
if (appName) {
free(appName); appName = NULL;
}
};
}
else
GSWHTTPRequest_HTTPToAppRequest(*p_ppHTTPRequest,
p_pAppRequest,
p_pURLComponents,
p_pszHTTPVersion,
p_pLogServerData);
if (GSWHTTPRequest_SendRequest(*p_ppHTTPRequest,
hConnect,
p_pLogServerData) != 0)
{
GSWLog(GSW_ERROR,p_pLogServerData,"Failed to send request");
GSWApp_Close(hConnect,p_pLogServerData);
hConnect=NULL;
fAppNotResponding=TRUE;
GSWLog(GSW_WARNING,p_pLogServerData,"%s:%d NOT LISTENING on %s:%d",
p_pAppRequest->pszName,
p_pAppRequest->iInstance,
p_pAppRequest->pszHost,
p_pAppRequest->iPort);
//TODO
/*
if (p_pAppRequest->eType == EAppType_Auto)
GSWLoadBalancing_MarkNotRespondingApp(p_pAppRequest,p_pLogServerData);
else*/ if (p_pAppRequest->eType==EAppType_LoadBalanced)
{
GSWLoadBalancing_MarkNotRespondingApp(p_pAppRequest,p_pLogServerData);
if (iAttemptsRemaining-->0)
fAppFound=GSWLoadBalancing_FindApp(p_pAppRequest,p_pLogServerData, p_pURLComponents);
};
};
};
if (fAppNotResponding)
{
GSWApp* pApp=(p_pAppRequest ? (p_pAppRequest->pAppInstance ? p_pAppRequest->pAppInstance->pApp : NULL) : NULL);
char* pszString=GSWTemplate_ErrorNoResponseMessage(TRUE,pApp);
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse(p_pAppRequest,
pszString,
p_pLogServerData);
free(pszString);
};
if (!pHTTPResponse)
{
GSWLog(GSW_WARNING,p_pLogServerData,
"Application %s not found or not responding",
p_pAppRequest->pszName);
pHTTPResponse = GSWDumpConfigFile(p_pURLComponents,p_pLogServerData);
if (!pHTTPResponse)
{
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse(p_pAppRequest,"No App Found",p_pLogServerData);
pHTTPResponse->uStatus = 404;
if (pHTTPResponse->pszStatusMessage)
{
free(pHTTPResponse->pszStatusMessage);
pHTTPResponse->pszStatusMessage=NULL;
};
pHTTPResponse->pszStatusMessage = strdup("File Not found");
}
};
else
{
GSWLog(GSW_INFO,p_pLogServerData,
"Request %s sent, awaiting response",
(*p_ppHTTPRequest)->pszRequest);
appName = strdup(p_pAppRequest->pszName);
appInstance = p_pAppRequest->iInstance;
p_pAppRequest->pRequest = NULL;
pHTTPResponse = GSWHTTPResponse_GetResponse(hConnect,
p_pLogServerData);
p_pAppRequest->pResponse = pHTTPResponse;
if (p_pAppRequest->eType == EAppType_LoadBalanced)
GSWLoadBalancing_StopAppRequest(p_pAppRequest,
p_pLogServerData);
GSWApp_Close(hConnect,p_pLogServerData);
hConnect=NULL;
glbResponsesNb++;
if (pHTTPResponse)
{
char *value =
GSWDict_ValueForKey(pHTTPResponse->pHeaders,
"x-gsweb-refusing-redirection");
if (value && (strncmp(value,"YES",3)==0))
{
// refuseNewSessions == YES in app
GSWLog(GSW_INFO,p_pLogServerData,
"### This app (%s / %d) is refusing all new sessions ###",
appName, appInstance);
GSWAppInfo_Set(appName, appInstance, TRUE);
}
GSWLog(GSW_INFO,p_pLogServerData,
"received: %d %s",
pHTTPResponse->uStatus,
pHTTPResponse->pszStatusMessage);
};
if (appName)
{
free(appName);
appName = NULL;
}
};
}
else
{
fAppNotResponding=TRUE;
GSWLog(GSW_WARNING,p_pLogServerData,
"%s:%d NOT LISTENING on %s:%d",
p_pAppRequest->pszName,
p_pAppRequest->iInstance,
p_pAppRequest->pszHost,
p_pAppRequest->iPort);
//TODO
/*
if (p_pAppRequest->eType == EAppType_Auto)
GSWLoadBalancing_MarkNotRespondingApp(p_pAppRequest,
p_pLogServerData);
else*/ if (p_pAppRequest->eType==EAppType_LoadBalanced)
{
GSWLoadBalancing_MarkNotRespondingApp(p_pAppRequest,
p_pLogServerData);
if (iAttemptsRemaining-->0)
fAppFound=GSWLoadBalancing_FindApp(p_pAppRequest,
p_pLogServerData,
p_pURLComponents);
};
};
};
if (fAppNotResponding)
{
GSWApp *pApp=(p_pAppRequest ?
(p_pAppRequest->pAppInstance ?
p_pAppRequest->pAppInstance->pApp : NULL) : NULL);
char *pszString=GSWTemplate_ErrorNoResponseMessage(TRUE,pApp);
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse(p_pAppRequest,
pszString,
p_pLogServerData);
free(pszString);
};
if (!pHTTPResponse)
{
GSWLog(GSW_WARNING,p_pLogServerData,
"Application %s not found or not responding",
p_pAppRequest->pszName);
pHTTPResponse = GSWDumpConfigFile(p_pURLComponents,p_pLogServerData);
if (!pHTTPResponse)
{
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse(p_pAppRequest,
"No App Found",
p_pLogServerData);
pHTTPResponse->uStatus = 404;
if (pHTTPResponse->pszStatusMessage)
{
free(pHTTPResponse->pszStatusMessage);
pHTTPResponse->pszStatusMessage=NULL;
};
pHTTPResponse->pszStatusMessage = strdup("File Not found");
}
};
GSWHTTPRequest_Free(*p_ppHTTPRequest,p_pLogServerData);
*p_ppHTTPRequest=NULL;
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWAppRequest_SendAppRequestToApp");
@ -217,111 +241,131 @@ GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequ
};
//--------------------------------------------------------------------
GSWHTTPResponse* GSWAppRequest_HandleRequest(GSWHTTPRequest** p_ppHTTPRequest,
GSWURLComponents* p_pURLComponents,
CONST char* p_pszHTTPVersion,
CONST char* p_pszDocRoot,
CONST char* p_pszTestAppName,
void* p_pLogServerData)
GSWHTTPResponse *
GSWAppRequest_HandleRequest(GSWHTTPRequest **p_ppHTTPRequest,
GSWURLComponents *p_pURLComponents,
CONST char *p_pszHTTPVersion,
CONST char *p_pszDocRoot,
CONST char *p_pszTestAppName,
void *p_pLogServerData)
{
GSWHTTPResponse* pHTTPResponse=NULL;
GSWHTTPResponse *pHTTPResponse=NULL;
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWAppRequest_HandleRequest");
glbRequestsNb++;
if (!p_pURLComponents)
{
GSWLog(GSW_CRITICAL,p_pLogServerData,"p_pURLComponents is NULL in GSWAppRequest_HandleRequest");
}
{
GSWLog(GSW_CRITICAL,p_pLogServerData,
"p_pURLComponents is NULL in GSWAppRequest_HandleRequest");
}
else
{
if (p_pURLComponents->stAppName.iLength<=0
|| !p_pURLComponents->stAppName.pszStart)
{
if (p_pURLComponents->stAppName.iLength<=0
|| !p_pURLComponents->stAppName.pszStart)
{
pHTTPResponse=GSWHTTPResponse_BuildErrorResponse(NULL,"No Application Name",p_pLogServerData);
}
pHTTPResponse=GSWHTTPResponse_BuildErrorResponse(NULL,
"No Application Name",
p_pLogServerData);
}
else
{
char szAppName[MAXPATHLEN+1]="";
char szHost[MAXHOSTNAMELEN+1]="";
GSWAppRequest stAppRequest;
memset(&stAppRequest,0,sizeof(stAppRequest));
GSWLog(GSW_DEBUG,p_pLogServerData,"Copy AppName");
// Get App Name
strncpy(szAppName,
p_pURLComponents->stAppName.pszStart,
p_pURLComponents->stAppName.iLength);
szAppName[p_pURLComponents->stAppName.iLength]=0;
DeleteTrailingSlash(szAppName);
if (strcmp(szAppName,p_pszTestAppName)==0)
pHTTPResponse=GSWHTTPResponse_BuildStatusResponse(*p_ppHTTPRequest,
p_pLogServerData);
else
{
GSWLog(GSW_DEBUG,p_pLogServerData,"Get HostByName");
// Get Host Name
if (p_pURLComponents->stAppHost.iLength>0 &&
p_pURLComponents->stAppHost.pszStart)
{
char szAppName[MAXPATHLEN+1]="";
char szHost[MAXHOSTNAMELEN+1]="";
GSWAppRequest stAppRequest;
memset(&stAppRequest,0,sizeof(stAppRequest));
GSWLog(GSW_DEBUG,p_pLogServerData,"Copy AppName");
// Get App Name
strncpy(szAppName,
p_pURLComponents->stAppName.pszStart,
p_pURLComponents->stAppName.iLength);
szAppName[p_pURLComponents->stAppName.iLength]=0;
DeleteTrailingSlash(szAppName);
if (strcmp(szAppName,p_pszTestAppName)==0)
pHTTPResponse=GSWHTTPResponse_BuildStatusResponse(*p_ppHTTPRequest,p_pLogServerData);
else
{
GSWLog(GSW_DEBUG,p_pLogServerData,"Get HostByName");
// Get Host Name
if (p_pURLComponents->stAppHost.iLength>0 && p_pURLComponents->stAppHost.pszStart)
{
strncpy(szHost,
p_pURLComponents->stAppHost.pszStart,
p_pURLComponents->stAppHost.iLength);
szHost[p_pURLComponents->stAppHost.iLength] = '\0';
};
// Get Request Instance Number
GSWLog(GSW_DEBUG,p_pLogServerData,"Get Request Instance Number");
// in URL ?
if (p_pURLComponents->stAppNumber.iLength>0 && p_pURLComponents->stAppNumber.pszStart)
stAppRequest.iInstance = atoi(p_pURLComponents->stAppNumber.pszStart);
// In Cookie ?
else
{
CONST char* pszCookie=GSWHTTPRequest_HeaderForKey(*p_ppHTTPRequest,g_szHeader_Cookie);
if (pszCookie)
{
CONST char* pszInstanceCookie=strstr(pszCookie, g_szGSWeb_InstanceCookie[GSWNAMES_INDEX]);
if (pszInstanceCookie)
{
stAppRequest.iInstance = atoi(pszInstanceCookie + strlen(g_szGSWeb_InstanceCookie[GSWNAMES_INDEX]));
GSWLog(GSW_INFO,p_pLogServerData,"Cookie instance %d from %s",
stAppRequest.iInstance,
pszCookie);
}
else
{
pszInstanceCookie=strstr(pszCookie, g_szGSWeb_InstanceCookie[WONAMES_INDEX]);
if (pszInstanceCookie)
{
stAppRequest.iInstance = atoi(pszInstanceCookie + strlen(g_szGSWeb_InstanceCookie[WONAMES_INDEX]));
GSWLog(GSW_INFO,p_pLogServerData,"Cookie instance %d from %s",
stAppRequest.iInstance,
pszCookie);
};
};
};
};
stAppRequest.pszName = szAppName;
stAppRequest.pszHost = szHost;
stAppRequest.pszDocRoot = p_pszDocRoot;
stAppRequest.pRequest = *p_ppHTTPRequest;
stAppRequest.uURLVersion = (p_pURLComponents->stVersion.pszStart) ?
atoi(p_pURLComponents->stVersion.pszStart) : GSWEB_VERSION_MAJOR;
GSWLog(GSW_DEBUG,p_pLogServerData,"Add Header");
GSWHTTPRequest_AddHeader(*p_ppHTTPRequest,
g_szHeader_GSWeb_ServerAdaptor,
g_szGSWeb_ServerAndAdaptorVersion);
GSWLog(GSW_DEBUG,p_pLogServerData,"SendAppRequestToApp");
pHTTPResponse=GSWAppRequest_SendAppRequestToApp(p_ppHTTPRequest,
p_pURLComponents,
&stAppRequest,
p_pszHTTPVersion,
p_pLogServerData);
};
strncpy(szHost,
p_pURLComponents->stAppHost.pszStart,
p_pURLComponents->stAppHost.iLength);
szHost[p_pURLComponents->stAppHost.iLength] = '\0';
};
// Get Request Instance Number
GSWLog(GSW_DEBUG,p_pLogServerData,"Get Request Instance Number");
// in URL ?
if (p_pURLComponents->stAppNumber.iLength>0 &&
p_pURLComponents->stAppNumber.pszStart)
stAppRequest.iInstance =
atoi(p_pURLComponents->stAppNumber.pszStart);
// In Cookie ?
else
{
CONST char *pszCookie=
GSWHTTPRequest_HeaderForKey(*p_ppHTTPRequest,
g_szHeader_Cookie);
if (pszCookie)
{
CONST char *pszInstanceCookie =
strstr(pszCookie,
g_szGSWeb_InstanceCookie[GSWNAMES_INDEX]);
if (pszInstanceCookie)
{
stAppRequest.iInstance = atoi(pszInstanceCookie +
strlen(g_szGSWeb_InstanceCookie[GSWNAMES_INDEX]));
GSWLog(GSW_INFO,p_pLogServerData,
"Cookie instance %d from %s",
stAppRequest.iInstance,
pszCookie);
}
else
{
pszInstanceCookie=strstr(pszCookie,
g_szGSWeb_InstanceCookie[WONAMES_INDEX]);
if (pszInstanceCookie)
{
stAppRequest.iInstance = atoi(pszInstanceCookie +
strlen(g_szGSWeb_InstanceCookie[WONAMES_INDEX]));
GSWLog(GSW_INFO,p_pLogServerData,
"Cookie instance %d from %s",
stAppRequest.iInstance,
pszCookie);
};
};
};
};
stAppRequest.pszName = szAppName;
stAppRequest.pszHost = szHost;
stAppRequest.pszDocRoot = p_pszDocRoot;
stAppRequest.pRequest = *p_ppHTTPRequest;
stAppRequest.uURLVersion =
(p_pURLComponents->stVersion.pszStart) ?
atoi(p_pURLComponents->stVersion.pszStart) :
GSWEB_VERSION_MAJOR;
GSWLog(GSW_DEBUG,p_pLogServerData,"Add Header");
GSWHTTPRequest_AddHeader(*p_ppHTTPRequest,
g_szHeader_GSWeb_ServerAdaptor,
g_szGSWeb_ServerAndAdaptorVersion);
GSWLog(GSW_DEBUG,p_pLogServerData,"SendAppRequestToApp");
pHTTPResponse =
GSWAppRequest_SendAppRequestToApp(p_ppHTTPRequest,
p_pURLComponents,
&stAppRequest,
p_pszHTTPVersion,
p_pLogServerData);
};
};
};
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWAppRequest_HandleRequest");
return pHTTPResponse;
};

View file

@ -1,8 +1,8 @@
/* GSWAppRequest.h - GSWeb: GSWeb App Request
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -30,12 +30,12 @@ extern "C" {
#define GSWAppRequest_INITIALIZER {NULL,NULL,NULL,0,0,AT_NONE,3,NULL,NULL,NULL,NULL}
GSWHTTPResponse* GSWAppRequest_HandleRequest(GSWHTTPRequest** p_ppHTTPRequest,
GSWURLComponents* p_pURLComponents,
CONST char* p_pszHTTPVersion,
CONST char* p_pszDocRoot,
CONST char* p_pszTestAppName,
void* p_pLogServerData);
GSWHTTPResponse *GSWAppRequest_HandleRequest(GSWHTTPRequest **p_ppHTTPRequest,
GSWURLComponents *p_pURLComponents,
CONST char *p_pszHTTPVersion,
CONST char *p_pszDocRoot,
CONST char *p_pszTestAppName,
void *p_pLogServerData);
#endif //_GSWAppRequest_h__

View file

@ -1,8 +1,8 @@
/* GSWAppRequestStruct.h - GSWeb: GSWeb App Request Struct
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -32,26 +32,26 @@ extern "C" {
// Application Type
typedef enum {
EAppType_Unknown,
EAppType_Auto, // autolaunched/co-hosted
EAppType_LoadBalanced
EAppType_Unknown,
EAppType_Auto, // autolaunched/co-hosted
EAppType_LoadBalanced
} EAppType;
// AppRequest
typedef struct _GSWAppRequest
{
char* pszName; // App Name relative to Prefix
char* pszHost; // App Host
void* pHostent; // App Host hostent
int iPort; // AppPort
int iInstance; // App Instance
EAppType eType; // AppType
unsigned char uURLVersion; // URL Version
CONST char* pszDocRoot; // Doc Root
void* pRequest; // HTTPRequest
void* pResponse; // HTTPResponse
GSWAppInstance* pAppInstance;
char *pszName; // App Name relative to Prefix
char *pszHost; // App Host
void *pHostent; // App Host hostent
int iPort; // AppPort
int iInstance; // App Instance
EAppType eType; // AppType
unsigned char uURLVersion; // URL Version
CONST char *pszDocRoot; // Doc Root
void *pRequest; // HTTPRequest
void *pResponse; // HTTPResponse
GSWAppInstance *pAppInstance;
} GSWAppRequest;

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,8 @@
/* GSWConfig.h - GSWeb: GSWeb Configuration Management
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -38,46 +38,46 @@
#define WONAMES_INDEX 1
extern GSWLock g_lockAppList;
extern GSWDict* g_pAppDict;
extern time_t config_mtime;
extern GSWLock g_lockAppList;
extern GSWDict *g_pAppDict;
extern time_t config_mtime;
extern const char* g_szGSWeb_AdaptorVersion;
extern const char *g_szGSWeb_AdaptorVersion;
extern const char* g_szGSWeb_Prefix;
extern const char* g_szGSWeb_Handler;
extern const char* g_szGSWeb_StatusResponseAppName;
extern const char *g_szGSWeb_Prefix;
extern const char *g_szGSWeb_Handler;
extern const char *g_szGSWeb_StatusResponseAppName;
extern const char* g_szGSWeb_AppExtention[2];
extern const char *g_szGSWeb_AppExtention[2];
extern const char* g_szGSWeb_MimeType;
//extern const char* g_szGSWeb_Conf_DocRoot;
extern const char* g_szGSWeb_Conf_ConfigFilePath;
extern const char *g_szGSWeb_MimeType;
//extern const char *g_szGSWeb_Conf_DocRoot;
extern const char *g_szGSWeb_Conf_ConfigFilePath;
// Apache
#if defined(Apache)
extern const char* g_szGSWeb_Conf_Alias;
extern const char *g_szGSWeb_Conf_Alias;
#endif
// Netscape
#if defined(Netscape)
extern const char* g_szGSWeb_Conf_PathTrans;
extern const char* g_szGSWeb_Conf_AppRoot;
extern const char* g_szGSWeb_Conf_Name;
extern const char *g_szGSWeb_Conf_PathTrans;
extern const char *g_szGSWeb_Conf_AppRoot;
extern const char *g_szGSWeb_Conf_Name;
#endif
extern const char* g_szGSWeb_InstanceCookie[2];
extern const char *g_szGSWeb_InstanceCookie[2];
extern const char* g_szGSWeb_Server;
extern const char* g_szGSWeb_ServerAndAdaptorVersion;
extern const char *g_szGSWeb_Server;
extern const char *g_szGSWeb_ServerAndAdaptorVersion;
extern const char* const g_szGNUstep;
extern const char* const g_szOKGSWeb[2];
extern const char* const g_szOKStatus[2];
extern const char *const g_szGNUstep;
extern const char *const g_szOKGSWeb[2];
extern const char *const g_szOKStatus[2];
@ -96,45 +96,50 @@ typedef enum
typedef struct _GSWConfig
{
char* pszConfigFilePath;
char* pszGSWExtensionsFrameworkWebServerResources;
char *pszConfigFilePath;
char *pszGSWExtensionsFrameworkWebServerResources;
BOOL fCanDumpStatus;
char* pszAdaptorTemplatesPath;
char *pszAdaptorTemplatesPath;
} GSWConfig;
EGSWConfigResult GSWConfig_ReadIFND(CONST char* p_pszConfigPath,
time_t* p_pLastReadTime,
proplist_t* p_ppPropList,//Please, PLRelease it after used !
void* p_pLogServerData);
EGSWConfigResult GSWConfig_ReadIFND(CONST char *p_pszConfigPath,
time_t *p_pLastReadTime,
proplist_t *p_ppPropList,//Please, PLRelease it after used !
void *p_pLogServerData);
proplist_t GSWConfig_GetApplicationsFromConfig(proplist_t p_propListConfig,void* p_pLogServerData);
proplist_t GSWConfig_GetApplicationsFromConfig(proplist_t p_propListConfig,
void *p_pLogServerData);
proplist_t GSWConfig_ApplicationKeyFromApplicationsKey(proplist_t p_propListApplicationsKeys,
int p_iIndex,
void* p_pLogServerData);
proplist_t GSWConfig_InstancesFromApplication(proplist_t p_propListApplication,void* p_pLogServerData);
int p_iIndex,
void *p_pLogServerData);
proplist_t GSWConfig_InstancesFromApplication(proplist_t p_propListApplication,
void *p_pLogServerData);
proplist_t GSWConfig_ApplicationFromApplications(proplist_t p_propListApplications,
proplist_t p_propListApplicationKey,void* p_pLogServerData);
proplist_t GSWConfig_ApplicationsKeysFromApplications(proplist_t p_propListApplications,void* p_pLogServerData);
proplist_t GSWConfig_ApplicationsKeysFromConfig(proplist_t p_propListConfig,void* p_pLogServerData);
proplist_t p_propListApplicationKey,
void *p_pLogServerData);
proplist_t GSWConfig_ApplicationsKeysFromApplications(proplist_t p_propListApplications,
void *p_pLogServerData);
proplist_t GSWConfig_ApplicationsKeysFromConfig(proplist_t p_propListConfig,
void *p_pLogServerData);
GSWConfig* GSWConfig_GetConfig();
GSWConfig *GSWConfig_GetConfig();
BOOL GSWConfig_CanDumpStatus();
CONST char* GSWConfig_GetConfigFilePath();
void GSWConfig_SetConfigFilePath(CONST char* p_pszConfigFilePath);
GSWString* GSWConfig_DumpGSWApps(const char* p_pszReqApp,
const char* p_pszPrefix,
BOOL p_fForceDump,
BOOL p_fHTML,
void* p_pLogServerData);
void GSWConfig_Init(GSWDict* p_pDict,
void* p_pLogServerData);
GSWApp* GSWConfig_GetApp(CONST char* p_pszAppName);
CONST char* GSWConfig_AdaptorBuilt();
CONST char* GSWConfig_ServerStringInfo();
CONST char* g_szGSWeb_AdaptorStringInfo();
CONST char* GSWConfig_ServerURL();
CONST char* g_szGSWeb_AdaptorURL();
CONST char *GSWConfig_GetConfigFilePath();
void GSWConfig_SetConfigFilePath(CONST char *p_pszConfigFilePath);
GSWString *GSWConfig_DumpGSWApps(const char *p_pszReqApp,
const char *p_pszPrefix,
BOOL p_fForceDump,
BOOL p_fHTML,
void *p_pLogServerData);
void GSWConfig_Init(GSWDict *p_pDict,
void *p_pLogServerData);
GSWApp *GSWConfig_GetApp(CONST char *p_pszAppName);
CONST char *GSWConfig_AdaptorBuilt();
CONST char *GSWConfig_ServerStringInfo();
CONST char *g_szGSWeb_AdaptorStringInfo();
CONST char *GSWConfig_ServerURL();
CONST char *g_szGSWeb_AdaptorURL();
#endif // _GSWConfig_h__

View file

@ -1,8 +1,8 @@
/* GSWDict.c - GSWeb: Dictionary
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -29,215 +29,242 @@
#include "GSWUtil.h"
#include "GSWDict.h"
void GSWDict_SetCapacity(GSWDict* p_pDict,unsigned int p_uCapacity)
void
GSWDict_SetCapacity(GSWDict *p_pDict,unsigned int p_uCapacity)
{
if (!p_pDict)
{
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
}
{
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
}
else
{
p_uCapacity=max(16,p_uCapacity);
if (p_uCapacity>p_pDict->uCapacity)
{
p_uCapacity=max(16,p_uCapacity);
if (p_uCapacity>p_pDict->uCapacity)
{
if (p_pDict->pElems)
p_pDict->pElems = realloc(p_pDict->pElems,p_uCapacity*sizeof(GSWDictElem));
else
p_pDict->pElems = malloc(p_uCapacity*sizeof(GSWDictElem));
p_pDict->uCapacity = p_uCapacity;
};
if (p_pDict->pElems)
p_pDict->pElems = realloc(p_pDict->pElems,
p_uCapacity*sizeof(GSWDictElem));
else
p_pDict->pElems = malloc(p_uCapacity*sizeof(GSWDictElem));
p_pDict->uCapacity = p_uCapacity;
};
};
};
GSWDict *GSWDict_New(unsigned int p_uCapacity)
GSWDict *
GSWDict_New(unsigned int p_uCapacity)
{
GSWDict* pDict = malloc(sizeof(GSWDict));
GSWDict *pDict = malloc(sizeof(GSWDict));
memset(pDict,0,sizeof(GSWDict));
GSWDict_SetCapacity(pDict,max(16,p_uCapacity));
return pDict;
};
void GSWDict_FreeElem(GSWDictElem* p_pElem,void* p_pData)
void
GSWDict_FreeElem(GSWDictElem *p_pElem,void *p_pData)
{
if (!p_pElem)
{
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict pElem");
}
{
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict pElem");
}
else
{
if (p_pElem->pszKey)
{
if (p_pElem->pszKey)
{
free((char*)p_pElem->pszKey);
p_pElem->pszKey=NULL;
};
if (p_pElem->pValue && p_pElem->fValueOwner)
{
free((void*)p_pElem->pValue);
};
p_pElem->pValue=NULL;
free((char *)p_pElem->pszKey);
p_pElem->pszKey=NULL;
};
if (p_pElem->pValue && p_pElem->fValueOwner)
{
free((void *)p_pElem->pValue);
};
p_pElem->pValue=NULL;
};
};
void GSWDict_FreeElements(GSWDict* p_pDict)
void
GSWDict_FreeElements(GSWDict *p_pDict)
{
GSWDict_PerformForAllElem(p_pDict,GSWDict_FreeElem,NULL);
};
void GSWDict_Free(GSWDict* p_pDict)
void
GSWDict_Free(GSWDict *p_pDict)
{
if (!p_pDict)
{
GSWLog(GSW_ERROR,NULL,"NULL GSWDict");
}
{
GSWLog(GSW_ERROR,NULL,"NULL GSWDict");
}
else
{
GSWDict_FreeElements(p_pDict);
if (p_pDict->pElems)
free(p_pDict->pElems);
free(p_pDict);
};
{
GSWDict_FreeElements(p_pDict);
if (p_pDict->pElems)
free(p_pDict->pElems);
free(p_pDict);
};
};
static GSWDictElem* GSWDict_FindFirstNullKey(GSWDict* p_pDict)
static GSWDictElem *
GSWDict_FindFirstNullKey(GSWDict *p_pDict)
{
int i=0;
GSWDictElem* pElem=NULL;
int i=0;
GSWDictElem *pElem=NULL;
for (pElem=p_pDict->pElems;i<p_pDict->uCount;i++,pElem++)
if (!pElem->pszKey)
return pElem;
if (!pElem->pszKey)
return pElem;
return NULL;
};
unsigned int GSWDict_Count(GSWDict* p_pDict)
unsigned int
GSWDict_Count(GSWDict *p_pDict)
{
unsigned int uCount=0;
if (!p_pDict)
{
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
}
{
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
}
else
{
int i=0;
GSWDictElem* pElem=NULL;
for (pElem=p_pDict->pElems;i<p_pDict->uCount;i++,pElem++)
if (pElem->pszKey)
uCount++;
};
{
int i=0;
GSWDictElem *pElem=NULL;
for (pElem=p_pDict->pElems;i<p_pDict->uCount;i++,pElem++)
if (pElem->pszKey)
uCount++;
};
return uCount;
};
void GSWDict_Add(GSWDict* p_pDict,CONST char* p_pszKey,CONST void* p_pValue,BOOL p_fValueOwner)
void
GSWDict_Add(GSWDict *p_pDict,
CONST char *p_pszKey,
CONST void *p_pValue,
BOOL p_fValueOwner)
{
GSWDictElem* pElem=NULL;
GSWDictElem *pElem=NULL;
if (!p_pDict)
{
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
}
{
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
}
else
{
if (p_pDict->uCount>=p_pDict->uCapacity)
{
if (p_pDict->uCount>=p_pDict->uCapacity)
{
pElem=GSWDict_FindFirstNullKey(p_pDict);
if (!pElem)
{
GSWDict_SetCapacity(p_pDict,p_pDict->uCapacity*2);
pElem=p_pDict->pElems+p_pDict->uCount;
p_pDict->uCount++;
};
}
else
{
pElem=p_pDict->pElems+p_pDict->uCount;
p_pDict->uCount++;
};
pElem=GSWDict_FindFirstNullKey(p_pDict);
if (!pElem)
{
GSWLog(GSW_CRITICAL,NULL,"No pElem in GSWDict Add");
};
pElem->pszKey=strdup(p_pszKey);
pElem->pValue=p_pValue;
pElem->fValueOwner=p_fValueOwner;
{
GSWDict_SetCapacity(p_pDict,p_pDict->uCapacity*2);
pElem=p_pDict->pElems+p_pDict->uCount;
p_pDict->uCount++;
};
}
else
{
pElem=p_pDict->pElems+p_pDict->uCount;
p_pDict->uCount++;
};
if (!pElem)
{
GSWLog(GSW_CRITICAL,NULL,"No pElem in GSWDict Add");
};
pElem->pszKey=strdup(p_pszKey);
pElem->pValue=p_pValue;
pElem->fValueOwner=p_fValueOwner;
};
};
void GSWDict_AddString(GSWDict* p_pDict,CONST char* p_pszKey,CONST char* p_pszValue,BOOL p_fValueOwner)
void
GSWDict_AddString(GSWDict *p_pDict,
CONST char *p_pszKey,
CONST char *p_pszValue,
BOOL p_fValueOwner)
{
GSWDict_Add(p_pDict,p_pszKey,(void*)p_pszValue,p_fValueOwner);
GSWDict_Add(p_pDict,p_pszKey,(void *)p_pszValue,p_fValueOwner);
};
void GSWDict_AddStringDup(GSWDict* p_pDict,CONST char* p_pszKey,CONST char* p_pValue)
void
GSWDict_AddStringDup(GSWDict *p_pDict,
CONST char *p_pszKey,
CONST char *p_pValue)
{
GSWDict_Add(p_pDict,p_pszKey,strdup(p_pValue),TRUE);
};
static GSWDictElem* GSWDict_FindKey(GSWDict* p_pDict,CONST char* p_pszKey)
static GSWDictElem *
GSWDict_FindKey(GSWDict *p_pDict,
CONST char *p_pszKey)
{
int iIndex=0;
GSWDictElem* pElem=NULL;
GSWDictElem *pElem=NULL;
if (!p_pDict)
{
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
}
{
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
}
else
{
for (pElem=p_pDict->pElems;iIndex<p_pDict->uCount;iIndex++,pElem++)
if (pElem->pszKey && strcasecmp(pElem->pszKey,p_pszKey)==0)
return pElem;
};
{
for (pElem=p_pDict->pElems;iIndex<p_pDict->uCount;iIndex++,pElem++)
if (pElem->pszKey && strcasecmp(pElem->pszKey,p_pszKey)==0)
return pElem;
};
return NULL;
};
void GSWDict_RemoveKey(GSWDict* p_pDict,CONST char* p_pszKey)
void
GSWDict_RemoveKey(GSWDict *p_pDict,
CONST char *p_pszKey)
{
GSWDictElem* pElem=GSWDict_FindKey(p_pDict,p_pszKey);
GSWDictElem *pElem=GSWDict_FindKey(p_pDict,p_pszKey);
if (pElem)
GSWDict_FreeElem(pElem,NULL);
GSWDict_FreeElem(pElem,NULL);
}
CONST void* GSWDict_ValueForKey(GSWDict* p_pDict,CONST char* p_pszKey)
CONST void *
GSWDict_ValueForKey(GSWDict *p_pDict,
CONST char *p_pszKey)
{
GSWDictElem* pElem=GSWDict_FindKey(p_pDict,p_pszKey);
GSWDictElem *pElem=GSWDict_FindKey(p_pDict,p_pszKey);
return (pElem) ? pElem->pValue : NULL;
};
void GSWDict_PerformForAllElem(GSWDict* p_pDict,
void (*pFN)(GSWDictElem* p_pElem,void* p_pData),
void* p_pData)
void
GSWDict_PerformForAllElem(GSWDict *p_pDict,
void (*pFN)(GSWDictElem *p_pElem,void *p_pData),
void *p_pData)
{
if (!p_pDict)
{
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
}
{
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
}
else
{
int i=0;
GSWDictElem *pElem=NULL;
for (pElem=p_pDict->pElems;i<p_pDict->uCount;i++,pElem++)
{
int i=0;
GSWDictElem* pElem=NULL;
for (pElem=p_pDict->pElems;i<p_pDict->uCount;i++,pElem++)
{
if (pElem->pszKey)
pFN(pElem,p_pData);
};
if (pElem->pszKey)
pFN(pElem,p_pData);
};
};
};
GSWList* GSWDict_AllKeys(GSWDict* p_pDict)
GSWList *
GSWDict_AllKeys(GSWDict *p_pDict)
{
GSWList* pList=NULL;
GSWList *pList=NULL;
if (!p_pDict)
{
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
}
{
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
}
else
{
int i=0;
GSWDictElem *pElem=NULL;
pList=GSWList_New(p_pDict->uCount);
for (pElem=p_pDict->pElems;i<p_pDict->uCount;i++,pElem++)
{
int i=0;
GSWDictElem* pElem=NULL;
pList=GSWList_New(p_pDict->uCount);
for (pElem=p_pDict->pElems;i<p_pDict->uCount;i++,pElem++)
{
if (pElem->pszKey)
GSWList_Add(pList,pElem->pszKey);
};
if (pElem->pszKey)
GSWList_Add(pList,pElem->pszKey);
};
};
return pList;
};

View file

@ -1,8 +1,8 @@
/* GSWDict.h - GSWeb: Dictionary
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -33,36 +33,46 @@ extern "C" {
typedef struct _GSWDictElem
{
CONST char *pszKey;
CONST void* pValue;
BOOL fValueOwner;
CONST void *pValue;
BOOL fValueOwner;
} GSWDictElem;
typedef struct _GSWDict
{
unsigned int uCount;
unsigned int uCapacity;
GSWDictElem* pElems;
GSWDictElem *pElems;
} GSWDict;
#define GSWDict_Initialized() ((GSWDict){0,0,NULL})
GSWDict *GSWDict_New(unsigned int p_uCapacity);
void GSWDict_Free(GSWDict* p_pDict);
void GSWDict_FreeElements(GSWDict* p_pDict);
void GSWDict_Add(GSWDict* p_pDict,CONST char* p_pszKey,CONST void* p_pValue,BOOL p_fValueOwner);
void GSWDict_AddString(GSWDict* p_pDict,CONST char* p_pszKey,CONST char* p_pValue,BOOL p_fValueOwner);
void GSWDict_AddStringDup(GSWDict* p_pDict,CONST char* p_pszKey,CONST char* p_pValue);
void GSWDict_RemoveKey(GSWDict* p_pDict, CONST char* p_pszKey);
CONST void* GSWDict_ValueForKey(GSWDict* p_pDict, CONST char* p_pszKey);
unsigned int GSWDict_Count(GSWDict* p_pDict);
void GSWDict_Free(GSWDict *p_pDict);
void GSWDict_FreeElements(GSWDict *p_pDict);
void GSWDict_Add(GSWDict *p_pDict,
CONST char *p_pszKey,
CONST void *p_pValue,
BOOL p_fValueOwner);
void GSWDict_AddString(GSWDict *p_pDict,
CONST char *p_pszKey,
CONST char *p_pValue,
BOOL p_fValueOwner);
void GSWDict_AddStringDup(GSWDict *p_pDict,
CONST char *p_pszKey,
CONST char *p_pValue);
void GSWDict_RemoveKey(GSWDict *p_pDict,
CONST char *p_pszKey);
CONST void* GSWDict_ValueForKey(GSWDict *p_pDict,
CONST char *p_pszKey);
unsigned int GSWDict_Count(GSWDict *p_pDict);
void GSWDict_PerformForAllElem(GSWDict* p_pDict,
void (*pFN)(GSWDictElem* p_pElem,void* p_pData),
void* p_pData);
void GSWDict_PerformForAllElem(GSWDict *p_pDict,
void (*pFN)(GSWDictElem *p_pElem,void *p_pData),
void *p_pData);
//Free the list but Do Not Free Elements
GSWList* GSWDict_AllKeys(GSWDict* p_pDict);
GSWList* GSWDict_AllKeys(GSWDict *p_pDict);
#ifdef __cplusplus
} // end of C header

View file

@ -1,8 +1,8 @@
/* GSWHTTPHeaders.c - GSWeb: GSWeb HTTP Headers
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -41,111 +41,112 @@
#include "GSWConfig.h"
#include "GSWHTTPHeaders.h"
const char* g_szHeader_GSWeb_ServerAdaptor="x-gsweb-adaptor-version";
const char* g_szHeader_GSWeb_RequestMethod="x-gsweb-request-method";
const char* g_szHeader_GSWeb_Recording="x-gsweb-recording";
const char* g_szHeader_GSWeb_QueryString="x-gsweb-query-string";
const char* g_szHeader_GSWeb_RemoteAddress="x-gsweb-remote-addr";
const char* g_szHeader_GSWeb_RemoteHost="x-gsweb-remote-host";
const char* g_szHeader_GSWeb_RemoteIdent="x-gsweb-remote-ident";
const char* g_szHeader_GSWeb_RemoteUser="x-gsweb-remote-user";
const char* g_szHeader_GSWeb_ServerName="x-gsweb-server-name";
const char* g_szHeader_GSWeb_ServerPort="x-gsweb-server-port";
const char* g_szHeader_GSWeb_ServerSoftware="x-gsweb-server-software";
const char* g_szHeader_GSWeb_AnnotationServer="x-gsweb-annotation-server";
const char* g_szHeader_GSWeb_AuthPass="x-gsweb-auth-pass";
const char* g_szHeader_GSWeb_AuthType="x-gsweb-auth-type";
const char* g_szHeader_GSWeb_DocumentRoot="x-gsweb-documentroot";
const char* g_szHeader_GSWeb_GatewayInterface="x-gsweb-gateway-interface";
const char *g_szHeader_GSWeb_ServerAdaptor="x-gsweb-adaptor-version";
const char *g_szHeader_GSWeb_RequestMethod="x-gsweb-request-method";
const char *g_szHeader_GSWeb_Recording="x-gsweb-recording";
const char *g_szHeader_GSWeb_QueryString="x-gsweb-query-string";
const char *g_szHeader_GSWeb_RemoteAddress="x-gsweb-remote-addr";
const char *g_szHeader_GSWeb_RemoteHost="x-gsweb-remote-host";
const char *g_szHeader_GSWeb_RemoteIdent="x-gsweb-remote-ident";
const char *g_szHeader_GSWeb_RemoteUser="x-gsweb-remote-user";
const char *g_szHeader_GSWeb_ServerName="x-gsweb-server-name";
const char *g_szHeader_GSWeb_ServerPort="x-gsweb-server-port";
const char *g_szHeader_GSWeb_ServerSoftware="x-gsweb-server-software";
const char *g_szHeader_GSWeb_AnnotationServer="x-gsweb-annotation-server";
const char *g_szHeader_GSWeb_AuthPass="x-gsweb-auth-pass";
const char *g_szHeader_GSWeb_AuthType="x-gsweb-auth-type";
const char *g_szHeader_GSWeb_DocumentRoot="x-gsweb-documentroot";
const char *g_szHeader_GSWeb_GatewayInterface="x-gsweb-gateway-interface";
const char* g_szHeader_Accept="accept";
const char* g_szHeader_AcceptEncoding="accept-encoding";
const char* g_szHeader_AcceptLanguage="accept-language";
const char* g_szHeader_Allow="allow";
const char* g_szHeader_Authorization="authorization";
const char* g_szHeader_AuthUser="auth-user";
const char* g_szHeader_Cookie="cookie";
const char* g_szHeader_ContentLength="content-length";
const char* g_szHeader_ContentType="content-type";
const char* g_szHeader_IfModifiedSince="if-modified-since";
const char* g_szHeader_LastModified="last-modified";
const char* g_szHeader_Method="method";
const char* g_szHeader_PathInfo="path-info";
const char* g_szHeader_Pragma="pragma";
const char* g_szHeader_Protocol="protocol";
const char* g_szHeader_Referer="referer";
const char* g_szHeader_UserAgent="user-agent";
const char* g_szHeader_Date="date";
const char* g_szHeader_Expires="expires";
const char* g_szHeader_From="from";
const char* g_szHeader_MimeVersion="mime-version";
const char* g_szHeader_ContentEncoding="content-encoding";
const char *g_szHeader_Accept="accept";
const char *g_szHeader_AcceptEncoding="accept-encoding";
const char *g_szHeader_AcceptLanguage="accept-language";
const char *g_szHeader_Allow="allow";
const char *g_szHeader_Authorization="authorization";
const char *g_szHeader_AuthUser="auth-user";
const char *g_szHeader_Cookie="cookie";
const char *g_szHeader_ContentLength="content-length";
const char *g_szHeader_ContentType="content-type";
const char *g_szHeader_IfModifiedSince="if-modified-since";
const char *g_szHeader_LastModified="last-modified";
const char *g_szHeader_Method="method";
const char *g_szHeader_PathInfo="path-info";
const char *g_szHeader_Pragma="pragma";
const char *g_szHeader_Protocol="protocol";
const char *g_szHeader_Referer="referer";
const char *g_szHeader_UserAgent="user-agent";
const char *g_szHeader_Date="date";
const char *g_szHeader_Expires="expires";
const char *g_szHeader_From="from";
const char *g_szHeader_MimeVersion="mime-version";
const char *g_szHeader_ContentEncoding="content-encoding";
const char* g_szServerInfo_DocumentRoot="DOCUMENT_ROOT";
const char* g_szServerInfo_HTTPAccept="HTTP_ACCEPT";
const char* g_szServerInfo_HTTPAcceptEncoding="HTTP_ACCEPT_ENCODING";
const char* g_szServerInfo_HTTPAllow="HTTP_ALLOW";
const char* g_szServerInfo_HTTPDate="HTTP_DATE";
const char* g_szServerInfo_HTTPExpires="HTTP_EXPIRES";
const char* g_szServerInfo_HTTPFrom="HTTP_FROM";
const char* g_szServerInfo_HTTPIfModifiedSince="HTTP_IF_MODIFIED_SINCE";
const char* g_szServerInfo_HTTPLastModified="HTTP_LAST_MODIFIED";
const char* g_szServerInfo_HTTPMimeVersion="HTTP_MIME_VERSION";
const char* g_szServerInfo_HTTPPragma="HTTP_PRAGMA";
const char* g_szServerInfo_HTTPReferer="HTTP_REFERER";
const char* g_szServerInfo_RemoteIdent="REMOTE_IDENT";
const char* g_szServerInfo_RequestMethod="REQUEST_METHOD";
const char *g_szServerInfo_DocumentRoot="DOCUMENT_ROOT";
const char *g_szServerInfo_HTTPAccept="HTTP_ACCEPT";
const char *g_szServerInfo_HTTPAcceptEncoding="HTTP_ACCEPT_ENCODING";
const char *g_szServerInfo_HTTPAllow="HTTP_ALLOW";
const char *g_szServerInfo_HTTPDate="HTTP_DATE";
const char *g_szServerInfo_HTTPExpires="HTTP_EXPIRES";
const char *g_szServerInfo_HTTPFrom="HTTP_FROM";
const char *g_szServerInfo_HTTPIfModifiedSince="HTTP_IF_MODIFIED_SINCE";
const char *g_szServerInfo_HTTPLastModified="HTTP_LAST_MODIFIED";
const char *g_szServerInfo_HTTPMimeVersion="HTTP_MIME_VERSION";
const char *g_szServerInfo_HTTPPragma="HTTP_PRAGMA";
const char *g_szServerInfo_HTTPReferer="HTTP_REFERER";
const char *g_szServerInfo_RemoteIdent="REMOTE_IDENT";
const char *g_szServerInfo_RequestMethod="REQUEST_METHOD";
const char* g_szServerInfo_AnnotationServer="ANNOTATION_SERVER";
const char* g_szServerInfo_AuthPass="AUTH_PASS";
const char* g_szServerInfo_AuthType="AUTH_TYPE";
const char* g_szServerInfo_AuthUser="AUTH_USER";
const char* g_szServerInfo_ClientCert="CLIENT_CERT";
const char* g_szServerInfo_ContentEncoding="CONTENT_ENCODING";
const char* g_szServerInfo_ContentLength="CONTENT_LENGTH";
const char* g_szServerInfo_ContentType="CONTENT_TYPE";
const char* g_szServerInfo_GatewayInterface="GATEWAY_INTERFACE";
const char* g_szServerInfo_Host="HOST";
const char* g_szServerInfo_HTTPAcceptLanguage="HTTP_ACCEPT_LANGUAGE";
const char* g_szServerInfo_HTTPAuthorization="HTTP_AUTHORIZATION";
const char* g_szServerInfo_HTTPCookie="HTTP_COOKIE";
const char* g_szServerInfo_HTTPUserAgent="HTTP_USER_AGENT";
const char* g_szServerInfo_HTTPS="HTTPS";
const char* g_szServerInfo_HTTPSKeySize="HTTPS_KEYSIZE";
const char* g_szServerInfo_HTTPSSecretKeySize="HTTPS_SECRETKEYSIZE";
const char* g_szServerInfo_PathInfo="PATH_INFO";
const char* g_szServerInfo_PathTranslated="PATH_TRANSLATED";
const char* g_szServerInfo_Query="QUERY";
const char* g_szServerInfo_QueryString="QUERY_STRING";
const char* g_szServerInfo_RemoteAddress="REMOTE_ADDR";
const char* g_szServerInfo_RemoteHost="REMOTE_HOST";
const char* g_szServerInfo_RemoteUser="REMOTE_USER";
const char* g_szServerInfo_ScriptName="SCRIPT_NAME";
const char* g_szServerInfo_ServerID="SERVER_ID";
const char* g_szServerInfo_ServerName="SERVER_NAME";
const char* g_szServerInfo_ServerPort="SERVER_PORT";
const char* g_szServerInfo_ServerProtocol="SERVER_PROTOCOL";
const char* g_szServerInfo_ServerSoftware="SERVER_SOFTWARE";
const char* g_szServerInfo_HTTPGSWebRecording="HTTP_X_GSWEB_RECORDING";
const char* g_szServerInfo_ServerAdmin="SERVER_ADMIN";
const char* g_szServerInfo_ScriptFileName="SCRIPT_FILENAME";
const char* g_szServerInfo_RemotePort="REMOTE_PORT";
const char *g_szServerInfo_AnnotationServer="ANNOTATION_SERVER";
const char *g_szServerInfo_AuthPass="AUTH_PASS";
const char *g_szServerInfo_AuthType="AUTH_TYPE";
const char *g_szServerInfo_AuthUser="AUTH_USER";
const char *g_szServerInfo_ClientCert="CLIENT_CERT";
const char *g_szServerInfo_ContentEncoding="CONTENT_ENCODING";
const char *g_szServerInfo_ContentLength="CONTENT_LENGTH";
const char *g_szServerInfo_ContentType="CONTENT_TYPE";
const char *g_szServerInfo_GatewayInterface="GATEWAY_INTERFACE";
const char *g_szServerInfo_Host="HOST";
const char *g_szServerInfo_HTTPAcceptLanguage="HTTP_ACCEPT_LANGUAGE";
const char *g_szServerInfo_HTTPAuthorization="HTTP_AUTHORIZATION";
const char *g_szServerInfo_HTTPCookie="HTTP_COOKIE";
const char *g_szServerInfo_HTTPUserAgent="HTTP_USER_AGENT";
const char *g_szServerInfo_HTTPS="HTTPS";
const char *g_szServerInfo_HTTPSKeySize="HTTPS_KEYSIZE";
const char *g_szServerInfo_HTTPSSecretKeySize="HTTPS_SECRETKEYSIZE";
const char *g_szServerInfo_PathInfo="PATH_INFO";
const char *g_szServerInfo_PathTranslated="PATH_TRANSLATED";
const char *g_szServerInfo_Query="QUERY";
const char *g_szServerInfo_QueryString="QUERY_STRING";
const char *g_szServerInfo_RemoteAddress="REMOTE_ADDR";
const char *g_szServerInfo_RemoteHost="REMOTE_HOST";
const char *g_szServerInfo_RemoteUser="REMOTE_USER";
const char *g_szServerInfo_ScriptName="SCRIPT_NAME";
const char *g_szServerInfo_ServerID="SERVER_ID";
const char *g_szServerInfo_ServerName="SERVER_NAME";
const char *g_szServerInfo_ServerPort="SERVER_PORT";
const char *g_szServerInfo_ServerProtocol="SERVER_PROTOCOL";
const char *g_szServerInfo_ServerSoftware="SERVER_SOFTWARE";
const char *g_szServerInfo_HTTPGSWebRecording="HTTP_X_GSWEB_RECORDING";
const char *g_szServerInfo_ServerAdmin="SERVER_ADMIN";
const char *g_szServerInfo_ScriptFileName="SCRIPT_FILENAME";
const char *g_szServerInfo_RemotePort="REMOTE_PORT";
const char* g_szMethod_Get="GET";
const char* g_szMethod_Post="POST";
const char* g_szMethod_Head="HEAD";
const char* g_szMethod_Put="PUT";
const char *g_szMethod_Get="GET";
const char *g_szMethod_Post="POST";
const char *g_szMethod_Head="HEAD";
const char *g_szMethod_Put="PUT";
const char* g_szContentType_TextHtml="text/html";
const char *g_szContentType_TextHtml="text/html";
/*const*/ GSWHeaderTranslationItem GSWHeaderTranslationTable[50];
int GSWHeaderTranslationTableItemsNb=0;
//--------------------------------------------------------------------
void GSWHeaderTranslationTable_Init()
void
GSWHeaderTranslationTable_Init()
{
int i=0;
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_AnnotationServer;
@ -251,12 +252,17 @@ void GSWHeaderTranslationTable_Init()
GSWHeaderTranslationTable[i++].pszGSWeb=NULL;
GSWHeaderTranslationTableItemsNb=i;
/*GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTableItemsNb=%d",GSWHeaderTranslationTableItemsNb);
for(i=0;i<GSWHeaderTranslationTableItemsNb-1;i++)
{
GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTable[i].pszHTTP=%s",GSWHeaderTranslationTable[i].pszHTTP);
GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTable[i].pszGSWeb=%s",GSWHeaderTranslationTable[i].pszGSWeb);
};*/
/*
GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTableItemsNb=%d",
GSWHeaderTranslationTableItemsNb);
for(i=0;i<GSWHeaderTranslationTableItemsNb-1;i++)
{
GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTable[i].pszHTTP=%s",
GSWHeaderTranslationTable[i].pszHTTP);
GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTable[i].pszGSWeb=%s",
GSWHeaderTranslationTable[i].pszGSWeb);
};
*/
};

View file

@ -1,8 +1,8 @@
/* GSWHTTPHeaders.h - GSWeb: GSWeb HTTP Headers
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -24,107 +24,107 @@
#ifndef _GSWHTTPHeaders_h__
#define _GSWHTTPHeaders_h__
extern const char* g_szHeader_GSWeb_ServerAdaptor;
extern const char* g_szHeader_GSWeb_RequestMethod;
extern const char* g_szHeader_GSWeb_Recording;
extern const char* g_szHeader_GSWeb_QueryString;
extern const char* g_szHeader_GSWeb_RemoteAddress;
extern const char* g_szHeader_GSWeb_RemoteHost;
extern const char* g_szHeader_GSWeb_RemoteIdent;
extern const char* g_szHeader_GSWeb_RemoteUser;
extern const char* g_szHeader_GSWeb_ServerName;
extern const char* g_szHeader_GSWeb_ServerPort;
extern const char* g_szHeader_GSWeb_ServerSoftware;
extern const char* g_szHeader_GSWeb_AnnotationServer;
extern const char* g_szHeader_GSWeb_AuthPass;
extern const char* g_szHeader_GSWeb_AuthType;
extern const char* g_szHeader_GSWeb_DocumentRoot;
extern const char* g_szHeader_GSWeb_GatewayInterface;
extern const char *g_szHeader_GSWeb_ServerAdaptor;
extern const char *g_szHeader_GSWeb_RequestMethod;
extern const char *g_szHeader_GSWeb_Recording;
extern const char *g_szHeader_GSWeb_QueryString;
extern const char *g_szHeader_GSWeb_RemoteAddress;
extern const char *g_szHeader_GSWeb_RemoteHost;
extern const char *g_szHeader_GSWeb_RemoteIdent;
extern const char *g_szHeader_GSWeb_RemoteUser;
extern const char *g_szHeader_GSWeb_ServerName;
extern const char *g_szHeader_GSWeb_ServerPort;
extern const char *g_szHeader_GSWeb_ServerSoftware;
extern const char *g_szHeader_GSWeb_AnnotationServer;
extern const char *g_szHeader_GSWeb_AuthPass;
extern const char *g_szHeader_GSWeb_AuthType;
extern const char *g_szHeader_GSWeb_DocumentRoot;
extern const char *g_szHeader_GSWeb_GatewayInterface;
extern const char* g_szHeader_Accept;
extern const char* g_szHeader_AcceptEncoding;
extern const char* g_szHeader_AcceptLanguage;
extern const char* g_szHeader_Allow;
extern const char* g_szHeader_Authorization;
extern const char* g_szHeader_AuthUser;
extern const char* g_szHeader_Cookie;
extern const char* g_szHeader_ContentLength;
extern const char* g_szHeader_ContentType;
extern const char* g_szHeader_IfModifiedSince;
extern const char* g_szHeader_LastModified;
extern const char* g_szHeader_Method;
extern const char* g_szHeader_PathInfo;
extern const char* g_szHeader_Pragma;
extern const char* g_szHeader_Protocol;
extern const char* g_szHeader_Referer;
extern const char* g_szHeader_UserAgent;
extern const char* g_szHeader_Date;
extern const char* g_szHeader_Expires;
extern const char* g_szHeader_From;
extern const char* g_szHeader_MimeVersion;
extern const char* g_szHeader_ContentEncoding;
extern const char *g_szHeader_Accept;
extern const char *g_szHeader_AcceptEncoding;
extern const char *g_szHeader_AcceptLanguage;
extern const char *g_szHeader_Allow;
extern const char *g_szHeader_Authorization;
extern const char *g_szHeader_AuthUser;
extern const char *g_szHeader_Cookie;
extern const char *g_szHeader_ContentLength;
extern const char *g_szHeader_ContentType;
extern const char *g_szHeader_IfModifiedSince;
extern const char *g_szHeader_LastModified;
extern const char *g_szHeader_Method;
extern const char *g_szHeader_PathInfo;
extern const char *g_szHeader_Pragma;
extern const char *g_szHeader_Protocol;
extern const char *g_szHeader_Referer;
extern const char *g_szHeader_UserAgent;
extern const char *g_szHeader_Date;
extern const char *g_szHeader_Expires;
extern const char *g_szHeader_From;
extern const char *g_szHeader_MimeVersion;
extern const char *g_szHeader_ContentEncoding;
extern const char* g_szServerInfo_DocumentRoot;
extern const char* g_szServerInfo_HTTPAccept;
extern const char* g_szServerInfo_HTTPAcceptEncoding;
extern const char* g_szServerInfo_HTTPAllow;
extern const char* g_szServerInfo_HTTPDate;
extern const char* g_szServerInfo_HTTPExpires;
extern const char* g_szServerInfo_HTTPFrom;
extern const char* g_szServerInfo_HTTPIfModifiedSince;
extern const char* g_szServerInfo_HTTPLastModified;
extern const char* g_szServerInfo_HTTPMimeVersion;
extern const char* g_szServerInfo_HTTPPragma;
extern const char* g_szServerInfo_HTTPReferer;
extern const char* g_szServerInfo_RemoteIdent;
extern const char* g_szServerInfo_RequestMethod;
extern const char *g_szServerInfo_DocumentRoot;
extern const char *g_szServerInfo_HTTPAccept;
extern const char *g_szServerInfo_HTTPAcceptEncoding;
extern const char *g_szServerInfo_HTTPAllow;
extern const char *g_szServerInfo_HTTPDate;
extern const char *g_szServerInfo_HTTPExpires;
extern const char *g_szServerInfo_HTTPFrom;
extern const char *g_szServerInfo_HTTPIfModifiedSince;
extern const char *g_szServerInfo_HTTPLastModified;
extern const char *g_szServerInfo_HTTPMimeVersion;
extern const char *g_szServerInfo_HTTPPragma;
extern const char *g_szServerInfo_HTTPReferer;
extern const char *g_szServerInfo_RemoteIdent;
extern const char *g_szServerInfo_RequestMethod;
extern const char* g_szServerInfo_AnnotationServer;
extern const char* g_szServerInfo_AuthPass;
extern const char* g_szServerInfo_AuthType;
extern const char* g_szServerInfo_AuthUser;
extern const char* g_szServerInfo_ClientCert;
extern const char* g_szServerInfo_ContentEncoding;
extern const char* g_szServerInfo_ContentLength;
extern const char* g_szServerInfo_ContentType;
extern const char* g_szServerInfo_GatewayInterface;
extern const char* g_szServerInfo_Host;
extern const char* g_szServerInfo_HTTPAcceptLanguage;
extern const char* g_szServerInfo_HTTPAuthorization;
extern const char* g_szServerInfo_HTTPCookie;
extern const char* g_szServerInfo_HTTPUserAgent;
extern const char* g_szServerInfo_HTTPS;
extern const char* g_szServerInfo_HTTPSKeySize;
extern const char* g_szServerInfo_HTTPSSecretKeySize;
extern const char* g_szServerInfo_PathInfo;
extern const char* g_szServerInfo_PathTranslated;
extern const char* g_szServerInfo_Query;
extern const char* g_szServerInfo_QueryString;
extern const char* g_szServerInfo_RemoteAddress;
extern const char* g_szServerInfo_RemoteHost;
extern const char* g_szServerInfo_RemoteUser;
extern const char* g_szServerInfo_ScriptName;
extern const char* g_szServerInfo_ServerID;
extern const char* g_szServerInfo_ServerName;
extern const char* g_szServerInfo_ServerPort;
extern const char* g_szServerInfo_ServerProtocol;
extern const char* g_szServerInfo_ServerSoftware;
extern const char* g_szServerInfo_HTTPGSWebRecording;
extern const char* g_szServerInfo_ServerAdmin;
extern const char* g_szServerInfo_ScriptFileName;
extern const char* g_szServerInfo_RemotePort;
extern const char *g_szServerInfo_AnnotationServer;
extern const char *g_szServerInfo_AuthPass;
extern const char *g_szServerInfo_AuthType;
extern const char *g_szServerInfo_AuthUser;
extern const char *g_szServerInfo_ClientCert;
extern const char *g_szServerInfo_ContentEncoding;
extern const char *g_szServerInfo_ContentLength;
extern const char *g_szServerInfo_ContentType;
extern const char *g_szServerInfo_GatewayInterface;
extern const char *g_szServerInfo_Host;
extern const char *g_szServerInfo_HTTPAcceptLanguage;
extern const char *g_szServerInfo_HTTPAuthorization;
extern const char *g_szServerInfo_HTTPCookie;
extern const char *g_szServerInfo_HTTPUserAgent;
extern const char *g_szServerInfo_HTTPS;
extern const char *g_szServerInfo_HTTPSKeySize;
extern const char *g_szServerInfo_HTTPSSecretKeySize;
extern const char *g_szServerInfo_PathInfo;
extern const char *g_szServerInfo_PathTranslated;
extern const char *g_szServerInfo_Query;
extern const char *g_szServerInfo_QueryString;
extern const char *g_szServerInfo_RemoteAddress;
extern const char *g_szServerInfo_RemoteHost;
extern const char *g_szServerInfo_RemoteUser;
extern const char *g_szServerInfo_ScriptName;
extern const char *g_szServerInfo_ServerID;
extern const char *g_szServerInfo_ServerName;
extern const char *g_szServerInfo_ServerPort;
extern const char *g_szServerInfo_ServerProtocol;
extern const char *g_szServerInfo_ServerSoftware;
extern const char *g_szServerInfo_HTTPGSWebRecording;
extern const char *g_szServerInfo_ServerAdmin;
extern const char *g_szServerInfo_ScriptFileName;
extern const char *g_szServerInfo_RemotePort;
extern const char* g_szMethod_Get;
extern const char* g_szMethod_Post;
extern const char* g_szMethod_Head;
extern const char* g_szMethod_Put;
extern const char *g_szMethod_Get;
extern const char *g_szMethod_Post;
extern const char *g_szMethod_Head;
extern const char *g_szMethod_Put;
extern const char* g_szContentType_TextHtml;
extern const char *g_szContentType_TextHtml;
typedef struct _GSWHeaderTranslationItem {
const char* /*const*/ pszHTTP;
const char* /*const*/ pszGSWeb;
const char /*const*/ *pszHTTP;
const char /*const*/ *pszGSWeb;
} GSWHeaderTranslationItem;
extern /*const*/ GSWHeaderTranslationItem GSWHeaderTranslationTable[];
@ -132,40 +132,40 @@ extern int GSWHeaderTranslationTableItemsNb;
/*
static const GSWHeaderTranslationItem GSWHeaderTranslationTable[] =
{
{ g_szServerInfo_AnnotationServer, g_szHeader_GSWeb_AnnotationServer },
{ g_szServerInfo_AuthPass, g_szHeader_GSWeb_AuthPass },
{ g_szServerInfo_AuthType, g_szHeader_GSWeb_AuthType },
{ g_szServerInfo_ContentEncoding, g_szHeader_ContentEncoding },
{ g_szServerInfo_ContentLength, g_szHeader_ContentLength },
{ g_szServerInfo_ContentType, g_szHeader_ContentType },
{ g_szServerInfo_DocumentRoot, g_szHeader_GSWeb_DocumentRoot },
{ g_szServerInfo_GatewayInterface, g_szHeader_GSWeb_GatewayInterface },
{ g_szServerInfo_HTTPAccept, g_szHeader_Accept },
{ g_szServerInfo_HTTPAcceptEncoding, g_szHeader_AcceptEncoding },
{ g_szServerInfo_HTTPAcceptLanguage, g_szHeader_AcceptLanguage },
{ g_szServerInfo_HTTPAllow, g_szHeader_Allow },
{ g_szServerInfo_HTTPAuthorization, g_szHeader_Authorization },
{ g_szServerInfo_HTTPCookie, g_szHeader_Cookie },
{ g_szServerInfo_HTTPDate, g_szHeader_Date },
{ g_szServerInfo_HTTPExpires, g_szHeader_Expires },
{ g_szServerInfo_HTTPFrom, g_szHeader_From },
{ g_szServerInfo_HTTPIfModifiedSince, g_szHeader_IfModifiedSince },
{ g_szServerInfo_HTTPLastModified, g_szHeader_LastModified },
{ g_szServerInfo_HTTPMimeVersion, g_szHeader_MimeVersion },
{ g_szServerInfo_HTTPPragma, g_szHeader_Pragma },
{ g_szServerInfo_HTTPReferer, g_szHeader_Referer },
{ g_szServerInfo_HTTPUserAgent, g_szHeader_UserAgent },
{ g_szServerInfo_HTTPGSWebRecording, g_szHeader_GSWeb_Recording },
{ g_szServerInfo_QueryString, g_szHeader_GSWeb_QueryString },
{ g_szServerInfo_RemoteAddress, g_szHeader_GSWeb_RemoteAddress },
{ g_szServerInfo_RemoteHost, g_szHeader_GSWeb_RemoteHost },
{ g_szServerInfo_RemoteIdent, g_szHeader_GSWeb_RemoteIdent },
{ g_szServerInfo_RemoteUser, g_szHeader_GSWeb_RemoteUser },
{ g_szServerInfo_RequestMethod, g_szHeader_GSWebRequestMethod },
{ g_szServerInfo_ServerName, g_szHeader_GSWeb_ServerName },
{ g_szServerInfo_ServerPort, g_szHeader_GSWeb_ServerPort },
{ g_szServerInfo_ServerSoftware, g_szHeader_GSWeb_ServerSoftware },
{ NULL, NULL }
{ g_szServerInfo_AnnotationServer, g_szHeader_GSWeb_AnnotationServer},
{ g_szServerInfo_AuthPass, g_szHeader_GSWeb_AuthPass },
{ g_szServerInfo_AuthType, g_szHeader_GSWeb_AuthType },
{ g_szServerInfo_ContentEncoding, g_szHeader_ContentEncoding },
{ g_szServerInfo_ContentLength, g_szHeader_ContentLength },
{ g_szServerInfo_ContentType, g_szHeader_ContentType },
{ g_szServerInfo_DocumentRoot, g_szHeader_GSWeb_DocumentRoot },
{ g_szServerInfo_GatewayInterface, g_szHeader_GSWeb_GatewayInterface},
{ g_szServerInfo_HTTPAccept, g_szHeader_Accept },
{ g_szServerInfo_HTTPAcceptEncoding, g_szHeader_AcceptEncoding },
{ g_szServerInfo_HTTPAcceptLanguage, g_szHeader_AcceptLanguage },
{ g_szServerInfo_HTTPAllow, g_szHeader_Allow },
{ g_szServerInfo_HTTPAuthorization, g_szHeader_Authorization },
{ g_szServerInfo_HTTPCookie, g_szHeader_Cookie },
{ g_szServerInfo_HTTPDate, g_szHeader_Date },
{ g_szServerInfo_HTTPExpires, g_szHeader_Expires },
{ g_szServerInfo_HTTPFrom, g_szHeader_From },
{ g_szServerInfo_HTTPIfModifiedSince,g_szHeader_IfModifiedSince },
{ g_szServerInfo_HTTPLastModified, g_szHeader_LastModified },
{ g_szServerInfo_HTTPMimeVersion, g_szHeader_MimeVersion },
{ g_szServerInfo_HTTPPragma, g_szHeader_Pragma },
{ g_szServerInfo_HTTPReferer, g_szHeader_Referer },
{ g_szServerInfo_HTTPUserAgent, g_szHeader_UserAgent },
{ g_szServerInfo_HTTPGSWebRecording, g_szHeader_GSWeb_Recording },
{ g_szServerInfo_QueryString, g_szHeader_GSWeb_QueryString },
{ g_szServerInfo_RemoteAddress, g_szHeader_GSWeb_RemoteAddress },
{ g_szServerInfo_RemoteHost, g_szHeader_GSWeb_RemoteHost },
{ g_szServerInfo_RemoteIdent, g_szHeader_GSWeb_RemoteIdent },
{ g_szServerInfo_RemoteUser, g_szHeader_GSWeb_RemoteUser },
{ g_szServerInfo_RequestMethod, g_szHeader_GSWebRequestMethod },
{ g_szServerInfo_ServerName, g_szHeader_GSWeb_ServerName },
{ g_szServerInfo_ServerPort, g_szHeader_GSWeb_ServerPort },
{ g_szServerInfo_ServerSoftware, g_szHeader_GSWeb_ServerSoftware },
{ NULL, NULL }
};
#define GSWHeaderTranslationTable_HeaderNb (sizeof(GSWHeaderTranslationTable)/sizeof(GSWHeaderTranslationTable[0]))

View file

@ -1,8 +1,8 @@
/* GSWHTTPRequest.c - GSWeb: Adaptors: HTTP Request
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -38,16 +38,19 @@
#include "GSWHTTPHeaders.h"
static ERequestMethod GetHTTPRequestMethod();
static CONST char* GSWebHeaderForHTTPHeader(CONST char *header);
static char* GSWHTTPRequest_PackageHeaders(GSWHTTPRequest* p_pHTTPRequest,
char* pszBuffer,
int p_iBufferSize);
static CONST char *GSWebHeaderForHTTPHeader(CONST char *header);
static char *GSWHTTPRequest_PackageHeaders(GSWHTTPRequest *p_pHTTPRequest,
char *pszBuffer,
int p_iBufferSize);
//--------------------------------------------------------------------
GSWHTTPRequest* GSWHTTPRequest_New(CONST char* p_pszMethod,char* p_pszURI,void* p_pLogServerData)
GSWHTTPRequest *
GSWHTTPRequest_New(CONST char *p_pszMethod,
char *p_pszURI,
void *p_pLogServerData)
{
GSWHTTPRequest* pHTTPRequest=calloc(1,sizeof(GSWHTTPRequest));
GSWHTTPRequest *pHTTPRequest=calloc(1,sizeof(GSWHTTPRequest));
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPRequest_New");
pHTTPRequest->eMethod = GetHTTPRequestMethod(p_pszMethod);
pHTTPRequest->pszRequest = p_pszURI; // It will be freed
@ -56,77 +59,84 @@ GSWHTTPRequest* GSWHTTPRequest_New(CONST char* p_pszMethod,char* p_pszURI,void*
};
//--------------------------------------------------------------------
void GSWHTTPRequest_Free(GSWHTTPRequest* p_pHTTPRequest,void* p_pLogServerData)
void
GSWHTTPRequest_Free(GSWHTTPRequest *p_pHTTPRequest,
void *p_pLogServerData)
{
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPRequest_Free");
if (p_pHTTPRequest)
{
if (p_pHTTPRequest->pHeaders)
{
if (p_pHTTPRequest->pHeaders)
{
GSWDict_Free(p_pHTTPRequest->pHeaders);
p_pHTTPRequest->pHeaders=NULL;
};
if (p_pHTTPRequest->pszRequest)
{
free(p_pHTTPRequest->pszRequest);
p_pHTTPRequest->pszRequest=NULL;
};
if (p_pHTTPRequest->pContent)
{
free(p_pHTTPRequest->pContent);
p_pHTTPRequest->pContent=NULL;
};
free(p_pHTTPRequest);
p_pHTTPRequest=NULL;
GSWDict_Free(p_pHTTPRequest->pHeaders);
p_pHTTPRequest->pHeaders=NULL;
};
if (p_pHTTPRequest->pszRequest)
{
free(p_pHTTPRequest->pszRequest);
p_pHTTPRequest->pszRequest=NULL;
};
if (p_pHTTPRequest->pContent)
{
free(p_pHTTPRequest->pContent);
p_pHTTPRequest->pContent=NULL;
};
free(p_pHTTPRequest);
p_pHTTPRequest=NULL;
};
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPRequest_Free");
};
//--------------------------------------------------------------------
CONST char* GSWHTTPRequest_ValidateMethod(GSWHTTPRequest* p_pHTTPRequest,void* p_pLogServerData)
CONST char *
GSWHTTPRequest_ValidateMethod(GSWHTTPRequest *p_pHTTPRequest,
void *p_pLogServerData)
{
CONST char* pszMsg=NULL;
CONST char *pszMsg=NULL;
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPRequest_ValidateMethod");
if (!p_pHTTPRequest)
{
GSWLog(GSW_CRITICAL,p_pLogServerData,"No Request in GSWHTTPRequest_ValidateMethod");
pszMsg="No Request in GSWHTTPRequest_ValidateMethod";
}
{
GSWLog(GSW_CRITICAL,p_pLogServerData,
"No Request in GSWHTTPRequest_ValidateMethod");
pszMsg="No Request in GSWHTTPRequest_ValidateMethod";
}
else
{
switch(p_pHTTPRequest->eMethod)
{
switch(p_pHTTPRequest->eMethod)
{
case ERequestMethod_None:
pszMsg="GSWeb Application must be launched by HTTP Server";
break;
case ERequestMethod_Unknown:
case ERequestMethod_Head:
case ERequestMethod_Put:
pszMsg="Invalid Method";
break;
case ERequestMethod_Get:
case ERequestMethod_Post:
default:
pszMsg=NULL;
};
case ERequestMethod_None:
pszMsg="GSWeb Application must be launched by HTTP Server";
break;
case ERequestMethod_Unknown:
case ERequestMethod_Head:
case ERequestMethod_Put:
pszMsg="Invalid Method";
break;
case ERequestMethod_Get:
case ERequestMethod_Post:
default:
pszMsg=NULL;
};
};
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPRequest_ValidateMethod");
return pszMsg;
};
//--------------------------------------------------------------------
void GSWHTTPRequest_HTTPToAppRequest(GSWHTTPRequest* p_pHTTPRequest,
GSWAppRequest* p_pAppRequest,
GSWURLComponents* p_pURLComponents,
CONST char* p_pszHTTPVersion,
void* p_pLogServerData)
void
GSWHTTPRequest_HTTPToAppRequest(GSWHTTPRequest *p_pHTTPRequest,
GSWAppRequest *p_pAppRequest,
GSWURLComponents *p_pURLComponents,
CONST char *p_pszHTTPVersion,
void *p_pLogServerData)
{
char szInstanceBuffer[65]="";
char* pszDefaultHTTPVersion = "HTTP/1.0";
int iHTTPVersionLength = p_pszHTTPVersion ? strlen(p_pszHTTPVersion) : strlen(pszDefaultHTTPVersion);
char *pszDefaultHTTPVersion = "HTTP/1.0";
int iHTTPVersionLength = p_pszHTTPVersion ?
strlen(p_pszHTTPVersion) : strlen(pszDefaultHTTPVersion);
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPRequest_HTTPToAppRequest");
if (p_pAppRequest->iInstance > 0) /* should be -1 !!! */
sprintf(szInstanceBuffer,"%d",p_pAppRequest->iInstance);
sprintf(szInstanceBuffer,"%d",p_pAppRequest->iInstance);
p_pURLComponents->stAppName.pszStart = p_pAppRequest->pszName;
p_pURLComponents->stAppName.iLength = strlen(p_pAppRequest->pszName);
p_pURLComponents->stAppNumber.pszStart = szInstanceBuffer;
@ -135,85 +145,94 @@ void GSWHTTPRequest_HTTPToAppRequest(GSWHTTPRequest* p_pHTTPRequest,
p_pURLComponents->stAppHost.iLength = strlen(p_pAppRequest->pszHost);
if (p_pHTTPRequest->pszRequest)
{
free(p_pHTTPRequest->pszRequest);
p_pHTTPRequest->pszRequest=NULL;
};
{
free(p_pHTTPRequest->pszRequest);
p_pHTTPRequest->pszRequest=NULL;
};
p_pHTTPRequest->pszRequest=malloc(8
+(GSWComposeURLLen(p_pURLComponents,p_pLogServerData)+1)
+iHTTPVersionLength);
p_pHTTPRequest->pszRequest=malloc(8+
(GSWComposeURLLen(p_pURLComponents,
p_pLogServerData)+1)+
iHTTPVersionLength);
if (p_pHTTPRequest->uContentLength>0)
{
strcpy(p_pHTTPRequest->pszRequest,"POST ");
GSWHTTPRequest_AddHeader(p_pHTTPRequest,g_szHeader_GSWeb_RequestMethod,"POST");
}
{
strcpy(p_pHTTPRequest->pszRequest,"POST ");
GSWHTTPRequest_AddHeader(p_pHTTPRequest,g_szHeader_GSWeb_RequestMethod,
"POST");
}
else
{
strcpy(p_pHTTPRequest->pszRequest,"GET ");
GSWHTTPRequest_AddHeader(p_pHTTPRequest,g_szHeader_GSWeb_RequestMethod,"GET");
};
{
strcpy(p_pHTTPRequest->pszRequest,"GET ");
GSWHTTPRequest_AddHeader(p_pHTTPRequest,g_szHeader_GSWeb_RequestMethod,
"GET");
};
GSWComposeURL(p_pHTTPRequest->pszRequest+strlen(p_pHTTPRequest->pszRequest),
p_pURLComponents,
p_pLogServerData);
p_pURLComponents,
p_pLogServerData);
strcat(p_pHTTPRequest->pszRequest," ");
if (p_pszHTTPVersion)
strcat(p_pHTTPRequest->pszRequest,p_pszHTTPVersion);
strcat(p_pHTTPRequest->pszRequest,p_pszHTTPVersion);
else
strcat(p_pHTTPRequest->pszRequest,pszDefaultHTTPVersion);
strcat(p_pHTTPRequest->pszRequest,pszDefaultHTTPVersion);
strcat(p_pHTTPRequest->pszRequest,"\n");
GSWLog(GSW_INFO,p_pLogServerData,"App Request: %s",p_pHTTPRequest->pszRequest);
GSWLog(GSW_INFO,p_pLogServerData,"App Request: %s",
p_pHTTPRequest->pszRequest);
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPRequest_HTTPToAppRequest");
};
//--------------------------------------------------------------------
void GSWHTTPRequest_AddHeader(GSWHTTPRequest* p_pHTTPRequest,
CONST char* p_pszKey,
CONST char* p_pszValue)
void
GSWHTTPRequest_AddHeader(GSWHTTPRequest *p_pHTTPRequest,
CONST char *p_pszKey,
CONST char *p_pszValue)
{
CONST char* pszCustomKey=GSWebHeaderForHTTPHeader(p_pszKey);
CONST char* pszHeaderKey=(pszCustomKey) ? pszCustomKey : p_pszKey;
CONST char *pszCustomKey=GSWebHeaderForHTTPHeader(p_pszKey);
CONST char *pszHeaderKey=(pszCustomKey) ? pszCustomKey : p_pszKey;
if (!p_pHTTPRequest->pHeaders)
p_pHTTPRequest->pHeaders = GSWDict_New(64);
p_pHTTPRequest->pHeaders = GSWDict_New(64);
// Search Content Length
if (p_pHTTPRequest->eMethod==ERequestMethod_Post
&& p_pHTTPRequest->uContentLength==0
&& strcasecmp(pszHeaderKey,g_szHeader_ContentLength)==0)
p_pHTTPRequest->uContentLength = atoi(p_pszValue);
&& p_pHTTPRequest->uContentLength==0
&& strcasecmp(pszHeaderKey,g_szHeader_ContentLength)==0)
p_pHTTPRequest->uContentLength = atoi(p_pszValue);
GSWDict_AddString(p_pHTTPRequest->pHeaders,pszHeaderKey,p_pszValue,FALSE);
};
//--------------------------------------------------------------------
CONST char* GSWHTTPRequest_HeaderForKey(GSWHTTPRequest* p_pHTTPRequest,CONST char* p_pszKey)
CONST char *
GSWHTTPRequest_HeaderForKey(GSWHTTPRequest *p_pHTTPRequest,
CONST char *p_pszKey)
{
if (p_pHTTPRequest->pHeaders)
return GSWDict_ValueForKey(p_pHTTPRequest->pHeaders,p_pszKey);
return GSWDict_ValueForKey(p_pHTTPRequest->pHeaders,p_pszKey);
else
return NULL;
return NULL;
};
//--------------------------------------------------------------------
static void GetHeaderLength(GSWDictElem* p_pElem,
void* p_piAddTo)
static void
GetHeaderLength(GSWDictElem *p_pElem,
void *p_piAddTo)
{
int* piAddTo=(int*)p_piAddTo;
int *piAddTo=(int *)p_piAddTo;
// +2=": "
// +1="\n"
(*piAddTo)+=strlen(p_pElem->pszKey)+strlen((char*)(p_pElem->pValue))+2+1+1;
(*piAddTo)+=strlen(p_pElem->pszKey)+strlen((char *)(p_pElem->pValue))+2+1+1;
}
//--------------------------------------------------------------------
static void FormatHeader(GSWDictElem* p_pElem,
void* p_ppszBuffer)
static void
FormatHeader(GSWDictElem *p_pElem,
void *p_ppszBuffer)
{
char** ppszBuffer=(char**)p_ppszBuffer;
char **ppszBuffer=(char **)p_ppszBuffer;
strcpy(*ppszBuffer,p_pElem->pszKey);
strcat(*ppszBuffer, ": ");
strcat(*ppszBuffer,(char*)p_pElem->pValue);
strcat(*ppszBuffer,(char *)p_pElem->pValue);
(*ppszBuffer)+= strlen(*ppszBuffer);
**ppszBuffer = '\n';
(*ppszBuffer)++;
@ -221,11 +240,14 @@ static void FormatHeader(GSWDictElem* p_pElem,
//--------------------------------------------------------------------
// Handle Request (send it to Application)
BOOL GSWHTTPRequest_SendRequest(GSWHTTPRequest* p_pHTTPRequest,AppConnectHandle p_socket,void* p_pLogServerData)
BOOL
GSWHTTPRequest_SendRequest(GSWHTTPRequest *p_pHTTPRequest,
AppConnectHandle p_socket,
void *p_pLogServerData)
{
BOOL fOk = TRUE;
char* pszBuffer=NULL;
char* pszTmp=NULL;
char *pszBuffer=NULL;
char *pszTmp=NULL;
int iLength = 0;
int iHeaderLength = 0;
int iRequestLength = 0;
@ -239,8 +261,8 @@ BOOL GSWHTTPRequest_SendRequest(GSWHTTPRequest* p_pHTTPRequest,AppConnectHandle
#endif
GSWDict_PerformForAllElem(p_pHTTPRequest->pHeaders,
GetHeaderLength,
&iHeaderLength);
GetHeaderLength,
&iHeaderLength);
iHeaderLength++; // Last /n
iLength=iRequestLength+iHeaderLength+iContentLength;
#ifdef DEBUG
@ -251,28 +273,28 @@ BOOL GSWHTTPRequest_SendRequest(GSWHTTPRequest* p_pHTTPRequest,AppConnectHandle
pszBuffer = malloc(iLength+1);
strncpy(pszBuffer,
p_pHTTPRequest->pszRequest,
iRequestLength);
p_pHTTPRequest->pszRequest,
iRequestLength);
pszTmp = pszBuffer+iRequestLength;
GSWDict_PerformForAllElem(p_pHTTPRequest->pHeaders,
FormatHeader,
(void*)&pszTmp);
FormatHeader,
(void *)&pszTmp);
*pszTmp++ = '\n';
if (iContentLength>0)
{
memcpy(pszTmp,p_pHTTPRequest->pContent,iContentLength);
pszTmp+=iContentLength;
};
{
memcpy(pszTmp,p_pHTTPRequest->pContent,iContentLength);
pszTmp+=iContentLength;
};
*pszTmp = '\0';
GSWLog(GSW_INFO,p_pLogServerData,
"Sending AppRequest Content: %s\n(%d Bytes)",
p_pHTTPRequest->pszRequest,
iContentLength);
"Sending AppRequest Content: %s\n(%d Bytes)",
p_pHTTPRequest->pszRequest,
iContentLength);
// Just To be sure of the length
iLength = pszTmp - pszBuffer;
#ifdef DEBUG
@ -287,18 +309,20 @@ BOOL GSWHTTPRequest_SendRequest(GSWHTTPRequest* p_pHTTPRequest,AppConnectHandle
}
//--------------------------------------------------------------------
static char* GSWHTTPRequest_PackageHeaders(GSWHTTPRequest* p_pHTTPRequest,
char* p_pszBuffer,
int p_iBufferSize)
static char *
GSWHTTPRequest_PackageHeaders(GSWHTTPRequest *p_pHTTPRequest,
char *p_pszBuffer,
int p_iBufferSize)
{
int iHeaderLength=0;
char* pszBuffer=NULL;
char* pszTmp=NULL;
char *pszBuffer=NULL;
char *pszTmp=NULL;
GSWDict_PerformForAllElem(p_pHTTPRequest->pHeaders,
GetHeaderLength,
(void*)&iHeaderLength);
pszBuffer = ((p_iBufferSize > (iHeaderLength+1)) ? p_pszBuffer : malloc(p_iBufferSize+2));
GetHeaderLength,
(void *)&iHeaderLength);
pszBuffer = ((p_iBufferSize > (iHeaderLength+1)) ?
p_pszBuffer : malloc(p_iBufferSize+2));
pszTmp = pszBuffer;
GSWDict_PerformForAllElem(p_pHTTPRequest->pHeaders,FormatHeader,&pszTmp);
@ -308,57 +332,64 @@ static char* GSWHTTPRequest_PackageHeaders(GSWHTTPRequest* p_pHTTPRequest,
};
//--------------------------------------------------------------------
static ERequestMethod GetHTTPRequestMethod(CONST char* pszMethod)
static ERequestMethod
GetHTTPRequestMethod(CONST char *pszMethod)
{
if (pszMethod)
{
if (strcmp(pszMethod,g_szMethod_Get)==0)
return ERequestMethod_Get;
else if (strcmp(pszMethod, g_szMethod_Post)==0)
return ERequestMethod_Post;
else if (!strcmp(pszMethod, g_szMethod_Head)==0)
return ERequestMethod_Head;
else if (!strcmp(pszMethod,g_szMethod_Put)==0)
return ERequestMethod_Put;
else
return ERequestMethod_Unknown;
{
if (strcmp(pszMethod,g_szMethod_Get)==0)
return ERequestMethod_Get;
else if (strcmp(pszMethod, g_szMethod_Post)==0)
return ERequestMethod_Post;
else if (!strcmp(pszMethod, g_szMethod_Head)==0)
return ERequestMethod_Head;
else if (!strcmp(pszMethod,g_szMethod_Put)==0)
return ERequestMethod_Put;
else
return ERequestMethod_Unknown;
}
else
return ERequestMethod_None;
return ERequestMethod_None;
};
//--------------------------------------------------------------------
static int compareHeader(CONST void* p_pKey0,CONST void* p_pKey1)
static int
compareHeader(CONST void *p_pKey0,
CONST void *p_pKey1)
{
CONST char* pKey1=((GSWHeaderTranslationItem*)p_pKey1)->pszHTTP;
CONST char *pKey1=((GSWHeaderTranslationItem *)p_pKey1)->pszHTTP;
/*
if (p_pKey0)
GSWLog(GSW_ERROR,NULL,"p_pKey0=%p (CONST char*)p_pKey0=%s",p_pKey0,(CONST char*)p_pKey0);
GSWLog(GSW_ERROR,NULL,"p_pKey0=%p (CONST char *)p_pKey0=%s",
p_pKey0,(CONST char *)p_pKey0);
if (p_pKey1)
{
if (((GSWHeaderTranslationItem*)p_pKey1)->pszHTTP)
GSWLog(GSW_ERROR,NULL,"p_pKey1=%p (CONST char*)p_pKey1=%s",p_pKey1,((GSWHeaderTranslationItem*)p_pKey1)->pszHTTP);
};
{
if (((GSWHeaderTranslationItem *)p_pKey1)->pszHTTP)
GSWLog(GSW_ERROR,NULL,"p_pKey1=%p (CONST char *)p_pKey1=%s",
p_pKey1,((GSWHeaderTranslationItem *)p_pKey1)->pszHTTP);
};
*/
if (pKey1)
return strcmp((CONST char*)p_pKey0,pKey1);
return strcmp((CONST char *)p_pKey0,pKey1);
else if (!p_pKey0)
return 0;
return 0;
else
return 1;
return 1;
};
//--------------------------------------------------------------------
static CONST char* GSWebHeaderForHTTPHeader(CONST char* p_pszHTTPHeader)
static CONST char *
GSWebHeaderForHTTPHeader(CONST char *p_pszHTTPHeader)
{
GSWHeaderTranslationItem* pItem=NULL;
GSWHeaderTranslationItem *pItem=NULL;
if (GSWHeaderTranslationTableItemsNb==0)
GSWHeaderTranslationTable_Init();
GSWHeaderTranslationTable_Init();
pItem=bsearch(p_pszHTTPHeader,
GSWHeaderTranslationTable,
GSWHeaderTranslationTableItemsNb,
sizeof(GSWHeaderTranslationItem),
compareHeader);
GSWHeaderTranslationTable,
GSWHeaderTranslationTableItemsNb,
sizeof(GSWHeaderTranslationItem),
compareHeader);
return (pItem ? pItem->pszGSWeb : NULL);
};

View file

@ -1,8 +1,8 @@
/* GSWHTTPRequest.h - GSWeb: GSWeb Request
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -43,45 +43,45 @@ typedef enum
typedef struct _GSWHTTPRequest
{
ERequestMethod eMethod; // Method
char* pszRequest; // Request String
GSWDict* pHeaders; // Headers
void* pServerHandle; // Server Handle
unsigned uContentLength; // Content Length
void* pContent; // Content
ERequestMethod eMethod; // Method
char *pszRequest; // Request String
GSWDict *pHeaders; // Headers
void *pServerHandle; // Server Handle
unsigned uContentLength; // Content Length
void *pContent; // Content
} GSWHTTPRequest;
GSWHTTPRequest* GSWHTTPRequest_New(CONST char* pszMethod,
char* p_pszURI,
void* p_pLogServerData);
void GSWHTTPRequest_Free(GSWHTTPRequest* p_pHTTPRequest,
void* p_pLogServerData);
GSWHTTPRequest *GSWHTTPRequest_New(CONST char *pszMethod,
char *p_pszURI,
void *p_pLogServerData);
void GSWHTTPRequest_Free(GSWHTTPRequest *p_pHTTPRequest,
void *p_pLogServerData);
// Return error message (NULL if ok)
CONST char*GSWHTTPRequest_ValidateMethod(GSWHTTPRequest* p_pHTTPRequest,
void* p_pLogServerData);
CONST char *GSWHTTPRequest_ValidateMethod(GSWHTTPRequest *p_pHTTPRequest,
void *p_pLogServerData);
// HTTP Request -> GSWeb App Request
void GSWHTTPRequest_HTTPToAppRequest(GSWHTTPRequest* p_pHTTPRequest,
GSWAppRequest* p_pAppRequest,
GSWURLComponents* p_pURLComponents,
CONST char* p_pszHTTPVersion,
void* p_pLogServerData);
void GSWHTTPRequest_HTTPToAppRequest(GSWHTTPRequest *p_pHTTPRequest,
GSWAppRequest *p_pAppRequest,
GSWURLComponents *p_pURLComponents,
CONST char *p_pszHTTPVersion,
void *p_pLogServerData);
// Add Header
void GSWHTTPRequest_AddHeader(GSWHTTPRequest* p_pHTTPRequest,
CONST char* p_pszKey,
CONST char* p_pszValue);
void GSWHTTPRequest_AddHeader(GSWHTTPRequest *p_pHTTPRequest,
CONST char *p_pszKey,
CONST char *p_pszValue);
// Get Header (case insensitive)
CONST char* GSWHTTPRequest_HeaderForKey(GSWHTTPRequest* p_pHTTPRequest,
CONST char* p_pszKey);
CONST char *GSWHTTPRequest_HeaderForKey(GSWHTTPRequest *p_pHTTPRequest,
CONST char *p_pszKey);
// Handle Request (send it to Application)
BOOL GSWHTTPRequest_SendRequest(GSWHTTPRequest* p_pHTTPRequest,
AppConnectHandle p_socket,
void* p_pLogServerData);
BOOL GSWHTTPRequest_SendRequest(GSWHTTPRequest *p_pHTTPRequest,
AppConnectHandle p_socket,
void *p_pLogServerData);
#ifdef __cplusplus
}

View file

@ -1,8 +1,8 @@
/* GSWHTTPResponse.c - GSWeb: Adaptors: HTTP Response
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -42,92 +42,100 @@
#include "GSWTemplates.h"
static char* g_pszLocalHostName = NULL;
static char *g_pszLocalHostName = NULL;
#define STATUS "Status"
#define HTTP_SLASH "HTTP/"
//--------------------------------------------------------------------
GSWHTTPResponse* GSWHTTPResponse_New(CONST char* p_pszStatus,void* p_pLogServerData)
GSWHTTPResponse *
GSWHTTPResponse_New(CONST char *p_pszStatus,
void *p_pLogServerData)
{
GSWHTTPResponse* pHTTPResponse=NULL;
GSWHTTPResponse *pHTTPResponse=NULL;
BOOL fOk=FALSE;
// Accept "HTTP/1.0 200 OK GSWeb..." and "HTTP/1.0 200 OK GNUstep GSWeb..."
#ifdef DEBUG
GSWLog(GSW_INFO,p_pLogServerData,"p_pszStatus=%s",p_pszStatus);
#endif
if (strncmp(p_pszStatus,HTTP_SLASH,strlen(HTTP_SLASH))==0)
{
// Status Code
CONST char *pszSpace=strchr(p_pszStatus,' ');
if (pszSpace)
{
// Status Code
CONST char* pszSpace=strchr(p_pszStatus,' ');
if (pszSpace)
unsigned int uStatus=0;
fOk=TRUE;
pszSpace++;
uStatus=atoi(pszSpace);
#ifdef DEBUG
GSWLog(GSW_INFO,p_pLogServerData,"uStatus=%u",uStatus);
#endif
for(;fOk && *pszSpace && !isspace(*pszSpace);pszSpace++)
fOk=isdigit(*pszSpace);
#ifdef DEBUG
GSWLog(GSW_INFO,p_pLogServerData,"fOk=%d",(int)fOk);
#endif
if (fOk)
{
pHTTPResponse = calloc(1,sizeof(GSWHTTPResponse));
memset(pHTTPResponse,0,sizeof(GSWHTTPResponse));
pHTTPResponse->uStatus=uStatus;
pHTTPResponse->pHeaders = GSWDict_New(16);
if (*pszSpace)
{
unsigned int uStatus=0;
fOk=TRUE;
pszSpace++;
uStatus=atoi(pszSpace);
#ifdef DEBUG
GSWLog(GSW_INFO,p_pLogServerData,"uStatus=%u",uStatus);
#endif
for(;fOk && *pszSpace && !isspace(*pszSpace);pszSpace++)
fOk=isdigit(*pszSpace);
#ifdef DEBUG
GSWLog(GSW_INFO,p_pLogServerData,"fOk=%d",(int)fOk);
#endif
if (fOk)
{
pHTTPResponse = calloc(1,sizeof(GSWHTTPResponse));
memset(pHTTPResponse,0,sizeof(GSWHTTPResponse));
pHTTPResponse->uStatus=uStatus;
pHTTPResponse->pHeaders = GSWDict_New(16);
if (*pszSpace)
{
pszSpace=strchr(pszSpace,' ');
if (pszSpace)
pHTTPResponse->pszStatusMessage=strdup(pszSpace);
};
};
pszSpace=strchr(pszSpace,' ');
if (pszSpace)
pHTTPResponse->pszStatusMessage=strdup(pszSpace);
};
};
};
};
if (!fOk)
GSWLog(GSW_ERROR,p_pLogServerData,"Invalid response");
GSWLog(GSW_ERROR,p_pLogServerData,"Invalid response");
return pHTTPResponse;
};
//--------------------------------------------------------------------
GSWHTTPResponse* GSWHTTPResponse_BuildErrorResponse(GSWAppRequest* p_pAppRequest,
CONST char* p_pszMessage,
void* p_pLogServerData)
GSWHTTPResponse *
GSWHTTPResponse_BuildErrorResponse(GSWAppRequest *p_pAppRequest,
CONST char *p_pszMessage,
void *p_pLogServerData)
{
char szBuffer[128]="";
GSWApp* pApp=NULL;
GSWString* pBuffer=GSWString_New();
GSWString* pBufferMessage=GSWString_New();
GSWHTTPResponse* pHTTPResponse=calloc(1,sizeof(GSWHTTPResponse));
char* pszString=NULL;
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPResponse_BuildErrorResponse");
char szBuffer[128]="";
GSWApp *pApp=NULL;
GSWString *pBuffer=GSWString_New();
GSWString *pBufferMessage=GSWString_New();
GSWHTTPResponse *pHTTPResponse=calloc(1,sizeof(GSWHTTPResponse));
char *pszString=NULL;
GSWLog(GSW_DEBUG,p_pLogServerData,
"Start GSWHTTPResponse_BuildErrorResponse");
if (p_pAppRequest && p_pAppRequest->pAppInstance)
pApp=p_pAppRequest->pAppInstance->pApp;
pApp=p_pAppRequest->pAppInstance->pApp;
#ifdef DEBUG
GSWLog(GSW_INFO,p_pLogServerData,"Build Error Response [%s] pApp=%p",p_pszMessage,pApp);
GSWLog(GSW_INFO,p_pLogServerData,
"Build Error Response [%s] pApp=%p",p_pszMessage,pApp);
#endif
pHTTPResponse->uStatus = 200;
pHTTPResponse->pszStatusMessage = strdup(g_szOKGSWeb[GSWNAMES_INDEX]);
pHTTPResponse->pHeaders = GSWDict_New(2);
GSWDict_Add(pHTTPResponse->pHeaders,
g_szHeader_ContentType,
g_szContentType_TextHtml,
FALSE);
g_szHeader_ContentType,
g_szContentType_TextHtml,
FALSE);
GSWString_Append(pBufferMessage,p_pszMessage);
if (p_pAppRequest)
{
GSWString_SearchReplace(pBufferMessage,"##APP_NAME##",p_pAppRequest->pszName);
sprintf(szBuffer,"%d",p_pAppRequest->iInstance);
GSWString_SearchReplace(pBufferMessage,"##APP_INSTANCE##",szBuffer);
GSWString_SearchReplace(pBufferMessage,"##APP_HOST##",p_pAppRequest->pszHost);
sprintf(szBuffer,"%d",p_pAppRequest->iPort);
GSWString_SearchReplace(pBufferMessage,"##APP_PORT##",szBuffer);
};
{
GSWString_SearchReplace(pBufferMessage,"##APP_NAME##",
p_pAppRequest->pszName);
sprintf(szBuffer,"%d",p_pAppRequest->iInstance);
GSWString_SearchReplace(pBufferMessage,"##APP_INSTANCE##",szBuffer);
GSWString_SearchReplace(pBufferMessage,"##APP_HOST##",
p_pAppRequest->pszHost);
sprintf(szBuffer,"%d",p_pAppRequest->iPort);
GSWString_SearchReplace(pBufferMessage,"##APP_PORT##",szBuffer);
};
GSWTemplate_ReplaceStd(pBufferMessage,pApp);
pszString=GSWTemplate_ErrorResponseText(TRUE,pApp);
@ -142,179 +150,203 @@ GSWHTTPResponse* GSWHTTPResponse_BuildErrorResponse(GSWAppRequest* p_pAppRequest
GSWString_Free(pBuffer);
pBuffer=NULL;
GSWString_Free(pBufferMessage);
pBufferMessage=NULL;
sprintf(szBuffer,"%d",pHTTPResponse->uContentLength);
GSWDict_AddStringDup(pHTTPResponse->pHeaders,g_szHeader_ContentLength,szBuffer);
GSWDict_AddStringDup(pHTTPResponse->pHeaders,
g_szHeader_ContentLength,szBuffer);
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPResponse_BuildErrorResponse");
return pHTTPResponse;
};
//--------------------------------------------------------------------
GSWHTTPResponse* GSWHTTPResponse_BuildRedirectedResponse(CONST char* p_pszRedirectPath,void* p_pLogServerData)
GSWHTTPResponse *
GSWHTTPResponse_BuildRedirectedResponse(CONST char *p_pszRedirectPath,
void *p_pLogServerData)
{
GSWHTTPResponse* pHTTPResponse=calloc(1,sizeof(GSWHTTPResponse));
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPResponse_BuildRedirectedResponse");
GSWHTTPResponse *pHTTPResponse=calloc(1,sizeof(GSWHTTPResponse));
GSWLog(GSW_DEBUG,p_pLogServerData,
"Start GSWHTTPResponse_BuildRedirectedResponse");
pHTTPResponse->uStatus = 302;
pHTTPResponse->pszStatusMessage = strdup(g_szOKGSWeb[GSWNAMES_INDEX]);
pHTTPResponse->pHeaders=GSWDict_New(2);
GSWDict_Add(pHTTPResponse->pHeaders, g_szHeader_ContentType, g_szContentType_TextHtml,FALSE);
GSWDict_Add(pHTTPResponse->pHeaders, g_szHeader_ContentType,
g_szContentType_TextHtml,FALSE);
GSWDict_AddStringDup(pHTTPResponse->pHeaders,"location",p_pszRedirectPath);
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPResponse_BuildRedirectedResponse");
GSWLog(GSW_DEBUG,p_pLogServerData,
"Stop GSWHTTPResponse_BuildRedirectedResponse");
return pHTTPResponse;
};
//--------------------------------------------------------------------
void GSWHTTPResponse_Free(GSWHTTPResponse* p_pHTTPResponse,void* p_pLogServerData)
void
GSWHTTPResponse_Free(GSWHTTPResponse *p_pHTTPResponse,
void *p_pLogServerData)
{
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPResponse_Free");
if (p_pHTTPResponse)
{
if (p_pHTTPResponse->pHeaders)
{
if (p_pHTTPResponse->pHeaders)
{
GSWDict_Free(p_pHTTPResponse->pHeaders);
p_pHTTPResponse->pHeaders=NULL;
};
if (p_pHTTPResponse->pszStatusMessage)
{
free(p_pHTTPResponse->pszStatusMessage);
p_pHTTPResponse->pszStatusMessage=NULL;
};
if (p_pHTTPResponse->pContent)
{
free(p_pHTTPResponse->pContent);
p_pHTTPResponse->pContent=NULL;
};
free(p_pHTTPResponse);
p_pHTTPResponse=NULL;
GSWDict_Free(p_pHTTPResponse->pHeaders);
p_pHTTPResponse->pHeaders=NULL;
};
if (p_pHTTPResponse->pszStatusMessage)
{
free(p_pHTTPResponse->pszStatusMessage);
p_pHTTPResponse->pszStatusMessage=NULL;
};
if (p_pHTTPResponse->pContent)
{
free(p_pHTTPResponse->pContent);
p_pHTTPResponse->pContent=NULL;
};
free(p_pHTTPResponse);
p_pHTTPResponse=NULL;
};
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPResponse_Free");
};
//--------------------------------------------------------------------
void GSWHTTPResponse_AddHeader(GSWHTTPResponse* p_pHTTPResponse,char* p_pszHeader)
void
GSWHTTPResponse_AddHeader(GSWHTTPResponse *p_pHTTPResponse,
char *p_pszHeader)
{
char* pszKey=NULL;
char* pszValue=NULL;
char *pszKey=NULL;
char *pszValue=NULL;
for (pszKey=p_pszHeader,pszValue=pszKey;*pszValue!=':';pszValue++)
{
if (isupper(*pszValue))
*pszValue = tolower(*pszValue);
};
{
if (isupper(*pszValue))
*pszValue = tolower(*pszValue);
};
if (*pszValue==':')
{
*pszValue++='\0';
while (*pszValue && isspace(*pszValue))
pszValue++;
GSWDict_AddStringDup(p_pHTTPResponse->pHeaders,pszKey,pszValue);
{
*pszValue++='\0';
while (*pszValue && isspace(*pszValue))
pszValue++;
GSWDict_AddStringDup(p_pHTTPResponse->pHeaders,pszKey,pszValue);
if (p_pHTTPResponse->uContentLength==0 && strcmp(g_szHeader_ContentLength,pszKey)==0)
p_pHTTPResponse->uContentLength = atoi(pszValue);
}
if (p_pHTTPResponse->uContentLength==0 &&
strcmp(g_szHeader_ContentLength,pszKey)==0)
p_pHTTPResponse->uContentLength = atoi(pszValue);
}
else
{
//TODO PB
};
{
//TODO PB
};
};
//--------------------------------------------------------------------
GSWHTTPResponse* GSWHTTPResponse_GetResponse(AppConnectHandle p_socket,void* p_pLogServerData)
GSWHTTPResponse *
GSWHTTPResponse_GetResponse(AppConnectHandle p_socket,
void *p_pLogServerData)
{
GSWHTTPResponse* pHTTPResponse=NULL;
GSWHTTPResponse *pHTTPResponse=NULL;
char szResponseBuffer[RESPONSE__LINE_MAX_SIZE];
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPResponse_GetResponse");
// Get the 1st Line
GSWApp_ReceiveLine(p_socket,szResponseBuffer, RESPONSE__LINE_MAX_SIZE,p_pLogServerData);
GSWApp_ReceiveLine(p_socket,szResponseBuffer,
RESPONSE__LINE_MAX_SIZE,p_pLogServerData);
pHTTPResponse = GSWHTTPResponse_New(szResponseBuffer,p_pLogServerData);
#ifdef DEBUG
GSWLog(GSW_INFO,p_pLogServerData,"Response receive first line:\t\t[%s]",szResponseBuffer);
GSWLog(GSW_INFO,p_pLogServerData,"Response receive first line:\t\t[%s]",
szResponseBuffer);
#endif
if (!pHTTPResponse) //Error
pHTTPResponse=GSWHTTPResponse_BuildErrorResponse(NULL,"Invalid Response",p_pLogServerData);
pHTTPResponse=GSWHTTPResponse_BuildErrorResponse(NULL,"Invalid Response",
p_pLogServerData);
else
{
int iHeader=0;
// Headers
while (GSWApp_ReceiveLine(p_socket,szResponseBuffer,
RESPONSE__LINE_MAX_SIZE,p_pLogServerData)>0
&& szResponseBuffer[0])
{
int iHeader=0;
// Headers
while (GSWApp_ReceiveLine(p_socket,szResponseBuffer,RESPONSE__LINE_MAX_SIZE,p_pLogServerData)>0
&& szResponseBuffer[0])
{
#ifdef DEBUG
GSWLog(GSW_INFO,p_pLogServerData,"Header %d=\t\t[%s]",iHeader,szResponseBuffer);
GSWLog(GSW_INFO,p_pLogServerData,"Header %d=\t\t[%s]",
iHeader,szResponseBuffer);
#endif
GSWHTTPResponse_AddHeader(pHTTPResponse,szResponseBuffer);
};
GSWHTTPResponse_AddHeader(pHTTPResponse,szResponseBuffer);
};
// Content
if (pHTTPResponse->uContentLength)
{
char* pszBuffer= malloc(pHTTPResponse->uContentLength);
int iReceivedCount=GSWApp_ReceiveBlock(p_socket,pszBuffer,pHTTPResponse->uContentLength,p_pLogServerData);
if (pHTTPResponse->uContentLength)
{
char *pszBuffer= malloc(pHTTPResponse->uContentLength);
int iReceivedCount=GSWApp_ReceiveBlock(p_socket,pszBuffer,
pHTTPResponse->uContentLength,
p_pLogServerData);
#ifdef DEBUG
GSWLog(GSW_INFO,p_pLogServerData,"iReceivedCount=%d",iReceivedCount);
GSWLog(GSW_INFO,p_pLogServerData,"iReceivedCount=%d",iReceivedCount);
#endif
if (iReceivedCount!= pHTTPResponse->uContentLength)
{
pHTTPResponse->pContent = pszBuffer;//TODO: Verify this (Turbocat patch)
if (iReceivedCount!= pHTTPResponse->uContentLength)
{
pHTTPResponse->pContent = pszBuffer;//TODO: Verify this (Turbocat patch)
GSWLog(GSW_ERROR,p_pLogServerData,
"Content received doesn't equal to ContentLength. Too bad, same player shoot again !");
GSWLog(GSW_ERROR,p_pLogServerData,
"Content received doesn't equal to ContentLength. Too bad, same player shoot again !");
free(pszBuffer);
pszBuffer=NULL;
GSWHTTPResponse_Free(pHTTPResponse,p_pLogServerData);
pHTTPResponse=NULL;
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse(NULL,
"Invalid Response",p_pLogServerData);
free(pszBuffer);
pszBuffer=NULL;
GSWHTTPResponse_Free(pHTTPResponse,p_pLogServerData);
pHTTPResponse=NULL;
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse(NULL,"Invalid Response",p_pLogServerData);
}
else
pHTTPResponse->pContent = pszBuffer;
}
}
else
pHTTPResponse->pContent = pszBuffer;
}
#ifdef DEBUG
/*
if (pHTTPResponse->pContent)
{
char szTraceBuffer[pHTTPResponse->uContentLength+1];
GSWLog(GSW_INFO,p_pLogServerData,"\ncontent (%d Bytes)=\n",pHTTPResponse->uContentLength);
memcpy(szTraceBuffer,pHTTPResponse->pContent,pHTTPResponse->uContentLength);
szTraceBuffer[pHTTPResponse->uContentLength] = 0;
GSWLogSized(GSW_INFO,p_pLogServerData,
pHTTPResponse->uContentLength+1,
"%.*s",
(int)pHTTPResponse->uContentLength,
szTraceBuffer);
// GSWLog(GSW_INFO,p_pLogServerData,"\nEND\n");
};
if (pHTTPResponse->pContent)
{
char szTraceBuffer[pHTTPResponse->uContentLength+1];
GSWLog(GSW_INFO,p_pLogServerData,"\ncontent (%d Bytes)=\n",
pHTTPResponse->uContentLength);
memcpy(szTraceBuffer,pHTTPResponse->pContent,
pHTTPResponse->uContentLength);
szTraceBuffer[pHTTPResponse->uContentLength] = 0;
GSWLogSized(GSW_INFO,p_pLogServerData,
pHTTPResponse->uContentLength+1,
"%.*s",
(int)pHTTPResponse->uContentLength,
szTraceBuffer);
// GSWLog(GSW_INFO,p_pLogServerData,"\nEND\n");
};
*/
#endif
};
};
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPResponse_GetResponse");
return pHTTPResponse;
};
//--------------------------------------------------------------------
static void GetHeaderLength(GSWDictElem* p_pElem,
void* p_piAddTo)
static void
GetHeaderLength(GSWDictElem *p_pElem,
void *p_piAddTo)
{
int* piAddTo=(int*)p_piAddTo;
int *piAddTo=(int *)p_piAddTo;
// +2=": "
// +1="\r"
// +1="\n"
(*piAddTo)+=strlen(p_pElem->pszKey)+strlen((char*)p_pElem->pValue)+2+1+2;
(*piAddTo)+=strlen(p_pElem->pszKey)+strlen((char *)p_pElem->pValue)+2+1+2;
};
//--------------------------------------------------------------------
static void FormatHeader(GSWDictElem* p_pElem,
void* p_ppszBuffer)
static void
FormatHeader(GSWDictElem *p_pElem,
void *p_ppszBuffer)
{
char** ppszBuffer=(char**)p_ppszBuffer;
char **ppszBuffer=(char **)p_ppszBuffer;
strcpy(*ppszBuffer,p_pElem->pszKey);
strcat(*ppszBuffer, ": ");
strcat(*ppszBuffer,(char*)p_pElem->pValue);
strcat(*ppszBuffer,(char *)p_pElem->pValue);
(*ppszBuffer)+= strlen(*ppszBuffer);
**ppszBuffer = '\r';
(*ppszBuffer)++;
@ -323,78 +355,92 @@ static void FormatHeader(GSWDictElem* p_pElem,
};
//--------------------------------------------------------------------
char *GSWHTTPResponse_PackageHeaders(GSWHTTPResponse* p_pHTTPResponse,
char* p_pszBuffer,
int p_iBufferSize)
char *
GSWHTTPResponse_PackageHeaders(GSWHTTPResponse *p_pHTTPResponse,
char *p_pszBuffer,
int p_iBufferSize)
{
int iHeaderLength=0;
char* pszBuffer=NULL;
char* pszTmp=NULL;
char *pszBuffer=NULL;
char *pszTmp=NULL;
GSWDict_PerformForAllElem(p_pHTTPResponse->pHeaders,
GetHeaderLength,
(void*)&iHeaderLength);
pszBuffer = ((p_iBufferSize > (iHeaderLength)) ? p_pszBuffer : malloc(p_iBufferSize+1));
GetHeaderLength,
(void *)&iHeaderLength);
pszBuffer = ((p_iBufferSize > (iHeaderLength)) ?
p_pszBuffer : malloc(p_iBufferSize+1));
pszTmp = pszBuffer;
GSWDict_PerformForAllElem(p_pHTTPResponse->pHeaders,FormatHeader,&pszTmp);
*pszTmp = '\0';
if (pszTmp-pszBuffer>1)
{
// Remove last \r\n
*(pszTmp-1) = 0;
*(pszTmp-2) = 0;
};
{
// Remove last \r\n
*(pszTmp-1) = 0;
*(pszTmp-2) = 0;
};
return pszBuffer;
};
//--------------------------------------------------------------------
void GSWHTTPResponse_AddHeaderToString(GSWDictElem* p_pElem,void* p_pData)
void
GSWHTTPResponse_AddHeaderToString(GSWDictElem *p_pElem,
void *p_pData)
{
GSWString* pString=(GSWString*)p_pData;
GSWString *pString=(GSWString *)p_pData;
GSWString_Append(pString,p_pElem->pszKey);
GSWString_Append(pString,": ");
GSWString_Append(pString,(char*)p_pElem->pValue);
GSWString_Append(pString,(char *)p_pElem->pValue);
GSWString_Append(pString,"<br>");
};
//--------------------------------------------------------------------
GSWHTTPResponse* GSWHTTPResponse_BuildStatusResponse(GSWHTTPRequest* p_pHTTPRequest,void* p_pLogServerData)
GSWHTTPResponse *
GSWHTTPResponse_BuildStatusResponse(GSWHTTPRequest *p_pHTTPRequest,
void *p_pLogServerData)
{
GSWHTTPResponse* pHTTPResponse=GSWHTTPResponse_New(g_szOKStatus[GSWNAMES_INDEX],p_pLogServerData);
GSWDict* pRequestHeaders=NULL;
GSWString* pContent=GSWString_New();
GSWString* pHeadersBuffer=GSWString_New();
const char* pszRemoteAddr=NULL;
const char* pszRemoteHost=NULL;
char* pszString=NULL;
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPResponse_BuildStatusResponse");
GSWHTTPResponse *pHTTPResponse=
GSWHTTPResponse_New(g_szOKStatus[GSWNAMES_INDEX],p_pLogServerData);
GSWDict *pRequestHeaders=NULL;
GSWString *pContent=GSWString_New();
GSWString *pHeadersBuffer=GSWString_New();
const char *pszRemoteAddr=NULL;
const char *pszRemoteHost=NULL;
char *pszString=NULL;
GSWLog(GSW_DEBUG,p_pLogServerData,
"Start GSWHTTPResponse_BuildStatusResponse");
GSWLog(GSW_INFO,p_pLogServerData,"Build Status Page.");
GSWConfig_LoadConfiguration(p_pLogServerData);
GSWDict_AddString(pHTTPResponse->pHeaders,
g_szHeader_ContentType,
g_szContentType_TextHtml,
FALSE);
g_szHeader_ContentType,
g_szContentType_TextHtml,
FALSE);
pRequestHeaders = (GSWDict*)(p_pHTTPRequest->pHeaders);
GSWDict_PerformForAllElem(pRequestHeaders,GSWHTTPResponse_AddHeaderToString,pHeadersBuffer);
pRequestHeaders = (GSWDict *)(p_pHTTPRequest->pHeaders);
GSWDict_PerformForAllElem(pRequestHeaders,
GSWHTTPResponse_AddHeaderToString,pHeadersBuffer);
if (GSWConfig_CanDumpStatus())
pszString=GSWTemplate_StatusAllowedResponse(TRUE,NULL);
else
pszString=GSWTemplate_StatusDeniedResponse(TRUE,NULL);
GSWString_Append(pContent,pszString);
free(pszString);
pszRemoteAddr=(const char*)GSWDict_ValueForKey(pRequestHeaders,"x-gsweb-remote-addr");
pszRemoteAddr=(const char *)GSWDict_ValueForKey(pRequestHeaders,
"x-gsweb-remote-addr");
if (!pszRemoteAddr)
pszRemoteAddr="";
pszRemoteHost=(const char*)GSWDict_ValueForKey(pRequestHeaders,"x-gsweb-remote-host");
pszRemoteAddr="";
pszRemoteHost=(const char *)GSWDict_ValueForKey(pRequestHeaders,
"x-gsweb-remote-host");
if (!pszRemoteHost)
pszRemoteHost="";
pszRemoteHost="";
GSWString_SearchReplace(pContent,"##REMOTE_ADDR##",pszRemoteAddr);
GSWString_SearchReplace(pContent,"##REMOTE_HOST##",pszRemoteHost);
GSWString_SearchReplace(pContent,"##SERVER_INFO##",GSWConfig_ServerStringInfo());
GSWString_SearchReplace(pContent,"##SERVER_INFO##",
GSWConfig_ServerStringInfo());
GSWString_SearchReplace(pContent,"##SERVER_URL##",GSWConfig_ServerURL());
GSWString_SearchReplace(pContent,"##ADAPTOR_INFO##",g_szGSWeb_AdaptorStringInfo());
GSWString_SearchReplace(pContent,"##ADAPTOR_INFO##",
g_szGSWeb_AdaptorStringInfo());
GSWString_SearchReplace(pContent,"##ADAPTOR_URL##",g_szGSWeb_AdaptorURL());
GSWString_SearchReplace(pContent,"##HEADERS##",pHeadersBuffer->pszData);
GSWTemplate_ReplaceStd(pContent,NULL);
@ -405,42 +451,51 @@ GSWHTTPResponse* GSWHTTPResponse_BuildStatusResponse(GSWHTTPRequest* p_pHTTPRequ
pHTTPResponse->pContent = pContent->pszData;
GSWString_Detach(pContent);
GSWString_Free(pContent);
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPResponse_BuildStatusResponse");
GSWLog(GSW_DEBUG,p_pLogServerData,
"Stop GSWHTTPResponse_BuildStatusResponse");
return pHTTPResponse;
};
//--------------------------------------------------------------------
GSWHTTPResponse* GSWDumpConfigFile(GSWURLComponents* p_pURLComponents,void* p_pLogServerData)
GSWHTTPResponse *
GSWDumpConfigFile(GSWURLComponents *p_pURLComponents,
void *p_pLogServerData)
{
GSWHTTPResponse* pHTTPResponse=NULL;
GSWString* pContent=NULL;
char pszPrefix[MAXPATHLEN]="";
char szReqAppName[MAXPATHLEN]="Unknown";
GSWHTTPResponse *pHTTPResponse=NULL;
GSWString *pContent=NULL;
char pszPrefix[MAXPATHLEN]="";
char szReqAppName[MAXPATHLEN]="Unknown";
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWDumpConfigFile");
GSWLog(GSW_INFO,p_pLogServerData,"Creating Applications Page.");
if (!g_pszLocalHostName)
{
char szHostName[MAXHOSTNAMELEN+1];
gethostname(szHostName, MAXHOSTNAMELEN);
g_pszLocalHostName= strdup(szHostName);
};
{
char szHostName[MAXHOSTNAMELEN+1];
gethostname(szHostName, MAXHOSTNAMELEN);
g_pszLocalHostName= strdup(szHostName);
};
pHTTPResponse = GSWHTTPResponse_New(g_szOKStatus[GSWNAMES_INDEX],p_pLogServerData);
pHTTPResponse = GSWHTTPResponse_New(g_szOKStatus[GSWNAMES_INDEX],
p_pLogServerData);
GSWDict_AddString(pHTTPResponse->pHeaders,
g_szHeader_ContentType,
g_szContentType_TextHtml,
FALSE);
if (p_pURLComponents->stAppName.iLength>0 && p_pURLComponents->stAppName.pszStart)
{
strncpy(szReqAppName,p_pURLComponents->stAppName.pszStart,p_pURLComponents->stAppName.iLength);
szReqAppName[p_pURLComponents->stAppName.iLength]=0;
};
g_szHeader_ContentType,
g_szContentType_TextHtml,
FALSE);
if (p_pURLComponents->stAppName.iLength>0 &&
p_pURLComponents->stAppName.pszStart)
{
strncpy(szReqAppName,p_pURLComponents->stAppName.pszStart,
p_pURLComponents->stAppName.iLength);
szReqAppName[p_pURLComponents->stAppName.iLength]=0;
};
strncpy(pszPrefix, p_pURLComponents->stPrefix.pszStart,p_pURLComponents->stPrefix.iLength);
strncpy(pszPrefix, p_pURLComponents->stPrefix.pszStart,
p_pURLComponents->stPrefix.iLength);
pszPrefix[p_pURLComponents->stPrefix.iLength] = '\0';
GSWConfig_LoadConfiguration(p_pLogServerData);
pContent=GSWConfig_DumpGSWApps(szReqAppName,pszPrefix,FALSE,TRUE,p_pLogServerData);
pContent=GSWConfig_DumpGSWApps(szReqAppName,pszPrefix,FALSE,TRUE,
p_pLogServerData);
GSWTemplate_ReplaceStd(pContent,NULL);
pHTTPResponse->uContentLength = pContent->iLen;
pHTTPResponse->pContent = pContent->pszData;
@ -449,6 +504,3 @@ GSWHTTPResponse* GSWDumpConfigFile(GSWURLComponents* p_pURLComponents,void* p_pL
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWDumpConfigFile");
return pHTTPResponse;
};

View file

@ -1,8 +1,8 @@
/* GSWHTTPResponse.h - GSWeb: GSWeb Request
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -31,34 +31,42 @@ extern "C" {
typedef struct _GSWHTTPResponse
{
unsigned int uStatus;
char* pszStatusMessage;
GSWDict* pHeaders;
char *pszStatusMessage;
GSWDict *pHeaders;
unsigned int uContentLength;
void* pContent;
void *pContent;
} GSWHTTPResponse;
GSWHTTPResponse* GSWHTTPResponse_New(CONST char* p_pszStatus,void* p_pLogServerData);
void GSWHTTPResponse_Free(GSWHTTPResponse* p_pHTTPResponse,void* p_pLogServerData);
GSWHTTPResponse *GSWHTTPResponse_New(CONST char *p_pszStatus,
void *p_pLogServerData);
void GSWHTTPResponse_Free(GSWHTTPResponse *p_pHTTPResponse,
void *p_pLogServerData);
// Get The response from Application
GSWHTTPResponse* GSWHTTPResponse_GetResponse(AppConnectHandle p_socket,void* p_pLogServerData);
GSWHTTPResponse *GSWHTTPResponse_GetResponse(AppConnectHandle p_socket,
void *p_pLogServerData);
// Build an error response
GSWHTTPResponse *GSWHTTPResponse_BuildErrorResponse(GSWAppRequest* p_pAppRequest,CONST char* p_pszMessage,void* p_pLogServerData);
GSWHTTPResponse *GSWHTTPResponse_BuildErrorResponse(GSWAppRequest *p_pAppRequest,
CONST char *p_pszMessage,
void *p_pLogServerData);
// Redirect Response
GSWHTTPResponse* GSWHTTPResponse_BuildRedirectedResponse(CONST char* p_pszRedirectPath,void* p_pLogServerData);
GSWHTTPResponse *GSWHTTPResponse_BuildRedirectedResponse(CONST char *p_pszRedirectPath,
void *p_pLogServerData);
// Add Header
void GSWHTTPResponse_AddHeader(GSWHTTPResponse* p_pHTTPResponse,
char* p_pszHeader);
void GSWHTTPResponse_AddHeader(GSWHTTPResponse *p_pHTTPResponse,
char *p_pszHeader);
char* p_pszGSWHTTPResponse_PackageHeaders(GSWHTTPResponse* p_pHTTPResponse,
char* p_pszBuffer,
int iBufferSize);
char *p_pszGSWHTTPResponse_PackageHeaders(GSWHTTPResponse *p_pHTTPResponse,
char *p_pszBuffer,
int iBufferSize);
GSWHTTPResponse* GSWHTTPResponse_BuildStatusResponse(GSWHTTPRequest* p_pHTTPRequest,void* p_pLogServerData);
GSWHTTPResponse* GSWDumpConfigFile(GSWURLComponents* p_pURLComponents,void* p_pLogServerData);
GSWHTTPResponse *GSWHTTPResponse_BuildStatusResponse(GSWHTTPRequest *p_pHTTPRequest,
void *p_pLogServerData);
GSWHTTPResponse* GSWDumpConfigFile(GSWURLComponents *p_pURLComponents,
void *p_pLogServerData);
#ifdef __cplusplus
}

View file

@ -1,8 +1,8 @@
/* GSWDict.c - GSWeb: Dictionary
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -29,112 +29,137 @@
#include "GSWUtil.h"
#include "GSWList.h"
unsigned int GSWList_Count(GSWList* p_pList)
unsigned int
GSWList_Count(GSWList *p_pList)
{
return p_pList->uCount;
};
GSWList *GSWList_New(unsigned int p_uCapacity)
GSWList *
GSWList_New(unsigned int p_uCapacity)
{
GSWList* pList=calloc(1,sizeof(GSWList));
GSWList *pList=calloc(1,sizeof(GSWList));
if (pList && p_uCapacity>0)
GSWList_SetCapacity(pList,p_uCapacity);
GSWList_SetCapacity(pList,p_uCapacity);
return pList;
};
void GSWList_FreeElements(GSWList* p_pList)
void
GSWList_FreeElements(GSWList *p_pList)
{
if (p_pList)
{
unsigned int i=0;
for(i=0;i<p_pList->uCount;i++)
{
unsigned int i=0;
for(i=0;i<p_pList->uCount;i++)
{
free(p_pList->ppElements[i]);
p_pList->ppElements[i]=NULL;
};
p_pList->uCount=0;
free(p_pList->ppElements[i]);
p_pList->ppElements[i]=NULL;
};
p_pList->uCount=0;
};
};
void GSWList_Free(GSWList* p_pList,BOOL p_fFreeElements)
void
GSWList_Free(GSWList *p_pList,
BOOL p_fFreeElements)
{
if (p_pList)
{
if (p_pList->ppElements)
{
if (p_pList->ppElements)
{
if (p_fFreeElements)
GSWList_FreeElements(p_pList);
free(p_pList->ppElements);
p_pList->ppElements=NULL;
};
free(p_pList);
if (p_fFreeElements)
GSWList_FreeElements(p_pList);
free(p_pList->ppElements);
p_pList->ppElements=NULL;
};
free(p_pList);
};
};
void GSWList_Add(GSWList* p_pList,void* p_pElement)
void
GSWList_Add(GSWList *p_pList,
void *p_pElement)
{
if (p_pList->uCount>=p_pList->uCapacity)
GSWList_SetCapacity(p_pList,(p_pList->uCapacity) ? p_pList->uCapacity*2 : 16);
GSWList_SetCapacity(p_pList,
(p_pList->uCapacity) ? p_pList->uCapacity*2 : 16);
p_pList->ppElements[p_pList->uCount] = p_pElement;
p_pList->uCount++;
};
void GSWList_RemoveAtIndex(GSWList* p_pList,int p_iIndex)
void
GSWList_RemoveAtIndex(GSWList *p_pList,
int p_iIndex)
{
if (p_iIndex>=0 && p_iIndex<p_pList->uCount)
{
p_pList->uCount--;
for (;p_iIndex<p_pList->uCount;p_iIndex++)
p_pList->ppElements[p_iIndex]=p_pList->ppElements[p_iIndex+1];
};
{
p_pList->uCount--;
for (;p_iIndex<p_pList->uCount;p_iIndex++)
p_pList->ppElements[p_iIndex]=p_pList->ppElements[p_iIndex+1];
};
};
void GSWList_Remove(GSWList* p_pList,void* p_pElement)
void
GSWList_Remove(GSWList *p_pList,
void *p_pElement)
{
int i;
for (i=0;i<p_pList->uCount;i++)
{
if (p_pList->ppElements[i]==p_pElement)
{
if (p_pList->ppElements[i]==p_pElement)
{
GSWList_RemoveAtIndex(p_pList,i);
i=p_pList->uCount;
};
GSWList_RemoveAtIndex(p_pList,i);
i=p_pList->uCount;
};
};
};
void GSWList_SetCapacity(GSWList* p_pList,unsigned int p_uCapacity)
void
GSWList_SetCapacity(GSWList *p_pList,
unsigned int p_uCapacity)
{
if (p_uCapacity>p_pList->uCapacity)
{
if (p_pList->ppElements)
p_pList->ppElements=realloc(p_pList->ppElements,p_uCapacity*sizeof(void*));
else
p_pList->ppElements=calloc(p_uCapacity, sizeof(void*));
{
if (p_pList->ppElements)
p_pList->ppElements=realloc(p_pList->ppElements,
p_uCapacity*sizeof(void *));
else
p_pList->ppElements=calloc(p_uCapacity, sizeof(void *));
p_pList->uCapacity=p_uCapacity;
};
};
void GSWList_Sort(GSWList* p_pList,int (*compare)(CONST void*, CONST void*))
void
GSWList_Sort(GSWList *p_pList,
int (*compare)(CONST void *, CONST void *))
{
if (p_pList->uCount>1)
qsort(p_pList->ppElements,p_pList->uCount,sizeof(void*), compare);
qsort(p_pList->ppElements,p_pList->uCount,sizeof(void *), compare);
}
void *GSWList_BSearch(GSWList* p_pList,CONST void* p_pKey,int (*compare)(CONST void*, CONST void*))
void *
GSWList_BSearch(GSWList *p_pList,
CONST void *p_pKey,
int (*compare)(CONST void *, CONST void *))
{
void** ppElement=NULL;
void **ppElement=NULL;
if (p_pList->uCount>0)
ppElement=bsearch(p_pKey,p_pList->ppElements,p_pList->uCount,sizeof(void*), compare);
ppElement=bsearch(p_pKey,
p_pList->ppElements,
p_pList->uCount,
sizeof(void *),
compare);
return (ppElement) ? *ppElement : NULL;
};
void* GSWList_ElementAtIndex(GSWList* p_pList,int p_iIndex)
void *
GSWList_ElementAtIndex(GSWList *p_pList,
int p_iIndex)
{
if (p_iIndex>=0 && p_iIndex<p_pList->uCount)
return p_pList->ppElements[p_iIndex];
return p_pList->ppElements[p_iIndex];
else
return NULL;
return NULL;
};

View file

@ -1,8 +1,8 @@
/* GSWList.h - GSWeb: List
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -33,22 +33,24 @@ typedef struct _GSWList
{
unsigned int uCount;
unsigned int uCapacity;
void** ppElements;
void **ppElements;
} GSWList;
unsigned int GSWList_Count(GSWList* p_pList);
unsigned int GSWList_Count(GSWList *p_pList);
GSWList *GSWList_New(unsigned int p_uCapacity);
void GSWList_Free(GSWList* p_pList,BOOL p_fFreeElements);
void GSWList_Free(GSWList *p_pList, BOOL p_fFreeElements);
void GSWList_Add(GSWList* p_pList,void* p_pElement);
void GSWList_Remove(GSWList* p_pList,void* p_pElement);
void GSWList_RemoveAtIndex(GSWList* p_pList,int p_iIndex);
void GSWList_SetCapacity(GSWList* p_pList,unsigned int p_uCapacity);
void GSWList_Sort(GSWList* p_pList,int (*compare)(CONST void *, CONST void *));
void *GSWList_BSearch(GSWList* p_pList,CONST void* p_pKey,int (*compare)(CONST void *, CONST void *));
void GSWList_Add(GSWList *p_pList, void *p_pElement);
void GSWList_Remove(GSWList *p_pList, void *p_pElement);
void GSWList_RemoveAtIndex(GSWList *p_pList, int p_iIndex);
void GSWList_SetCapacity(GSWList *p_pList, unsigned int p_uCapacity);
void GSWList_Sort(GSWList *p_pList,int (*compare)(CONST void *, CONST void *));
void *GSWList_BSearch(GSWList *p_pList,
CONST void *p_pKey,
int (*compare)(CONST void *, CONST void *));
void* GSWList_ElementAtIndex(GSWList* p_pList,int p_iIndex);
void *GSWList_ElementAtIndex(GSWList *p_pList,int p_iIndex);
#ifdef __cplusplus
}

View file

@ -1,8 +1,8 @@
/* GSWLoadBalancing.c - GSWeb: Adaptors: Load Balancing
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -45,11 +45,13 @@
#include "GSWApp.h"
//--------------------------------------------------------------------
BOOL GSWLoadBalancing_FindApp(GSWAppRequest* p_pAppRequest,
void* p_pLogServerData, GSWURLComponents* p_pURLComponents)
BOOL
GSWLoadBalancing_FindApp(GSWAppRequest *p_pAppRequest,
void *p_pLogServerData,
GSWURLComponents *p_pURLComponents)
{
BOOL fFound=FALSE;
GSWApp* pApp=NULL;
GSWApp *pApp=NULL;
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWLoadBalancing_FindApp");
GSWLog(GSW_INFO,p_pLogServerData,"LoadBalance: looking for %s",
p_pAppRequest->pszName);
@ -57,191 +59,220 @@ BOOL GSWLoadBalancing_FindApp(GSWAppRequest* p_pAppRequest,
GSWLock_Lock(g_lockAppList);
pApp = GSWConfig_GetApp(p_pAppRequest->pszName);
if (pApp)
{
GSWList* pInstancesList=GSWDict_AllKeys(&pApp->stInstancesDict);
unsigned int uInstancesCount=GSWList_Count(pInstancesList);
int iTries=uInstancesCount;
GSWAppInstance* pAppInstance=NULL;
time_t curTime = (time_t)0;
{
GSWList *pInstancesList=GSWDict_AllKeys(&pApp->stInstancesDict);
unsigned int uInstancesCount=GSWList_Count(pInstancesList);
int iTries=uInstancesCount;
GSWAppInstance *pAppInstance=NULL;
time_t curTime = (time_t)0;
while (!fFound && iTries-->0)
while (!fFound && iTries-->0)
{
pApp->iIndex = (pApp->iIndex+1) % uInstancesCount;
pAppInstance =
(GSWAppInstance *)GSWDict_ValueForKey(&pApp->stInstancesDict,
GSWList_ElementAtIndex(pInstancesList,pApp->iIndex));
if (pAppInstance)
{
if (!pAppInstance->pApp)
{
pApp->iIndex = (pApp->iIndex+1) % uInstancesCount;
pAppInstance=(GSWAppInstance*)GSWDict_ValueForKey(&pApp->stInstancesDict,
GSWList_ElementAtIndex(pInstancesList,pApp->iIndex));
if (pAppInstance)
{
if (!pAppInstance->pApp)
{
GSWLog(GSW_CRITICAL,p_pLogServerData,
"AppInstance pApp is null pAppInstance=%p",
pAppInstance);
};
if (pAppInstance->timeNextRetryTime!=0)
{
if (!curTime)
time(&curTime);
if (pAppInstance->timeNextRetryTime<curTime)
{
GSWLog(GSW_CRITICAL,
p_pLogServerData,
"LoadBalance: Instance %s:%d was marked dead for %d secs. Now resurecting !",
p_pAppRequest->pszName,
pAppInstance->iInstance,
APP_CONNECT_RETRY_DELAY);
pAppInstance->timeNextRetryTime=0;
};
};
if (pAppInstance->timeNextRetryTime==0 && pAppInstance->fValid)
{
BOOL okay = TRUE;
// check if refused, time to try again ?
if (p_pURLComponents->stRequestHandlerKey.iLength==0 || p_pURLComponents->stRequestHandlerKey.pszStart==NULL) {
GSWAppInfo *thisAppInfo = GSWAppInfo_Find(p_pAppRequest->pszName, pAppInstance->iInstance);
if (thisAppInfo && thisAppInfo->isRefused) {
time_t actTime = (time_t)0;
// this instance refuses new sessions
time(&actTime);
if (actTime > thisAppInfo->timeNextRetryTime) {
thisAppInfo->isRefused = FALSE; // try it again
} else {
okay = FALSE; // try an other instance
}
}
}
if (okay == TRUE) {
fFound = TRUE;
strcpy(p_pAppRequest->pszName,pApp->pszName);
p_pAppRequest->iInstance = pAppInstance->iInstance;
p_pAppRequest->pszHost = pAppInstance->pszHostName;
p_pAppRequest->iPort = pAppInstance->iPort;
p_pAppRequest->eType = EAppType_LoadBalanced;
p_pAppRequest->pAppInstance = pAppInstance;
pAppInstance->uOpenedRequestsNb++;
}
};
};
GSWLog(GSW_CRITICAL,p_pLogServerData,
"AppInstance pApp is null pAppInstance=%p",
pAppInstance);
};
GSWList_Free(pInstancesList,FALSE);
if (pAppInstance->timeNextRetryTime!=0)
{
if (!curTime)
time(&curTime);
if (pAppInstance->timeNextRetryTime<curTime)
{
GSWLog(GSW_CRITICAL,
p_pLogServerData,
"LoadBalance: Instance %s:%d was marked dead for %d secs. Now resurecting !",
p_pAppRequest->pszName,
pAppInstance->iInstance,
APP_CONNECT_RETRY_DELAY);
pAppInstance->timeNextRetryTime=0;
};
};
if (pAppInstance->timeNextRetryTime==0 && pAppInstance->fValid)
{
BOOL okay = TRUE;
// check if refused, time to try again ?
if (p_pURLComponents->stRequestHandlerKey.iLength==0 ||
p_pURLComponents->stRequestHandlerKey.pszStart==NULL)
{
GSWAppInfo *thisAppInfo =
GSWAppInfo_Find(p_pAppRequest->pszName,
pAppInstance->iInstance);
if (thisAppInfo && thisAppInfo->isRefused)
{
time_t actTime = (time_t)0;
// this instance refuses new sessions
time(&actTime);
if (actTime > thisAppInfo->timeNextRetryTime)
{
thisAppInfo->isRefused = FALSE; // try it again
}
else
{
okay = FALSE; // try an other instance
}
}
}
if (okay == TRUE)
{
fFound = TRUE;
strcpy(p_pAppRequest->pszName,pApp->pszName);
p_pAppRequest->iInstance = pAppInstance->iInstance;
p_pAppRequest->pszHost = pAppInstance->pszHostName;
p_pAppRequest->iPort = pAppInstance->iPort;
p_pAppRequest->eType = EAppType_LoadBalanced;
p_pAppRequest->pAppInstance = pAppInstance;
pAppInstance->uOpenedRequestsNb++;
}
};
};
};
GSWList_Free(pInstancesList,FALSE);
};
GSWLock_Unlock(g_lockAppList);
if (fFound)
GSWLog(GSW_INFO,p_pLogServerData,"LoadBalance: looking for %s, fFound instance %d on %s:%d",
p_pAppRequest->pszName,
p_pAppRequest->iInstance,
p_pAppRequest->pszHost,
p_pAppRequest->iPort);
GSWLog(GSW_INFO,p_pLogServerData,
"LoadBalance: looking for %s, fFound instance %d on %s:%d",
p_pAppRequest->pszName,
p_pAppRequest->iInstance,
p_pAppRequest->pszHost,
p_pAppRequest->iPort);
else
GSWLog(GSW_INFO,p_pLogServerData,"LoadBalance: looking for %s, Not Found",
p_pAppRequest->pszName);
GSWLog(GSW_INFO,p_pLogServerData,"LoadBalance: looking for %s, Not Found",
p_pAppRequest->pszName);
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWLoadBalancing_FindApp");
return fFound;
};
//--------------------------------------------------------------------
BOOL GSWLoadBalancing_FindInstance(GSWAppRequest *p_pAppRequest,void* p_pLogServerData, GSWURLComponents* p_pURLComponents)
BOOL
GSWLoadBalancing_FindInstance(GSWAppRequest *p_pAppRequest,
void *p_pLogServerData,
GSWURLComponents *p_pURLComponents)
{
BOOL fFound=FALSE;
GSWApp* pApp=NULL;
GSWApp *pApp=NULL;
int i=0;
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWLoadBalancing_FindInstance");
GSWConfig_LoadConfiguration(p_pLogServerData);
GSWLock_Lock(g_lockAppList);
pApp = (GSWApp*)GSWConfig_GetApp(p_pAppRequest->pszName);
pApp = (GSWApp *)GSWConfig_GetApp(p_pAppRequest->pszName);
if (pApp)
{
GSWAppInstance *pAppInstance=NULL;
char szInstanceNum[50]="";
sprintf(szInstanceNum,"%d",p_pAppRequest->iInstance);
pAppInstance =
(GSWAppInstance *)GSWDict_ValueForKey(&pApp->stInstancesDict,
szInstanceNum);
if (pAppInstance)
{
GSWAppInstance* pAppInstance=NULL;
char szInstanceNum[50]="";
sprintf(szInstanceNum,"%d",p_pAppRequest->iInstance);
pAppInstance=(GSWAppInstance*)GSWDict_ValueForKey(&pApp->stInstancesDict,szInstanceNum);
if (pAppInstance)
GSWLog(GSW_DEBUG,p_pLogServerData,"Instance Found");
if (pAppInstance->fValid)
{
BOOL okay = TRUE;
// check if refused, time to try again ?
if (p_pURLComponents->stRequestHandlerKey.iLength==0 ||
p_pURLComponents->stRequestHandlerKey.pszStart==NULL)
{
GSWLog(GSW_DEBUG,p_pLogServerData,"Instance Found");
if (pAppInstance->fValid)
GSWAppInfo *thisAppInfo =
GSWAppInfo_Find(p_pAppRequest->pszName,
pAppInstance->iInstance);
if (thisAppInfo && thisAppInfo->isRefused)
{
time_t actTime = (time_t)0;
// this instance refuses new sessions
time(&actTime);
if (actTime > thisAppInfo->timeNextRetryTime)
{
BOOL okay = TRUE;
// check if refused, time to try again ?
if (p_pURLComponents->stRequestHandlerKey.iLength==0 || p_pURLComponents->stRequestHandlerKey.pszStart==NULL) {
GSWAppInfo *thisAppInfo = GSWAppInfo_Find(p_pAppRequest->pszName, pAppInstance->iInstance);
if (thisAppInfo && thisAppInfo->isRefused) {
time_t actTime = (time_t)0;
// this instance refuses new sessions
time(&actTime);
if (actTime > thisAppInfo->timeNextRetryTime) {
thisAppInfo->isRefused = FALSE; // try it again
} else {
okay = FALSE; // try an other instance
}
}
}
if (okay == TRUE) {
fFound=TRUE;
p_pAppRequest->iInstance = pAppInstance->iInstance;
p_pAppRequest->pszHost = pAppInstance->pszHostName;
p_pAppRequest->iPort = pAppInstance->iPort;
p_pAppRequest->eType = EAppType_LoadBalanced;
p_pAppRequest->pAppInstance = pAppInstance;
pAppInstance->uOpenedRequestsNb++;
GSWLog(GSW_DEBUG,p_pLogServerData,"Instance is valid");
}
thisAppInfo->isRefused = FALSE; // try it again
}
else
else
{
GSWLog(GSW_DEBUG,p_pLogServerData,"Instance is not valid");
};
};
okay = FALSE; // try an other instance
}
}
}
if (okay == TRUE)
{
fFound=TRUE;
p_pAppRequest->iInstance = pAppInstance->iInstance;
p_pAppRequest->pszHost = pAppInstance->pszHostName;
p_pAppRequest->iPort = pAppInstance->iPort;
p_pAppRequest->eType = EAppType_LoadBalanced;
p_pAppRequest->pAppInstance = pAppInstance;
pAppInstance->uOpenedRequestsNb++;
GSWLog(GSW_DEBUG,p_pLogServerData,"Instance is valid");
}
}
else
{
GSWLog(GSW_DEBUG,p_pLogServerData,"Instance is not valid");
};
};
};
GSWLock_Unlock(g_lockAppList);
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWLoadBalancing_FindInstance");
return fFound;
};
//--------------------------------------------------------------------
void GSWLoadBalancing_MarkNotRespondingApp(GSWAppRequest* p_pAppRequest,
void* p_pLogServerData)
void
GSWLoadBalancing_MarkNotRespondingApp(GSWAppRequest *p_pAppRequest,
void *p_pLogServerData)
{
GSWAppInstance* pAppInstance;
GSWAppInstance *pAppInstance;
time_t now;
time(&now);
pAppInstance =p_pAppRequest->pAppInstance;
pAppInstance = p_pAppRequest->pAppInstance;
pAppInstance->uOpenedRequestsNb--;
pAppInstance->timeNextRetryTime=now+APP_CONNECT_RETRY_DELAY;
GSWLog(GSW_WARNING,p_pLogServerData,"Marking %s unresponsive",p_pAppRequest->pszName);
GSWLog(GSW_WARNING,p_pLogServerData,"Marking %s unresponsive",
p_pAppRequest->pszName);
if (!pAppInstance->fValid)
{
if (GSWAppInstance_FreeIFND(pAppInstance))
pAppInstance=NULL;
};
{
if (GSWAppInstance_FreeIFND(pAppInstance))
pAppInstance=NULL;
};
};
//--------------------------------------------------------------------
void GSWLoadBalancing_StartAppRequest(GSWAppRequest* p_pAppRequest,
void* p_pLogServerData)
void
GSWLoadBalancing_StartAppRequest(GSWAppRequest *p_pAppRequest,
void *p_pLogServerData)
{
GSWAppInstance* pAppInstance=p_pAppRequest->pAppInstance;
GSWAppInstance *pAppInstance=p_pAppRequest->pAppInstance;
if (pAppInstance->timeNextRetryTime!=0)
{
pAppInstance->timeNextRetryTime=0;
GSWLog(GSW_WARNING,p_pLogServerData,"Marking %s as alive",p_pAppRequest->pszName);
};
{
pAppInstance->timeNextRetryTime=0;
GSWLog(GSW_WARNING,p_pLogServerData,
"Marking %s as alive",p_pAppRequest->pszName);
};
}
//--------------------------------------------------------------------
void GSWLoadBalancing_StopAppRequest(GSWAppRequest *p_pAppRequest,
void* p_pLogServerData)
void
GSWLoadBalancing_StopAppRequest(GSWAppRequest *p_pAppRequest,
void *p_pLogServerData)
{
GSWAppInstance* pAppInstance=p_pAppRequest->pAppInstance;
GSWAppInstance *pAppInstance=p_pAppRequest->pAppInstance;
GSWLock_Lock(g_lockAppList);
pAppInstance->uOpenedRequestsNb--;
if (!pAppInstance->fValid)
{
if (GSWAppInstance_FreeIFND(pAppInstance))
pAppInstance=NULL;
};
{
if (GSWAppInstance_FreeIFND(pAppInstance))
pAppInstance=NULL;
};
GSWLock_Unlock(g_lockAppList);
p_pAppRequest->pAppInstance = NULL;
};

View file

@ -1,8 +1,8 @@
/* GSWLoadBalancing.h - GSWeb: GSWeb Load Balancing
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -24,11 +24,18 @@
#ifndef _GSWLoadBalancing_h__
#define _GSWLoadBalancing_h__
BOOL GSWLoadBalancing_FindApp(GSWAppRequest* p_pAppRequest,void* p_pLogServerData, GSWURLComponents* p_pURLComponents);
BOOL GSWLoadBalancing_FindInstance(GSWAppRequest* p_pAppRequest,void* p_pLogServerData, GSWURLComponents* p_pURLComponents);
void GSWLoadBalancing_MarkNotRespondingApp(GSWAppRequest* p_pAppRequest,void* p_pLogServerData);
void GSWLoadBalancing_StartAppRequest(GSWAppRequest* p_pAppRequest,void* p_pLogServerData);
void GSWLoadBalancing_StopAppRequest(GSWAppRequest* p_pAppRequest,void* p_pLogServerData);
BOOL GSWLoadBalancing_FindApp(GSWAppRequest *p_pAppRequest,
void *p_pLogServerData,
GSWURLComponents *p_pURLComponents);
BOOL GSWLoadBalancing_FindInstance(GSWAppRequest *p_pAppRequest,
void *p_pLogServerData,
GSWURLComponents *p_pURLComponents);
void GSWLoadBalancing_MarkNotRespondingApp(GSWAppRequest *p_pAppRequest,
void *p_pLogServerData);
void GSWLoadBalancing_StartAppRequest(GSWAppRequest *p_pAppRequest,
void *p_pLogServerData);
void GSWLoadBalancing_StopAppRequest(GSWAppRequest *p_pAppRequest,
void *p_pLogServerData);
#endif // GSWLoadBalancing

View file

@ -1,8 +1,8 @@
/* GSWLock.h - GSWeb: Lock
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.

View file

@ -1,8 +1,8 @@
/* GSWPropList.c - GSWeb: Adaptors: GSWPropList
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: March 2000
Date: March 2000
This file is part of the GNUstep Web Library.
@ -39,232 +39,249 @@
#include "GSWPropList.h"
//--------------------------------------------------------------------
CONST char* PLGetType(proplist_t pl)
CONST char *
PLGetType(proplist_t pl)
{
if (!pl)
return "NULL";
return "NULL";
else if (PLIsDictionary(pl))
return "Dictionary";
return "Dictionary";
else if (PLIsArray(pl))
return "Array";
return "Array";
else if (PLIsString(pl))
return "String";
return "String";
else if (PLIsData(pl))
return "Data";
return "Data";
else if (PLIsSimple(pl))
return "Simple";
return "Simple";
else if (PLIsCompound(pl))
return "Compound";
return "Compound";
else
return "Unknown";
return "Unknown";
};
//--------------------------------------------------------------------
BOOL GSWPropList_TestDictionary(proplist_t pl,
BOOL p_fErrorIfNotExists,
CONST char* p_pszKey,
CONST char* p_pszParents,
void* p_pLogServerData)
BOOL
GSWPropList_TestDictionary(proplist_t pl,
BOOL p_fErrorIfNotExists,
CONST char *p_pszKey,
CONST char *p_pszParents,
void *p_pLogServerData)
{
char* pszMsgInfo0=NULL;
char* pszMsgInfo1=NULL;
char *pszMsgInfo0=NULL;
char *pszMsgInfo1=NULL;
BOOL fOk=TRUE;
if (pl)
{
if (!PLIsDictionary(pl))
{
if (!PLIsDictionary(pl))
{
CONST char* pszType=PLGetType(pl);
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
sprintf(pszMsgInfo0,"is not a dictionary its a %s:",pszType);
pszMsgInfo1=PLGetDescription(pl);//We have to free it
fOk=FALSE;
};
}
CONST char *pszType=PLGetType(pl);
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
sprintf(pszMsgInfo0,"is not a dictionary its a %s:",pszType);
pszMsgInfo1=PLGetDescription(pl);//We have to free it
fOk=FALSE;
};
}
else
{
if (p_fErrorIfNotExists)
{
if (p_fErrorIfNotExists)
{
pszMsgInfo0=strdup("not found");
fOk=FALSE;
};
pszMsgInfo0=strdup("not found");
fOk=FALSE;
};
};
if (!fOk)
{
GSWLogSized(GSW_CRITICAL,
p_pLogServerData,
256+SafeStrlen(p_pszParents)+SafeStrlen(p_pszKey)+SafeStrlen(pszMsgInfo0)+SafeStrlen(pszMsgInfo1),
"%s/%s %s %s",
(p_pszParents ? p_pszParents : ""),
(p_pszKey ? p_pszKey : ""),
(pszMsgInfo0 ? pszMsgInfo0 : ""),
(pszMsgInfo1 ? pszMsgInfo1 : ""));
if (pszMsgInfo0)
free(pszMsgInfo0);
if (pszMsgInfo1)
free(pszMsgInfo1);
};
{
GSWLogSized(GSW_CRITICAL,
p_pLogServerData,
256+SafeStrlen(p_pszParents)+SafeStrlen(p_pszKey)+
SafeStrlen(pszMsgInfo0)+SafeStrlen(pszMsgInfo1),
"%s/%s %s %s",
(p_pszParents ? p_pszParents : ""),
(p_pszKey ? p_pszKey : ""),
(pszMsgInfo0 ? pszMsgInfo0 : ""),
(pszMsgInfo1 ? pszMsgInfo1 : ""));
if (pszMsgInfo0)
free(pszMsgInfo0);
if (pszMsgInfo1)
free(pszMsgInfo1);
};
return fOk;
};
//--------------------------------------------------------------------
BOOL GSWPropList_TestArray(proplist_t pl,
BOOL p_fErrorIfNotExists,
CONST char* p_pszKey,
CONST char* p_pszParents,
void* p_pLogServerData)
BOOL
GSWPropList_TestArray(proplist_t pl,
BOOL p_fErrorIfNotExists,
CONST char *p_pszKey,
CONST char *p_pszParents,
void *p_pLogServerData)
{
char* pszMsgInfo0=NULL;
char* pszMsgInfo1=NULL;
char *pszMsgInfo0=NULL;
char *pszMsgInfo1=NULL;
BOOL fOk=TRUE;
if (pl)
{
if (!PLIsArray(pl))
{
if (!PLIsArray(pl))
{
CONST char* pszType=PLGetType(pl);
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
sprintf(pszMsgInfo0,"is not an array its a %s:",pszType);
pszMsgInfo1=PLGetDescription(pl);//We have to free it
fOk=FALSE;
};
}
CONST char *pszType=PLGetType(pl);
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
sprintf(pszMsgInfo0,"is not an array its a %s:",pszType);
pszMsgInfo1=PLGetDescription(pl);//We have to free it
fOk=FALSE;
};
}
else
{
if (p_fErrorIfNotExists)
{
if (p_fErrorIfNotExists)
{
pszMsgInfo0="not found";
fOk=FALSE;
};
pszMsgInfo0="not found";
fOk=FALSE;
};
};
if (!fOk)
{
GSWLogSized(GSW_CRITICAL,
p_pLogServerData,
256+SafeStrlen(p_pszParents)+SafeStrlen(p_pszKey)+SafeStrlen(pszMsgInfo0)+SafeStrlen(pszMsgInfo1),
"%s/%s %s %s",
(p_pszParents ? p_pszParents : ""),
(p_pszKey ? p_pszKey : ""),
(pszMsgInfo0 ? pszMsgInfo0 : ""),
(pszMsgInfo1 ? pszMsgInfo1 : ""));
if (pszMsgInfo0)
free(pszMsgInfo0);
if (pszMsgInfo1)
free(pszMsgInfo1);
};
{
GSWLogSized(GSW_CRITICAL,
p_pLogServerData,
256+SafeStrlen(p_pszParents)+SafeStrlen(p_pszKey)+
SafeStrlen(pszMsgInfo0)+SafeStrlen(pszMsgInfo1),
"%s/%s %s %s",
(p_pszParents ? p_pszParents : ""),
(p_pszKey ? p_pszKey : ""),
(pszMsgInfo0 ? pszMsgInfo0 : ""),
(pszMsgInfo1 ? pszMsgInfo1 : ""));
if (pszMsgInfo0)
free(pszMsgInfo0);
if (pszMsgInfo1)
free(pszMsgInfo1);
};
return fOk;
};
//--------------------------------------------------------------------
BOOL GSWPropList_TestString(proplist_t pl,
BOOL p_fErrorIfNotExists,
CONST char* p_pszKey,
CONST char* p_pszParents,
void* p_pLogServerData)
BOOL
GSWPropList_TestString(proplist_t pl,
BOOL p_fErrorIfNotExists,
CONST char *p_pszKey,
CONST char *p_pszParents,
void *p_pLogServerData)
{
char* pszMsgInfo0=NULL;
char* pszMsgInfo1=NULL;
char *pszMsgInfo0=NULL;
char *pszMsgInfo1=NULL;
BOOL fOk=TRUE;
if (pl)
{
if (!PLIsString(pl))
{
if (!PLIsString(pl))
{
CONST char* pszType=PLGetType(pl);
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
sprintf(pszMsgInfo0,"is not a string its a %s:",pszType);
pszMsgInfo1=PLGetDescription(pl);//We have to free it
fOk=FALSE;
};
}
CONST char *pszType=PLGetType(pl);
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
sprintf(pszMsgInfo0,"is not a string its a %s:",pszType);
pszMsgInfo1=PLGetDescription(pl);//We have to free it
fOk=FALSE;
};
}
else
{
if (p_fErrorIfNotExists)
{
if (p_fErrorIfNotExists)
{
pszMsgInfo0="not found";
fOk=FALSE;
};
pszMsgInfo0="not found";
fOk=FALSE;
};
};
if (!fOk)
{
GSWLogSized(GSW_CRITICAL,
p_pLogServerData,
256+SafeStrlen(p_pszParents)+SafeStrlen(p_pszKey)+SafeStrlen(pszMsgInfo0)+SafeStrlen(pszMsgInfo1),
"%s/%s %s %s",
(p_pszParents ? p_pszParents : ""),
(p_pszKey ? p_pszKey : ""),
(pszMsgInfo0 ? pszMsgInfo0 : ""),
(pszMsgInfo1 ? pszMsgInfo1 : ""));
if (pszMsgInfo0)
free(pszMsgInfo0);
if (pszMsgInfo1)
free(pszMsgInfo1);
};
{
GSWLogSized(GSW_CRITICAL,
p_pLogServerData,
256+SafeStrlen(p_pszParents)+SafeStrlen(p_pszKey)+
SafeStrlen(pszMsgInfo0)+SafeStrlen(pszMsgInfo1),
"%s/%s %s %s",
(p_pszParents ? p_pszParents : ""),
(p_pszKey ? p_pszKey : ""),
(pszMsgInfo0 ? pszMsgInfo0 : ""),
(pszMsgInfo1 ? pszMsgInfo1 : ""));
if (pszMsgInfo0)
free(pszMsgInfo0);
if (pszMsgInfo1)
free(pszMsgInfo1);
};
return fOk;
};
//--------------------------------------------------------------------
//Do not destroy the returned proplist !
proplist_t GSWPropList_GetDictionaryEntry(proplist_t p_propListDictionary,
CONST char* p_pszKey,
CONST char* p_pszParents,
BOOL p_fErrorIfNotExists,
PLTypeTestFn p_pTestFn,
void* p_pLogServerData)
proplist_t
GSWPropList_GetDictionaryEntry(proplist_t p_propListDictionary,
CONST char *p_pszKey,
CONST char *p_pszParents,
BOOL p_fErrorIfNotExists,
PLTypeTestFn p_pTestFn,
void *p_pLogServerData)
{
proplist_t propListKey=PLMakeString((char*)p_pszKey);
proplist_t propListKey=PLMakeString((char *)p_pszKey);
proplist_t propList=NULL;
if (GSWPropList_TestDictionary(p_propListDictionary,TRUE,NULL,p_pszParents,p_pLogServerData))
if (GSWPropList_TestDictionary(p_propListDictionary,TRUE,NULL,
p_pszParents,p_pLogServerData))
{
propList=PLGetDictionaryEntry(p_propListDictionary,propListKey);
if (p_pTestFn)
{
propList=PLGetDictionaryEntry(p_propListDictionary,propListKey);
if (p_pTestFn)
{
if (!(*p_pTestFn)(propList,p_fErrorIfNotExists,p_pszKey,p_pszParents,p_pLogServerData))
propList=NULL;
};
if (!(*p_pTestFn)(propList,p_fErrorIfNotExists,
p_pszKey,p_pszParents,p_pLogServerData))
propList=NULL;
};
};
PLRelease(propListKey);
return propList;
};
//--------------------------------------------------------------------
//Do not destroy the returned proplist !
proplist_t GSWPropList_GetArrayElement(proplist_t p_propListArray,
int p_iIndex,
CONST char* p_pszParents,
BOOL p_fErrorIfNotExists,
PLTypeTestFn p_pTestFn,
void* p_pLogServerData)
proplist_t
GSWPropList_GetArrayElement(proplist_t p_propListArray,
int p_iIndex,
CONST char *p_pszParents,
BOOL p_fErrorIfNotExists,
PLTypeTestFn p_pTestFn,
void *p_pLogServerData)
{
proplist_t propList=NULL;
if (GSWPropList_TestArray(p_propListArray,TRUE,NULL,p_pszParents,p_pLogServerData))
if (GSWPropList_TestArray(p_propListArray,TRUE,NULL,
p_pszParents,p_pLogServerData))
{
propList=PLGetArrayElement(p_propListArray,p_iIndex);
if (p_pTestFn)
{
propList=PLGetArrayElement(p_propListArray,p_iIndex);
if (p_pTestFn)
{
char szKey[120]="";
sprintf(szKey,"index: %d",p_iIndex);
if (!(*p_pTestFn)(propList,p_fErrorIfNotExists,szKey,p_pszParents,p_pLogServerData))
propList=NULL;
};
char szKey[120]="";
sprintf(szKey,"index: %d",p_iIndex);
if (!(*p_pTestFn)(propList,p_fErrorIfNotExists,szKey,
p_pszParents,p_pLogServerData))
propList=NULL;
};
};
return propList;
};
//--------------------------------------------------------------------
//You have to free the returned proplist !
proplist_t GSWPropList_GetAllDictionaryKeys(proplist_t p_propListDictionary,
CONST char* p_pszParents,
BOOL p_fErrorIfNotExists,
PLTypeTestFn p_pTestFn,
void* p_pLogServerData)
proplist_t
GSWPropList_GetAllDictionaryKeys(proplist_t p_propListDictionary,
CONST char *p_pszParents,
BOOL p_fErrorIfNotExists,
PLTypeTestFn p_pTestFn,
void *p_pLogServerData)
{
proplist_t propList=NULL;
if (GSWPropList_TestDictionary(p_propListDictionary,TRUE,NULL,p_pszParents,p_pLogServerData))
if (GSWPropList_TestDictionary(p_propListDictionary,TRUE,NULL,
p_pszParents,p_pLogServerData))
{
propList=PLGetAllDictionaryKeys(p_propListDictionary);
if (p_pTestFn)
{
propList=PLGetAllDictionaryKeys(p_propListDictionary);
if (p_pTestFn)
{
if (!(*p_pTestFn)(propList,p_fErrorIfNotExists,NULL,p_pszParents,p_pLogServerData))
propList=NULL;
};
if (!(*p_pTestFn)(propList,p_fErrorIfNotExists,NULL,
p_pszParents,p_pLogServerData))
propList=NULL;
};
};
return propList;
};

View file

@ -1,8 +1,8 @@
/* GSWPropList.h - GSWeb: PropList
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: March 2000
Date: March 2000
This file is part of the GNUstep Web Library.
@ -28,44 +28,48 @@
#include <time.h>
#include "GSWList.h"
typedef BOOL (*PLTypeTestFn)(proplist_t pl,BOOL p_fErrorIfNotExists,CONST char* p_pszKey,CONST char* p_pszParents,void* p_pLogServerData);
typedef BOOL (*PLTypeTestFn)(proplist_t pl,
BOOL p_fErrorIfNotExists,
CONST char *p_pszKey,
CONST char *p_pszParents,
void *p_pLogServerData);
CONST char* PLGetType(proplist_t pl);
BOOL GSWPropList_TestDictionary(proplist_t pl,
BOOL p_fErrorIfNotExists,
CONST char* p_pszKey,
CONST char* p_pszParents,
void* p_pLogServerData);
BOOL GSWPropList_TestArray(proplist_t pl,
BOOL p_fErrorIfNotExists,
CONST char* p_pszKey,
CONST char* p_pszParents,
void* p_pLogServerData);
BOOL GSWPropList_TestString(proplist_t pl,
BOOL p_fErrorIfNotExists,
CONST char* p_pszKey,
CONST char* p_pszParents,
void* p_pLogServerData);
CONST char *PLGetType(proplist_t pl);
BOOL GSWPropList_TestDictionary(proplist_t pl,
BOOL p_fErrorIfNotExists,
CONST char *p_pszKey,
CONST char *p_pszParents,
void *p_pLogServerData);
BOOL GSWPropList_TestArray(proplist_t pl,
BOOL p_fErrorIfNotExists,
CONST char *p_pszKey,
CONST char *p_pszParents,
void *p_pLogServerData);
BOOL GSWPropList_TestString(proplist_t pl,
BOOL p_fErrorIfNotExists,
CONST char *p_pszKey,
CONST char *p_pszParents,
void *p_pLogServerData);
//Do not destroy the returned proplist !
proplist_t GSWPropList_GetDictionaryEntry(proplist_t p_propListDictionary,
CONST char* p_pszKey,
CONST char* p_pszParents,
BOOL p_fErrorIfNotExists,
PLTypeTestFn p_pTestFn,
void* p_pLogServerData);
proplist_t GSWPropList_GetDictionaryEntry(proplist_t p_propListDictionary,
CONST char *p_pszKey,
CONST char *p_pszParents,
BOOL p_fErrorIfNotExists,
PLTypeTestFn p_pTestFn,
void *p_pLogServerData);
//Do not destroy the returned proplist !
proplist_t GSWPropList_GetArrayElement(proplist_t p_propListArray,
int p_iIndex,
CONST char* p_pszParents,
BOOL p_fErrorIfNotExists,
PLTypeTestFn p_pTestFn,
void* p_pLogServerData);
proplist_t GSWPropList_GetArrayElement(proplist_t p_propListArray,
int p_iIndex,
CONST char *p_pszParents,
BOOL p_fErrorIfNotExists,
PLTypeTestFn p_pTestFn,
void *p_pLogServerData);
//You have to free the returned proplist !
proplist_t GSWPropList_GetAllDictionaryKeys(proplist_t p_propListDictionary,
CONST char* p_pszParents,
BOOL p_fErrorIfNotExists,
PLTypeTestFn p_pTestFn,
void* p_pLogServerData);
proplist_t GSWPropList_GetAllDictionaryKeys(proplist_t p_propListDictionary,
CONST char *p_pszParents,
BOOL p_fErrorIfNotExists,
PLTypeTestFn p_pTestFn,
void *p_pLogServerData);
#endif //_GSWPropList_h__

View file

@ -1,8 +1,8 @@
/* GSWString.c - GSWeb: Adaptors: String
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: Jully 1999
This file is part of the GNUstep Web Library.
@ -33,61 +33,67 @@
//--------------------------------------------------------------------
GSWString* GSWString_New()
GSWString *
GSWString_New()
{
GSWString* pString = malloc(sizeof(GSWString));
GSWString *pString = malloc(sizeof(GSWString));
memset(pString,0,sizeof(GSWString));
return pString;
};
//--------------------------------------------------------------------
void GSWString_Free(GSWString* p_pString)
void
GSWString_Free(GSWString *p_pString)
{
if (p_pString)
{
if (p_pString->pszData)
{
if (p_pString->pszData)
{
free(p_pString->pszData);
p_pString->pszData=NULL;
};
free(p_pString);
free(p_pString->pszData);
p_pString->pszData=NULL;
};
free(p_pString);
};
};
//--------------------------------------------------------------------
int GSWString_Len(GSWString* p_pString)
int
GSWString_Len(GSWString *p_pString)
{
return p_pString->iLen;
};
//--------------------------------------------------------------------
void GSWString_Detach(GSWString* p_pString)
void
GSWString_Detach(GSWString *p_pString)
{
memset(p_pString,0,sizeof(GSWString));
};
//--------------------------------------------------------------------
void GSWString_GrowUpToSize(GSWString* p_pString,
int p_iSize)
void
GSWString_GrowUpToSize(GSWString *p_pString,
int p_iSize)
{
if (p_iSize>p_pString->iSize)
{
if (!p_pString->pszData)
{
if (!p_pString->pszData)
{
p_pString->iSize=max(p_iSize,4096);
p_pString->pszData=malloc(p_pString->iSize);
}
else
{
p_pString->iSize=max(p_iSize,4096);
p_pString->pszData=realloc(p_pString->pszData,p_pString->iSize);
};
p_pString->iSize=max(p_iSize,4096);
p_pString->pszData=malloc(p_pString->iSize);
}
else
{
p_pString->iSize=max(p_iSize,4096);
p_pString->pszData=realloc(p_pString->pszData,p_pString->iSize);
};
};
};
//--------------------------------------------------------------------
void GSWString_Append(GSWString* p_pString,
CONST char* p_pszString)
void
GSWString_Append(GSWString *p_pString,
CONST char *p_pszString)
{
int iLen = strlen(p_pszString);
GSWString_GrowUpToSize(p_pString,p_pString->iLen+iLen+1);
@ -96,33 +102,34 @@ void GSWString_Append(GSWString* p_pString,
};
//--------------------------------------------------------------------
void GSWString_SearchReplace(GSWString* p_pString,
CONST char* p_pszSearch,
CONST char* p_pszReplace)
void
GSWString_SearchReplace(GSWString *p_pString,
CONST char *p_pszSearch,
CONST char *p_pszReplace)
{
int iSearchLen=SafeStrlen(p_pszSearch);
if (iSearchLen>0)
{
char *p=strstr(p_pString->pszData,p_pszSearch);
if (p)
{
char* p=strstr(p_pString->pszData,p_pszSearch);
if (p)
{
int iIndex=0;
int iReplaceLen=SafeStrlen(p_pszReplace);
int iDiff=iReplaceLen-iSearchLen;
while(p)
{
iIndex=p-p_pString->pszData;
if (iDiff>0)
GSWString_GrowUpToSize(p_pString,p_pString->iSize+iDiff);
if (iDiff!=0)
memmove(p_pString->pszData+iIndex+iReplaceLen,
p_pString->pszData+iIndex+iSearchLen,
p_pString->iLen-iIndex-iSearchLen+1);
if (iReplaceLen>0)
memcpy(p_pString->pszData+iIndex,p_pszReplace,iReplaceLen);
p_pString->iLen+=iDiff;
p=strstr(p_pString->pszData+iIndex+iReplaceLen,p_pszSearch);
};
};
int iIndex=0;
int iReplaceLen=SafeStrlen(p_pszReplace);
int iDiff=iReplaceLen-iSearchLen;
while(p)
{
iIndex=p-p_pString->pszData;
if (iDiff>0)
GSWString_GrowUpToSize(p_pString,p_pString->iSize+iDiff);
if (iDiff!=0)
memmove(p_pString->pszData+iIndex+iReplaceLen,
p_pString->pszData+iIndex+iSearchLen,
p_pString->iLen-iIndex-iSearchLen+1);
if (iReplaceLen>0)
memcpy(p_pString->pszData+iIndex,p_pszReplace,iReplaceLen);
p_pString->iLen+=iDiff;
p=strstr(p_pString->pszData+iIndex+iReplaceLen,p_pszSearch);
};
};
};
};

View file

@ -1,8 +1,8 @@
/* GSWString.h - GSWeb: String
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -30,20 +30,20 @@ extern "C" {
typedef struct _GSWString
{
int iSize;
int iLen;
char* pszData;
int iSize;
int iLen;
char *pszData;
} GSWString;
GSWString* GSWString_New();
int GSWString_Len(GSWString* p_pString);
void GSWString_Free(GSWString* p_pString);
void GSWString_Detach(GSWString* p_pString);
void GSWString_Append(GSWString* p_pString,
CONST char* p_pszString);
void GSWString_SearchReplace(GSWString* p_pString,
CONST char* p_pszSearch,
CONST char* p_pszReplace);
GSWString *GSWString_New();
int GSWString_Len(GSWString *p_pString);
void GSWString_Free(GSWString *p_pString);
void GSWString_Detach(GSWString *p_pString);
void GSWString_Append(GSWString *p_pString,
CONST char *p_pszString);
void GSWString_SearchReplace(GSWString *p_pString,
CONST char *p_pszSearch,
CONST char *p_pszReplace);
#ifdef __cplusplus
} // end of C header
#endif //_cplusplus

View file

@ -1,8 +1,8 @@
/* GSWTemplates.c - GSWeb: GSWTemplates
Copyright (C) 2000 Free Software Foundation, Inc.
Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: March 2000
Date: March 2000
This file is part of the GNUstep Web Library.
@ -34,7 +34,7 @@
#include "GSWTemplates.h"
//--------------------------------------------------------------------
const char* g_szErrorResponseTextTemplate[2]={
const char *g_szErrorResponseTextTemplate[2]={
"##TEXT##",
"<HTML><BODY BGCOLOR=\"#FFFFFF\">\n"
"<CENTER><H1>##TEXT##</H1></CENTER>\n"
@ -43,12 +43,12 @@ const char* g_szErrorResponseTextTemplate[2]={
"</BODY></HTML>\n"};
//--------------------------------------------------------------------
const char* g_szErrorNoResponseMessageTemplate[2]={
const char *g_szErrorNoResponseMessageTemplate[2]={
"##APP_NAME##:##APP_INSTANCE## (##APP_HOST##:##APP_PORT##) doesn't repond",
"##APP_NAME##:##APP_INSTANCE## (##APP_HOST##:##APP_PORT##) doesn't repond"};
//--------------------------------------------------------------------
const char* g_szStatusResponseAllowedTemplate[2]={
const char *g_szStatusResponseAllowedTemplate[2]={
"Server Status\n"
"##SERVER_INFO## ##SERVER_URL##\n"
"##ADAPTOR_INFO## ##ADAPTOR_URL##\n"
@ -66,7 +66,7 @@ const char* g_szStatusResponseAllowedTemplate[2]={
"</BODY></HTML>\n"};
//--------------------------------------------------------------------
const char* g_szStatusResponseDeniedTemplate[2]={
const char *g_szStatusResponseDeniedTemplate[2]={
"Don't play with me ##REMOTE_ADDR## ##REMOTE_HOST##, I'll win!\n",
"<HTML><HEAD><TITLE>Server Status</TITLE></HEAD>\n"
@ -77,7 +77,7 @@ const char* g_szStatusResponseDeniedTemplate[2]={
"</BODY></HTML>\n"};
//--------------------------------------------------------------------
const char* g_szDump_HeadTemplate[2]={
const char *g_szDump_HeadTemplate[2]={
"GNUstepWeb Application\n",
"<HTML><HEAD><TITLE>Index of GNUstepWeb Applications</TITLE></HEAD>\n"
"<BODY BGCOLOR=\"#FFFFFF\">"
@ -96,7 +96,7 @@ const char* g_szDump_HeadTemplate[2]={
"</tr>\n"};
//--------------------------------------------------------------------
const char* g_szDump_FootTemplate[2]={
const char *g_szDump_FootTemplate[2]={
"",
"</table></CENTER>\n"
"<BR>\n"
@ -104,7 +104,7 @@ const char* g_szDump_FootTemplate[2]={
"</BODY></HTML>"};
//--------------------------------------------------------------------
char* g_szDump_AppTemplate[2]={
char *g_szDump_AppTemplate[2]={
"AppName: ##NAME##\n"
"URL: ##URL##\n"
"Instances:\n"
@ -119,7 +119,7 @@ char* g_szDump_AppTemplate[2]={
"</TR>\n"};
//--------------------------------------------------------------------
char* g_szDump_AppInstanceTemplate[2]={
char *g_szDump_AppInstanceTemplate[2]={
"Instance ##NUM##\n"
"URL: ##URL##\n"
"HOST: ##HOST##\n"
@ -132,36 +132,45 @@ char* g_szDump_AppInstanceTemplate[2]={
"</TR>"};
//--------------------------------------------------------------------
char* GSWTemplate_GetTemplate(BOOL p_fHTML,GSWApp* pApp,CONST char* p_pszTemplateName)
char *
GSWTemplate_GetTemplate(BOOL p_fHTML,
GSWApp *pApp,
CONST char *p_pszTemplateName)
{
char* pszTemplate=NULL;
char *pszTemplate=NULL;
if (pApp && pApp->pszAdaptorTemplatesPath && p_pszTemplateName)
{
FILE* fd=NULL;
GSWConfig* gswConfig=GSWConfig_GetConfig();
int applen=strlen(pApp->pszAdaptorTemplatesPath)+strlen(p_pszTemplateName);
int globallen=strlen(gswConfig->pszAdaptorTemplatesPath)+strlen(p_pszTemplateName);
FILE *fd=NULL;
GSWConfig *gswConfig=GSWConfig_GetConfig();
int applen=strlen(pApp->pszAdaptorTemplatesPath)+
strlen(p_pszTemplateName);
int globallen=strlen(gswConfig->pszAdaptorTemplatesPath)+
strlen(p_pszTemplateName);
int maxlen=(applen > globallen ? applen : globallen)+20;
{
char* pathName=malloc(maxlen);
char *pathName=malloc(maxlen);
memset(pathName,0,maxlen);
if (p_fHTML)
sprintf(pathName,"%s/%s.html",pApp->pszAdaptorTemplatesPath,p_pszTemplateName);
sprintf(pathName,"%s/%s.html",pApp->pszAdaptorTemplatesPath,
p_pszTemplateName);
else
sprintf(pathName,"%s/%s.txt",pApp->pszAdaptorTemplatesPath,p_pszTemplateName);
sprintf(pathName,"%s/%s.txt",pApp->pszAdaptorTemplatesPath,
p_pszTemplateName);
fd=fopen(pathName,"r");
if (!fd)
{
if (p_fHTML)
sprintf(pathName,"%s/%s.html",gswConfig->pszAdaptorTemplatesPath,p_pszTemplateName);
sprintf(pathName,"%s/%s.html",
gswConfig->pszAdaptorTemplatesPath,p_pszTemplateName);
else
sprintf(pathName,"%s/%s.txt",gswConfig->pszAdaptorTemplatesPath,p_pszTemplateName);
sprintf(pathName,"%s/%s.txt",
gswConfig->pszAdaptorTemplatesPath,p_pszTemplateName);
fd=fopen(pathName,"r");
}
if (fd)
{
char buff[4096]="";
GSWString* pBuffer=GSWString_New();
GSWString *pBuffer=GSWString_New();
while(fgets(buff,4096,fd))
{
GSWString_Append(pBuffer,buff);
@ -180,9 +189,11 @@ char* GSWTemplate_GetTemplate(BOOL p_fHTML,GSWApp* pApp,CONST char* p_pszTemplat
//--------------------------------------------------------------------
char* GSWTemplate_ErrorResponseText(BOOL p_fHTML,GSWApp* pApp)
char *
GSWTemplate_ErrorResponseText(BOOL p_fHTML,
GSWApp *pApp)
{
char* pszString=NULL;
char *pszString=NULL;
pszString=GSWTemplate_GetTemplate(p_fHTML,pApp,"ErrorResponseText");
if (!pszString)
pszString=strdup(g_szErrorResponseTextTemplate[p_fHTML ? 1 : 0]);
@ -190,9 +201,11 @@ char* GSWTemplate_ErrorResponseText(BOOL p_fHTML,GSWApp* pApp)
};
//--------------------------------------------------------------------
char* GSWTemplate_ErrorNoResponseMessage(BOOL p_fHTML,GSWApp* pApp)
char *
GSWTemplate_ErrorNoResponseMessage(BOOL p_fHTML,
GSWApp *pApp)
{
char* pszString=NULL;
char *pszString=NULL;
pszString=GSWTemplate_GetTemplate(p_fHTML,pApp,"ErrorNoResponse");
if (!pszString)
pszString=strdup(g_szErrorNoResponseMessageTemplate[p_fHTML ? 1 : 0]);
@ -200,9 +213,11 @@ char* GSWTemplate_ErrorNoResponseMessage(BOOL p_fHTML,GSWApp* pApp)
};
//--------------------------------------------------------------------
char* GSWTemplate_StatusAllowedResponse(BOOL p_fHTML,GSWApp* pApp)
char *
GSWTemplate_StatusAllowedResponse(BOOL p_fHTML,
GSWApp *pApp)
{
char* pszString=NULL;
char *pszString=NULL;
pszString=GSWTemplate_GetTemplate(p_fHTML,pApp,"StatusAllowedResponse");
if (!pszString)
pszString=strdup(g_szStatusResponseAllowedTemplate[p_fHTML ? 1 : 0]);
@ -210,9 +225,11 @@ char* GSWTemplate_StatusAllowedResponse(BOOL p_fHTML,GSWApp* pApp)
};
//--------------------------------------------------------------------
char* GSWTemplate_StatusDeniedResponse(BOOL p_fHTML,GSWApp* pApp)
char *
GSWTemplate_StatusDeniedResponse(BOOL p_fHTML,
GSWApp *pApp)
{
char* pszString=NULL;
char *pszString=NULL;
pszString=GSWTemplate_GetTemplate(p_fHTML,pApp,"StatusDeniedResponse");
if (!pszString)
pszString=strdup(g_szStatusResponseDeniedTemplate[p_fHTML ? 1 : 0]);
@ -220,9 +237,10 @@ char* GSWTemplate_StatusDeniedResponse(BOOL p_fHTML,GSWApp* pApp)
};
//--------------------------------------------------------------------
char* GSWTemplate_GetDumpHead(BOOL p_fHTML)
char *
GSWTemplate_GetDumpHead(BOOL p_fHTML)
{
char* pszString=NULL;
char *pszString=NULL;
/* pszString=GSWTemplate_GetTemplate(p_fHTML,pApp,"DumpHead");
if (!pszString)*/
pszString=strdup(g_szDump_HeadTemplate[p_fHTML ? 1 : 0]);
@ -230,9 +248,10 @@ char* GSWTemplate_GetDumpHead(BOOL p_fHTML)
};
//--------------------------------------------------------------------
char* GSWTemplate_GetDumpFoot(BOOL p_fHTML)
char *
GSWTemplate_GetDumpFoot(BOOL p_fHTML)
{
char* pszString=NULL;
char *pszString=NULL;
/* pszString=GSWTemplate_GetTemplate(p_fHTML,pApp,"DumpFoot");
if (!pszString)*/
pszString=strdup(g_szDump_FootTemplate[p_fHTML ? 1 : 0]);
@ -240,9 +259,10 @@ char* GSWTemplate_GetDumpFoot(BOOL p_fHTML)
};
//--------------------------------------------------------------------
char* GSWTemplate_GetDumpApp(BOOL p_fHTML)
char *
GSWTemplate_GetDumpApp(BOOL p_fHTML)
{
char* pszString=NULL;
char *pszString=NULL;
/* pszString=GSWTemplate_GetTemplate(p_fHTML,pApp,"DumpApp");
if (!pszString)*/
pszString=strdup(g_szDump_AppTemplate[p_fHTML ? 1 : 0]);
@ -250,9 +270,10 @@ char* GSWTemplate_GetDumpApp(BOOL p_fHTML)
};
//--------------------------------------------------------------------
char* GSWTemplate_GetDumpAppInstance(BOOL p_fHTML)
char *
GSWTemplate_GetDumpAppInstance(BOOL p_fHTML)
{
char* pszString=NULL;
char *pszString=NULL;
/* pszString=GSWTemplate_GetTemplate(p_fHTML,pApp,"DumpAppInstance");
if (!pszString)*/
pszString=strdup(g_szDump_AppInstanceTemplate[p_fHTML ? 1 : 0]);
@ -260,17 +281,20 @@ char* GSWTemplate_GetDumpAppInstance(BOOL p_fHTML)
};
//--------------------------------------------------------------------
void GSWTemplate_ReplaceStd(GSWString* p_pString,GSWApp* p_pApp)
void
GSWTemplate_ReplaceStd(GSWString *p_pString,
GSWApp *p_pApp)
{
GSWString_SearchReplace(p_pString,"##CONF_FILE##",GSWConfig_GetConfigFilePath());
GSWString_SearchReplace(p_pString,"##CONF_FILE##",
GSWConfig_GetConfigFilePath());
if (p_pApp)
{
GSWString_SearchReplace(p_pString,"##APP_NAME##",p_pApp->pszName);
};
{
GSWString_SearchReplace(p_pString,"##APP_NAME##",p_pApp->pszName);
};
if (p_pApp && p_pApp->pszGSWExtensionsFrameworkWebServerResources)
GSWString_SearchReplace(p_pString,"##GSWEXTFWKWSR##",
p_pApp->pszGSWExtensionsFrameworkWebServerResources);
GSWString_SearchReplace(p_pString,"##GSWEXTFWKWSR##",
p_pApp->pszGSWExtensionsFrameworkWebServerResources);
else
GSWString_SearchReplace(p_pString,"##GSWEXTFWKWSR##",
GSWConfig_GetConfig()->pszGSWExtensionsFrameworkWebServerResources);
GSWString_SearchReplace(p_pString,"##GSWEXTFWKWSR##",
GSWConfig_GetConfig()->pszGSWExtensionsFrameworkWebServerResources);
};

View file

@ -1,8 +1,8 @@
/* GSWTemplates.h - GSWeb: GSWTemplates
Copyright (C) 2000 Free Software Foundation, Inc.
Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: March 2000
Date: March 2000
This file is part of the GNUstep Web Library.
@ -27,14 +27,14 @@
#include "GSWApp.h"
//You need to free returned char
char* GSWTemplate_ErrorResponseText(BOOL p_fHTML,GSWApp* pApp);
char* GSWTemplate_ErrorNoResponseMessage(BOOL p_fHTML,GSWApp* pApp);
char* GSWTemplate_StatusAllowedResponse(BOOL p_fHTML,GSWApp* pApp);
char* GSWTemplate_StatusDeniedResponse(BOOL p_fHTML,GSWApp* pApp);
char* GSWTemplate_GetDumpHead(BOOL p_fHTML);
char* GSWTemplate_GetDumpFoot(BOOL p_fHTML);
char* GSWTemplate_GetDumpApp(BOOL p_fHTML);
char* GSWTemplate_GetDumpAppInstance(BOOL p_fHTML);
void GSWTemplate_ReplaceStd(GSWString* p_pString,GSWApp* p_pApp);
char *GSWTemplate_ErrorResponseText(BOOL p_fHTML, GSWApp *pApp);
char *GSWTemplate_ErrorNoResponseMessage(BOOL p_fHTML, GSWApp *pApp);
char *GSWTemplate_StatusAllowedResponse(BOOL p_fHTML, GSWApp *pApp);
char *GSWTemplate_StatusDeniedResponse(BOOL p_fHTML, GSWApp *pApp);
char *GSWTemplate_GetDumpHead(BOOL p_fHTML);
char *GSWTemplate_GetDumpFoot(BOOL p_fHTML);
char *GSWTemplate_GetDumpApp(BOOL p_fHTML);
char *GSWTemplate_GetDumpAppInstance(BOOL p_fHTML);
void GSWTemplate_ReplaceStd(GSWString *p_pString, GSWApp *p_pApp);
#endif //_GSWTemplates_h__

View file

@ -1,8 +1,8 @@
/* GSWURLUtil.c - GSWeb: Adaptors: URL Utils
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -36,225 +36,244 @@
#include "GSWURLUtil.h"
//--------------------------------------------------------------------
GSWURLError GSWParseURL(GSWURLComponents* p_pURLComponents,CONST char* p_pszURL,void* p_pLogServerData)
GSWURLError
GSWParseURL(GSWURLComponents *p_pURLComponents,
CONST char *p_pszURL,
void *p_pLogServerData)
{
GSWURLError eError=GSWURLError_OK;
GSWURLComponent* pURLCPrefix=&p_pURLComponents->stPrefix;
GSWURLComponent* pURLCVersion=&p_pURLComponents->stVersion;
GSWURLComponent* pURLCAppName=&p_pURLComponents->stAppName;
GSWURLComponent* pURLCAppNum=&p_pURLComponents->stAppNumber;
GSWURLComponent* pURLCReqHandlerKey=&p_pURLComponents->stRequestHandlerKey;
GSWURLComponent* pURLCReqHandlerPath=&p_pURLComponents->stRequestHandlerPath;
GSWURLComponent* pURLCQueryString=&p_pURLComponents->stQueryString;
GSWURLComponent *pURLCPrefix=&p_pURLComponents->stPrefix;
GSWURLComponent *pURLCVersion=&p_pURLComponents->stVersion;
GSWURLComponent *pURLCAppName=&p_pURLComponents->stAppName;
GSWURLComponent *pURLCAppNum=&p_pURLComponents->stAppNumber;
GSWURLComponent *pURLCReqHandlerKey=&p_pURLComponents->stRequestHandlerKey;
GSWURLComponent *pURLCReqHandlerPath=&p_pURLComponents->stRequestHandlerPath;
GSWURLComponent *pURLCQueryString=&p_pURLComponents->stQueryString;
int iURLLen=p_pszURL ? strlen(p_pszURL) : 0;
CONST char* pszStart=pszStart = (p_pszURL ? p_pszURL : "");
CONST char *pszStart=pszStart = (p_pszURL ? p_pszURL : "");
CONST char *pszStop=NULL;
CONST char *pszNext=NULL;
CONST char* pszPrefix=NULL;
CONST char *pszPrefix=NULL;
CONST char *pszS=NULL;
CONST char* pszURLEnd=p_pszURL+iURLLen;
CONST char* pszQueryStringMark=strchr(pszStart,'?');
CONST char* pszTmpStop=(pszQueryStringMark && pszQueryStringMark<pszURLEnd) ? pszQueryStringMark : pszURLEnd;
CONST char *pszURLEnd=p_pszURL+iURLLen;
CONST char *pszQueryStringMark=strchr(pszStart,'?');
CONST char *pszTmpStop=(pszQueryStringMark && pszQueryStringMark<pszURLEnd) ?
pszQueryStringMark : pszURLEnd;
int i, j;
memset(p_pURLComponents,0,sizeof(GSWURLComponents));
// First, get URL prefix
pszPrefix=strcasestr(pszStart,g_szGSWeb_Prefix);
if (pszPrefix && pszQueryStringMark && pszQueryStringMark<=pszPrefix)
pszPrefix=NULL;
pszPrefix=NULL;
if (pszPrefix)
{
CONST char *pszAppExtension=NULL;
CONST char *pszfoundExtension=NULL;
pszStop=pszPrefix+strlen(g_szGSWeb_Prefix);
pszNext=*pszStop ? pszStop+1 : pszStop; // Drop the trailing /
pURLCPrefix->pszStart = pszPrefix;
pURLCPrefix->iLength = pszStop-pszStart;
pURLCPrefix->iLength = max(pURLCPrefix->iLength,0);
pURLCVersion->pszStart = g_szGSWeb_AdaptorVersion;
pURLCVersion->iLength = strlen(g_szGSWeb_AdaptorVersion);
// Get Application Name
pszStart=pszNext;
pszAppExtension=strcasestr(pszStart,
g_szGSWeb_AppExtention[GSWNAMES_INDEX]);
if (pszAppExtension)
pszfoundExtension=g_szGSWeb_AppExtention[GSWNAMES_INDEX];
else
{
CONST char* pszAppExtension=NULL;
CONST char* pszfoundExtension=NULL;
pszStop=pszPrefix+strlen(g_szGSWeb_Prefix);
pszNext=*pszStop ? pszStop+1 : pszStop; // Drop the trailing /
pURLCPrefix->pszStart = pszPrefix;
pURLCPrefix->iLength = pszStop-pszStart;
pURLCPrefix->iLength = max(pURLCPrefix->iLength,0);
pURLCVersion->pszStart = g_szGSWeb_AdaptorVersion;
pURLCVersion->iLength = strlen(g_szGSWeb_AdaptorVersion);
// Get Application Name
pszStart=pszNext;
pszAppExtension=strcasestr(pszStart,g_szGSWeb_AppExtention[GSWNAMES_INDEX]);
if (pszAppExtension)
pszfoundExtension=g_szGSWeb_AppExtention[GSWNAMES_INDEX];
else
{
pszAppExtension=strcasestr(pszStart,g_szGSWeb_AppExtention[WONAMES_INDEX]);
if (pszAppExtension)
pszfoundExtension=g_szGSWeb_AppExtention[WONAMES_INDEX];
};
pszAppExtension=strcasestr(pszStart,
g_szGSWeb_AppExtention[WONAMES_INDEX]);
if (pszAppExtension)
{
if (pszQueryStringMark && pszQueryStringMark<=pszAppExtension)
{
pszAppExtension=NULL;
pszStop=pszURLEnd;
pszNext=pszStop;
}
else
{
pszStop=pszAppExtension;
pszNext=pszStop+strlen(pszfoundExtension);
};
}
pszfoundExtension=g_szGSWeb_AppExtention[WONAMES_INDEX];
};
if (pszAppExtension)
{
if (pszQueryStringMark && pszQueryStringMark<=pszAppExtension)
{
pszAppExtension=NULL;
pszStop=pszURLEnd;
pszNext=pszStop;
}
else
{
pszStop=strchr(pszStart,'/');
if (pszStop && pszQueryStringMark && pszQueryStringMark<=pszStop)
pszStop=pszQueryStringMark-1;
if (pszStop)
pszNext=pszStop+1;
else
{
pszStop=pszTmpStop;
pszNext=NULL;
};
};
pURLCAppName->pszStart = pszStart;
pURLCAppName->iLength = pszStop-pszStart;
pURLCAppName->iLength = max(pURLCAppName->iLength,0);
// Drop trailing slashes
while(pURLCAppName->iLength && pURLCAppName->pszStart[pURLCAppName->iLength-1]== '/')
pURLCAppName->iLength--;
pURLCAppName->iLength = max(pURLCAppName->iLength,0);
{
pszStop=pszAppExtension;
pszNext=pszStop+strlen(pszfoundExtension);
};
}
else
{
pszStop=strchr(pszStart,'/');
if (pszStop && pszQueryStringMark && pszQueryStringMark<=pszStop)
pszStop=pszQueryStringMark-1;
if (pszStop)
pszNext=pszStop+1;
else
{
pszStop=pszTmpStop;
pszNext=NULL;
};
};
pURLCAppName->pszStart = pszStart;
pURLCAppName->iLength = pszStop-pszStart;
pURLCAppName->iLength = max(pURLCAppName->iLength,0);
// Drop trailing slashes
while(pURLCAppName->iLength &&
pURLCAppName->pszStart[pURLCAppName->iLength-1]== '/')
pURLCAppName->iLength--;
pURLCAppName->iLength = max(pURLCAppName->iLength,0);
// Get Instance Number
pszStart = pszNext;
if (!pszStart)
{
pURLCAppNum->pszStart="";
pURLCAppNum->iLength=0;
}
else
{
// Skip slashes
while(*pszStart=='/')
pszStart++;
// Get Instance Number
pszStart = pszNext;
if (!pszStart)
// Find
for (pszS=pszStart;pszS<pszTmpStop && *pszS!='/';pszS++);
pszStop= pszS;
pszNext=(pszStop<pszTmpStop) ? pszStop+1 : pszStop;
pURLCAppNum->pszStart = pszStart;
pURLCAppNum->iLength = pszStop-pszStart;
pURLCAppNum->iLength = max(pURLCAppNum->iLength,0);
// -1 case ?
if (!(pURLCAppNum->iLength==2
&& pURLCAppNum->pszStart[0]=='-'
&& pURLCAppNum->pszStart[1]=='1'))
{
// Test if alldigits
for (pszS=pszStart;pszS<pszStop && isdigit(*pszS);pszS++);
if (pszS!=pszStop)
{
// not all digits, so it's the request handler key !
pURLCReqHandlerKey->pszStart = pURLCAppNum->pszStart;
pURLCReqHandlerKey->iLength = pURLCAppNum->iLength;
pURLCReqHandlerKey->iLength =
max(pURLCReqHandlerKey->iLength,0);
pURLCAppNum->pszStart="";
pURLCAppNum->iLength=0;
}
else
else
{
pszStart=pszNext;
// Skip slashes
while(*pszStart=='/')
pszStart++;
// Find
for (pszS=pszStart;pszS<pszTmpStop && *pszS!='/';pszS++);
pszStop= pszS;
pszNext=(pszStop<pszTmpStop) ? pszStop+1 : pszStop;
pURLCAppNum->pszStart = pszStart;
pURLCAppNum->iLength = pszStop-pszStart;
pURLCAppNum->iLength = max(pURLCAppNum->iLength,0);
// -1 case ?
if (!(pURLCAppNum->iLength==2
&& pURLCAppNum->pszStart[0]=='-'
&& pURLCAppNum->pszStart[1]=='1'))
{
// Test if alldigits
for (pszS=pszStart;pszS<pszStop && isdigit(*pszS);pszS++);
pszStart++;
if (pszS!=pszStop)
{
// not all digits, so it's the request handler key !
pURLCReqHandlerKey->pszStart = pURLCAppNum->pszStart;
pURLCReqHandlerKey->iLength = pURLCAppNum->iLength;
pURLCReqHandlerKey->iLength = max(pURLCReqHandlerKey->iLength,0);
pURLCAppNum->pszStart="";
pURLCAppNum->iLength=0;
}
else
{
pszStart=pszNext;
// Skip slashes
while(*pszStart=='/')
pszStart++;
for (pszS=pszStart;pszS<pszTmpStop && *pszS!='/';pszS++);
pszStop = pszS;
pURLCReqHandlerKey->pszStart = pszStart;
pURLCReqHandlerKey->iLength = pszStop-pszStart;
pURLCReqHandlerKey->iLength = max(pURLCReqHandlerKey->iLength,0);
pszNext=(pszStop<pszTmpStop) ? pszStop+1 : pszStop;
};
};
// Get Request Handler Path
pszStart = pszNext;
for (pszS=pszStart;pszS<pszTmpStop;pszS++);
for (pszS=pszStart;pszS<pszTmpStop && *pszS!='/';pszS++);
pszStop = pszS;
pURLCReqHandlerPath->pszStart = pszStart;
pURLCReqHandlerPath->iLength = pszStop-pszStart;
pURLCReqHandlerPath->iLength = max(pURLCReqHandlerPath->iLength,0);
pURLCReqHandlerKey->pszStart = pszStart;
pURLCReqHandlerKey->iLength = pszStop-pszStart;
pURLCReqHandlerKey->iLength =
max(pURLCReqHandlerKey->iLength,0);
pszNext=(pszStop<pszTmpStop) ? pszStop+1 : pszStop;
pszStart=pszNext;
};
// Query String
if (!pszStart)
pszStart=pszTmpStop;
pURLCQueryString->pszStart = pszStart;
pURLCQueryString->iLength = pszURLEnd - pszStart;
pURLCQueryString->iLength = max(pURLCQueryString->iLength,0);
};
// Get Request Handler Path
pszStart = pszNext;
for (pszS=pszStart;pszS<pszTmpStop;pszS++);
pszStop = pszS;
pURLCReqHandlerPath->pszStart = pszStart;
pURLCReqHandlerPath->iLength = pszStop-pszStart;
pURLCReqHandlerPath->iLength = max(pURLCReqHandlerPath->iLength,0);
pszNext=(pszStop<pszTmpStop) ? pszStop+1 : pszStop;
pszStart=pszNext;
};
// Query String
if (!pszStart)
pszStart=pszTmpStop;
pURLCQueryString->pszStart = pszStart;
pURLCQueryString->iLength = pszURLEnd - pszStart;
pURLCQueryString->iLength = max(pURLCQueryString->iLength,0);
};
if (!pURLCPrefix->pszStart || pURLCPrefix->iLength<=0)
{
eError=GSWURLError_InvalidPrefix;
GSWLog(GSW_ERROR,p_pLogServerData,"ParseURL GSWURLError_InvalidPrefix");
}
{
eError=GSWURLError_InvalidPrefix;
GSWLog(GSW_ERROR,p_pLogServerData,"ParseURL GSWURLError_InvalidPrefix");
}
else
{
GSWLog(GSW_DEBUG,p_pLogServerData,
"pURLCPrefix=%.*s",
pURLCPrefix->iLength,pURLCPrefix->pszStart);
if (!pURLCAppName->pszStart || pURLCAppName->iLength<=0)
{
eError=GSWURLError_InvalidAppName;
GSWLog(GSW_ERROR,p_pLogServerData,
"ParseURL GSWURLError_InvalidAppName");
}
else
{
GSWLog(GSW_DEBUG,p_pLogServerData,
"pURLCPrefix=%.*s",
pURLCPrefix->iLength,pURLCPrefix->pszStart);
if (!pURLCAppName->pszStart || pURLCAppName->iLength<=0)
{
eError=GSWURLError_InvalidAppName;
GSWLog(GSW_ERROR,p_pLogServerData,"ParseURL GSWURLError_InvalidAppName");
}
"pURLCAppName=%.*s",
pURLCAppName->iLength,pURLCAppName->pszStart);
if (!pURLCAppNum->pszStart)
{
eError=GSWURLError_InvalidAppNumber;
GSWLog(GSW_ERROR,p_pLogServerData,
"ParseURL GSWURLError_InvalidAppNumber");
}
else
{
GSWLog(GSW_DEBUG,p_pLogServerData,
"pURLCAppNum=%.*s",
pURLCAppNum->iLength,pURLCAppNum->pszStart);
if ((!pURLCReqHandlerKey->pszStart ||
pURLCReqHandlerKey->iLength<=0)
&& pURLCReqHandlerPath->iLength>0)
{
eError=GSWURLError_InvalidRequestHandlerKey;
GSWLog(GSW_ERROR,p_pLogServerData,
"ParseURL GSWURLError_InvalidRequestHandlerKey");
}
else
{
GSWLog(GSW_DEBUG,p_pLogServerData,
"pURLCAppName=%.*s",
pURLCAppName->iLength,pURLCAppName->pszStart);
if (!pURLCAppNum->pszStart)
{
eError=GSWURLError_InvalidAppNumber;
GSWLog(GSW_ERROR,p_pLogServerData,"ParseURL GSWURLError_InvalidAppNumber");
}
else
{
GSWLog(GSW_DEBUG,p_pLogServerData,
"pURLCAppNum=%.*s",
pURLCAppNum->iLength,pURLCAppNum->pszStart);
if ((!pURLCReqHandlerKey->pszStart || pURLCReqHandlerKey->iLength<=0)
&& pURLCReqHandlerPath->iLength>0)
{
eError=GSWURLError_InvalidRequestHandlerKey;
GSWLog(GSW_ERROR,p_pLogServerData,"ParseURL GSWURLError_InvalidRequestHandlerKey");
}
else
{
GSWLog(GSW_DEBUG,p_pLogServerData,
"pURLCReqHandlerPath=%.*s",
pURLCReqHandlerPath->iLength,pURLCReqHandlerPath->pszStart);
/*
if (!pURLCReqHandlerPath->pszStart || pURLCReqHandlerPath->iLength<=0)
eError=GSWURLError_InvalidRequestHandlerPath;
else if (!pURLCQueryString->pszStart || pURLCQueryString->iLength<=0)
eError=GSWURLError_InvalidQueryString;
*/
};
};
"pURLCReqHandlerPath=%.*s",
pURLCReqHandlerPath->iLength,
pURLCReqHandlerPath->pszStart);
/*
if (!pURLCReqHandlerPath->pszStart ||
pURLCReqHandlerPath->iLength<=0)
eError=GSWURLError_InvalidRequestHandlerPath;
else if (!pURLCQueryString->pszStart ||
pURLCQueryString->iLength<=0)
eError=GSWURLError_InvalidQueryString;
*/
};
};
};
};
GSWLog(GSW_DEBUG,p_pLogServerData,"End ParseURL eError=%d",eError);
return eError;
};
//--------------------------------------------------------------------
void GSWComposeURL(char* p_pszURL,GSWURLComponents* p_pURLComponents,void* p_pLogServerData)
void
GSWComposeURL(char *p_pszURL,
GSWURLComponents *p_pURLComponents,
void *p_pLogServerData)
{
GSWURLComponent* pURLCPrefix=&p_pURLComponents->stPrefix;
GSWURLComponent* pURLCAppName=&p_pURLComponents->stAppName;
GSWURLComponent* pURLCAppNum=&p_pURLComponents->stAppNumber;
GSWURLComponent* pURLCReqHandlerKey=&p_pURLComponents->stRequestHandlerKey;
GSWURLComponent* pURLCReqHandlerPath=&p_pURLComponents->stRequestHandlerPath;
GSWURLComponent* pURLCQueryString=&p_pURLComponents->stQueryString;
GSWURLComponent *pURLCPrefix=&p_pURLComponents->stPrefix;
GSWURLComponent *pURLCAppName=&p_pURLComponents->stAppName;
GSWURLComponent *pURLCAppNum=&p_pURLComponents->stAppNumber;
GSWURLComponent *pURLCReqHandlerKey=&p_pURLComponents->stRequestHandlerKey;
GSWURLComponent *pURLCReqHandlerPath=&p_pURLComponents->stRequestHandlerPath;
GSWURLComponent *pURLCQueryString=&p_pURLComponents->stQueryString;
strncpy(p_pszURL,pURLCPrefix->pszStart, pURLCPrefix->iLength);
p_pszURL+=pURLCPrefix->iLength;
@ -266,83 +285,91 @@ void GSWComposeURL(char* p_pszURL,GSWURLComponents* p_pURLComponents,void* p_pLo
p_pszURL+=strlen(g_szGSWeb_AppExtention[GSWNAMES_INDEX]);
if (pURLCAppNum->iLength>0)
{
*p_pszURL++='/';
strncpy(p_pszURL,pURLCAppNum->pszStart,pURLCAppNum->iLength);
p_pszURL+= pURLCAppNum->iLength;
{
*p_pszURL++='/';
strncpy(p_pszURL,pURLCAppNum->pszStart,pURLCAppNum->iLength);
p_pszURL+= pURLCAppNum->iLength;
};
if (pURLCReqHandlerKey->iLength>0)
{
*p_pszURL++='/';
strncpy(p_pszURL, pURLCReqHandlerKey->pszStart,pURLCReqHandlerKey->iLength);
p_pszURL+= pURLCReqHandlerKey->iLength;
{
*p_pszURL++='/';
strncpy(p_pszURL, pURLCReqHandlerKey->pszStart,
pURLCReqHandlerKey->iLength);
p_pszURL+= pURLCReqHandlerKey->iLength;
};
if (pURLCReqHandlerPath->iLength>0)
{
{
*p_pszURL++='/';
strncpy(p_pszURL, pURLCReqHandlerPath->pszStart,pURLCReqHandlerPath->iLength);
strncpy(p_pszURL, pURLCReqHandlerPath->pszStart,
pURLCReqHandlerPath->iLength);
p_pszURL+= pURLCReqHandlerPath->iLength;
};
};
if (pURLCQueryString->iLength>0)
{
{
*p_pszURL++='?';
strncpy(p_pszURL,pURLCQueryString->pszStart,pURLCQueryString->iLength);
strncpy(p_pszURL,pURLCQueryString->pszStart,
pURLCQueryString->iLength);
p_pszURL+= pURLCQueryString->iLength;
};
};
*p_pszURL=0;
};
//--------------------------------------------------------------------
int GSWComposeURLLen(GSWURLComponents* p_pURLComponents,void* p_pLogServerData)
int
GSWComposeURLLen(GSWURLComponents *p_pURLComponents,
void *p_pLogServerData)
{
int iLength=0;
GSWURLComponent* pURLCPrefix=&p_pURLComponents->stPrefix;
GSWURLComponent* pURLCAppName=&p_pURLComponents->stAppName;
GSWURLComponent* pURLCAppNum=&p_pURLComponents->stAppNumber;
GSWURLComponent* pURLCReqHandlerKey=&p_pURLComponents->stRequestHandlerKey;
GSWURLComponent* pURLCReqHandlerPath=&p_pURLComponents->stRequestHandlerPath;
GSWURLComponent* pURLCQueryString=&p_pURLComponents->stQueryString;
GSWURLComponent *pURLCPrefix=&p_pURLComponents->stPrefix;
GSWURLComponent *pURLCAppName=&p_pURLComponents->stAppName;
GSWURLComponent *pURLCAppNum=&p_pURLComponents->stAppNumber;
GSWURLComponent *pURLCReqHandlerKey=&p_pURLComponents->stRequestHandlerKey;
GSWURLComponent *pURLCReqHandlerPath=&p_pURLComponents->stRequestHandlerPath;
GSWURLComponent *pURLCQueryString=&p_pURLComponents->stQueryString;
iLength+=pURLCPrefix->iLength;
iLength+=1+pURLCAppName->iLength;
iLength+=strlen(g_szGSWeb_AppExtention[GSWNAMES_INDEX]);
if (pURLCAppNum->iLength>0)
iLength+= 1+pURLCAppNum->iLength;
iLength+= 1+pURLCAppNum->iLength;
if (pURLCReqHandlerKey->iLength>0)
iLength+=1+pURLCReqHandlerKey->iLength;
iLength+=1+pURLCReqHandlerKey->iLength;
if (pURLCReqHandlerPath->iLength>0)
iLength+= 1+pURLCReqHandlerPath->iLength;
iLength+= 1+pURLCReqHandlerPath->iLength;
if (pURLCQueryString->iLength>0)
iLength+=1+pURLCQueryString->iLength;
iLength+=1+pURLCQueryString->iLength;
return iLength;
};
//--------------------------------------------------------------------
CONST char* szGSWURLErrorMessage[]=
CONST char *szGSWURLErrorMessage[]=
{
"", // GSWURLError_OK
"Invalid prefix in URL", // GSWURLError_InvalidPrefix
"Invalid version in URL", // GSWURLError_InvalidVersion
"Invalid application name", // GSWURLError_InvalidAppName
"Invalid application number in URL", // GSWURLError_InvalidAppNumber,
"Invalid request handler key in URL", // GSWURLError_InvalidRequestHandlerKey,
"Invalid request handler path in URL", // GSWURLError_InvalidRequestHandlerPath,
"Invalid application host name in URL", // GSWURLError_InvalidAppHost,
"Invalid page name in URL", // GSWURLError_InvalidPageName,
"Invalid session ID in URL", // GSWURLError_InvalidSessionID,
"Invalid context ID in URL", // GSWURLError_InvalidContextID,
"Invalid sender ID in URL", // GSWURLError_InvalidSenderID,
"Invalid query string in URL", // GSWURLError_InvalidQueryString,
"Invalid suffix in URL" // GSWURLError_InvalidSuffix
"", //GSWURLError_OK
"Invalid prefix in URL", //GSWURLError_InvalidPrefix
"Invalid version in URL", //GSWURLError_InvalidVersion
"Invalid application name", //GSWURLError_InvalidAppName
"Invalid application number in URL", //GSWURLError_InvalidAppNumber,
"Invalid request handler key in URL", //GSWURLError_InvalidRequestHandlerKey,
"Invalid request handler path in URL",//GSWURLError_InvalidRequestHandlerPath,
"Invalid application host name in URL",//GSWURLError_InvalidAppHost,
"Invalid page name in URL", //GSWURLError_InvalidPageName,
"Invalid session ID in URL", //GSWURLError_InvalidSessionID,
"Invalid context ID in URL", //GSWURLError_InvalidContextID,
"Invalid sender ID in URL", //GSWURLError_InvalidSenderID,
"Invalid query string in URL", //GSWURLError_InvalidQueryString,
"Invalid suffix in URL" //GSWURLError_InvalidSuffix
};
CONST char* GSWURLErrorMessage(GSWURLError p_eError,void* p_pLogServerData)
CONST char *
GSWURLErrorMessage(GSWURLError p_eError,
void *p_pLogServerData)
{
if (p_eError>=0 && p_eError<sizeof(szGSWURLErrorMessage)/sizeof(szGSWURLErrorMessage[0]))
return szGSWURLErrorMessage[p_eError];
if (p_eError>=0 &&
p_eError<sizeof(szGSWURLErrorMessage)/sizeof(szGSWURLErrorMessage[0]))
return szGSWURLErrorMessage[p_eError];
else
return "";
return "";
};

View file

@ -1,8 +1,8 @@
/* GSWURLUtil.h - GSWeb: Adaptors: URL Utils
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -30,8 +30,8 @@ extern "C" {
typedef struct _GSWURLComponent
{
CONST char* pszStart;
int iLength;
CONST char *pszStart;
int iLength;
} GSWURLComponent;
typedef struct _GSWURLComponents
@ -69,10 +69,20 @@ typedef enum
GSWURLError_InvalidSuffix
} GSWURLError;
GSWURLError GSWParseURL(GSWURLComponents* p_pURLComponents,CONST char* p_pszURL,void* p_pLogServerData);
void GSWComposeURL(char* p_pszURL,GSWURLComponents* p_pURLComponents,void* p_pLogServerData);
int GSWComposeURLLen(GSWURLComponents* p_pURLComponents,void* p_pLogServerData);
CONST char* GSWURLErrorMessage(GSWURLError p_eError,void* p_pLogServerData);
GSWURLError GSWParseURL(GSWURLComponents *p_pURLComponents,
CONST char *p_pszURL,
void *p_pLogServerData);
void GSWComposeURL(char *p_pszURL,
GSWURLComponents *p_pURLComponents,
void *p_pLogServerData);
int GSWComposeURLLen(GSWURLComponents *p_pURLComponents,
void *p_pLogServerData);
CONST char *GSWURLErrorMessage(GSWURLError p_eError,
void *p_pLogServerData);
#ifdef __cplusplus
}
#endif //_cplusplus

View file

@ -1,8 +1,8 @@
/* GSWUtil.c - GSWeb: Util
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -53,29 +53,32 @@
// Hosts Cache
static GSWDict* g_pHostCache = NULL;
static GSWDict *g_pHostCache = NULL;
//--------------------------------------------------------------------
void GSWLog_Init(GSWDict* p_pDict,int p_iLevel)
void
GSWLog_Init(GSWDict *p_pDict,
int p_iLevel)
{
};
//--------------------------------------------------------------------
void VGSWLogSizedIntern(char* file,
int line,
char* fn,
int p_iLevel,
void
VGSWLogSizedIntern(char *file,
int line,
char *fn,
int p_iLevel,
#if defined(Apache)
server_rec* p_pLogServerData,
server_rec *p_pLogServerData,
#else
void* p_pLogServerData,
void *p_pLogServerData,
#endif
int p_iBufferSize,
CONST char* p_pszFormat,
va_list ap)
int p_iBufferSize,
CONST char *p_pszFormat,
va_list ap)
{
FILE* pLog = NULL;
FILE *pLog = NULL;
char szBuffer[p_iBufferSize+512];
szBuffer[0] = 0;
@ -89,228 +92,244 @@ void VGSWLogSizedIntern(char* file,
#if defined(Apache)
#if defined(Apache2)
ap_log_error(APLOG_MARK,p_iLevel,0,
(server_rec*)p_pLogServerData,
"%s",szBuffer);
(server_rec *)p_pLogServerData,
"%s",szBuffer);
#else
ap_log_error(APLOG_MARK,p_iLevel,
(server_rec*)p_pLogServerData,
"%s",szBuffer);
(server_rec *)p_pLogServerData,
"%s",szBuffer);
#endif
#endif
};
//--------------------------------------------------------------------
void GSWLog(int p_iLevel,
void
GSWLog(int p_iLevel,
#if defined(Apache)
server_rec* p_pLogServerData,
server_rec *p_pLogServerData,
#else
void* p_pLogServerData,
void *p_pLogServerData,
#endif
CONST char *p_pszFormat, ...)
CONST char *p_pszFormat, ...)
{
va_list ap;
va_start(ap,p_pszFormat);
VGSWLogSizedIntern(NULL,
0,
NULL,
p_iLevel,
p_pLogServerData,
4096,
p_pszFormat,
ap);
0,
NULL,
p_iLevel,
p_pLogServerData,
4096,
p_pszFormat,
ap);
va_end(ap);
};
//--------------------------------------------------------------------
void GSWLogSized(int p_iLevel,
void
GSWLogSized(int p_iLevel,
#if defined(Apache)
server_rec* p_pLogServerData,
server_rec *p_pLogServerData,
#else
void* p_pLogServerData,
void *p_pLogServerData,
#endif
int p_iBufferSize,
CONST char *p_pszFormat, ...)
int p_iBufferSize,
CONST char *p_pszFormat, ...)
{
va_list ap;
va_start(ap,p_pszFormat);
VGSWLogSizedIntern(NULL,
0,
NULL,
p_iLevel,
p_pLogServerData,
p_iBufferSize,
p_pszFormat,
ap);
0,
NULL,
p_iLevel,
p_pLogServerData,
p_iBufferSize,
p_pszFormat,
ap);
va_end(ap);
};
//--------------------------------------------------------------------
void GSWLogIntern(char* file,
int line,
char* fn,
int p_iLevel,
void
GSWLogIntern(char *file,
int line,
char *fn,
int p_iLevel,
#if defined(Apache)
server_rec* p_pLogServerData,
server_rec *p_pLogServerData,
#else
void* p_pLogServerData,
void *p_pLogServerData,
#endif
CONST char* p_pszFormat,...)
CONST char *p_pszFormat,...)
{
va_list ap;
va_start(ap,p_pszFormat);
VGSWLogSizedIntern(file,
line,
fn,
p_iLevel,
p_pLogServerData,
4096,
p_pszFormat,
ap);
line,
fn,
p_iLevel,
p_pLogServerData,
4096,
p_pszFormat,
ap);
va_end(ap);
};
//--------------------------------------------------------------------
void GSWLogSizedIntern(char* file,
int line,
char* fn,
int p_iLevel,
void
GSWLogSizedIntern(char *file,
int line,
char *fn,
int p_iLevel,
#if defined(Apache)
server_rec* p_pLogServerData,
server_rec *p_pLogServerData,
#else
void* p_pLogServerData,
void *p_pLogServerData,
#endif
int p_iBufferSize,
CONST char* p_pszFormat,...)
int p_iBufferSize,
CONST char *p_pszFormat,...)
{
va_list ap;
va_start(ap,p_pszFormat);
VGSWLogSizedIntern(file,
line,
fn,
p_iLevel,
p_pLogServerData,
p_iBufferSize,
p_pszFormat,
ap);
line,
fn,
p_iLevel,
p_pLogServerData,
p_iBufferSize,
p_pszFormat,
ap);
va_end(ap);
};
//--------------------------------------------------------------------
// return new len
int DeleteTrailingCRNL(char* p_pszString)
int
DeleteTrailingCRNL(char *p_pszString)
{
int i=0;
if (p_pszString)
{
i=strlen(p_pszString)-1;
while (i>=0 && p_pszString[i] && (p_pszString[i]=='\r' || p_pszString[i]=='\n'))
p_pszString[i--]=0;
i++;
};
{
i=strlen(p_pszString)-1;
while (i>=0 && p_pszString[i] &&
(p_pszString[i]=='\r' || p_pszString[i]=='\n'))
p_pszString[i--]=0;
i++;
};
return i;
}
//--------------------------------------------------------------------
int DeleteTrailingSlash(char* p_pszString)
int
DeleteTrailingSlash(char *p_pszString)
{
int i=0;
if (p_pszString)
{
i=strlen(p_pszString)-1;
while (i>=0 && p_pszString[i] && p_pszString[i]=='/')
p_pszString[i--]=0;
i++;
};
{
i=strlen(p_pszString)-1;
while (i>=0 && p_pszString[i] && p_pszString[i]=='/')
p_pszString[i--]=0;
i++;
};
return i;
}
//--------------------------------------------------------------------
int DeleteTrailingSpaces(char* p_pszString)
int
DeleteTrailingSpaces(char *p_pszString)
{
int i=0;
if (p_pszString)
{
i=strlen(p_pszString)-1;
while (i>=0 && p_pszString[i] && p_pszString[i]==' ')
p_pszString[i--]=0;
i++;
};
{
i=strlen(p_pszString)-1;
while (i>=0 && p_pszString[i] && p_pszString[i]==' ')
p_pszString[i--]=0;
i++;
};
return i;
}
//--------------------------------------------------------------------
int SafeStrlen(CONST char* p_pszString)
int
SafeStrlen(CONST char *p_pszString)
{
return (p_pszString ? strlen(p_pszString) : 0);
};
//--------------------------------------------------------------------
char* SafeStrdup(CONST char* p_pszString)
char *
SafeStrdup(CONST char *p_pszString)
{
return (p_pszString ? strdup(p_pszString) : NULL);
};
char* strcasestr(CONST char* p_pszString,CONST char* p_pszSearchedString)
char *
strcasestr(CONST char *p_pszString,CONST char *p_pszSearchedString)
{
if (p_pszString && p_pszSearchedString)
{
int i=0;
int iStringLen=strlen(p_pszString);
int iSearchedStringLen=strlen(p_pszSearchedString);
if (iStringLen>0 && iSearchedStringLen>0)
{
int i=0;
int iStringLen=strlen(p_pszString);
int iSearchedStringLen=strlen(p_pszSearchedString);
if (iStringLen>0 && iSearchedStringLen>0)
char ch1stUpper=toupper(p_pszSearchedString[0]);
for(i=0;i<iStringLen-iSearchedStringLen+1;i++)
{
if (toupper(p_pszString[i])==ch1stUpper)
{
char ch1stUpper=toupper(p_pszSearchedString[0]);
for(i=0;i<iStringLen-iSearchedStringLen+1;i++)
{
if (toupper(p_pszString[i])==ch1stUpper)
{
BOOL fSame=TRUE;
int j=0;
for(j=1;j<iSearchedStringLen && fSame;j++)
fSame=toupper(p_pszString[i+j])==toupper(p_pszSearchedString[j]);
if (fSame)
return p_pszString+i;
};
};
BOOL fSame=TRUE;
int j=0;
for(j=1;j<iSearchedStringLen && fSame;j++)
fSame=toupper(p_pszString[i+j]) ==
toupper(p_pszSearchedString[j]);
if (fSame)
return p_pszString+i;
};
};
};
};
return NULL;
};
#if defined(HAS_REENTRANT_GETHOSTENT) && !defined(_REENTRANT)
#define _REENTRANT /* needs to be defined so proper structs get included */
#define _REENTRANT /* needs to be defined so proper structs get included */
#endif
//--------------------------------------------------------------------
void GSWUtil_ClearHostCache()
void
GSWUtil_ClearHostCache()
{
if (g_pHostCache)
{
GSWDict_Free(g_pHostCache);
g_pHostCache=NULL;
};
{
GSWDict_Free(g_pHostCache);
g_pHostCache=NULL;
};
};
//--------------------------------------------------------------------
PSTHostent GSWUtil_FindHost(CONST char* p_pszHost,void* p_pLogServerData)
PSTHostent
GSWUtil_FindHost(CONST char *p_pszHost,
void *p_pLogServerData)
{
PSTHostent pHost=NULL;
if (!p_pszHost)
p_pszHost="localhost";
p_pszHost="localhost";
pHost = (g_pHostCache) ? (PSTHostent)GSWDict_ValueForKey(g_pHostCache,p_pszHost) : NULL;
pHost = (g_pHostCache) ?
(PSTHostent)GSWDict_ValueForKey(g_pHostCache,p_pszHost) : NULL;
if (!pHost)
{
pHost = GSWUtil_HostLookup(p_pszHost,p_pLogServerData);
if (pHost)
{
pHost = GSWUtil_HostLookup(p_pszHost,p_pLogServerData);
if (pHost)
{
if (!g_pHostCache)
g_pHostCache = GSWDict_New(32);
GSWDict_Add(g_pHostCache,p_pszHost,pHost,TRUE);
GSWLog(GSW_INFO,p_pLogServerData,"Caching hostent for %s",p_pszHost);
};
if (!g_pHostCache)
g_pHostCache = GSWDict_New(32);
GSWDict_Add(g_pHostCache,p_pszHost,pHost,TRUE);
GSWLog(GSW_INFO,p_pLogServerData,"Caching hostent for %s",p_pszHost);
};
};
return pHost;
};
@ -325,99 +344,107 @@ PSTHostent GSWUtil_FindHost(CONST char* p_pszHost,void* p_pLogServerData)
#endif
//--------------------------------------------------------------------
CONST char* hstrerror(int herr)
CONST char *
hstrerror(int herr)
{
if (herr == -1) // see errno
return strerror(errno);
return strerror(errno);
else if (herr == HOST_NOT_FOUND)
return "Host not found";
return "Host not found";
else if (herr == TRY_AGAIN)
return "Try again"; // ?
return "Try again"; // ?
else if (herr == NO_RECOVERY)
return "Non recoverable error";
return "Non recoverable error";
else if (herr == NO_DATA)
return "No data";
return "No data";
else if (herr == NO_ADDRESS)
return "No address"; // same as no data
return "No address"; // same as no data
else if (herr == NETDB_SUCCESS)
return "No error"; // Gag !
return "No error"; // Gag !
else
return "unknown error";
return "unknown error";
}
#endif
//--------------------------------------------------------------------
static PSTHostent GSWUtil_CopyHostent(PSTHostent p_pHost)
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;
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++;
};
ppszAliasOrAddress && *ppszAliasOrAddress;
ppszAliasOrAddress++)
{
iSize+=strlen(*ppszAliasOrAddress)+1;
iAliasNb++;
};
// Aliases Pointers Null Terminated List
iSize=ROUND_UP(iSize,sizeof(char *));
iSize+=(iAliasNb+1)*sizeof(char*);
iSize+=(iAliasNb+1)*sizeof(char *);
for (ppszAliasOrAddress=p_pHost->h_addr_list;
ppszAliasOrAddress && *ppszAliasOrAddress;
ppszAliasOrAddress++)
iAddressesNb++;
ppszAliasOrAddress && *ppszAliasOrAddress;
ppszAliasOrAddress++)
iAddressesNb++;
iSize+=iAddressesNb*(sizeof(char*)+p_pHost->h_length+1);
iSize+=iAddressesNb*(sizeof(char *)+p_pHost->h_length+1);
pNewHost=malloc(ROUND_UP(iSize,sizeof(char*)));
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*));
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*);
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++)
{
*ppszNewHostAliasOrAddress = (char*)pTmp;
strcpy((char*)pTmp,*ppszAliasOrAddress);
pTmp+=strlen(*ppszAliasOrAddress) + 1;
};
for (ppszAliasOrAddress=p_pHost->h_aliases,
ppszNewHostAliasOrAddress=pNewHost->h_aliases;
ppszAliasOrAddress && *ppszAliasOrAddress;
ppszAliasOrAddress++,ppszNewHostAliasOrAddress++)
{
*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++)
{
*ppszNewHostAliasOrAddress=(char*)pTmp;
memcpy(*ppszNewHostAliasOrAddress,*ppszAliasOrAddress,pNewHost->h_length);
pTmp+=pNewHost->h_length;
};
for (ppszAliasOrAddress=p_pHost->h_addr_list,
ppszNewHostAliasOrAddress=pNewHost->h_addr_list;
ppszAliasOrAddress && *ppszAliasOrAddress;
ppszAliasOrAddress++,ppszNewHostAliasOrAddress++)
{
*ppszNewHostAliasOrAddress=(char *)pTmp;
memcpy(*ppszNewHostAliasOrAddress,*ppszAliasOrAddress,
pNewHost->h_length);
pTmp+=pNewHost->h_length;
};
*ppszNewHostAliasOrAddress=NULL;
return pNewHost;
};
//--------------------------------------------------------------------
PSTHostent GSWUtil_HostLookup(CONST char *p_pszHost,void* p_pLogServerData)
PSTHostent
GSWUtil_HostLookup(CONST char *p_pszHost,
void *p_pLogServerData)
{
PSTHostent pHost=NULL;
struct in_addr hostaddr;
@ -433,76 +460,79 @@ PSTHostent GSWUtil_HostLookup(CONST char *p_pszHost,void* p_pLogServerData)
#endif
if (!p_pszHost)
p_pszHost="localhost";
p_pszHost="localhost";
if (isdigit(*p_pszHost))
hostaddr.s_addr=inet_addr(p_pszHost);
hostaddr.s_addr=inet_addr(p_pszHost);
#if defined(HAS_REENTRANT_GETHOSTENT)
if (isdigit(*p_pszHost))
{
if (isdigit(*p_pszHost))
{
#if defined(SOLARIS)
pHost = gethostbyaddr_r((char *)&hostaddr.s_addr,
sizeof(hostaddr.s_addr),
AF_INET,
pHost,
szBuffer,
BUFLEN, &error);
pHost = gethostbyaddr_r((char *)&hostaddr.s_addr,
sizeof(hostaddr.s_addr),
AF_INET,
pHost,
szBuffer,
BUFLEN, &error);
#else // !SOLARIS
if (gethostbyaddr_r((char *)&hostaddr.s_addr,
sizeof(hostaddr.s_addr),
AF_INET,
&stTmpHost,
szBuffer) == 0)
{
pHost = &stTmpHost;
error = 0;
}
else
{
pHost=NULL;
error = h_errno;
};
if (gethostbyaddr_r((char *)&hostaddr.s_addr,
sizeof(hostaddr.s_addr),
AF_INET,
&stTmpHost,
szBuffer) == 0)
{
pHost = &stTmpHost;
error = 0;
}
else
{
pHost=NULL;
error = h_errno;
};
#endif // SOLARIS
}
else
{
}
else
{
#if defined(SOLARIS)
pHost = gethostbyname_r(p_pszHost,
&stTmpHost,
szBuffer,
BUFLEN,
&error);
pHost = gethostbyname_r(p_pszHost,
&stTmpHost,
szBuffer,
BUFLEN,
&error);
#else // !SOLARIS
pHost = (gethostbyname_r(p_pszHost,&stTmpHost,szBuffer)==0) ? &stTmpHost : NULL;
error = (pHost) ? 0 : h_errno;
pHost = (gethostbyname_r(p_pszHost,&stTmpHost,szBuffer)==0) ?
&stTmpHost : NULL;
error = (pHost) ? 0 : h_errno;
#endif // SOLARIS
};
};
#else // !HAS_REENTRANT_GETHOSTENT
if (isdigit(*p_pszHost))
{
pHost = gethostbyaddr((char *)&hostaddr.s_addr, sizeof(hostaddr.s_addr), AF_INET);
error = (pHost) ? 0 : h_errno;
}
else
{
pHost = gethostbyname(p_pszHost);
error = (pHost) ? 0 : h_errno;
}
if (isdigit(*p_pszHost))
{
pHost = gethostbyaddr((char *)&hostaddr.s_addr, sizeof(hostaddr.s_addr),
AF_INET);
error = (pHost) ? 0 : h_errno;
}
else
{
pHost = gethostbyname(p_pszHost);
error = (pHost) ? 0 : h_errno;
}
#endif // HAS_REENTRANT_GETHOSTENT
if (!pHost)
{
GSWLog(GSW_ERROR,p_pLogServerData,"gethostbyname(%s) returns no host: %s",
p_pszHost,
hstrerror(error));
}
else if (pHost->h_addrtype != AF_INET)
{
GSWLog(GSW_ERROR,p_pLogServerData,"Wrong address type in hostptr for host %s",p_pszHost);
};
if (pHost)
pHost=GSWUtil_CopyHostent(pHost);
return pHost;
if (!pHost)
{
GSWLog(GSW_ERROR,p_pLogServerData,
"gethostbyname(%s) returns no host: %s",
p_pszHost,
hstrerror(error));
}
else if (pHost->h_addrtype != AF_INET)
{
GSWLog(GSW_ERROR,p_pLogServerData,"Wrong address type in hostptr for host %s",p_pszHost);
};
if (pHost)
pHost=GSWUtil_CopyHostent(pHost);
return pHost;
};

View file

@ -1,8 +1,8 @@
/* GSWUtil.h - GSWeb: Adaptors: Util
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -62,65 +62,65 @@ extern "C" {
void GSWLog(int p_iLevel,
#if defined(Apache)
server_rec* p_pLogServerData,
server_rec *p_pLogServerData,
#else
void* p_pLogServerData,
void *p_pLogServerData,
#endif
CONST char *p_pszFormat, ...);
CONST char *p_pszFormat, ...);
void GSWLogSized(int p_iLevel,
#if defined(Apache)
server_rec* p_pLogServerData,
server_rec *p_pLogServerData,
#else
void* p_pLogServerData,
void *p_pLogServerData,
#endif
int p_iBufferSize,
CONST char *p_pszFormat, ...);
void GSWLogIntern(char* file,
int line,
char* fn,
int p_iLevel,
void GSWLogIntern(char *file,
int line,
char *fn,
int p_iLevel,
#if defined(Apache)
server_rec* p_pLogServerData,
server_rec *p_pLogServerData,
#else
void* p_pLogServerData,
void *p_pLogServerData,
#endif
CONST char *p_pszFormat, ...);
CONST char *p_pszFormat, ...);
void GSWLogSizedIntern(char* file,
int line,
char* fn,
int p_iLevel,
void GSWLogSizedIntern(char *file,
int line,
char *fn,
int p_iLevel,
#if defined(Apache)
server_rec* p_pLogServerData,
server_rec *p_pLogServerData,
#else
void* p_pLogServerData,
void *p_pLogServerData,
#endif
int p_iBufferSize,
CONST char *p_pszFormat, ...);
int p_iBufferSize,
CONST char *p_pszFormat, ...);
// return new len
int DeleteTrailingCRNL(char* p_pszString);
int DeleteTrailingSlash(char* p_pszString);
int DeleteTrailingSpaces(char* p_pszString);
int DeleteTrailingCRNL(char *p_pszString);
int DeleteTrailingSlash(char *p_pszString);
int DeleteTrailingSpaces(char *p_pszString);
int SafeStrlen(CONST char* p_pszString);
char* SafeStrdup(CONST char* p_pszString);
char* strcasestr(CONST char* p_pszString,CONST char* p_pszSearchedString);
int SafeStrlen(CONST char *p_pszString);
char *SafeStrdup(CONST char *p_pszString);
char *strcasestr(CONST char *p_pszString, CONST char *p_pszSearchedString);
//#include <netdb.h>
typedef struct hostent* PSTHostent;
typedef struct hostent *PSTHostent;
PSTHostent GSWUtil_HostLookup(CONST char* p_pszHost,void* p_pLogServerData);
PSTHostent GSWUtil_HostLookup(CONST char *p_pszHost, void *p_pLogServerData);
void GSWUtil_ClearHostCache();
PSTHostent GSWUtil_FindHost(CONST char* p_pszHost,void* p_pLogServerData);
PSTHostent GSWUtil_FindHost(CONST char *p_pszHost, void *p_pLogServerData);
#include "GSWDict.h"
void GSWLog_Init(GSWDict* p_pDict,int p_iLevel);
void GSWLog_Init(GSWDict *p_pDict, int p_iLevel);
#ifdef __cplusplus

View file

@ -3,7 +3,7 @@
#
# Set all of the common environment variables.
#
# Copyright (C) 1999 Free Software Foundation, Inc.
# Copyright (C) 1999, 2000 Free Software Foundation, Inc.
#
# Author: Manuel Guesdon <mguesdon@sbuilders.com>
#

View file

@ -1,8 +1,8 @@
/* config.h - GSWeb: Adaptors: Config
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.

View file

@ -1,8 +1,8 @@
/* config.h - GSWeb: Adaptors: Config
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jully 1999
Date: July 1999
This file is part of the GNUstep Web Library.
@ -37,10 +37,10 @@ extern "C" {
#define CONST const
#define DEBUG
#define GSWEB_SERVER_ADAPTOR_VERSION_MAJOR 1
#define GSWEB_SERVER_ADAPTOR_VERSION_MAJOR_STRING "1"
#define GSWEB_SERVER_ADAPTOR_VERSION_MINOR 1
#define GSWEB_SERVER_ADAPTOR_VERSION_MINOR_STRING "1"
#define GSWEB_SERVER_ADAPTOR_VERSION_MAJOR 1
#define GSWEB_SERVER_ADAPTOR_VERSION_MAJOR_STRING "1"
#define GSWEB_SERVER_ADAPTOR_VERSION_MINOR 1
#define GSWEB_SERVER_ADAPTOR_VERSION_MINOR_STRING "1"
#define GSWEB_VERSION_MAJOR 1
#define GSWEB_VERSION_MINOR 0
@ -58,13 +58,13 @@ extern "C" {
#define GSWAPP_EXTENSION_GSW ".gswa"
// Time Outs ...
#define APP_CONNECT_TIMEOUT 300
#define APP_CONNECT_TIMEOUT 300
#define RESPONSE__LINE_MAX_SIZE 8192
#define APP_CONNECT_RETRY_DELAY 3
#define APP_CONNECT_RETRIES_NB 10
#define HITS_PER_SECOND 80
#define HITS_PER_SECOND 80
#define CONFIG_FILE_STAT_INTERVAL 10
@ -77,19 +77,19 @@ extern "C" {
// Config File Keywords
// All
//#define GSWEB_CONF__DOC_ROOT "GSWeb_DocumentRoot"
#define GSWEB_CONF__CONFIG_FILE_PATH "GSWeb_ConfigFilePath"
//#define GSWEB_CONF__DOC_ROOT "GSWeb_DocumentRoot"
#define GSWEB_CONF__CONFIG_FILE_PATH "GSWeb_ConfigFilePath"
// Aapche
#if defined(Apache)
#define GSWEB_CONF__ALIAS "GSWeb_Alias"
#define GSWEB_CONF__ALIAS "GSWeb_Alias"
#endif
// Netscape
#if defined(Netscape)
#define GSWEB_CONF__PATH_TRANS "from" // NameTrans
#define GSWEB_CONF__APP_ROOT "dir" // NameTrans
#define GSWEB_CONF__NAME "name" // NameTrans, Object
#define GSWEB_CONF__NAME "name" // NameTrans, Object
#endif