mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-05-31 09:11:11 +00:00
* 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:
parent
ef9aeb9211
commit
2e0c8afdee
40 changed files with 3998 additions and 3409 deletions
31
ChangeLog
31
ChangeLog
|
@ -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>
|
2003-02-20 Mirko Viviani <mirko.viviani@rccr.cremona.it>
|
||||||
|
|
||||||
* GSWAdaptors/common/GSWUtil.c|.h (strcasestr): removed CONST from
|
* GSWAdaptors/common/GSWUtil.c|.h (strcasestr): removed CONST from
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# Makefile for Apache 1.x GNUstepWeb module
|
# Makefile for Apache 1.x GNUstepWeb module
|
||||||
# Copyright (C) 1999 Free Software Foundation, Inc.
|
# Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
# Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
# Date: Jully 1999
|
# Date: July 1999
|
||||||
#
|
#
|
||||||
# This file is part of the GNUstep Web Library.
|
# This file is part of the GNUstep Web Library.
|
||||||
#
|
#
|
||||||
|
@ -53,7 +53,7 @@ OBJROOT = .
|
||||||
# Directory
|
# Directory
|
||||||
SERVERAPI = Apache
|
SERVERAPI = Apache
|
||||||
|
|
||||||
ADAPTOR = $(DSTROOT)/mod_gsweb.so
|
ADAPTOR = mod_gsweb.so
|
||||||
|
|
||||||
LOADBALANCING = roundrobin
|
LOADBALANCING = roundrobin
|
||||||
ADAPTORLIB = $(OBJROOT)/libAdaptor.a
|
ADAPTORLIB = $(OBJROOT)/libAdaptor.a
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -59,9 +59,9 @@ module GSWeb_Module;
|
||||||
|
|
||||||
typedef struct _GSWeb_Config
|
typedef struct _GSWeb_Config
|
||||||
{
|
{
|
||||||
const char* pszGSWeb; // default = GSWeb
|
const char *pszGSWeb; // default = GSWeb
|
||||||
const char* pszConfigPath; // path to GSWeb.conf
|
const char *pszConfigPath; // path to GSWeb.conf
|
||||||
// const char* pszRoot; // normally htdocs/GSWeb
|
// const char *pszRoot; // normally htdocs/GSWeb
|
||||||
} GSWeb_Config;
|
} GSWeb_Config;
|
||||||
|
|
||||||
#ifdef Apache2
|
#ifdef Apache2
|
||||||
|
@ -89,10 +89,10 @@ typedef apr_table_entry_t table_entry;
|
||||||
struct table
|
struct table
|
||||||
{
|
{
|
||||||
/* This has to be first to promote backwards compatibility with
|
/* This has to be first to promote backwards compatibility with
|
||||||
* older modules which cast a table * to an array_header *...
|
* older modules which cast a table * to an array_header *...
|
||||||
* they should use the table_elts() function for most of the
|
* they should use the table_elts() function for most of the
|
||||||
* cases they do this for.
|
* cases they do this for.
|
||||||
*/
|
*/
|
||||||
array_header a;
|
array_header a;
|
||||||
#ifdef MAKE_TABLE_PROFILE
|
#ifdef MAKE_TABLE_PROFILE
|
||||||
void *creator;
|
void *creator;
|
||||||
|
@ -100,63 +100,84 @@ struct table
|
||||||
};
|
};
|
||||||
#endif
|
#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_SetDocRoot(cmd_parms *p_pCmdParams,
|
||||||
static CONST char *GSWeb_SetConfig(cmd_parms *p_pCmdParams, void *p_pUnused, char *p_pszArg);
|
void *p_pUnused,
|
||||||
static int GSWeb_Handler(request_rec* p_pRequestRec);
|
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.
|
* 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
|
// Init
|
||||||
#ifdef Apache2
|
#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
|
#else
|
||||||
static void GSWeb_Init(server_rec* p_pServerRec, pool *p)
|
static void
|
||||||
|
GSWeb_Init(server_rec *p_pServerRec,
|
||||||
|
pool *p)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
GSWDict* pDict=GSWDict_New(0);
|
GSWDict *pDict=GSWDict_New(0);
|
||||||
GSWeb_Config* pConfig=NULL;
|
GSWeb_Config *pConfig=NULL;
|
||||||
|
|
||||||
pConfig=GSWeb_GetServerConfig(p_pServerRec);
|
pConfig=GSWeb_GetServerConfig(p_pServerRec);
|
||||||
GSWLog_Init(NULL,GSW_INFO);
|
GSWLog_Init(NULL,GSW_INFO);
|
||||||
GSWLog(GSW_INFO,p_pServerRec,
|
GSWLog(GSW_INFO,p_pServerRec,
|
||||||
"GSWeb Init Start Config. Handler: " GSWEB_HANDLER);
|
"GSWeb Init Start Config. Handler: " GSWEB_HANDLER);
|
||||||
GSWLog(GSW_DEBUG,p_pServerRec,
|
GSWLog(GSW_DEBUG,p_pServerRec,
|
||||||
"GSWeb_Init: pConfig->pszGSWeb=%s",
|
"GSWeb_Init: pConfig->pszGSWeb=%s",
|
||||||
pConfig->pszGSWeb);
|
pConfig->pszGSWeb);
|
||||||
|
|
||||||
if (pConfig && pConfig->pszConfigPath)
|
if (pConfig && pConfig->pszConfigPath)
|
||||||
GSWDict_AddStringDup(pDict,
|
GSWDict_AddStringDup(pDict,
|
||||||
g_szGSWeb_Conf_ConfigFilePath,
|
g_szGSWeb_Conf_ConfigFilePath,
|
||||||
pConfig->pszConfigPath);
|
pConfig->pszConfigPath);
|
||||||
/* if (pConfig && pConfig->pszRoot)
|
/*
|
||||||
GSWDict_AddStringDup(pDict,
|
if (pConfig && pConfig->pszRoot)
|
||||||
g_szGSWeb_Conf_DocRoot,
|
GSWDict_AddStringDup(pDict,
|
||||||
pConfig->pszRoot);*/
|
g_szGSWeb_Conf_DocRoot,
|
||||||
|
pConfig->pszRoot);
|
||||||
|
*/
|
||||||
GSWLog(GSW_INFO,p_pServerRec,
|
GSWLog(GSW_INFO,p_pServerRec,
|
||||||
"GSWeb Init LB Init. Handler: " GSWEB_HANDLER);
|
"GSWeb Init LB Init. Handler: " GSWEB_HANDLER);
|
||||||
GSWConfig_Init(pDict,p_pServerRec);
|
GSWConfig_Init(pDict,p_pServerRec);
|
||||||
|
|
||||||
GSWLog(GSW_INFO,p_pServerRec,
|
GSWLog(GSW_INFO,p_pServerRec,
|
||||||
"GSWeb Init. Handler: " GSWEB_HANDLER);
|
"GSWeb Init. Handler: " GSWEB_HANDLER);
|
||||||
GSWDict_Free(pDict);
|
GSWDict_Free(pDict);
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// Create Config
|
// Create Config
|
||||||
static void* GSWeb_CreateServerConfig(pool* p_pPool,
|
static void *
|
||||||
server_rec* p_pServerRec)
|
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;
|
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->pszGSWeb);
|
||||||
pConfig->pszConfigPath = NULL;
|
pConfig->pszConfigPath = NULL;
|
||||||
// pConfig->pszRoot = NULL;
|
// pConfig->pszRoot = NULL;
|
||||||
|
@ -165,24 +186,31 @@ static void* GSWeb_CreateServerConfig(pool* p_pPool,
|
||||||
/*
|
/*
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// Set Param: DocRoot
|
// 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;
|
server_rec *pServerRec = p_pCmdParams->server;
|
||||||
GSWeb_Config* pConfig = NULL;
|
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;
|
|
||||||
GSWLog(GSW_DEBUG,pServerRec,"Start GSWeb_SetDocRoot");
|
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
|
// 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;
|
server_rec *pServerRec = p_pCmdParams->server;
|
||||||
GSWeb_Config* pConfig = NULL;
|
GSWeb_Config *pConfig = NULL;
|
||||||
GSWLog(GSW_DEBUG,pServerRec,"Start GSWeb_SetScriptAlias");
|
GSWLog(GSW_DEBUG,pServerRec,"Start GSWeb_SetScriptAlias");
|
||||||
pConfig=GSWeb_GetServerConfig(pServerRec);
|
pConfig=GSWeb_GetServerConfig(pServerRec);
|
||||||
pConfig->pszGSWeb = p_pszArg;
|
pConfig->pszGSWeb = p_pszArg;
|
||||||
|
@ -192,10 +220,14 @@ static CONST char* GSWeb_SetScriptAlias(cmd_parms *p_pCmdParams, void *p_pUnused
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// Set Param: ConfigFile
|
// 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;
|
server_rec *pServerRec = p_pCmdParams->server;
|
||||||
GSWeb_Config* pConfig = NULL;
|
GSWeb_Config *pConfig = NULL;
|
||||||
|
|
||||||
GSWLog(GSW_DEBUG,pServerRec,"Start GSWeb_SetConfig");
|
GSWLog(GSW_DEBUG,pServerRec,"Start GSWeb_SetConfig");
|
||||||
pConfig=GSWeb_GetServerConfig(pServerRec);
|
pConfig=GSWeb_GetServerConfig(pServerRec);
|
||||||
GSWLog(GSW_DEBUG,pServerRec,"pConfig=%p",pConfig);
|
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
|
// Translate
|
||||||
int GSWeb_Translation(request_rec* p_pRequestRec)
|
int
|
||||||
|
GSWeb_Translation(request_rec *p_pRequestRec)
|
||||||
{
|
{
|
||||||
int iRetValue=OK;
|
int iRetValue=OK;
|
||||||
GSWeb_Config* pConfig=NULL;
|
GSWeb_Config *pConfig=NULL;
|
||||||
GSWURLComponents stURL;
|
GSWURLComponents stURL;
|
||||||
|
|
||||||
memset(&stURL,0,sizeof(stURL));
|
memset(&stURL,0,sizeof(stURL));
|
||||||
GSWLog(GSW_DEBUG,p_pRequestRec->server,"Start GSWeb_Translation");
|
GSWLog(GSW_DEBUG,p_pRequestRec->server,"Start GSWeb_Translation");
|
||||||
pConfig=GSWeb_GetServerConfig(p_pRequestRec->server);
|
pConfig=GSWeb_GetServerConfig(p_pRequestRec->server);
|
||||||
|
|
||||||
// Is this for us ?
|
// Is this for us ?
|
||||||
if (strncmp(pConfig->pszGSWeb,
|
if (strncmp(pConfig->pszGSWeb,
|
||||||
p_pRequestRec->uri,
|
p_pRequestRec->uri,
|
||||||
strlen(pConfig->pszGSWeb))==0)
|
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,
|
GSWLog(GSW_ERROR,p_pRequestRec->server,
|
||||||
p_pRequestRec->server);
|
"GSWeb_Translation Declined (Error %d)",(int)eError);
|
||||||
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");
|
|
||||||
iRetValue=DECLINED;
|
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,
|
GSWLog(GSW_DEBUG,p_pRequestRec->server,
|
||||||
"Stop GSWeb_Translation return %d",
|
"Stop GSWeb_Translation return %d",
|
||||||
iRetValue);
|
iRetValue);
|
||||||
return 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;
|
server_rec *pServerRec = p_pRequestRec->server;
|
||||||
conn_rec* pConnection = p_pRequestRec->connection;
|
conn_rec *pConnection = p_pRequestRec->connection;
|
||||||
const array_header *headers_arr=ap_table_elts(p_pRequestRec->headers_in);
|
const array_header *headers_arr=ap_table_elts(p_pRequestRec->headers_in);
|
||||||
table_entry *headers=NULL;
|
table_entry *headers=NULL;
|
||||||
int i;
|
int i;
|
||||||
char szPort[40]="";
|
char szPort[40]="";
|
||||||
CONST char* pszRemoteLogName=NULL;
|
CONST char *pszRemoteLogName=NULL;
|
||||||
GSWLog(GSW_DEBUG,pServerRec,"Start copyHeaders");
|
GSWLog(GSW_DEBUG,pServerRec,"Start copyHeaders");
|
||||||
|
|
||||||
// copy p_pRequestRec headers
|
// 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++)
|
for (i=0;i<headers_arr->nelts;i++)
|
||||||
{
|
{
|
||||||
if (headers[i].key)
|
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
|
// Add server headers
|
||||||
|
@ -296,18 +335,22 @@ static void copyHeaders(request_rec* p_pRequestRec,GSWHTTPRequest* p_pGSWHTTPReq
|
||||||
#ifdef Apache2
|
#ifdef Apache2
|
||||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||||
g_szServerInfo_RemoteHost,
|
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 */
|
#else /* Apache 1.x */
|
||||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||||
g_szServerInfo_RemoteHost,
|
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
|
#endif
|
||||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||||
g_szServerInfo_RemoteAddress,
|
g_szServerInfo_RemoteAddress,
|
||||||
pConnection->remote_ip);
|
pConnection->remote_ip);
|
||||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||||
g_szServerInfo_DocumentRoot,
|
g_szServerInfo_DocumentRoot,
|
||||||
(char*)ap_document_root(p_pRequestRec));
|
(char *)ap_document_root(p_pRequestRec));
|
||||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||||
g_szServerInfo_ServerAdmin,
|
g_szServerInfo_ServerAdmin,
|
||||||
pServerRec->server_admin);
|
pServerRec->server_admin);
|
||||||
|
@ -339,7 +382,7 @@ static void copyHeaders(request_rec* p_pRequestRec,GSWHTTPRequest* p_pGSWHTTPReq
|
||||||
g_szServerInfo_AuthType,//"auth_type",
|
g_szServerInfo_AuthType,//"auth_type",
|
||||||
pConnection->ap_auth_type);
|
pConnection->ap_auth_type);
|
||||||
#endif
|
#endif
|
||||||
pszRemoteLogName = (char*)ap_get_remote_logname(p_pRequestRec);
|
pszRemoteLogName = (char *)ap_get_remote_logname(p_pRequestRec);
|
||||||
if (pszRemoteLogName)
|
if (pszRemoteLogName)
|
||||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||||
g_szServerInfo_RemoteIdent,
|
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
|
// 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)
|
if (!pRequestRec->content_type &&
|
||||||
pRequestRec->content_type = (char*)ap_pstrdup(pRequestRec->pool,(char*)p_pElem->pValue);
|
strcasecmp(p_pElem->pszKey,g_szHeader_ContentType)==0)
|
||||||
|
pRequestRec->content_type = (char *)ap_pstrdup(pRequestRec->pool,
|
||||||
|
(char *)p_pElem->pValue);
|
||||||
else
|
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
|
// 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]="";
|
char szStatusBuffer[512]="";
|
||||||
server_rec* pServerRec = p_pRequestRec->server;
|
server_rec *pServerRec = p_pRequestRec->server;
|
||||||
GSWLog(GSW_DEBUG,pServerRec,"Start sendResponse");
|
GSWLog(GSW_DEBUG,pServerRec,"Start sendResponse");
|
||||||
|
|
||||||
// Process Headers
|
// Process Headers
|
||||||
GSWDict_PerformForAllElem(p_pHTTPResponse->pHeaders,getHeader,p_pRequestRec);
|
GSWDict_PerformForAllElem(p_pHTTPResponse->pHeaders,getHeader,p_pRequestRec);
|
||||||
|
|
||||||
ap_snprintf(szStatusBuffer,sizeof(szStatusBuffer),"%u %s",
|
ap_snprintf(szStatusBuffer,sizeof(szStatusBuffer),"%u %s",
|
||||||
p_pHTTPResponse->uStatus,
|
p_pHTTPResponse->uStatus,
|
||||||
p_pHTTPResponse->pszStatusMessage);
|
p_pHTTPResponse->pszStatusMessage);
|
||||||
p_pRequestRec->status_line = szStatusBuffer;
|
p_pRequestRec->status_line = szStatusBuffer;
|
||||||
p_pRequestRec->status = p_pHTTPResponse->uStatus;
|
p_pRequestRec->status = p_pHTTPResponse->uStatus;
|
||||||
|
|
||||||
// Set content type if none
|
// Set content type if none
|
||||||
if (!p_pRequestRec->content_type)
|
if (!p_pRequestRec->content_type)
|
||||||
p_pRequestRec->content_type = g_szContentType_TextHtml;
|
p_pRequestRec->content_type = g_szContentType_TextHtml;
|
||||||
|
|
||||||
// Set content length
|
// 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...
|
// Now Send response...
|
||||||
|
|
||||||
|
@ -391,20 +441,25 @@ static void sendResponse(request_rec* p_pRequestRec,GSWHTTPResponse* p_pHTTPResp
|
||||||
|
|
||||||
// If not headers only
|
// If not headers only
|
||||||
if (!p_pRequestRec->header_only)
|
if (!p_pRequestRec->header_only)
|
||||||
{
|
{
|
||||||
ap_soft_timeout("Send GSWeb response",p_pRequestRec);
|
ap_soft_timeout("Send GSWeb response",p_pRequestRec);
|
||||||
ap_rwrite(p_pHTTPResponse->pContent,p_pHTTPResponse->uContentLength,p_pRequestRec);
|
ap_rwrite(p_pHTTPResponse->pContent,p_pHTTPResponse->uContentLength,
|
||||||
ap_kill_timeout(p_pRequestRec);
|
p_pRequestRec);
|
||||||
};
|
ap_kill_timeout(p_pRequestRec);
|
||||||
|
};
|
||||||
GSWLog(GSW_DEBUG,pServerRec,"Stop sendResponse");
|
GSWLog(GSW_DEBUG,pServerRec,"Stop sendResponse");
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// die/send response
|
// 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;
|
server_rec *pServerRec = p_pRequestRec->server;
|
||||||
void* pLogServerData=pServerRec;
|
void *pLogServerData=pServerRec;
|
||||||
|
|
||||||
GSWLog(GSW_DEBUG,pLogServerData,"Start dieSendResponse");
|
GSWLog(GSW_DEBUG,pLogServerData,"Start dieSendResponse");
|
||||||
sendResponse(p_pRequestRec,*p_ppHTTPResponse);
|
sendResponse(p_pRequestRec,*p_ppHTTPResponse);
|
||||||
GSWHTTPResponse_Free(*p_ppHTTPResponse,pLogServerData);
|
GSWHTTPResponse_Free(*p_ppHTTPResponse,pLogServerData);
|
||||||
|
@ -415,14 +470,19 @@ static int dieSendResponse(request_rec* p_pRequestRec,GSWHTTPResponse** p_ppHTTP
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// die with a message
|
// 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;
|
int iReturn=0;
|
||||||
GSWHTTPResponse* pResponse=NULL;
|
GSWHTTPResponse *pResponse=NULL;
|
||||||
server_rec* pServerRec = p_pRequestRec->server;
|
server_rec *pServerRec = p_pRequestRec->server;
|
||||||
|
|
||||||
GSWLog(GSW_DEBUG,pServerRec,"Start dieWithMessage");
|
GSWLog(GSW_DEBUG,pServerRec,"Start dieWithMessage");
|
||||||
GSWLog(GSW_ERROR,pServerRec,"Send Error Response: %s",p_pszMessage);
|
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);
|
iReturn=dieSendResponse(p_pRequestRec,&pResponse,p_fDecline);
|
||||||
GSWLog(GSW_DEBUG,pServerRec,"Stop dieWithMessage");
|
GSWLog(GSW_DEBUG,pServerRec,"Stop dieWithMessage");
|
||||||
return iReturn;
|
return iReturn;
|
||||||
|
@ -430,16 +490,17 @@ static int dieWithMessage(request_rec* p_pRequestRec,CONST char* p_pszMessage,BO
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// GSWeb Request Handler
|
// GSWeb Request Handler
|
||||||
static int GSWeb_Handler(request_rec* p_pRequestRec)
|
static int
|
||||||
|
GSWeb_Handler(request_rec *p_pRequestRec)
|
||||||
{
|
{
|
||||||
int iRetVal=OK;
|
int iRetVal=OK;
|
||||||
GSWURLComponents stURLComponents;
|
GSWURLComponents stURLComponents;
|
||||||
GSWHTTPResponse* pResponse = NULL;
|
GSWHTTPResponse *pResponse = NULL;
|
||||||
GSWURLError eError=GSWURLError_OK;
|
GSWURLError eError=GSWURLError_OK;
|
||||||
CONST char* pszURLError=NULL;
|
CONST char *pszURLError=NULL;
|
||||||
server_rec* pServerRec = p_pRequestRec->server;
|
server_rec *pServerRec = p_pRequestRec->server;
|
||||||
void* pLogServerData=pServerRec;
|
void *pLogServerData=pServerRec;
|
||||||
GSWeb_Config* pConfig=NULL;
|
GSWeb_Config *pConfig=NULL;
|
||||||
|
|
||||||
memset(&stURLComponents,0,sizeof(stURLComponents));
|
memset(&stURLComponents,0,sizeof(stURLComponents));
|
||||||
GSWLog(GSW_DEBUG,pLogServerData,"Start GSWeb_Handler");
|
GSWLog(GSW_DEBUG,pLogServerData,"Start GSWeb_Handler");
|
||||||
|
@ -448,9 +509,9 @@ static int GSWeb_Handler(request_rec* p_pRequestRec)
|
||||||
|
|
||||||
// Log the request
|
// Log the request
|
||||||
GSWLog(GSW_INFO,
|
GSWLog(GSW_INFO,
|
||||||
pLogServerData,
|
pLogServerData,
|
||||||
"GNUstepWeb New request: %s",
|
"GNUstepWeb New request: %s",
|
||||||
p_pRequestRec->uri);
|
p_pRequestRec->uri);
|
||||||
|
|
||||||
// Is this for us ?
|
// Is this for us ?
|
||||||
if (strncmp(pConfig->pszGSWeb,
|
if (strncmp(pConfig->pszGSWeb,
|
||||||
|
@ -480,20 +541,22 @@ static int GSWeb_Handler(request_rec* p_pRequestRec)
|
||||||
if (iRetVal==0) // OK Continue
|
if (iRetVal==0) // OK Continue
|
||||||
{
|
{
|
||||||
// Build the GSWHTTPRequest with the method
|
// Build the GSWHTTPRequest with the method
|
||||||
GSWHTTPRequest* pRequest=NULL;
|
GSWHTTPRequest *pRequest=NULL;
|
||||||
CONST char* pszRequestError=NULL;
|
CONST char *pszRequestError=NULL;
|
||||||
|
|
||||||
pRequest=GSWHTTPRequest_New(p_pRequestRec->method,NULL,pLogServerData);
|
pRequest=GSWHTTPRequest_New(p_pRequestRec->method,NULL,
|
||||||
|
pLogServerData);
|
||||||
|
|
||||||
// validate the method
|
// validate the method
|
||||||
pszRequestError=GSWHTTPRequest_ValidateMethod(pRequest,pLogServerData);
|
pszRequestError=GSWHTTPRequest_ValidateMethod(pRequest,
|
||||||
|
pLogServerData);
|
||||||
if (pszRequestError)
|
if (pszRequestError)
|
||||||
{
|
{
|
||||||
iRetVal=dieWithMessage(p_pRequestRec,pszRequestError,NO);
|
iRetVal=dieWithMessage(p_pRequestRec,pszRequestError,NO);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CONST char* pszDocRoot=NULL;
|
CONST char *pszDocRoot=NULL;
|
||||||
|
|
||||||
// copy headers
|
// copy headers
|
||||||
copyHeaders(p_pRequestRec,pRequest);
|
copyHeaders(p_pRequestRec,pRequest);
|
||||||
|
@ -506,19 +569,22 @@ static int GSWeb_Handler(request_rec* p_pRequestRec)
|
||||||
{
|
{
|
||||||
int iReadLength=0;
|
int iReadLength=0;
|
||||||
int iRemainingLength = pRequest->uContentLength;
|
int iRemainingLength = pRequest->uContentLength;
|
||||||
char* pszBuffer = malloc(pRequest->uContentLength);
|
char *pszBuffer = malloc(pRequest->uContentLength);
|
||||||
char* pszData = pszBuffer;
|
char *pszData = pszBuffer;
|
||||||
|
|
||||||
while (iRemainingLength>0)
|
while (iRemainingLength>0)
|
||||||
{
|
{
|
||||||
ap_soft_timeout("reading GSWeb request",p_pRequestRec);
|
ap_soft_timeout("reading GSWeb request",
|
||||||
iReadLength=ap_get_client_block(p_pRequestRec,pszData,iRemainingLength);
|
p_pRequestRec);
|
||||||
|
iReadLength=ap_get_client_block(p_pRequestRec,
|
||||||
|
pszData,
|
||||||
|
iRemainingLength);
|
||||||
ap_kill_timeout(p_pRequestRec);
|
ap_kill_timeout(p_pRequestRec);
|
||||||
pszData += iReadLength;
|
pszData += iReadLength;
|
||||||
iRemainingLength-=iReadLength;
|
iRemainingLength-=iReadLength;
|
||||||
};
|
};
|
||||||
GSWLog(GSW_INFO,pLogServerData,"pszBuffer(%p)=%.*s",
|
GSWLog(GSW_INFO,pLogServerData,"pszBuffer(%p)=%.*s",
|
||||||
(void*)pszBuffer,
|
(void *)pszBuffer,
|
||||||
(int)pRequest->uContentLength,
|
(int)pRequest->uContentLength,
|
||||||
pszBuffer);
|
pszBuffer);
|
||||||
pRequest->pContent = pszBuffer;
|
pRequest->pContent = pszBuffer;
|
||||||
|
@ -526,25 +592,28 @@ static int GSWeb_Handler(request_rec* p_pRequestRec)
|
||||||
else if (pRequest->eMethod==ERequestMethod_Get)
|
else if (pRequest->eMethod==ERequestMethod_Get)
|
||||||
{
|
{
|
||||||
// Get the QueryString
|
// Get the QueryString
|
||||||
stURLComponents.stQueryString.pszStart = p_pRequestRec->args;
|
stURLComponents.stQueryString.pszStart =
|
||||||
stURLComponents.stQueryString.iLength = p_pRequestRec->args ? strlen(p_pRequestRec->args) : 0;
|
p_pRequestRec->args;
|
||||||
|
stURLComponents.stQueryString.iLength =
|
||||||
|
p_pRequestRec->args ? strlen(p_pRequestRec->args) : 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// get the document root
|
// get the document root
|
||||||
/* if (pConfig && pConfig->pszRoot)
|
/* if (pConfig && pConfig->pszRoot)
|
||||||
pszDocRoot = pConfig->pszRoot;
|
pszDocRoot = pConfig->pszRoot;
|
||||||
else*/
|
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);
|
ap_soft_timeout("Call GSWeb Application",p_pRequestRec);
|
||||||
pRequest->pServerHandle = p_pRequestRec;
|
pRequest->pServerHandle = p_pRequestRec;
|
||||||
pResponse=GSWAppRequest_HandleRequest(&pRequest,
|
pResponse=GSWAppRequest_HandleRequest(&pRequest,
|
||||||
&stURLComponents,
|
&stURLComponents,
|
||||||
p_pRequestRec->protocol,
|
p_pRequestRec->protocol,
|
||||||
pszDocRoot,
|
pszDocRoot,
|
||||||
g_szGSWeb_StatusResponseAppName, //AppTest name
|
g_szGSWeb_StatusResponseAppName, //AppTest name
|
||||||
pLogServerData);
|
pLogServerData);
|
||||||
ap_kill_timeout(p_pRequestRec);
|
ap_kill_timeout(p_pRequestRec);
|
||||||
|
|
||||||
// Send the response (if any)
|
// 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
|
* The actual delivery of content to the browser [9] is not handled by
|
||||||
* a hook; see the handler declarations below.
|
* 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_pre_config(GSWeb_PreConfig, NULL, NULL, APR_HOOK_MIDDLE);
|
||||||
ap_hook_post_config(GSWeb_PostConfig, 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[] =
|
static const command_rec GSWeb_Commands[] =
|
||||||
{
|
{
|
||||||
AP_INIT_TAKE1(
|
AP_INIT_TAKE1
|
||||||
GSWEB_CONF__ALIAS, /* directive name */
|
(
|
||||||
GSWeb_SetScriptAlias, /* config action routine */
|
GSWEB_CONF__ALIAS, /* directive name */
|
||||||
NULL, /* argument to include in call */
|
GSWeb_SetScriptAlias, /* config action routine */
|
||||||
RSRC_CONF, /* where available */
|
NULL, /* argument to include in call */
|
||||||
"ScriptAlias for GSWeb" /* directive description */
|
RSRC_CONF, /* where available */
|
||||||
),
|
"ScriptAlias for GSWeb" /* directive description */
|
||||||
AP_INIT_TAKE1(
|
);
|
||||||
GSWEB_CONF__CONFIG_FILE_PATH, /* directive name */
|
AP_INIT_TAKE1
|
||||||
GSWeb_SetConfig, /* config action routine */
|
(
|
||||||
NULL, /* argument to include in call */
|
GSWEB_CONF__CONFIG_FILE_PATH, /* directive name */
|
||||||
RSRC_CONF, /* where available */
|
GSWeb_SetConfig, /* config action routine */
|
||||||
"Configuration File Path for GSWeb" /* directive description */
|
NULL, /* argument to include in call */
|
||||||
),
|
RSRC_CONF, /* where available */
|
||||||
{NULL}
|
"Configuration File Path for GSWeb" /* directive description */
|
||||||
|
),
|
||||||
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
module AP_MODULE_DECLARE_DATA GSWeb_Module =
|
module AP_MODULE_DECLARE_DATA GSWeb_Module =
|
||||||
|
@ -667,10 +739,10 @@ module AP_MODULE_DECLARE_DATA GSWeb_Module =
|
||||||
STANDARD20_MODULE_STUFF,
|
STANDARD20_MODULE_STUFF,
|
||||||
NULL,//x_create_dir_config, /* per-directory config creator */
|
NULL,//x_create_dir_config, /* per-directory config creator */
|
||||||
NULL,//x_merge_dir_config, /* dir config merger */
|
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 */
|
NULL,//x_merge_server_config, /* server config merger */
|
||||||
GSWeb_Commands, /* command table */
|
GSWeb_Commands, /* command table */
|
||||||
GSWeb_register_hooks, /* set up other request processing hooks */
|
GSWeb_register_hooks, /* set up other request processing hooks */
|
||||||
};
|
};
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -682,23 +754,23 @@ module AP_MODULE_DECLARE_DATA GSWeb_Module =
|
||||||
static command_rec GSWeb_Commands[] =
|
static command_rec GSWeb_Commands[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
GSWEB_CONF__ALIAS, // Command keyword
|
GSWEB_CONF__ALIAS, // Command keyword
|
||||||
GSWeb_SetScriptAlias, // Function
|
GSWeb_SetScriptAlias, // Function
|
||||||
NULL, // Fixed Arg
|
NULL, // Fixed Arg
|
||||||
RSRC_CONF, // Type
|
RSRC_CONF, // Type
|
||||||
TAKE1, // Args Descr
|
TAKE1, // Args Descr
|
||||||
"ScriptAlias for GSWeb"
|
"ScriptAlias for GSWeb"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
GSWEB_CONF__CONFIG_FILE_PATH, // Command keyword
|
GSWEB_CONF__CONFIG_FILE_PATH, // Command keyword
|
||||||
GSWeb_SetConfig, // Function
|
GSWeb_SetConfig, // Function
|
||||||
NULL, // Fixed Arg
|
NULL, // Fixed Arg
|
||||||
RSRC_CONF, // Type
|
RSRC_CONF, // Type
|
||||||
TAKE1, // Args Descr
|
TAKE1, // Args Descr
|
||||||
"Configuration File Path for GSWeb"
|
"Configuration File Path for GSWeb"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
NULL
|
NULL
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -723,14 +795,14 @@ handler_rec GSWeb_Handlers[] =
|
||||||
module GSWeb_Module =
|
module GSWeb_Module =
|
||||||
{
|
{
|
||||||
STANDARD_MODULE_STUFF,
|
STANDARD_MODULE_STUFF,
|
||||||
GSWeb_Init, // Init
|
GSWeb_Init, // Init
|
||||||
NULL, // Create DirectoryConfig
|
NULL, // Create DirectoryConfig
|
||||||
NULL, // Merge DirectoryConfig
|
NULL, // Merge DirectoryConfig
|
||||||
GSWeb_CreateServerConfig, // Create ServerConfig
|
GSWeb_CreateServerConfig, // Create ServerConfig
|
||||||
NULL, // Merge ServerConfig
|
NULL, // Merge ServerConfig
|
||||||
GSWeb_Commands, // Commands List
|
GSWeb_Commands, // Commands List
|
||||||
GSWeb_Handlers, // Handlers List
|
GSWeb_Handlers, // Handlers List
|
||||||
GSWeb_Translation, // Fn to Translatie Filename/URI
|
GSWeb_Translation, // Fn to Translatie Filename/URI
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -1,96 +1,102 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Adaptor Configuration File</title>
|
<title>Adaptor Configuration File</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
Configuration file path is specified with Apache directive (/etc/httpd/conf/gsweb.conf is an exemple): <br>
|
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>
|
The format is GNUstep/OpenStep property list.<br>
|
||||||
Here is an exemple with all the possible options:<br>
|
Here is an exemple with all the possible options:<br>
|
||||||
|
|
||||||
<PRE>
|
<PRE>
|
||||||
|
{
|
||||||
{
|
//Global Parameters
|
||||||
//Global Parameters
|
canDumpStatus = YES; //YES if server can display status (URL: /GSWeb/status)
|
||||||
canDumpStatus=YES; //YES if server can display status (URL: /GSWeb/status)
|
GSWExtensionsFrameworkWebServerResources =
|
||||||
GSWExtensionsFrameworkWebServerResources="/GSW/GSWExtensions/WebServerResources"; //URL of GSWExtensions Framework WebServerResources directory
|
"/GSW/GSWExtensions/WebServerResources"; // URL of GSWExtensions
|
||||||
|
// Framework
|
||||||
|
// WebServerResources directory
|
||||||
|
|
||||||
//List of applications
|
//List of applications
|
||||||
applications= {
|
applications = {
|
||||||
//The 1st application: MyApp
|
//The 1st application: MyApp
|
||||||
MyApp = {
|
MyApp = {
|
||||||
//List of its instances
|
//List of its instances
|
||||||
instances = {
|
instances = {
|
||||||
//First Instance
|
//First Instance
|
||||||
1 = {
|
1 = {
|
||||||
host=145.146.147.20; //Host of this instance
|
host = 145.146.147.20; //Host of this instance
|
||||||
port=9001; //Port of this instance
|
port = 9001; //Port of this instance
|
||||||
parameters= { //Unused
|
parameters = { //Unused
|
||||||
transport=socket;
|
transport=socket;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
//The 2nd application: AnotherOne
|
//The 2nd application: AnotherOne
|
||||||
AnotherOne = {
|
AnotherOne = {
|
||||||
//URL of GSWExtensions Framework WebServerResources directory. It overides Global parameter
|
|
||||||
GSWExtensionsFrameworkWebServerResources="/GSW/GSWExtensions/WebServerResources";
|
// URL of GSWExtensions Framework WebServerResources directory.
|
||||||
//YES to say that this application can be listed when the adaptor don't find an application
|
// It overides Global parameter
|
||||||
canDump = YES;
|
GSWExtensionsFrameworkWebServerResources =
|
||||||
//Unused for the moment
|
"/GSW/GSWExtensions/WebServerResources";
|
||||||
applicationHeaders = {
|
|
||||||
header1=1264;
|
// YES to say that this application can be listed when the
|
||||||
header2=4567;
|
// adaptor don't find an application
|
||||||
};
|
canDump = YES;
|
||||||
//Instances
|
|
||||||
instances = {
|
//Unused for the moment
|
||||||
//1st instance
|
applicationHeaders = {
|
||||||
1 = {
|
header1 = 1264;
|
||||||
host=145.146.147.20;
|
header2 = 4567;
|
||||||
port=9002;
|
};
|
||||||
parameters= {
|
|
||||||
transport=socket;
|
//Instances
|
||||||
};
|
instances = {
|
||||||
};
|
//1st instance
|
||||||
};
|
1 = {
|
||||||
};
|
host = 145.146.147.20;
|
||||||
MyAppVoid = {
|
port = 9002;
|
||||||
//Here we have 3 instances
|
parameters = {
|
||||||
instances = {
|
transport = socket;
|
||||||
1 = {
|
};
|
||||||
host=145.146.147.20;
|
};
|
||||||
port=9001;
|
};
|
||||||
parameters= {
|
};
|
||||||
transport=socket;
|
MyAppVoid = {
|
||||||
};
|
// Here we have 3 instances
|
||||||
};
|
instances = {
|
||||||
2 = {
|
1 = {
|
||||||
host=145.146.147.21;
|
host = 145.146.147.20;
|
||||||
port=9002;
|
port = 9001;
|
||||||
parameters= {
|
parameters = {
|
||||||
transport=socket;
|
transport = socket;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
5 ={
|
2 = {
|
||||||
host=145.146.147.22;
|
host = 145.146.147.21;
|
||||||
port=9003;
|
port = 9002;
|
||||||
parameters= {
|
parameters = {
|
||||||
transport=socket;
|
transport=socket;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
5 = {
|
||||||
};
|
host = 145.146.147.22;
|
||||||
|
port = 9003;
|
||||||
};
|
parameters = {
|
||||||
|
transport=socket;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
</PRE>
|
</PRE>
|
||||||
|
</body>
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWApp.c - GSWeb: Adaptors: GSWApp & GSWAppInstance
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: March 2000
|
Date: March 2000
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -38,117 +38,132 @@
|
||||||
#include "GSWUtil.h"
|
#include "GSWUtil.h"
|
||||||
#include "GSWApp.h"
|
#include "GSWApp.h"
|
||||||
|
|
||||||
void GSWApp_InternFreeNotValidInstances(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 GSWApp_InternClearInstances(GSWDictElem *p_pElem,void *p_pData);
|
||||||
void GSWAppInstance_InternClear(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));
|
memset(pApp,0,sizeof(GSWApp));
|
||||||
pApp->iUsageCounter++;
|
pApp->iUsageCounter++;
|
||||||
return pApp;
|
return pApp;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWApp_Free(GSWApp* p_pApp)
|
void
|
||||||
|
GSWApp_Free(GSWApp *p_pApp)
|
||||||
{
|
{
|
||||||
if (!p_pApp)
|
if (!p_pApp)
|
||||||
GSWLog(GSW_CRITICAL,NULL,"No App to free");
|
GSWLog(GSW_CRITICAL,NULL,"No App to free");
|
||||||
else
|
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->pszName)
|
||||||
if (p_pApp->iUsageCounter<0)
|
free(p_pApp->pszName);
|
||||||
GSWLog(GSW_CRITICAL,NULL,"App seems to have been freed too much times");
|
if (p_pApp->pszGSWExtensionsFrameworkWebServerResources)
|
||||||
if (p_pApp->iUsageCounter<=0)
|
free(p_pApp->pszGSWExtensionsFrameworkWebServerResources);
|
||||||
{
|
if (p_pApp->pszAdaptorTemplatesPath)
|
||||||
if (p_pApp->pszName)
|
free(p_pApp->pszAdaptorTemplatesPath);
|
||||||
free(p_pApp->pszName);
|
GSWDict_FreeElements(&p_pApp->stInstancesDict);
|
||||||
if (p_pApp->pszGSWExtensionsFrameworkWebServerResources)
|
GSWDict_FreeElements(&p_pApp->stHeadersDict);
|
||||||
free(p_pApp->pszGSWExtensionsFrameworkWebServerResources);
|
free(p_pApp);
|
||||||
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)
|
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)
|
else if (!p_pInstance)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_CRITICAL,NULL,"No instance to add");
|
GSWLog(GSW_CRITICAL,NULL,"No instance to add");
|
||||||
}
|
}
|
||||||
else
|
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)
|
||||||
GSWLog(GSW_CRITICAL,NULL,"Trying to add instance to another app");
|
p_pInstance->pApp->iUsageCounter--;
|
||||||
if (p_pInstance->pApp)
|
p_pInstance->pApp=p_pApp;
|
||||||
p_pInstance->pApp->iUsageCounter--;
|
p_pInstance->pApp->iUsageCounter++;
|
||||||
p_pInstance->pApp=p_pApp;
|
|
||||||
p_pInstance->pApp->iUsageCounter++;
|
|
||||||
};
|
|
||||||
GSWDict_Add(&p_pApp->stInstancesDict,p_pszInstanceNum,p_pInstance,FALSE);//NotOwner
|
|
||||||
};
|
};
|
||||||
|
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;
|
GSWDict *pInstancesDict=(GSWDict *)p_pData;
|
||||||
GSWAppInstance* pInstance=(GSWAppInstance*)p_pElem->pValue;
|
GSWAppInstance *pInstance=(GSWAppInstance *)p_pElem->pValue;
|
||||||
|
|
||||||
if (!pInstance->fValid)
|
if (!pInstance->fValid)
|
||||||
{
|
{
|
||||||
GSWDict_RemoveKey(pInstancesDict,p_pElem->pszKey);
|
GSWDict_RemoveKey(pInstancesDict,p_pElem->pszKey);
|
||||||
if (GSWAppInstance_FreeIFND(pInstance))
|
if (GSWAppInstance_FreeIFND(pInstance))
|
||||||
pInstance=NULL;
|
pInstance=NULL;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWApp_FreeNotValidInstances(GSWApp* p_pApp)
|
void
|
||||||
|
GSWApp_FreeNotValidInstances(GSWApp *p_pApp)
|
||||||
{
|
{
|
||||||
GSWDict_PerformForAllElem(&p_pApp->stInstancesDict,
|
GSWDict_PerformForAllElem(&p_pApp->stInstancesDict,
|
||||||
GSWApp_InternFreeNotValidInstances,
|
GSWApp_InternFreeNotValidInstances,
|
||||||
&p_pApp->stInstancesDict);
|
&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,
|
GSWDict_PerformForAllElem(&pApp->stInstancesDict,
|
||||||
GSWAppInstance_InternClear,
|
GSWAppInstance_InternClear,
|
||||||
NULL);
|
NULL);
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWApp_AppsClearInstances(GSWDict* p_pAppsDict)
|
void
|
||||||
|
GSWApp_AppsClearInstances(GSWDict *p_pAppsDict)
|
||||||
{
|
{
|
||||||
GSWDict_PerformForAllElem(p_pAppsDict,
|
GSWDict_PerformForAllElem(p_pAppsDict,
|
||||||
GSWApp_InternClearInstances,
|
GSWApp_InternClearInstances,
|
||||||
NULL);
|
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));
|
memset(pInstance,0,sizeof(GSWAppInstance));
|
||||||
if (!p_pApp)
|
if (!p_pApp)
|
||||||
GSWLog(GSW_CRITICAL,NULL,"Intance %p created without App",
|
GSWLog(GSW_CRITICAL,NULL,"Intance %p created without App",
|
||||||
pInstance);
|
pInstance);
|
||||||
pInstance->pApp=p_pApp;
|
pInstance->pApp=p_pApp;
|
||||||
return pInstance;
|
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)
|
||||||
|
{
|
||||||
|
if (p_pInstance->pszHostName)
|
||||||
|
free(p_pInstance->pszHostName);
|
||||||
|
if (p_pInstance->pApp)
|
||||||
{
|
{
|
||||||
if (p_pInstance->pszHostName)
|
char szBuffer[128]="";
|
||||||
free(p_pInstance->pszHostName);
|
sprintf(szBuffer,"%d",p_pInstance->iInstance);
|
||||||
if (p_pInstance->pApp)
|
if (GSWDict_ValueForKey(&p_pInstance->pApp->stInstancesDict,
|
||||||
{
|
szBuffer)==p_pInstance)
|
||||||
char szBuffer[128]="";
|
GSWDict_RemoveKey(&p_pInstance->pApp->stInstancesDict,szBuffer);
|
||||||
sprintf(szBuffer,"%d",p_pInstance->iInstance);
|
p_pInstance->pApp->iUsageCounter--;
|
||||||
if (GSWDict_ValueForKey(&p_pInstance->pApp->stInstancesDict,szBuffer)==p_pInstance)
|
};
|
||||||
GSWDict_RemoveKey(&p_pInstance->pApp->stInstancesDict,szBuffer);
|
free(p_pInstance);
|
||||||
p_pInstance->pApp->iUsageCounter--;
|
};
|
||||||
};
|
|
||||||
free(p_pInstance);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
BOOL GSWAppInstance_FreeIFND(GSWAppInstance* p_pInstance)
|
BOOL
|
||||||
|
GSWAppInstance_FreeIFND(GSWAppInstance *p_pInstance)
|
||||||
{
|
{
|
||||||
if (p_pInstance->uOpenedRequestsNb==0)
|
if (p_pInstance->uOpenedRequestsNb==0)
|
||||||
{
|
{
|
||||||
GSWAppInstance_Free(p_pInstance);
|
GSWAppInstance_Free(p_pInstance);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
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;
|
pInstance->fValid=FALSE;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
void GSWAppInfo_Init()
|
void
|
||||||
|
GSWAppInfo_Init()
|
||||||
{
|
{
|
||||||
if (_gswAppInfoDict == NULL) {
|
if (_gswAppInfoDict == NULL)
|
||||||
_gswAppInfoDict = GSWDict_New(50); // allows 50 different instances of apps
|
{
|
||||||
}
|
_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;
|
char *name = NULL;
|
||||||
|
|
||||||
if (name = calloc(1,50)) {
|
|
||||||
if (pszName) {
|
|
||||||
strncpy(name, pszName,45);
|
|
||||||
name[45]=0;
|
|
||||||
}
|
|
||||||
sprintf(name + strlen(name), "%d", iInstance);
|
|
||||||
|
|
||||||
|
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;
|
char *name;
|
||||||
GSWAppInfo* newInfo = NULL;
|
GSWAppInfo *newInfo = NULL;
|
||||||
|
|
||||||
if (_gswAppInfoDict == NULL) {
|
if (_gswAppInfoDict == NULL)
|
||||||
GSWAppInfo_Init();
|
{
|
||||||
return NULL;
|
GSWAppInfo_Init();
|
||||||
}
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
name = GSWAppInfo_MakeDictKeyName(pszName, iInstance);
|
name = GSWAppInfo_MakeDictKeyName(pszName, iInstance);
|
||||||
if (name) {
|
if (name)
|
||||||
newInfo = GSWDict_ValueForKey(_gswAppInfoDict, name);
|
{
|
||||||
free(name); name = NULL;
|
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) {
|
if (appInfoDict)
|
||||||
GSWDict_Add(_gswAppInfoDict, keyName, appInfoDict, TRUE);
|
{
|
||||||
}
|
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;
|
char *name;
|
||||||
GSWAppInfo* newInfo = GSWAppInfo_Find(pszName, iInstance);
|
GSWAppInfo *newInfo = GSWAppInfo_Find(pszName, iInstance);
|
||||||
time_t curTime = (time_t)0;
|
time_t curTime = (time_t)0;
|
||||||
BOOL addDict = FALSE;
|
BOOL addDict = FALSE;
|
||||||
|
|
||||||
if (newInfo == NULL) {
|
if (newInfo == NULL)
|
||||||
newInfo=(GSWAppInfo*)calloc(1,sizeof(GSWAppInfo));
|
{
|
||||||
addDict = TRUE;
|
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);
|
||||||
}
|
}
|
||||||
|
free(name);
|
||||||
if (newInfo && (name = GSWAppInfo_MakeDictKeyName(pszName, iInstance) )) {
|
name = NULL;
|
||||||
newInfo->isRefused = isRefused;
|
}
|
||||||
time(&curTime);
|
else
|
||||||
newInfo->timeNextRetryTime = curTime + 10; // + 10 sec
|
{
|
||||||
|
if (newInfo)
|
||||||
if (addDict == TRUE) {
|
{
|
||||||
GSWAppInfo_Add(newInfo, name);
|
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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWApp.h - GSWeb: Adaptors: GSWApp & GSWAppInstance
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: March 2000
|
Date: March 2000
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -26,38 +26,40 @@
|
||||||
|
|
||||||
typedef struct _GSWApp
|
typedef struct _GSWApp
|
||||||
{
|
{
|
||||||
int iUsageCounter;
|
int iUsageCounter;
|
||||||
char* pszName;
|
char *pszName;
|
||||||
int iIndex;//Current Instance Index
|
int iIndex;//Current Instance Index
|
||||||
GSWDict stInstancesDict;
|
GSWDict stInstancesDict;
|
||||||
GSWDict stHeadersDict;
|
GSWDict stHeadersDict;
|
||||||
char* pszGSWExtensionsFrameworkWebServerResources;
|
char *pszGSWExtensionsFrameworkWebServerResources;
|
||||||
BOOL fCanDump;
|
BOOL fCanDump;
|
||||||
char* pszAdaptorTemplatesPath;
|
char *pszAdaptorTemplatesPath;
|
||||||
} GSWApp;
|
} GSWApp;
|
||||||
|
|
||||||
typedef struct _GSWAppInstance
|
typedef struct _GSWAppInstance
|
||||||
{
|
{
|
||||||
GSWApp* pApp;
|
GSWApp *pApp;
|
||||||
int iInstance;
|
int iInstance;
|
||||||
char* pszHostName;
|
char *pszHostName;
|
||||||
int iPort;
|
int iPort;
|
||||||
time_t timeNextRetryTime; // Timer
|
time_t timeNextRetryTime; // Timer
|
||||||
unsigned int uOpenedRequestsNb;
|
unsigned int uOpenedRequestsNb;
|
||||||
BOOL fValid;
|
BOOL fValid;
|
||||||
} GSWAppInstance;
|
} GSWAppInstance;
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
GSWApp* GSWApp_New();
|
GSWApp *GSWApp_New();
|
||||||
void GSWApp_Free(GSWApp* p_pApp);
|
void GSWApp_Free(GSWApp *p_pApp);
|
||||||
void GSWApp_FreeNotValidInstances(GSWApp* p_pApp);
|
void GSWApp_FreeNotValidInstances(GSWApp *p_pApp);
|
||||||
void GSWApp_AppsClearInstances(GSWDict* p_pAppsDict);
|
void GSWApp_AppsClearInstances(GSWDict *p_pAppsDict);
|
||||||
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);
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
GSWAppInstance* GSWAppInstance_New(GSWApp* p_pApp);
|
GSWAppInstance *GSWAppInstance_New(GSWApp *p_pApp);
|
||||||
void GSWAppInstance_Free(GSWAppInstance* p_pInstance);
|
void GSWAppInstance_Free(GSWAppInstance *p_pInstance);
|
||||||
BOOL GSWAppInstance_FreeIFND(GSWAppInstance* p_pInstance);
|
BOOL GSWAppInstance_FreeIFND(GSWAppInstance *p_pInstance);
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
typedef struct _GSWAppInfo
|
typedef struct _GSWAppInfo
|
||||||
|
@ -66,13 +68,13 @@ typedef struct _GSWAppInfo
|
||||||
time_t timeNextRetryTime; // next try to look, if it is not refused
|
time_t timeNextRetryTime; // next try to look, if it is not refused
|
||||||
} GSWAppInfo;
|
} GSWAppInfo;
|
||||||
|
|
||||||
static GSWDict* _gswAppInfoDict = NULL;
|
static GSWDict *_gswAppInfoDict = NULL;
|
||||||
|
|
||||||
void GSWAppInfo_Init();
|
void GSWAppInfo_Init();
|
||||||
GSWAppInfo* GSWAppInfo_Find(char* pszName, int iInstance);
|
GSWAppInfo *GSWAppInfo_Find(char *pszName,int iInstance);
|
||||||
void GSWAppInfo_Add(GSWAppInfo* appInfoDict, CONST char* keyName);
|
void GSWAppInfo_Add(GSWAppInfo *appInfoDict, CONST char *keyName);
|
||||||
void GSWAppInfo_Set(char* pszName, int iInstance, BOOL isRefused);
|
void GSWAppInfo_Set(char *pszName, int iInstance, BOOL isRefused);
|
||||||
void GSWAppInfo_Remove(GSWAppInfo* _appInfo);
|
void GSWAppInfo_Remove(GSWAppInfo *_appInfo);
|
||||||
|
|
||||||
|
|
||||||
#endif // _GSWApp_h__
|
#endif // _GSWApp_h__
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWAppConnect.h - GSWeb: GSWeb App Connect
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -26,33 +26,33 @@
|
||||||
|
|
||||||
typedef struct _STAppConnectHandle
|
typedef struct _STAppConnectHandle
|
||||||
{
|
{
|
||||||
void* foo;
|
void *foo;
|
||||||
} STAppConnectHandle;
|
} STAppConnectHandle;
|
||||||
|
|
||||||
typedef STAppConnectHandle* AppConnectHandle;
|
typedef STAppConnectHandle *AppConnectHandle;
|
||||||
|
|
||||||
|
|
||||||
AppConnectHandle GSWApp_Open(GSWAppRequest* p_pAppRequest,
|
AppConnectHandle GSWApp_Open(GSWAppRequest *p_pAppRequest,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
void GSWApp_Close(AppConnectHandle p_handle,
|
void GSWApp_Close(AppConnectHandle p_handle,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
|
|
||||||
int GSWApp_SendBlock(AppConnectHandle p_handle,
|
int GSWApp_SendBlock(AppConnectHandle p_handle,
|
||||||
CONST char* p_pszBuffer,
|
CONST char *p_pszBuffer,
|
||||||
int p_iSize,
|
int p_iSize,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
int GSWApp_ReceiveBlock(AppConnectHandle p_handle,
|
int GSWApp_ReceiveBlock(AppConnectHandle p_handle,
|
||||||
char* p_pszBuffer,
|
char *p_pszBuffer,
|
||||||
int p_iBufferSize,
|
int p_iBufferSize,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
|
|
||||||
int GSWApp_SendLine(AppConnectHandle p_handle,
|
int GSWApp_SendLine(AppConnectHandle p_handle,
|
||||||
CONST char* p_pszBuffer,
|
CONST char *p_pszBuffer,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
int GSWApp_ReceiveLine(AppConnectHandle p_handle,
|
int GSWApp_ReceiveLine(AppConnectHandle p_handle,
|
||||||
char* p_pszBuffer,
|
char *p_pszBuffer,
|
||||||
int p_iBufferSize,
|
int p_iBufferSize,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
|
|
||||||
|
|
||||||
#endif // _GSWAppConnect_h__
|
#endif // _GSWAppConnect_h__
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWAppConnectNSSocket.c - GSWeb: Adaptors: App Connection by Netscape Sockets
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -41,180 +41,195 @@
|
||||||
|
|
||||||
typedef SYS_NETFD AppConnectNSSocketHandle;
|
typedef SYS_NETFD AppConnectNSSocketHandle;
|
||||||
|
|
||||||
AppConnectHandle GSWApp_Open(GSWAppRequest* p_pAppRequest,
|
AppConnectHandle
|
||||||
void* p_pLogServerData)
|
GSWApp_Open(GSWAppRequest *p_pAppRequest,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
AppConnectHandle handle=NULL;
|
AppConnectHandle handle=NULL;
|
||||||
if (!p_pAppRequest)
|
if (!p_pAppRequest)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
struct hostent *pHost=hl_find(p_pAppRequest->pszHost);
|
||||||
|
if (!pHost)
|
||||||
{
|
{
|
||||||
struct hostent* pHost=hl_find(p_pAppRequest->pszHost);
|
GSWLog(GSW_ERROR, p_pLogServerData,
|
||||||
if (!pHost)
|
"gethostbyname(%s) returns no host",
|
||||||
{
|
p_pAppRequest->pszHost);
|
||||||
GSWLog(GSW_ERROR, "gethostbyname(%s) returns no host",p_pAppRequest->pszHost);
|
}
|
||||||
}
|
else if (pHost->h_addrtype!=AF_INET)
|
||||||
else if (pHost->h_addrtype!=AF_INET)
|
{
|
||||||
{
|
GSWLog(GSW_ERROR, p_pLogServerData, "Host %s has bad address type",
|
||||||
GSWLog(GSW_ERROR,"Host %s has bad address type",p_pAppRequest->pszHost);
|
p_pAppRequest->pszHost);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AppConnectNSSocketHandle nshandle=NULL;
|
AppConnectNSSocketHandle nshandle=NULL;
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
memset(&sin,0,sizeof(sin));
|
memset(&sin,0,sizeof(sin));
|
||||||
sin.sin_family = pHost->h_addrtype;
|
sin.sin_family = pHost->h_addrtype;
|
||||||
sin.sin_port = htons(p_pAppRequest->iPort);
|
sin.sin_port = htons(p_pAppRequest->iPort);
|
||||||
memcpy(&sin.sin_addr, pHost->h_addr_list[0] , pHost->h_length);
|
memcpy(&sin.sin_addr, pHost->h_addr_list[0] , pHost->h_length);
|
||||||
|
|
||||||
GSWLog(GSW_INFO, "Try contacting %s on port %d...",
|
GSWLog(GSW_INFO, p_pLogServerData, "Try contacting %s on port %d...",
|
||||||
p_pAppRequest->pszHost,
|
p_pAppRequest->pszHost,
|
||||||
p_pAppRequest->iPort);
|
p_pAppRequest->iPort);
|
||||||
nshandle = net_socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
|
nshandle = net_socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
|
||||||
if (nshandle<0)
|
if (nshandle<0)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_ERROR,"Can't Create socket to %s:%d. Error=%d (%s)",
|
GSWLog(GSW_ERROR, p_pLogServerData,
|
||||||
p_pAppRequest->pszHost,
|
"Can't Create socket to %s:%d. Error=%d (%s)",
|
||||||
p_pAppRequest->iPort,
|
p_pAppRequest->pszHost,
|
||||||
errno,
|
p_pAppRequest->iPort,
|
||||||
strerror(errno));
|
errno,
|
||||||
}
|
strerror(errno));
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
if (net_connect(nshandle,(struct sockaddr*)&sin,sizeof(sin))<0)
|
{
|
||||||
{
|
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,
|
GSWLog(GSW_ERROR, p_pLogServerData,
|
||||||
p_pAppRequest->iPort,
|
"Can't connect to %s:%d. Error=%d (%s)",
|
||||||
errno,
|
p_pAppRequest->pszHost,
|
||||||
strerror(errno));
|
p_pAppRequest->iPort,
|
||||||
net_close(nshandle);
|
errno,
|
||||||
};
|
strerror(errno));
|
||||||
};
|
net_close(nshandle);
|
||||||
handle=(AppConnectHandle)nshandle;
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
handle=(AppConnectHandle)nshandle;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
return handle;
|
return handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
void GSWApp_Close(AppConnectHandle p_handle,
|
void
|
||||||
void* p_pLogServerData)
|
GSWApp_Close(AppConnectHandle p_handle,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
if (p_handle)
|
if (p_handle)
|
||||||
{
|
{
|
||||||
AppConnectNSSocketHandle handle=(AppConnectNSSocketHandle)p_handle;
|
AppConnectNSSocketHandle handle=(AppConnectNSSocketHandle)p_handle;
|
||||||
if (handle && handle>(AppConnectNSSocketHandle)1)
|
if (handle && handle>(AppConnectNSSocketHandle)1)
|
||||||
net_close(handle);
|
net_close(handle);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
int GSWApp_SendLine(AppConnectHandle p_handle,
|
int
|
||||||
CONST char* p_pszBuffer,
|
GSWApp_SendLine(AppConnectHandle p_handle,
|
||||||
void* p_pLogServerData)
|
CONST char *p_pszBuffer,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
int iRetValue=-1;
|
int iRetValue=-1;
|
||||||
if (p_handle)
|
if (p_handle)
|
||||||
iRetValue=sendbytes(p_handle,p_pszBuffer,strlen(p_pszBuffer));
|
iRetValue=sendbytes(p_handle,p_pszBuffer,strlen(p_pszBuffer));
|
||||||
return iRetValue;
|
return iRetValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GSWApp_SendBlock(AppConnectHandle p_handle,
|
int
|
||||||
CONST char* p_pszBuffer,
|
GSWApp_SendBlock(AppConnectHandle p_handle,
|
||||||
int p_iSize,
|
CONST char *p_pszBuffer,
|
||||||
void* p_pLogServerData)
|
int p_iSize,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
int iRetValue=-1;
|
int iRetValue=-1;
|
||||||
if (p_handle)
|
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;
|
iSent=net_write(handle,(char *)p_pszBuffer,iRemainingSize);
|
||||||
int iSent=0;
|
if (iSent<0)
|
||||||
int iRemainingSize = p_iSize;
|
GSWLog(GSW_ERROR, p_pLogServerData,
|
||||||
while (iRemainingSize>0 && iSent>=0)
|
"send failed. Error=%d (%s)",
|
||||||
{
|
errno,
|
||||||
iSent=net_write(handle,(char*)p_pszBuffer,iRemainingSize);
|
strerror(errno));
|
||||||
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);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
iRetValue=0; //??
|
{
|
||||||
|
p_pszBuffer+=iSent;
|
||||||
|
iRemainingSize-=iSent;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
iRetValue=(iRemainingSize>0) ? -1 : 0;
|
||||||
|
};
|
||||||
return iRetValue;
|
return iRetValue;
|
||||||
};
|
}
|
||||||
|
|
||||||
int GSWApp_ReceiveBlock(AppConnectHandle p_handle,
|
int
|
||||||
char* p_pszBuffer,
|
GSWApp_ReceiveLine(AppConnectHandle p_handle,
|
||||||
int p_iBufferSize,
|
char *p_pszBuffer,
|
||||||
void* p_pLogServerData)
|
int p_iBufferSize,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
int iRetValue=-1;
|
int iRetValue=-1;
|
||||||
if (p_handle)
|
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;
|
iReaden=net_read(handle,&c,1,APP_CONNECT_TIMEOUT);
|
||||||
int iReceived=0;
|
if (iReaden<1)
|
||||||
int iRemainingSize=p_iBufferSize;
|
{
|
||||||
BOOL fOk=TRUE;
|
GSWLog(GSW_ERROR, p_pLogServerData,
|
||||||
while (iRemainingSize>0 && fOk)
|
"GSWApp_ReceiveLine. Error=%d (%s)",
|
||||||
{
|
errno,
|
||||||
iReceived=net_read(handle,p_pszBuffer,iRemainingSize,APP_CONNECT_TIMEOUT);
|
strerror(errno));
|
||||||
if (iReceived<0)
|
iRetValue=0; //??
|
||||||
{
|
fOk=FALSE;
|
||||||
GSWLog(GSW_ERROR,"GSWApp_ReceiveBlock failed. Error=%d %s",
|
}
|
||||||
errno,
|
else
|
||||||
strerror(errno));
|
p_pszBuffer[i++] = c;
|
||||||
fOk=FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p_pszBuffer+=iReceived;
|
|
||||||
iRemainingSize-=iReceived;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
iRetValue=p_iBufferSize-iRemainingSize;
|
|
||||||
};
|
};
|
||||||
|
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;
|
return iRetValue;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWAppConnectSocket.c - GSWeb: Adaptors: App Connection by Socket
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWAppRequest.c - GSWeb: Adaptors: App Request
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -60,156 +60,180 @@ Connection closed by foreign host.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequest,
|
GSWHTTPResponse *
|
||||||
GSWURLComponents* p_pURLComponents,
|
GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest **p_ppHTTPRequest,
|
||||||
GSWAppRequest* p_pAppRequest,
|
GSWURLComponents *p_pURLComponents,
|
||||||
CONST char* p_pszHTTPVersion,
|
GSWAppRequest *p_pAppRequest,
|
||||||
void* p_pLogServerData)
|
CONST char *p_pszHTTPVersion,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
GSWHTTPResponse* pHTTPResponse=NULL;
|
GSWHTTPResponse *pHTTPResponse=NULL;
|
||||||
BOOL fAppFound=FALSE;
|
BOOL fAppFound=FALSE;
|
||||||
BOOL fAppNotResponding=FALSE;
|
BOOL fAppNotResponding=FALSE;
|
||||||
int iAttemptsRemaining=APP_CONNECT_RETRIES_NB;
|
int iAttemptsRemaining=APP_CONNECT_RETRIES_NB;
|
||||||
AppConnectHandle hConnect=NULL;
|
AppConnectHandle hConnect=NULL;
|
||||||
char *appName = NULL;
|
char *appName = NULL;
|
||||||
int appInstance = 0;
|
int appInstance = 0;
|
||||||
|
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWAppRequest_SendAppRequestToApp");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWAppRequest_SendAppRequestToApp");
|
||||||
|
|
||||||
if (p_pAppRequest->iInstance>0) //-1 or 0 mean any instance
|
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
|
else
|
||||||
fAppFound = GSWLoadBalancing_FindApp(p_pAppRequest,p_pLogServerData, p_pURLComponents);
|
fAppFound = GSWLoadBalancing_FindApp(p_pAppRequest,
|
||||||
|
p_pLogServerData,
|
||||||
|
p_pURLComponents);
|
||||||
|
|
||||||
if (!fAppFound)
|
if (!fAppFound)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_WARNING,p_pLogServerData,"App not found");
|
GSWLog(GSW_WARNING,p_pLogServerData,"App not found");
|
||||||
//TODO
|
//TODO
|
||||||
// Call AppStart daemon
|
// Call AppStart daemon
|
||||||
};
|
};
|
||||||
|
|
||||||
while (!pHTTPResponse && fAppFound && iAttemptsRemaining-->0)
|
while (!pHTTPResponse && fAppFound && iAttemptsRemaining-->0)
|
||||||
{
|
{
|
||||||
fAppNotResponding=FALSE;
|
fAppNotResponding=FALSE;
|
||||||
GSWLog(GSW_INFO,p_pLogServerData,"Trying to contact %s:%d on %s(%d)",
|
GSWLog(GSW_INFO,p_pLogServerData,"Trying to contact %s:%d on %s(%d)",
|
||||||
p_pAppRequest->pszName,
|
p_pAppRequest->pszName,
|
||||||
p_pAppRequest->iInstance,
|
p_pAppRequest->iInstance,
|
||||||
p_pAppRequest->pszHost,
|
p_pAppRequest->pszHost,
|
||||||
p_pAppRequest->iPort);
|
p_pAppRequest->iPort);
|
||||||
|
|
||||||
hConnect = GSWApp_Open(p_pAppRequest,p_pLogServerData);
|
hConnect = GSWApp_Open(p_pAppRequest,p_pLogServerData);
|
||||||
if (hConnect)
|
if (hConnect)
|
||||||
{
|
{
|
||||||
if (p_pAppRequest->eType==EAppType_LoadBalanced)
|
if (p_pAppRequest->eType==EAppType_LoadBalanced)
|
||||||
GSWLoadBalancing_StartAppRequest(p_pAppRequest,p_pLogServerData);
|
GSWLoadBalancing_StartAppRequest(p_pAppRequest,
|
||||||
|
p_pLogServerData);
|
||||||
|
|
||||||
GSWLog(GSW_INFO,p_pLogServerData,"%s:%d on %s(%d) connected",
|
GSWLog(GSW_INFO,p_pLogServerData,"%s:%d on %s(%d) connected",
|
||||||
p_pAppRequest->pszName,
|
p_pAppRequest->pszName,
|
||||||
p_pAppRequest->iInstance,
|
p_pAppRequest->iInstance,
|
||||||
p_pAppRequest->pszHost,
|
p_pAppRequest->pszHost,
|
||||||
p_pAppRequest->iPort);
|
p_pAppRequest->iPort);
|
||||||
|
|
||||||
GSWHTTPRequest_HTTPToAppRequest(*p_ppHTTPRequest,
|
GSWHTTPRequest_HTTPToAppRequest(*p_ppHTTPRequest,
|
||||||
p_pAppRequest,
|
p_pAppRequest,
|
||||||
p_pURLComponents,
|
p_pURLComponents,
|
||||||
p_pszHTTPVersion,
|
p_pszHTTPVersion,
|
||||||
p_pLogServerData);
|
p_pLogServerData);
|
||||||
if (GSWHTTPRequest_SendRequest(*p_ppHTTPRequest,
|
if (GSWHTTPRequest_SendRequest(*p_ppHTTPRequest,
|
||||||
hConnect,
|
hConnect,
|
||||||
p_pLogServerData) != 0)
|
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
|
|
||||||
{
|
{
|
||||||
|
GSWLog(GSW_ERROR,p_pLogServerData,"Failed to send request");
|
||||||
|
GSWApp_Close(hConnect,p_pLogServerData);
|
||||||
|
hConnect=NULL;
|
||||||
fAppNotResponding=TRUE;
|
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);
|
GSWHTTPRequest_Free(*p_ppHTTPRequest,p_pLogServerData);
|
||||||
*p_ppHTTPRequest=NULL;
|
*p_ppHTTPRequest=NULL;
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWAppRequest_SendAppRequestToApp");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWAppRequest_SendAppRequestToApp");
|
||||||
|
@ -217,111 +241,131 @@ GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequ
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
GSWHTTPResponse* GSWAppRequest_HandleRequest(GSWHTTPRequest** p_ppHTTPRequest,
|
GSWHTTPResponse *
|
||||||
GSWURLComponents* p_pURLComponents,
|
GSWAppRequest_HandleRequest(GSWHTTPRequest **p_ppHTTPRequest,
|
||||||
CONST char* p_pszHTTPVersion,
|
GSWURLComponents *p_pURLComponents,
|
||||||
CONST char* p_pszDocRoot,
|
CONST char *p_pszHTTPVersion,
|
||||||
CONST char* p_pszTestAppName,
|
CONST char *p_pszDocRoot,
|
||||||
void* p_pLogServerData)
|
CONST char *p_pszTestAppName,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
GSWHTTPResponse* pHTTPResponse=NULL;
|
GSWHTTPResponse *pHTTPResponse=NULL;
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWAppRequest_HandleRequest");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWAppRequest_HandleRequest");
|
||||||
glbRequestsNb++;
|
glbRequestsNb++;
|
||||||
if (!p_pURLComponents)
|
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
|
else
|
||||||
|
{
|
||||||
|
if (p_pURLComponents->stAppName.iLength<=0
|
||||||
|
|| !p_pURLComponents->stAppName.pszStart)
|
||||||
{
|
{
|
||||||
if (p_pURLComponents->stAppName.iLength<=0
|
pHTTPResponse=GSWHTTPResponse_BuildErrorResponse(NULL,
|
||||||
|| !p_pURLComponents->stAppName.pszStart)
|
"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
|
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]="";
|
strncpy(szHost,
|
||||||
char szHost[MAXHOSTNAMELEN+1]="";
|
p_pURLComponents->stAppHost.pszStart,
|
||||||
GSWAppRequest stAppRequest;
|
p_pURLComponents->stAppHost.iLength);
|
||||||
memset(&stAppRequest,0,sizeof(stAppRequest));
|
szHost[p_pURLComponents->stAppHost.iLength] = '\0';
|
||||||
|
|
||||||
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);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 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");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWAppRequest_HandleRequest");
|
||||||
return pHTTPResponse;
|
return pHTTPResponse;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWAppRequest.h - GSWeb: GSWeb App Request
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
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}
|
#define GSWAppRequest_INITIALIZER {NULL,NULL,NULL,0,0,AT_NONE,3,NULL,NULL,NULL,NULL}
|
||||||
|
|
||||||
GSWHTTPResponse* GSWAppRequest_HandleRequest(GSWHTTPRequest** p_ppHTTPRequest,
|
GSWHTTPResponse *GSWAppRequest_HandleRequest(GSWHTTPRequest **p_ppHTTPRequest,
|
||||||
GSWURLComponents* p_pURLComponents,
|
GSWURLComponents *p_pURLComponents,
|
||||||
CONST char* p_pszHTTPVersion,
|
CONST char *p_pszHTTPVersion,
|
||||||
CONST char* p_pszDocRoot,
|
CONST char *p_pszDocRoot,
|
||||||
CONST char* p_pszTestAppName,
|
CONST char *p_pszTestAppName,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
|
|
||||||
#endif //_GSWAppRequest_h__
|
#endif //_GSWAppRequest_h__
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWAppRequestStruct.h - GSWeb: GSWeb App Request Struct
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -32,26 +32,26 @@ extern "C" {
|
||||||
|
|
||||||
// Application Type
|
// Application Type
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EAppType_Unknown,
|
EAppType_Unknown,
|
||||||
EAppType_Auto, // autolaunched/co-hosted
|
EAppType_Auto, // autolaunched/co-hosted
|
||||||
EAppType_LoadBalanced
|
EAppType_LoadBalanced
|
||||||
} EAppType;
|
} EAppType;
|
||||||
|
|
||||||
|
|
||||||
// AppRequest
|
// AppRequest
|
||||||
typedef struct _GSWAppRequest
|
typedef struct _GSWAppRequest
|
||||||
{
|
{
|
||||||
char* pszName; // App Name relative to Prefix
|
char *pszName; // App Name relative to Prefix
|
||||||
char* pszHost; // App Host
|
char *pszHost; // App Host
|
||||||
void* pHostent; // App Host hostent
|
void *pHostent; // App Host hostent
|
||||||
int iPort; // AppPort
|
int iPort; // AppPort
|
||||||
int iInstance; // App Instance
|
int iInstance; // App Instance
|
||||||
EAppType eType; // AppType
|
EAppType eType; // AppType
|
||||||
unsigned char uURLVersion; // URL Version
|
unsigned char uURLVersion; // URL Version
|
||||||
CONST char* pszDocRoot; // Doc Root
|
CONST char *pszDocRoot; // Doc Root
|
||||||
void* pRequest; // HTTPRequest
|
void *pRequest; // HTTPRequest
|
||||||
void* pResponse; // HTTPResponse
|
void *pResponse; // HTTPResponse
|
||||||
GSWAppInstance* pAppInstance;
|
GSWAppInstance *pAppInstance;
|
||||||
} GSWAppRequest;
|
} GSWAppRequest;
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,8 @@
|
||||||
/* GSWConfig.h - GSWeb: GSWeb Configuration Management
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -38,46 +38,46 @@
|
||||||
#define WONAMES_INDEX 1
|
#define WONAMES_INDEX 1
|
||||||
|
|
||||||
|
|
||||||
extern GSWLock g_lockAppList;
|
extern GSWLock g_lockAppList;
|
||||||
extern GSWDict* g_pAppDict;
|
extern GSWDict *g_pAppDict;
|
||||||
extern time_t config_mtime;
|
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_Prefix;
|
||||||
extern const char* g_szGSWeb_Handler;
|
extern const char *g_szGSWeb_Handler;
|
||||||
extern const char* g_szGSWeb_StatusResponseAppName;
|
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_MimeType;
|
||||||
//extern const char* g_szGSWeb_Conf_DocRoot;
|
//extern const char *g_szGSWeb_Conf_DocRoot;
|
||||||
extern const char* g_szGSWeb_Conf_ConfigFilePath;
|
extern const char *g_szGSWeb_Conf_ConfigFilePath;
|
||||||
|
|
||||||
// Apache
|
// Apache
|
||||||
#if defined(Apache)
|
#if defined(Apache)
|
||||||
extern const char* g_szGSWeb_Conf_Alias;
|
extern const char *g_szGSWeb_Conf_Alias;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Netscape
|
// Netscape
|
||||||
#if defined(Netscape)
|
#if defined(Netscape)
|
||||||
extern const char* g_szGSWeb_Conf_PathTrans;
|
extern const char *g_szGSWeb_Conf_PathTrans;
|
||||||
extern const char* g_szGSWeb_Conf_AppRoot;
|
extern const char *g_szGSWeb_Conf_AppRoot;
|
||||||
extern const char* g_szGSWeb_Conf_Name;
|
extern const char *g_szGSWeb_Conf_Name;
|
||||||
#endif
|
#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_Server;
|
||||||
extern const char* g_szGSWeb_ServerAndAdaptorVersion;
|
extern const char *g_szGSWeb_ServerAndAdaptorVersion;
|
||||||
|
|
||||||
|
|
||||||
extern const char* const g_szGNUstep;
|
extern const char *const g_szGNUstep;
|
||||||
extern const char* const g_szOKGSWeb[2];
|
extern const char *const g_szOKGSWeb[2];
|
||||||
extern const char* const g_szOKStatus[2];
|
extern const char *const g_szOKStatus[2];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,45 +96,50 @@ typedef enum
|
||||||
|
|
||||||
typedef struct _GSWConfig
|
typedef struct _GSWConfig
|
||||||
{
|
{
|
||||||
char* pszConfigFilePath;
|
char *pszConfigFilePath;
|
||||||
char* pszGSWExtensionsFrameworkWebServerResources;
|
char *pszGSWExtensionsFrameworkWebServerResources;
|
||||||
BOOL fCanDumpStatus;
|
BOOL fCanDumpStatus;
|
||||||
char* pszAdaptorTemplatesPath;
|
char *pszAdaptorTemplatesPath;
|
||||||
} GSWConfig;
|
} GSWConfig;
|
||||||
|
|
||||||
|
|
||||||
EGSWConfigResult GSWConfig_ReadIFND(CONST char* p_pszConfigPath,
|
EGSWConfigResult GSWConfig_ReadIFND(CONST char *p_pszConfigPath,
|
||||||
time_t* p_pLastReadTime,
|
time_t *p_pLastReadTime,
|
||||||
proplist_t* p_ppPropList,//Please, PLRelease it after used !
|
proplist_t *p_ppPropList,//Please, PLRelease it after used !
|
||||||
void* p_pLogServerData);
|
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,
|
proplist_t GSWConfig_ApplicationKeyFromApplicationsKey(proplist_t p_propListApplicationsKeys,
|
||||||
int p_iIndex,
|
int p_iIndex,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
proplist_t GSWConfig_InstancesFromApplication(proplist_t p_propListApplication,void* p_pLogServerData);
|
proplist_t GSWConfig_InstancesFromApplication(proplist_t p_propListApplication,
|
||||||
|
void *p_pLogServerData);
|
||||||
proplist_t GSWConfig_ApplicationFromApplications(proplist_t p_propListApplications,
|
proplist_t GSWConfig_ApplicationFromApplications(proplist_t p_propListApplications,
|
||||||
proplist_t p_propListApplicationKey,void* p_pLogServerData);
|
proplist_t p_propListApplicationKey,
|
||||||
proplist_t GSWConfig_ApplicationsKeysFromApplications(proplist_t p_propListApplications,void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
proplist_t GSWConfig_ApplicationsKeysFromConfig(proplist_t p_propListConfig,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();
|
BOOL GSWConfig_CanDumpStatus();
|
||||||
CONST char* GSWConfig_GetConfigFilePath();
|
CONST char *GSWConfig_GetConfigFilePath();
|
||||||
void GSWConfig_SetConfigFilePath(CONST char* p_pszConfigFilePath);
|
void GSWConfig_SetConfigFilePath(CONST char *p_pszConfigFilePath);
|
||||||
GSWString* GSWConfig_DumpGSWApps(const char* p_pszReqApp,
|
GSWString *GSWConfig_DumpGSWApps(const char *p_pszReqApp,
|
||||||
const char* p_pszPrefix,
|
const char *p_pszPrefix,
|
||||||
BOOL p_fForceDump,
|
BOOL p_fForceDump,
|
||||||
BOOL p_fHTML,
|
BOOL p_fHTML,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
void GSWConfig_Init(GSWDict* p_pDict,
|
void GSWConfig_Init(GSWDict *p_pDict,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
GSWApp* GSWConfig_GetApp(CONST char* p_pszAppName);
|
GSWApp *GSWConfig_GetApp(CONST char *p_pszAppName);
|
||||||
CONST char* GSWConfig_AdaptorBuilt();
|
CONST char *GSWConfig_AdaptorBuilt();
|
||||||
CONST char* GSWConfig_ServerStringInfo();
|
CONST char *GSWConfig_ServerStringInfo();
|
||||||
CONST char* g_szGSWeb_AdaptorStringInfo();
|
CONST char *g_szGSWeb_AdaptorStringInfo();
|
||||||
CONST char* GSWConfig_ServerURL();
|
CONST char *GSWConfig_ServerURL();
|
||||||
CONST char* g_szGSWeb_AdaptorURL();
|
CONST char *g_szGSWeb_AdaptorURL();
|
||||||
|
|
||||||
#endif // _GSWConfig_h__
|
#endif // _GSWConfig_h__
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWDict.c - GSWeb: Dictionary
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -29,215 +29,242 @@
|
||||||
#include "GSWUtil.h"
|
#include "GSWUtil.h"
|
||||||
#include "GSWDict.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)
|
if (!p_pDict)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
|
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
p_uCapacity=max(16,p_uCapacity);
|
||||||
|
if (p_uCapacity>p_pDict->uCapacity)
|
||||||
{
|
{
|
||||||
p_uCapacity=max(16,p_uCapacity);
|
if (p_pDict->pElems)
|
||||||
if (p_uCapacity>p_pDict->uCapacity)
|
p_pDict->pElems = realloc(p_pDict->pElems,
|
||||||
{
|
p_uCapacity*sizeof(GSWDictElem));
|
||||||
if (p_pDict->pElems)
|
else
|
||||||
p_pDict->pElems = realloc(p_pDict->pElems,p_uCapacity*sizeof(GSWDictElem));
|
p_pDict->pElems = malloc(p_uCapacity*sizeof(GSWDictElem));
|
||||||
else
|
p_pDict->uCapacity = p_uCapacity;
|
||||||
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));
|
memset(pDict,0,sizeof(GSWDict));
|
||||||
GSWDict_SetCapacity(pDict,max(16,p_uCapacity));
|
GSWDict_SetCapacity(pDict,max(16,p_uCapacity));
|
||||||
return pDict;
|
return pDict;
|
||||||
};
|
};
|
||||||
|
|
||||||
void GSWDict_FreeElem(GSWDictElem* p_pElem,void* p_pData)
|
void
|
||||||
|
GSWDict_FreeElem(GSWDictElem *p_pElem,void *p_pData)
|
||||||
{
|
{
|
||||||
if (!p_pElem)
|
if (!p_pElem)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict pElem");
|
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict pElem");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (p_pElem->pszKey)
|
||||||
{
|
{
|
||||||
if (p_pElem->pszKey)
|
free((char *)p_pElem->pszKey);
|
||||||
{
|
p_pElem->pszKey=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;
|
|
||||||
};
|
};
|
||||||
|
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);
|
GSWDict_PerformForAllElem(p_pDict,GSWDict_FreeElem,NULL);
|
||||||
};
|
};
|
||||||
|
|
||||||
void GSWDict_Free(GSWDict* p_pDict)
|
void
|
||||||
|
GSWDict_Free(GSWDict *p_pDict)
|
||||||
{
|
{
|
||||||
if (!p_pDict)
|
if (!p_pDict)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_ERROR,NULL,"NULL GSWDict");
|
GSWLog(GSW_ERROR,NULL,"NULL GSWDict");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GSWDict_FreeElements(p_pDict);
|
GSWDict_FreeElements(p_pDict);
|
||||||
if (p_pDict->pElems)
|
if (p_pDict->pElems)
|
||||||
free(p_pDict->pElems);
|
free(p_pDict->pElems);
|
||||||
free(p_pDict);
|
free(p_pDict);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static GSWDictElem* GSWDict_FindFirstNullKey(GSWDict* p_pDict)
|
static GSWDictElem *
|
||||||
|
GSWDict_FindFirstNullKey(GSWDict *p_pDict)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
GSWDictElem* pElem=NULL;
|
GSWDictElem *pElem=NULL;
|
||||||
for (pElem=p_pDict->pElems;i<p_pDict->uCount;i++,pElem++)
|
for (pElem=p_pDict->pElems;i<p_pDict->uCount;i++,pElem++)
|
||||||
if (!pElem->pszKey)
|
if (!pElem->pszKey)
|
||||||
return pElem;
|
return pElem;
|
||||||
return NULL;
|
return NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned int GSWDict_Count(GSWDict* p_pDict)
|
unsigned int
|
||||||
|
GSWDict_Count(GSWDict *p_pDict)
|
||||||
{
|
{
|
||||||
unsigned int uCount=0;
|
unsigned int uCount=0;
|
||||||
if (!p_pDict)
|
if (!p_pDict)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
|
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
GSWDictElem* pElem=NULL;
|
GSWDictElem *pElem=NULL;
|
||||||
for (pElem=p_pDict->pElems;i<p_pDict->uCount;i++,pElem++)
|
for (pElem=p_pDict->pElems;i<p_pDict->uCount;i++,pElem++)
|
||||||
if (pElem->pszKey)
|
if (pElem->pszKey)
|
||||||
uCount++;
|
uCount++;
|
||||||
};
|
};
|
||||||
return 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)
|
if (!p_pDict)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
|
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (p_pDict->uCount>=p_pDict->uCapacity)
|
||||||
{
|
{
|
||||||
if (p_pDict->uCount>=p_pDict->uCapacity)
|
pElem=GSWDict_FindFirstNullKey(p_pDict);
|
||||||
{
|
|
||||||
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++;
|
|
||||||
};
|
|
||||||
if (!pElem)
|
if (!pElem)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_CRITICAL,NULL,"No pElem in GSWDict Add");
|
GSWDict_SetCapacity(p_pDict,p_pDict->uCapacity*2);
|
||||||
};
|
pElem=p_pDict->pElems+p_pDict->uCount;
|
||||||
pElem->pszKey=strdup(p_pszKey);
|
p_pDict->uCount++;
|
||||||
pElem->pValue=p_pValue;
|
};
|
||||||
pElem->fValueOwner=p_fValueOwner;
|
}
|
||||||
|
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);
|
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;
|
int iIndex=0;
|
||||||
GSWDictElem* pElem=NULL;
|
GSWDictElem *pElem=NULL;
|
||||||
if (!p_pDict)
|
if (!p_pDict)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
|
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (pElem=p_pDict->pElems;iIndex<p_pDict->uCount;iIndex++,pElem++)
|
for (pElem=p_pDict->pElems;iIndex<p_pDict->uCount;iIndex++,pElem++)
|
||||||
if (pElem->pszKey && strcasecmp(pElem->pszKey,p_pszKey)==0)
|
if (pElem->pszKey && strcasecmp(pElem->pszKey,p_pszKey)==0)
|
||||||
return pElem;
|
return pElem;
|
||||||
};
|
};
|
||||||
return NULL;
|
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)
|
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;
|
return (pElem) ? pElem->pValue : NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
void GSWDict_PerformForAllElem(GSWDict* p_pDict,
|
void
|
||||||
void (*pFN)(GSWDictElem* p_pElem,void* p_pData),
|
GSWDict_PerformForAllElem(GSWDict *p_pDict,
|
||||||
void* p_pData)
|
void (*pFN)(GSWDictElem *p_pElem,void *p_pData),
|
||||||
|
void *p_pData)
|
||||||
{
|
{
|
||||||
if (!p_pDict)
|
if (!p_pDict)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
|
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
int i=0;
|
||||||
|
GSWDictElem *pElem=NULL;
|
||||||
|
for (pElem=p_pDict->pElems;i<p_pDict->uCount;i++,pElem++)
|
||||||
{
|
{
|
||||||
int i=0;
|
if (pElem->pszKey)
|
||||||
GSWDictElem* pElem=NULL;
|
pFN(pElem,p_pData);
|
||||||
for (pElem=p_pDict->pElems;i<p_pDict->uCount;i++,pElem++)
|
|
||||||
{
|
|
||||||
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)
|
if (!p_pDict)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
|
GSWLog(GSW_CRITICAL,NULL,"NULL GSWDict");
|
||||||
}
|
}
|
||||||
else
|
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;
|
if (pElem->pszKey)
|
||||||
GSWDictElem* pElem=NULL;
|
GSWList_Add(pList,pElem->pszKey);
|
||||||
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);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
return pList;
|
return pList;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWDict.h - GSWeb: Dictionary
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -33,36 +33,46 @@ extern "C" {
|
||||||
typedef struct _GSWDictElem
|
typedef struct _GSWDictElem
|
||||||
{
|
{
|
||||||
CONST char *pszKey;
|
CONST char *pszKey;
|
||||||
CONST void* pValue;
|
CONST void *pValue;
|
||||||
BOOL fValueOwner;
|
BOOL fValueOwner;
|
||||||
} GSWDictElem;
|
} GSWDictElem;
|
||||||
|
|
||||||
typedef struct _GSWDict
|
typedef struct _GSWDict
|
||||||
{
|
{
|
||||||
unsigned int uCount;
|
unsigned int uCount;
|
||||||
unsigned int uCapacity;
|
unsigned int uCapacity;
|
||||||
GSWDictElem* pElems;
|
GSWDictElem *pElems;
|
||||||
} GSWDict;
|
} GSWDict;
|
||||||
|
|
||||||
#define GSWDict_Initialized() ((GSWDict){0,0,NULL})
|
#define GSWDict_Initialized() ((GSWDict){0,0,NULL})
|
||||||
|
|
||||||
GSWDict *GSWDict_New(unsigned int p_uCapacity);
|
GSWDict *GSWDict_New(unsigned int p_uCapacity);
|
||||||
|
|
||||||
void GSWDict_Free(GSWDict* p_pDict);
|
void GSWDict_Free(GSWDict *p_pDict);
|
||||||
void GSWDict_FreeElements(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_Add(GSWDict *p_pDict,
|
||||||
void GSWDict_AddString(GSWDict* p_pDict,CONST char* p_pszKey,CONST char* p_pValue,BOOL p_fValueOwner);
|
CONST char *p_pszKey,
|
||||||
void GSWDict_AddStringDup(GSWDict* p_pDict,CONST char* p_pszKey,CONST char* p_pValue);
|
CONST void *p_pValue,
|
||||||
void GSWDict_RemoveKey(GSWDict* p_pDict, CONST char* p_pszKey);
|
BOOL p_fValueOwner);
|
||||||
CONST void* GSWDict_ValueForKey(GSWDict* p_pDict, CONST char* p_pszKey);
|
void GSWDict_AddString(GSWDict *p_pDict,
|
||||||
unsigned int GSWDict_Count(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 GSWDict_PerformForAllElem(GSWDict *p_pDict,
|
||||||
void (*pFN)(GSWDictElem* p_pElem,void* p_pData),
|
void (*pFN)(GSWDictElem *p_pElem,void *p_pData),
|
||||||
void* p_pData);
|
void *p_pData);
|
||||||
|
|
||||||
//Free the list but Do Not Free Elements
|
//Free the list but Do Not Free Elements
|
||||||
GSWList* GSWDict_AllKeys(GSWDict* p_pDict);
|
GSWList* GSWDict_AllKeys(GSWDict *p_pDict);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // end of C header
|
} // end of C header
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWHTTPHeaders.c - GSWeb: GSWeb HTTP Headers
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -41,111 +41,112 @@
|
||||||
#include "GSWConfig.h"
|
#include "GSWConfig.h"
|
||||||
#include "GSWHTTPHeaders.h"
|
#include "GSWHTTPHeaders.h"
|
||||||
|
|
||||||
const char* g_szHeader_GSWeb_ServerAdaptor="x-gsweb-adaptor-version";
|
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_RequestMethod="x-gsweb-request-method";
|
||||||
const char* g_szHeader_GSWeb_Recording="x-gsweb-recording";
|
const char *g_szHeader_GSWeb_Recording="x-gsweb-recording";
|
||||||
const char* g_szHeader_GSWeb_QueryString="x-gsweb-query-string";
|
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_RemoteAddress="x-gsweb-remote-addr";
|
||||||
const char* g_szHeader_GSWeb_RemoteHost="x-gsweb-remote-host";
|
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_RemoteIdent="x-gsweb-remote-ident";
|
||||||
const char* g_szHeader_GSWeb_RemoteUser="x-gsweb-remote-user";
|
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_ServerName="x-gsweb-server-name";
|
||||||
const char* g_szHeader_GSWeb_ServerPort="x-gsweb-server-port";
|
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_ServerSoftware="x-gsweb-server-software";
|
||||||
const char* g_szHeader_GSWeb_AnnotationServer="x-gsweb-annotation-server";
|
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_AuthPass="x-gsweb-auth-pass";
|
||||||
const char* g_szHeader_GSWeb_AuthType="x-gsweb-auth-type";
|
const char *g_szHeader_GSWeb_AuthType="x-gsweb-auth-type";
|
||||||
const char* g_szHeader_GSWeb_DocumentRoot="x-gsweb-documentroot";
|
const char *g_szHeader_GSWeb_DocumentRoot="x-gsweb-documentroot";
|
||||||
const char* g_szHeader_GSWeb_GatewayInterface="x-gsweb-gateway-interface";
|
const char *g_szHeader_GSWeb_GatewayInterface="x-gsweb-gateway-interface";
|
||||||
|
|
||||||
const char* g_szHeader_Accept="accept";
|
const char *g_szHeader_Accept="accept";
|
||||||
const char* g_szHeader_AcceptEncoding="accept-encoding";
|
const char *g_szHeader_AcceptEncoding="accept-encoding";
|
||||||
const char* g_szHeader_AcceptLanguage="accept-language";
|
const char *g_szHeader_AcceptLanguage="accept-language";
|
||||||
const char* g_szHeader_Allow="allow";
|
const char *g_szHeader_Allow="allow";
|
||||||
const char* g_szHeader_Authorization="authorization";
|
const char *g_szHeader_Authorization="authorization";
|
||||||
const char* g_szHeader_AuthUser="auth-user";
|
const char *g_szHeader_AuthUser="auth-user";
|
||||||
const char* g_szHeader_Cookie="cookie";
|
const char *g_szHeader_Cookie="cookie";
|
||||||
const char* g_szHeader_ContentLength="content-length";
|
const char *g_szHeader_ContentLength="content-length";
|
||||||
const char* g_szHeader_ContentType="content-type";
|
const char *g_szHeader_ContentType="content-type";
|
||||||
const char* g_szHeader_IfModifiedSince="if-modified-since";
|
const char *g_szHeader_IfModifiedSince="if-modified-since";
|
||||||
const char* g_szHeader_LastModified="last-modified";
|
const char *g_szHeader_LastModified="last-modified";
|
||||||
const char* g_szHeader_Method="method";
|
const char *g_szHeader_Method="method";
|
||||||
const char* g_szHeader_PathInfo="path-info";
|
const char *g_szHeader_PathInfo="path-info";
|
||||||
const char* g_szHeader_Pragma="pragma";
|
const char *g_szHeader_Pragma="pragma";
|
||||||
const char* g_szHeader_Protocol="protocol";
|
const char *g_szHeader_Protocol="protocol";
|
||||||
const char* g_szHeader_Referer="referer";
|
const char *g_szHeader_Referer="referer";
|
||||||
const char* g_szHeader_UserAgent="user-agent";
|
const char *g_szHeader_UserAgent="user-agent";
|
||||||
const char* g_szHeader_Date="date";
|
const char *g_szHeader_Date="date";
|
||||||
const char* g_szHeader_Expires="expires";
|
const char *g_szHeader_Expires="expires";
|
||||||
const char* g_szHeader_From="from";
|
const char *g_szHeader_From="from";
|
||||||
const char* g_szHeader_MimeVersion="mime-version";
|
const char *g_szHeader_MimeVersion="mime-version";
|
||||||
const char* g_szHeader_ContentEncoding="content-encoding";
|
const char *g_szHeader_ContentEncoding="content-encoding";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const char* g_szServerInfo_DocumentRoot="DOCUMENT_ROOT";
|
const char *g_szServerInfo_DocumentRoot="DOCUMENT_ROOT";
|
||||||
const char* g_szServerInfo_HTTPAccept="HTTP_ACCEPT";
|
const char *g_szServerInfo_HTTPAccept="HTTP_ACCEPT";
|
||||||
const char* g_szServerInfo_HTTPAcceptEncoding="HTTP_ACCEPT_ENCODING";
|
const char *g_szServerInfo_HTTPAcceptEncoding="HTTP_ACCEPT_ENCODING";
|
||||||
const char* g_szServerInfo_HTTPAllow="HTTP_ALLOW";
|
const char *g_szServerInfo_HTTPAllow="HTTP_ALLOW";
|
||||||
const char* g_szServerInfo_HTTPDate="HTTP_DATE";
|
const char *g_szServerInfo_HTTPDate="HTTP_DATE";
|
||||||
const char* g_szServerInfo_HTTPExpires="HTTP_EXPIRES";
|
const char *g_szServerInfo_HTTPExpires="HTTP_EXPIRES";
|
||||||
const char* g_szServerInfo_HTTPFrom="HTTP_FROM";
|
const char *g_szServerInfo_HTTPFrom="HTTP_FROM";
|
||||||
const char* g_szServerInfo_HTTPIfModifiedSince="HTTP_IF_MODIFIED_SINCE";
|
const char *g_szServerInfo_HTTPIfModifiedSince="HTTP_IF_MODIFIED_SINCE";
|
||||||
const char* g_szServerInfo_HTTPLastModified="HTTP_LAST_MODIFIED";
|
const char *g_szServerInfo_HTTPLastModified="HTTP_LAST_MODIFIED";
|
||||||
const char* g_szServerInfo_HTTPMimeVersion="HTTP_MIME_VERSION";
|
const char *g_szServerInfo_HTTPMimeVersion="HTTP_MIME_VERSION";
|
||||||
const char* g_szServerInfo_HTTPPragma="HTTP_PRAGMA";
|
const char *g_szServerInfo_HTTPPragma="HTTP_PRAGMA";
|
||||||
const char* g_szServerInfo_HTTPReferer="HTTP_REFERER";
|
const char *g_szServerInfo_HTTPReferer="HTTP_REFERER";
|
||||||
const char* g_szServerInfo_RemoteIdent="REMOTE_IDENT";
|
const char *g_szServerInfo_RemoteIdent="REMOTE_IDENT";
|
||||||
const char* g_szServerInfo_RequestMethod="REQUEST_METHOD";
|
const char *g_szServerInfo_RequestMethod="REQUEST_METHOD";
|
||||||
|
|
||||||
const char* g_szServerInfo_AnnotationServer="ANNOTATION_SERVER";
|
const char *g_szServerInfo_AnnotationServer="ANNOTATION_SERVER";
|
||||||
const char* g_szServerInfo_AuthPass="AUTH_PASS";
|
const char *g_szServerInfo_AuthPass="AUTH_PASS";
|
||||||
const char* g_szServerInfo_AuthType="AUTH_TYPE";
|
const char *g_szServerInfo_AuthType="AUTH_TYPE";
|
||||||
const char* g_szServerInfo_AuthUser="AUTH_USER";
|
const char *g_szServerInfo_AuthUser="AUTH_USER";
|
||||||
const char* g_szServerInfo_ClientCert="CLIENT_CERT";
|
const char *g_szServerInfo_ClientCert="CLIENT_CERT";
|
||||||
const char* g_szServerInfo_ContentEncoding="CONTENT_ENCODING";
|
const char *g_szServerInfo_ContentEncoding="CONTENT_ENCODING";
|
||||||
const char* g_szServerInfo_ContentLength="CONTENT_LENGTH";
|
const char *g_szServerInfo_ContentLength="CONTENT_LENGTH";
|
||||||
const char* g_szServerInfo_ContentType="CONTENT_TYPE";
|
const char *g_szServerInfo_ContentType="CONTENT_TYPE";
|
||||||
const char* g_szServerInfo_GatewayInterface="GATEWAY_INTERFACE";
|
const char *g_szServerInfo_GatewayInterface="GATEWAY_INTERFACE";
|
||||||
const char* g_szServerInfo_Host="HOST";
|
const char *g_szServerInfo_Host="HOST";
|
||||||
const char* g_szServerInfo_HTTPAcceptLanguage="HTTP_ACCEPT_LANGUAGE";
|
const char *g_szServerInfo_HTTPAcceptLanguage="HTTP_ACCEPT_LANGUAGE";
|
||||||
const char* g_szServerInfo_HTTPAuthorization="HTTP_AUTHORIZATION";
|
const char *g_szServerInfo_HTTPAuthorization="HTTP_AUTHORIZATION";
|
||||||
const char* g_szServerInfo_HTTPCookie="HTTP_COOKIE";
|
const char *g_szServerInfo_HTTPCookie="HTTP_COOKIE";
|
||||||
const char* g_szServerInfo_HTTPUserAgent="HTTP_USER_AGENT";
|
const char *g_szServerInfo_HTTPUserAgent="HTTP_USER_AGENT";
|
||||||
const char* g_szServerInfo_HTTPS="HTTPS";
|
const char *g_szServerInfo_HTTPS="HTTPS";
|
||||||
const char* g_szServerInfo_HTTPSKeySize="HTTPS_KEYSIZE";
|
const char *g_szServerInfo_HTTPSKeySize="HTTPS_KEYSIZE";
|
||||||
const char* g_szServerInfo_HTTPSSecretKeySize="HTTPS_SECRETKEYSIZE";
|
const char *g_szServerInfo_HTTPSSecretKeySize="HTTPS_SECRETKEYSIZE";
|
||||||
const char* g_szServerInfo_PathInfo="PATH_INFO";
|
const char *g_szServerInfo_PathInfo="PATH_INFO";
|
||||||
const char* g_szServerInfo_PathTranslated="PATH_TRANSLATED";
|
const char *g_szServerInfo_PathTranslated="PATH_TRANSLATED";
|
||||||
const char* g_szServerInfo_Query="QUERY";
|
const char *g_szServerInfo_Query="QUERY";
|
||||||
const char* g_szServerInfo_QueryString="QUERY_STRING";
|
const char *g_szServerInfo_QueryString="QUERY_STRING";
|
||||||
const char* g_szServerInfo_RemoteAddress="REMOTE_ADDR";
|
const char *g_szServerInfo_RemoteAddress="REMOTE_ADDR";
|
||||||
const char* g_szServerInfo_RemoteHost="REMOTE_HOST";
|
const char *g_szServerInfo_RemoteHost="REMOTE_HOST";
|
||||||
const char* g_szServerInfo_RemoteUser="REMOTE_USER";
|
const char *g_szServerInfo_RemoteUser="REMOTE_USER";
|
||||||
const char* g_szServerInfo_ScriptName="SCRIPT_NAME";
|
const char *g_szServerInfo_ScriptName="SCRIPT_NAME";
|
||||||
const char* g_szServerInfo_ServerID="SERVER_ID";
|
const char *g_szServerInfo_ServerID="SERVER_ID";
|
||||||
const char* g_szServerInfo_ServerName="SERVER_NAME";
|
const char *g_szServerInfo_ServerName="SERVER_NAME";
|
||||||
const char* g_szServerInfo_ServerPort="SERVER_PORT";
|
const char *g_szServerInfo_ServerPort="SERVER_PORT";
|
||||||
const char* g_szServerInfo_ServerProtocol="SERVER_PROTOCOL";
|
const char *g_szServerInfo_ServerProtocol="SERVER_PROTOCOL";
|
||||||
const char* g_szServerInfo_ServerSoftware="SERVER_SOFTWARE";
|
const char *g_szServerInfo_ServerSoftware="SERVER_SOFTWARE";
|
||||||
const char* g_szServerInfo_HTTPGSWebRecording="HTTP_X_GSWEB_RECORDING";
|
const char *g_szServerInfo_HTTPGSWebRecording="HTTP_X_GSWEB_RECORDING";
|
||||||
const char* g_szServerInfo_ServerAdmin="SERVER_ADMIN";
|
const char *g_szServerInfo_ServerAdmin="SERVER_ADMIN";
|
||||||
const char* g_szServerInfo_ScriptFileName="SCRIPT_FILENAME";
|
const char *g_szServerInfo_ScriptFileName="SCRIPT_FILENAME";
|
||||||
const char* g_szServerInfo_RemotePort="REMOTE_PORT";
|
const char *g_szServerInfo_RemotePort="REMOTE_PORT";
|
||||||
|
|
||||||
const char* g_szMethod_Get="GET";
|
const char *g_szMethod_Get="GET";
|
||||||
const char* g_szMethod_Post="POST";
|
const char *g_szMethod_Post="POST";
|
||||||
const char* g_szMethod_Head="HEAD";
|
const char *g_szMethod_Head="HEAD";
|
||||||
const char* g_szMethod_Put="PUT";
|
const char *g_szMethod_Put="PUT";
|
||||||
|
|
||||||
const char* g_szContentType_TextHtml="text/html";
|
const char *g_szContentType_TextHtml="text/html";
|
||||||
|
|
||||||
|
|
||||||
/*const*/ GSWHeaderTranslationItem GSWHeaderTranslationTable[50];
|
/*const*/ GSWHeaderTranslationItem GSWHeaderTranslationTable[50];
|
||||||
int GSWHeaderTranslationTableItemsNb=0;
|
int GSWHeaderTranslationTableItemsNb=0;
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWHeaderTranslationTable_Init()
|
void
|
||||||
|
GSWHeaderTranslationTable_Init()
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_AnnotationServer;
|
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_AnnotationServer;
|
||||||
|
@ -251,12 +252,17 @@ void GSWHeaderTranslationTable_Init()
|
||||||
GSWHeaderTranslationTable[i++].pszGSWeb=NULL;
|
GSWHeaderTranslationTable[i++].pszGSWeb=NULL;
|
||||||
|
|
||||||
GSWHeaderTranslationTableItemsNb=i;
|
GSWHeaderTranslationTableItemsNb=i;
|
||||||
/*GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTableItemsNb=%d",GSWHeaderTranslationTableItemsNb);
|
/*
|
||||||
for(i=0;i<GSWHeaderTranslationTableItemsNb-1;i++)
|
GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTableItemsNb=%d",
|
||||||
{
|
GSWHeaderTranslationTableItemsNb);
|
||||||
GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTable[i].pszHTTP=%s",GSWHeaderTranslationTable[i].pszHTTP);
|
for(i=0;i<GSWHeaderTranslationTableItemsNb-1;i++)
|
||||||
GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTable[i].pszGSWeb=%s",GSWHeaderTranslationTable[i].pszGSWeb);
|
{
|
||||||
};*/
|
GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTable[i].pszHTTP=%s",
|
||||||
|
GSWHeaderTranslationTable[i].pszHTTP);
|
||||||
|
GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTable[i].pszGSWeb=%s",
|
||||||
|
GSWHeaderTranslationTable[i].pszGSWeb);
|
||||||
|
};
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWHTTPHeaders.h - GSWeb: GSWeb HTTP Headers
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -24,107 +24,107 @@
|
||||||
#ifndef _GSWHTTPHeaders_h__
|
#ifndef _GSWHTTPHeaders_h__
|
||||||
#define _GSWHTTPHeaders_h__
|
#define _GSWHTTPHeaders_h__
|
||||||
|
|
||||||
extern const char* g_szHeader_GSWeb_ServerAdaptor;
|
extern const char *g_szHeader_GSWeb_ServerAdaptor;
|
||||||
extern const char* g_szHeader_GSWeb_RequestMethod;
|
extern const char *g_szHeader_GSWeb_RequestMethod;
|
||||||
extern const char* g_szHeader_GSWeb_Recording;
|
extern const char *g_szHeader_GSWeb_Recording;
|
||||||
extern const char* g_szHeader_GSWeb_QueryString;
|
extern const char *g_szHeader_GSWeb_QueryString;
|
||||||
extern const char* g_szHeader_GSWeb_RemoteAddress;
|
extern const char *g_szHeader_GSWeb_RemoteAddress;
|
||||||
extern const char* g_szHeader_GSWeb_RemoteHost;
|
extern const char *g_szHeader_GSWeb_RemoteHost;
|
||||||
extern const char* g_szHeader_GSWeb_RemoteIdent;
|
extern const char *g_szHeader_GSWeb_RemoteIdent;
|
||||||
extern const char* g_szHeader_GSWeb_RemoteUser;
|
extern const char *g_szHeader_GSWeb_RemoteUser;
|
||||||
extern const char* g_szHeader_GSWeb_ServerName;
|
extern const char *g_szHeader_GSWeb_ServerName;
|
||||||
extern const char* g_szHeader_GSWeb_ServerPort;
|
extern const char *g_szHeader_GSWeb_ServerPort;
|
||||||
extern const char* g_szHeader_GSWeb_ServerSoftware;
|
extern const char *g_szHeader_GSWeb_ServerSoftware;
|
||||||
extern const char* g_szHeader_GSWeb_AnnotationServer;
|
extern const char *g_szHeader_GSWeb_AnnotationServer;
|
||||||
extern const char* g_szHeader_GSWeb_AuthPass;
|
extern const char *g_szHeader_GSWeb_AuthPass;
|
||||||
extern const char* g_szHeader_GSWeb_AuthType;
|
extern const char *g_szHeader_GSWeb_AuthType;
|
||||||
extern const char* g_szHeader_GSWeb_DocumentRoot;
|
extern const char *g_szHeader_GSWeb_DocumentRoot;
|
||||||
extern const char* g_szHeader_GSWeb_GatewayInterface;
|
extern const char *g_szHeader_GSWeb_GatewayInterface;
|
||||||
|
|
||||||
|
|
||||||
extern const char* g_szHeader_Accept;
|
extern const char *g_szHeader_Accept;
|
||||||
extern const char* g_szHeader_AcceptEncoding;
|
extern const char *g_szHeader_AcceptEncoding;
|
||||||
extern const char* g_szHeader_AcceptLanguage;
|
extern const char *g_szHeader_AcceptLanguage;
|
||||||
extern const char* g_szHeader_Allow;
|
extern const char *g_szHeader_Allow;
|
||||||
extern const char* g_szHeader_Authorization;
|
extern const char *g_szHeader_Authorization;
|
||||||
extern const char* g_szHeader_AuthUser;
|
extern const char *g_szHeader_AuthUser;
|
||||||
extern const char* g_szHeader_Cookie;
|
extern const char *g_szHeader_Cookie;
|
||||||
extern const char* g_szHeader_ContentLength;
|
extern const char *g_szHeader_ContentLength;
|
||||||
extern const char* g_szHeader_ContentType;
|
extern const char *g_szHeader_ContentType;
|
||||||
extern const char* g_szHeader_IfModifiedSince;
|
extern const char *g_szHeader_IfModifiedSince;
|
||||||
extern const char* g_szHeader_LastModified;
|
extern const char *g_szHeader_LastModified;
|
||||||
extern const char* g_szHeader_Method;
|
extern const char *g_szHeader_Method;
|
||||||
extern const char* g_szHeader_PathInfo;
|
extern const char *g_szHeader_PathInfo;
|
||||||
extern const char* g_szHeader_Pragma;
|
extern const char *g_szHeader_Pragma;
|
||||||
extern const char* g_szHeader_Protocol;
|
extern const char *g_szHeader_Protocol;
|
||||||
extern const char* g_szHeader_Referer;
|
extern const char *g_szHeader_Referer;
|
||||||
extern const char* g_szHeader_UserAgent;
|
extern const char *g_szHeader_UserAgent;
|
||||||
extern const char* g_szHeader_Date;
|
extern const char *g_szHeader_Date;
|
||||||
extern const char* g_szHeader_Expires;
|
extern const char *g_szHeader_Expires;
|
||||||
extern const char* g_szHeader_From;
|
extern const char *g_szHeader_From;
|
||||||
extern const char* g_szHeader_MimeVersion;
|
extern const char *g_szHeader_MimeVersion;
|
||||||
extern const char* g_szHeader_ContentEncoding;
|
extern const char *g_szHeader_ContentEncoding;
|
||||||
|
|
||||||
extern const char* g_szServerInfo_DocumentRoot;
|
extern const char *g_szServerInfo_DocumentRoot;
|
||||||
extern const char* g_szServerInfo_HTTPAccept;
|
extern const char *g_szServerInfo_HTTPAccept;
|
||||||
extern const char* g_szServerInfo_HTTPAcceptEncoding;
|
extern const char *g_szServerInfo_HTTPAcceptEncoding;
|
||||||
extern const char* g_szServerInfo_HTTPAllow;
|
extern const char *g_szServerInfo_HTTPAllow;
|
||||||
extern const char* g_szServerInfo_HTTPDate;
|
extern const char *g_szServerInfo_HTTPDate;
|
||||||
extern const char* g_szServerInfo_HTTPExpires;
|
extern const char *g_szServerInfo_HTTPExpires;
|
||||||
extern const char* g_szServerInfo_HTTPFrom;
|
extern const char *g_szServerInfo_HTTPFrom;
|
||||||
extern const char* g_szServerInfo_HTTPIfModifiedSince;
|
extern const char *g_szServerInfo_HTTPIfModifiedSince;
|
||||||
extern const char* g_szServerInfo_HTTPLastModified;
|
extern const char *g_szServerInfo_HTTPLastModified;
|
||||||
extern const char* g_szServerInfo_HTTPMimeVersion;
|
extern const char *g_szServerInfo_HTTPMimeVersion;
|
||||||
extern const char* g_szServerInfo_HTTPPragma;
|
extern const char *g_szServerInfo_HTTPPragma;
|
||||||
extern const char* g_szServerInfo_HTTPReferer;
|
extern const char *g_szServerInfo_HTTPReferer;
|
||||||
extern const char* g_szServerInfo_RemoteIdent;
|
extern const char *g_szServerInfo_RemoteIdent;
|
||||||
extern const char* g_szServerInfo_RequestMethod;
|
extern const char *g_szServerInfo_RequestMethod;
|
||||||
|
|
||||||
extern const char* g_szServerInfo_AnnotationServer;
|
extern const char *g_szServerInfo_AnnotationServer;
|
||||||
extern const char* g_szServerInfo_AuthPass;
|
extern const char *g_szServerInfo_AuthPass;
|
||||||
extern const char* g_szServerInfo_AuthType;
|
extern const char *g_szServerInfo_AuthType;
|
||||||
extern const char* g_szServerInfo_AuthUser;
|
extern const char *g_szServerInfo_AuthUser;
|
||||||
extern const char* g_szServerInfo_ClientCert;
|
extern const char *g_szServerInfo_ClientCert;
|
||||||
extern const char* g_szServerInfo_ContentEncoding;
|
extern const char *g_szServerInfo_ContentEncoding;
|
||||||
extern const char* g_szServerInfo_ContentLength;
|
extern const char *g_szServerInfo_ContentLength;
|
||||||
extern const char* g_szServerInfo_ContentType;
|
extern const char *g_szServerInfo_ContentType;
|
||||||
extern const char* g_szServerInfo_GatewayInterface;
|
extern const char *g_szServerInfo_GatewayInterface;
|
||||||
extern const char* g_szServerInfo_Host;
|
extern const char *g_szServerInfo_Host;
|
||||||
extern const char* g_szServerInfo_HTTPAcceptLanguage;
|
extern const char *g_szServerInfo_HTTPAcceptLanguage;
|
||||||
extern const char* g_szServerInfo_HTTPAuthorization;
|
extern const char *g_szServerInfo_HTTPAuthorization;
|
||||||
extern const char* g_szServerInfo_HTTPCookie;
|
extern const char *g_szServerInfo_HTTPCookie;
|
||||||
extern const char* g_szServerInfo_HTTPUserAgent;
|
extern const char *g_szServerInfo_HTTPUserAgent;
|
||||||
extern const char* g_szServerInfo_HTTPS;
|
extern const char *g_szServerInfo_HTTPS;
|
||||||
extern const char* g_szServerInfo_HTTPSKeySize;
|
extern const char *g_szServerInfo_HTTPSKeySize;
|
||||||
extern const char* g_szServerInfo_HTTPSSecretKeySize;
|
extern const char *g_szServerInfo_HTTPSSecretKeySize;
|
||||||
extern const char* g_szServerInfo_PathInfo;
|
extern const char *g_szServerInfo_PathInfo;
|
||||||
extern const char* g_szServerInfo_PathTranslated;
|
extern const char *g_szServerInfo_PathTranslated;
|
||||||
extern const char* g_szServerInfo_Query;
|
extern const char *g_szServerInfo_Query;
|
||||||
extern const char* g_szServerInfo_QueryString;
|
extern const char *g_szServerInfo_QueryString;
|
||||||
extern const char* g_szServerInfo_RemoteAddress;
|
extern const char *g_szServerInfo_RemoteAddress;
|
||||||
extern const char* g_szServerInfo_RemoteHost;
|
extern const char *g_szServerInfo_RemoteHost;
|
||||||
extern const char* g_szServerInfo_RemoteUser;
|
extern const char *g_szServerInfo_RemoteUser;
|
||||||
extern const char* g_szServerInfo_ScriptName;
|
extern const char *g_szServerInfo_ScriptName;
|
||||||
extern const char* g_szServerInfo_ServerID;
|
extern const char *g_szServerInfo_ServerID;
|
||||||
extern const char* g_szServerInfo_ServerName;
|
extern const char *g_szServerInfo_ServerName;
|
||||||
extern const char* g_szServerInfo_ServerPort;
|
extern const char *g_szServerInfo_ServerPort;
|
||||||
extern const char* g_szServerInfo_ServerProtocol;
|
extern const char *g_szServerInfo_ServerProtocol;
|
||||||
extern const char* g_szServerInfo_ServerSoftware;
|
extern const char *g_szServerInfo_ServerSoftware;
|
||||||
extern const char* g_szServerInfo_HTTPGSWebRecording;
|
extern const char *g_szServerInfo_HTTPGSWebRecording;
|
||||||
extern const char* g_szServerInfo_ServerAdmin;
|
extern const char *g_szServerInfo_ServerAdmin;
|
||||||
extern const char* g_szServerInfo_ScriptFileName;
|
extern const char *g_szServerInfo_ScriptFileName;
|
||||||
extern const char* g_szServerInfo_RemotePort;
|
extern const char *g_szServerInfo_RemotePort;
|
||||||
|
|
||||||
extern const char* g_szMethod_Get;
|
extern const char *g_szMethod_Get;
|
||||||
extern const char* g_szMethod_Post;
|
extern const char *g_szMethod_Post;
|
||||||
extern const char* g_szMethod_Head;
|
extern const char *g_szMethod_Head;
|
||||||
extern const char* g_szMethod_Put;
|
extern const char *g_szMethod_Put;
|
||||||
|
|
||||||
extern const char* g_szContentType_TextHtml;
|
extern const char *g_szContentType_TextHtml;
|
||||||
|
|
||||||
typedef struct _GSWHeaderTranslationItem {
|
typedef struct _GSWHeaderTranslationItem {
|
||||||
const char* /*const*/ pszHTTP;
|
const char /*const*/ *pszHTTP;
|
||||||
const char* /*const*/ pszGSWeb;
|
const char /*const*/ *pszGSWeb;
|
||||||
} GSWHeaderTranslationItem;
|
} GSWHeaderTranslationItem;
|
||||||
|
|
||||||
extern /*const*/ GSWHeaderTranslationItem GSWHeaderTranslationTable[];
|
extern /*const*/ GSWHeaderTranslationItem GSWHeaderTranslationTable[];
|
||||||
|
@ -132,40 +132,40 @@ extern int GSWHeaderTranslationTableItemsNb;
|
||||||
/*
|
/*
|
||||||
static const GSWHeaderTranslationItem GSWHeaderTranslationTable[] =
|
static const GSWHeaderTranslationItem GSWHeaderTranslationTable[] =
|
||||||
{
|
{
|
||||||
{ g_szServerInfo_AnnotationServer, g_szHeader_GSWeb_AnnotationServer },
|
{ g_szServerInfo_AnnotationServer, g_szHeader_GSWeb_AnnotationServer},
|
||||||
{ g_szServerInfo_AuthPass, g_szHeader_GSWeb_AuthPass },
|
{ g_szServerInfo_AuthPass, g_szHeader_GSWeb_AuthPass },
|
||||||
{ g_szServerInfo_AuthType, g_szHeader_GSWeb_AuthType },
|
{ g_szServerInfo_AuthType, g_szHeader_GSWeb_AuthType },
|
||||||
{ g_szServerInfo_ContentEncoding, g_szHeader_ContentEncoding },
|
{ g_szServerInfo_ContentEncoding, g_szHeader_ContentEncoding },
|
||||||
{ g_szServerInfo_ContentLength, g_szHeader_ContentLength },
|
{ g_szServerInfo_ContentLength, g_szHeader_ContentLength },
|
||||||
{ g_szServerInfo_ContentType, g_szHeader_ContentType },
|
{ g_szServerInfo_ContentType, g_szHeader_ContentType },
|
||||||
{ g_szServerInfo_DocumentRoot, g_szHeader_GSWeb_DocumentRoot },
|
{ g_szServerInfo_DocumentRoot, g_szHeader_GSWeb_DocumentRoot },
|
||||||
{ g_szServerInfo_GatewayInterface, g_szHeader_GSWeb_GatewayInterface },
|
{ g_szServerInfo_GatewayInterface, g_szHeader_GSWeb_GatewayInterface},
|
||||||
{ g_szServerInfo_HTTPAccept, g_szHeader_Accept },
|
{ g_szServerInfo_HTTPAccept, g_szHeader_Accept },
|
||||||
{ g_szServerInfo_HTTPAcceptEncoding, g_szHeader_AcceptEncoding },
|
{ g_szServerInfo_HTTPAcceptEncoding, g_szHeader_AcceptEncoding },
|
||||||
{ g_szServerInfo_HTTPAcceptLanguage, g_szHeader_AcceptLanguage },
|
{ g_szServerInfo_HTTPAcceptLanguage, g_szHeader_AcceptLanguage },
|
||||||
{ g_szServerInfo_HTTPAllow, g_szHeader_Allow },
|
{ g_szServerInfo_HTTPAllow, g_szHeader_Allow },
|
||||||
{ g_szServerInfo_HTTPAuthorization, g_szHeader_Authorization },
|
{ g_szServerInfo_HTTPAuthorization, g_szHeader_Authorization },
|
||||||
{ g_szServerInfo_HTTPCookie, g_szHeader_Cookie },
|
{ g_szServerInfo_HTTPCookie, g_szHeader_Cookie },
|
||||||
{ g_szServerInfo_HTTPDate, g_szHeader_Date },
|
{ g_szServerInfo_HTTPDate, g_szHeader_Date },
|
||||||
{ g_szServerInfo_HTTPExpires, g_szHeader_Expires },
|
{ g_szServerInfo_HTTPExpires, g_szHeader_Expires },
|
||||||
{ g_szServerInfo_HTTPFrom, g_szHeader_From },
|
{ g_szServerInfo_HTTPFrom, g_szHeader_From },
|
||||||
{ g_szServerInfo_HTTPIfModifiedSince, g_szHeader_IfModifiedSince },
|
{ g_szServerInfo_HTTPIfModifiedSince,g_szHeader_IfModifiedSince },
|
||||||
{ g_szServerInfo_HTTPLastModified, g_szHeader_LastModified },
|
{ g_szServerInfo_HTTPLastModified, g_szHeader_LastModified },
|
||||||
{ g_szServerInfo_HTTPMimeVersion, g_szHeader_MimeVersion },
|
{ g_szServerInfo_HTTPMimeVersion, g_szHeader_MimeVersion },
|
||||||
{ g_szServerInfo_HTTPPragma, g_szHeader_Pragma },
|
{ g_szServerInfo_HTTPPragma, g_szHeader_Pragma },
|
||||||
{ g_szServerInfo_HTTPReferer, g_szHeader_Referer },
|
{ g_szServerInfo_HTTPReferer, g_szHeader_Referer },
|
||||||
{ g_szServerInfo_HTTPUserAgent, g_szHeader_UserAgent },
|
{ g_szServerInfo_HTTPUserAgent, g_szHeader_UserAgent },
|
||||||
{ g_szServerInfo_HTTPGSWebRecording, g_szHeader_GSWeb_Recording },
|
{ g_szServerInfo_HTTPGSWebRecording, g_szHeader_GSWeb_Recording },
|
||||||
{ g_szServerInfo_QueryString, g_szHeader_GSWeb_QueryString },
|
{ g_szServerInfo_QueryString, g_szHeader_GSWeb_QueryString },
|
||||||
{ g_szServerInfo_RemoteAddress, g_szHeader_GSWeb_RemoteAddress },
|
{ g_szServerInfo_RemoteAddress, g_szHeader_GSWeb_RemoteAddress },
|
||||||
{ g_szServerInfo_RemoteHost, g_szHeader_GSWeb_RemoteHost },
|
{ g_szServerInfo_RemoteHost, g_szHeader_GSWeb_RemoteHost },
|
||||||
{ g_szServerInfo_RemoteIdent, g_szHeader_GSWeb_RemoteIdent },
|
{ g_szServerInfo_RemoteIdent, g_szHeader_GSWeb_RemoteIdent },
|
||||||
{ g_szServerInfo_RemoteUser, g_szHeader_GSWeb_RemoteUser },
|
{ g_szServerInfo_RemoteUser, g_szHeader_GSWeb_RemoteUser },
|
||||||
{ g_szServerInfo_RequestMethod, g_szHeader_GSWebRequestMethod },
|
{ g_szServerInfo_RequestMethod, g_szHeader_GSWebRequestMethod },
|
||||||
{ g_szServerInfo_ServerName, g_szHeader_GSWeb_ServerName },
|
{ g_szServerInfo_ServerName, g_szHeader_GSWeb_ServerName },
|
||||||
{ g_szServerInfo_ServerPort, g_szHeader_GSWeb_ServerPort },
|
{ g_szServerInfo_ServerPort, g_szHeader_GSWeb_ServerPort },
|
||||||
{ g_szServerInfo_ServerSoftware, g_szHeader_GSWeb_ServerSoftware },
|
{ g_szServerInfo_ServerSoftware, g_szHeader_GSWeb_ServerSoftware },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GSWHeaderTranslationTable_HeaderNb (sizeof(GSWHeaderTranslationTable)/sizeof(GSWHeaderTranslationTable[0]))
|
#define GSWHeaderTranslationTable_HeaderNb (sizeof(GSWHeaderTranslationTable)/sizeof(GSWHeaderTranslationTable[0]))
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWHTTPRequest.c - GSWeb: Adaptors: HTTP Request
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -38,16 +38,19 @@
|
||||||
#include "GSWHTTPHeaders.h"
|
#include "GSWHTTPHeaders.h"
|
||||||
|
|
||||||
static ERequestMethod GetHTTPRequestMethod();
|
static ERequestMethod GetHTTPRequestMethod();
|
||||||
static CONST char* GSWebHeaderForHTTPHeader(CONST char *header);
|
static CONST char *GSWebHeaderForHTTPHeader(CONST char *header);
|
||||||
static char* GSWHTTPRequest_PackageHeaders(GSWHTTPRequest* p_pHTTPRequest,
|
static char *GSWHTTPRequest_PackageHeaders(GSWHTTPRequest *p_pHTTPRequest,
|
||||||
char* pszBuffer,
|
char *pszBuffer,
|
||||||
int p_iBufferSize);
|
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");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPRequest_New");
|
||||||
pHTTPRequest->eMethod = GetHTTPRequestMethod(p_pszMethod);
|
pHTTPRequest->eMethod = GetHTTPRequestMethod(p_pszMethod);
|
||||||
pHTTPRequest->pszRequest = p_pszURI; // It will be freed
|
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");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPRequest_Free");
|
||||||
if (p_pHTTPRequest)
|
if (p_pHTTPRequest)
|
||||||
|
{
|
||||||
|
if (p_pHTTPRequest->pHeaders)
|
||||||
{
|
{
|
||||||
if (p_pHTTPRequest->pHeaders)
|
GSWDict_Free(p_pHTTPRequest->pHeaders);
|
||||||
{
|
p_pHTTPRequest->pHeaders=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;
|
|
||||||
};
|
};
|
||||||
|
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");
|
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");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPRequest_ValidateMethod");
|
||||||
if (!p_pHTTPRequest)
|
if (!p_pHTTPRequest)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_CRITICAL,p_pLogServerData,"No Request in GSWHTTPRequest_ValidateMethod");
|
GSWLog(GSW_CRITICAL,p_pLogServerData,
|
||||||
pszMsg="No Request in GSWHTTPRequest_ValidateMethod";
|
"No Request in GSWHTTPRequest_ValidateMethod");
|
||||||
}
|
pszMsg="No Request in GSWHTTPRequest_ValidateMethod";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
switch(p_pHTTPRequest->eMethod)
|
||||||
{
|
{
|
||||||
switch(p_pHTTPRequest->eMethod)
|
case ERequestMethod_None:
|
||||||
{
|
pszMsg="GSWeb Application must be launched by HTTP Server";
|
||||||
case ERequestMethod_None:
|
break;
|
||||||
pszMsg="GSWeb Application must be launched by HTTP Server";
|
case ERequestMethod_Unknown:
|
||||||
break;
|
case ERequestMethod_Head:
|
||||||
case ERequestMethod_Unknown:
|
case ERequestMethod_Put:
|
||||||
case ERequestMethod_Head:
|
pszMsg="Invalid Method";
|
||||||
case ERequestMethod_Put:
|
break;
|
||||||
pszMsg="Invalid Method";
|
case ERequestMethod_Get:
|
||||||
break;
|
case ERequestMethod_Post:
|
||||||
case ERequestMethod_Get:
|
default:
|
||||||
case ERequestMethod_Post:
|
pszMsg=NULL;
|
||||||
default:
|
|
||||||
pszMsg=NULL;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPRequest_ValidateMethod");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPRequest_ValidateMethod");
|
||||||
return pszMsg;
|
return pszMsg;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWHTTPRequest_HTTPToAppRequest(GSWHTTPRequest* p_pHTTPRequest,
|
void
|
||||||
GSWAppRequest* p_pAppRequest,
|
GSWHTTPRequest_HTTPToAppRequest(GSWHTTPRequest *p_pHTTPRequest,
|
||||||
GSWURLComponents* p_pURLComponents,
|
GSWAppRequest *p_pAppRequest,
|
||||||
CONST char* p_pszHTTPVersion,
|
GSWURLComponents *p_pURLComponents,
|
||||||
void* p_pLogServerData)
|
CONST char *p_pszHTTPVersion,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
char szInstanceBuffer[65]="";
|
char szInstanceBuffer[65]="";
|
||||||
char* pszDefaultHTTPVersion = "HTTP/1.0";
|
char *pszDefaultHTTPVersion = "HTTP/1.0";
|
||||||
int iHTTPVersionLength = p_pszHTTPVersion ? strlen(p_pszHTTPVersion) : strlen(pszDefaultHTTPVersion);
|
int iHTTPVersionLength = p_pszHTTPVersion ?
|
||||||
|
strlen(p_pszHTTPVersion) : strlen(pszDefaultHTTPVersion);
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPRequest_HTTPToAppRequest");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPRequest_HTTPToAppRequest");
|
||||||
if (p_pAppRequest->iInstance > 0) /* should be -1 !!! */
|
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.pszStart = p_pAppRequest->pszName;
|
||||||
p_pURLComponents->stAppName.iLength = strlen(p_pAppRequest->pszName);
|
p_pURLComponents->stAppName.iLength = strlen(p_pAppRequest->pszName);
|
||||||
p_pURLComponents->stAppNumber.pszStart = szInstanceBuffer;
|
p_pURLComponents->stAppNumber.pszStart = szInstanceBuffer;
|
||||||
|
@ -135,85 +145,94 @@ void GSWHTTPRequest_HTTPToAppRequest(GSWHTTPRequest* p_pHTTPRequest,
|
||||||
p_pURLComponents->stAppHost.iLength = strlen(p_pAppRequest->pszHost);
|
p_pURLComponents->stAppHost.iLength = strlen(p_pAppRequest->pszHost);
|
||||||
|
|
||||||
if (p_pHTTPRequest->pszRequest)
|
if (p_pHTTPRequest->pszRequest)
|
||||||
{
|
{
|
||||||
free(p_pHTTPRequest->pszRequest);
|
free(p_pHTTPRequest->pszRequest);
|
||||||
p_pHTTPRequest->pszRequest=NULL;
|
p_pHTTPRequest->pszRequest=NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
p_pHTTPRequest->pszRequest=malloc(8
|
p_pHTTPRequest->pszRequest=malloc(8+
|
||||||
+(GSWComposeURLLen(p_pURLComponents,p_pLogServerData)+1)
|
(GSWComposeURLLen(p_pURLComponents,
|
||||||
+iHTTPVersionLength);
|
p_pLogServerData)+1)+
|
||||||
|
iHTTPVersionLength);
|
||||||
if (p_pHTTPRequest->uContentLength>0)
|
if (p_pHTTPRequest->uContentLength>0)
|
||||||
{
|
{
|
||||||
strcpy(p_pHTTPRequest->pszRequest,"POST ");
|
strcpy(p_pHTTPRequest->pszRequest,"POST ");
|
||||||
GSWHTTPRequest_AddHeader(p_pHTTPRequest,g_szHeader_GSWeb_RequestMethod,"POST");
|
GSWHTTPRequest_AddHeader(p_pHTTPRequest,g_szHeader_GSWeb_RequestMethod,
|
||||||
}
|
"POST");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy(p_pHTTPRequest->pszRequest,"GET ");
|
strcpy(p_pHTTPRequest->pszRequest,"GET ");
|
||||||
GSWHTTPRequest_AddHeader(p_pHTTPRequest,g_szHeader_GSWeb_RequestMethod,"GET");
|
GSWHTTPRequest_AddHeader(p_pHTTPRequest,g_szHeader_GSWeb_RequestMethod,
|
||||||
};
|
"GET");
|
||||||
|
};
|
||||||
GSWComposeURL(p_pHTTPRequest->pszRequest+strlen(p_pHTTPRequest->pszRequest),
|
GSWComposeURL(p_pHTTPRequest->pszRequest+strlen(p_pHTTPRequest->pszRequest),
|
||||||
p_pURLComponents,
|
p_pURLComponents,
|
||||||
p_pLogServerData);
|
p_pLogServerData);
|
||||||
strcat(p_pHTTPRequest->pszRequest," ");
|
strcat(p_pHTTPRequest->pszRequest," ");
|
||||||
if (p_pszHTTPVersion)
|
if (p_pszHTTPVersion)
|
||||||
strcat(p_pHTTPRequest->pszRequest,p_pszHTTPVersion);
|
strcat(p_pHTTPRequest->pszRequest,p_pszHTTPVersion);
|
||||||
else
|
else
|
||||||
strcat(p_pHTTPRequest->pszRequest,pszDefaultHTTPVersion);
|
strcat(p_pHTTPRequest->pszRequest,pszDefaultHTTPVersion);
|
||||||
strcat(p_pHTTPRequest->pszRequest,"\n");
|
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");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPRequest_HTTPToAppRequest");
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWHTTPRequest_AddHeader(GSWHTTPRequest* p_pHTTPRequest,
|
void
|
||||||
CONST char* p_pszKey,
|
GSWHTTPRequest_AddHeader(GSWHTTPRequest *p_pHTTPRequest,
|
||||||
CONST char* p_pszValue)
|
CONST char *p_pszKey,
|
||||||
|
CONST char *p_pszValue)
|
||||||
{
|
{
|
||||||
CONST char* pszCustomKey=GSWebHeaderForHTTPHeader(p_pszKey);
|
CONST char *pszCustomKey=GSWebHeaderForHTTPHeader(p_pszKey);
|
||||||
CONST char* pszHeaderKey=(pszCustomKey) ? pszCustomKey : p_pszKey;
|
CONST char *pszHeaderKey=(pszCustomKey) ? pszCustomKey : p_pszKey;
|
||||||
|
|
||||||
if (!p_pHTTPRequest->pHeaders)
|
if (!p_pHTTPRequest->pHeaders)
|
||||||
p_pHTTPRequest->pHeaders = GSWDict_New(64);
|
p_pHTTPRequest->pHeaders = GSWDict_New(64);
|
||||||
|
|
||||||
// Search Content Length
|
// Search Content Length
|
||||||
if (p_pHTTPRequest->eMethod==ERequestMethod_Post
|
if (p_pHTTPRequest->eMethod==ERequestMethod_Post
|
||||||
&& p_pHTTPRequest->uContentLength==0
|
&& p_pHTTPRequest->uContentLength==0
|
||||||
&& strcasecmp(pszHeaderKey,g_szHeader_ContentLength)==0)
|
&& strcasecmp(pszHeaderKey,g_szHeader_ContentLength)==0)
|
||||||
p_pHTTPRequest->uContentLength = atoi(p_pszValue);
|
p_pHTTPRequest->uContentLength = atoi(p_pszValue);
|
||||||
|
|
||||||
GSWDict_AddString(p_pHTTPRequest->pHeaders,pszHeaderKey,p_pszValue,FALSE);
|
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)
|
if (p_pHTTPRequest->pHeaders)
|
||||||
return GSWDict_ValueForKey(p_pHTTPRequest->pHeaders,p_pszKey);
|
return GSWDict_ValueForKey(p_pHTTPRequest->pHeaders,p_pszKey);
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
static void GetHeaderLength(GSWDictElem* p_pElem,
|
static void
|
||||||
void* p_piAddTo)
|
GetHeaderLength(GSWDictElem *p_pElem,
|
||||||
|
void *p_piAddTo)
|
||||||
{
|
{
|
||||||
int* piAddTo=(int*)p_piAddTo;
|
int *piAddTo=(int *)p_piAddTo;
|
||||||
// +2=": "
|
// +2=": "
|
||||||
// +1="\n"
|
// +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,
|
static void
|
||||||
void* p_ppszBuffer)
|
FormatHeader(GSWDictElem *p_pElem,
|
||||||
|
void *p_ppszBuffer)
|
||||||
{
|
{
|
||||||
char** ppszBuffer=(char**)p_ppszBuffer;
|
char **ppszBuffer=(char **)p_ppszBuffer;
|
||||||
strcpy(*ppszBuffer,p_pElem->pszKey);
|
strcpy(*ppszBuffer,p_pElem->pszKey);
|
||||||
strcat(*ppszBuffer, ": ");
|
strcat(*ppszBuffer, ": ");
|
||||||
strcat(*ppszBuffer,(char*)p_pElem->pValue);
|
strcat(*ppszBuffer,(char *)p_pElem->pValue);
|
||||||
(*ppszBuffer)+= strlen(*ppszBuffer);
|
(*ppszBuffer)+= strlen(*ppszBuffer);
|
||||||
**ppszBuffer = '\n';
|
**ppszBuffer = '\n';
|
||||||
(*ppszBuffer)++;
|
(*ppszBuffer)++;
|
||||||
|
@ -221,11 +240,14 @@ static void FormatHeader(GSWDictElem* p_pElem,
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// Handle Request (send it to Application)
|
// 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;
|
BOOL fOk = TRUE;
|
||||||
char* pszBuffer=NULL;
|
char *pszBuffer=NULL;
|
||||||
char* pszTmp=NULL;
|
char *pszTmp=NULL;
|
||||||
int iLength = 0;
|
int iLength = 0;
|
||||||
int iHeaderLength = 0;
|
int iHeaderLength = 0;
|
||||||
int iRequestLength = 0;
|
int iRequestLength = 0;
|
||||||
|
@ -239,8 +261,8 @@ BOOL GSWHTTPRequest_SendRequest(GSWHTTPRequest* p_pHTTPRequest,AppConnectHandle
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GSWDict_PerformForAllElem(p_pHTTPRequest->pHeaders,
|
GSWDict_PerformForAllElem(p_pHTTPRequest->pHeaders,
|
||||||
GetHeaderLength,
|
GetHeaderLength,
|
||||||
&iHeaderLength);
|
&iHeaderLength);
|
||||||
iHeaderLength++; // Last /n
|
iHeaderLength++; // Last /n
|
||||||
iLength=iRequestLength+iHeaderLength+iContentLength;
|
iLength=iRequestLength+iHeaderLength+iContentLength;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -251,28 +273,28 @@ BOOL GSWHTTPRequest_SendRequest(GSWHTTPRequest* p_pHTTPRequest,AppConnectHandle
|
||||||
pszBuffer = malloc(iLength+1);
|
pszBuffer = malloc(iLength+1);
|
||||||
|
|
||||||
strncpy(pszBuffer,
|
strncpy(pszBuffer,
|
||||||
p_pHTTPRequest->pszRequest,
|
p_pHTTPRequest->pszRequest,
|
||||||
iRequestLength);
|
iRequestLength);
|
||||||
|
|
||||||
pszTmp = pszBuffer+iRequestLength;
|
pszTmp = pszBuffer+iRequestLength;
|
||||||
GSWDict_PerformForAllElem(p_pHTTPRequest->pHeaders,
|
GSWDict_PerformForAllElem(p_pHTTPRequest->pHeaders,
|
||||||
FormatHeader,
|
FormatHeader,
|
||||||
(void*)&pszTmp);
|
(void *)&pszTmp);
|
||||||
|
|
||||||
*pszTmp++ = '\n';
|
*pszTmp++ = '\n';
|
||||||
|
|
||||||
if (iContentLength>0)
|
if (iContentLength>0)
|
||||||
{
|
{
|
||||||
memcpy(pszTmp,p_pHTTPRequest->pContent,iContentLength);
|
memcpy(pszTmp,p_pHTTPRequest->pContent,iContentLength);
|
||||||
pszTmp+=iContentLength;
|
pszTmp+=iContentLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
*pszTmp = '\0';
|
*pszTmp = '\0';
|
||||||
|
|
||||||
GSWLog(GSW_INFO,p_pLogServerData,
|
GSWLog(GSW_INFO,p_pLogServerData,
|
||||||
"Sending AppRequest Content: %s\n(%d Bytes)",
|
"Sending AppRequest Content: %s\n(%d Bytes)",
|
||||||
p_pHTTPRequest->pszRequest,
|
p_pHTTPRequest->pszRequest,
|
||||||
iContentLength);
|
iContentLength);
|
||||||
// Just To be sure of the length
|
// Just To be sure of the length
|
||||||
iLength = pszTmp - pszBuffer;
|
iLength = pszTmp - pszBuffer;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -287,18 +309,20 @@ BOOL GSWHTTPRequest_SendRequest(GSWHTTPRequest* p_pHTTPRequest,AppConnectHandle
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
static char* GSWHTTPRequest_PackageHeaders(GSWHTTPRequest* p_pHTTPRequest,
|
static char *
|
||||||
char* p_pszBuffer,
|
GSWHTTPRequest_PackageHeaders(GSWHTTPRequest *p_pHTTPRequest,
|
||||||
int p_iBufferSize)
|
char *p_pszBuffer,
|
||||||
|
int p_iBufferSize)
|
||||||
{
|
{
|
||||||
int iHeaderLength=0;
|
int iHeaderLength=0;
|
||||||
char* pszBuffer=NULL;
|
char *pszBuffer=NULL;
|
||||||
char* pszTmp=NULL;
|
char *pszTmp=NULL;
|
||||||
|
|
||||||
GSWDict_PerformForAllElem(p_pHTTPRequest->pHeaders,
|
GSWDict_PerformForAllElem(p_pHTTPRequest->pHeaders,
|
||||||
GetHeaderLength,
|
GetHeaderLength,
|
||||||
(void*)&iHeaderLength);
|
(void *)&iHeaderLength);
|
||||||
pszBuffer = ((p_iBufferSize > (iHeaderLength+1)) ? p_pszBuffer : malloc(p_iBufferSize+2));
|
pszBuffer = ((p_iBufferSize > (iHeaderLength+1)) ?
|
||||||
|
p_pszBuffer : malloc(p_iBufferSize+2));
|
||||||
pszTmp = pszBuffer;
|
pszTmp = pszBuffer;
|
||||||
|
|
||||||
GSWDict_PerformForAllElem(p_pHTTPRequest->pHeaders,FormatHeader,&pszTmp);
|
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 (pszMethod)
|
||||||
{
|
{
|
||||||
if (strcmp(pszMethod,g_szMethod_Get)==0)
|
if (strcmp(pszMethod,g_szMethod_Get)==0)
|
||||||
return ERequestMethod_Get;
|
return ERequestMethod_Get;
|
||||||
else if (strcmp(pszMethod, g_szMethod_Post)==0)
|
else if (strcmp(pszMethod, g_szMethod_Post)==0)
|
||||||
return ERequestMethod_Post;
|
return ERequestMethod_Post;
|
||||||
else if (!strcmp(pszMethod, g_szMethod_Head)==0)
|
else if (!strcmp(pszMethod, g_szMethod_Head)==0)
|
||||||
return ERequestMethod_Head;
|
return ERequestMethod_Head;
|
||||||
else if (!strcmp(pszMethod,g_szMethod_Put)==0)
|
else if (!strcmp(pszMethod,g_szMethod_Put)==0)
|
||||||
return ERequestMethod_Put;
|
return ERequestMethod_Put;
|
||||||
else
|
else
|
||||||
return ERequestMethod_Unknown;
|
return ERequestMethod_Unknown;
|
||||||
}
|
}
|
||||||
else
|
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)
|
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 (p_pKey1)
|
||||||
{
|
{
|
||||||
if (((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);
|
GSWLog(GSW_ERROR,NULL,"p_pKey1=%p (CONST char *)p_pKey1=%s",
|
||||||
|
p_pKey1,((GSWHeaderTranslationItem *)p_pKey1)->pszHTTP);
|
||||||
};
|
|
||||||
|
};
|
||||||
*/
|
*/
|
||||||
if (pKey1)
|
if (pKey1)
|
||||||
return strcmp((CONST char*)p_pKey0,pKey1);
|
return strcmp((CONST char *)p_pKey0,pKey1);
|
||||||
else if (!p_pKey0)
|
else if (!p_pKey0)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
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)
|
if (GSWHeaderTranslationTableItemsNb==0)
|
||||||
GSWHeaderTranslationTable_Init();
|
GSWHeaderTranslationTable_Init();
|
||||||
pItem=bsearch(p_pszHTTPHeader,
|
pItem=bsearch(p_pszHTTPHeader,
|
||||||
GSWHeaderTranslationTable,
|
GSWHeaderTranslationTable,
|
||||||
GSWHeaderTranslationTableItemsNb,
|
GSWHeaderTranslationTableItemsNb,
|
||||||
sizeof(GSWHeaderTranslationItem),
|
sizeof(GSWHeaderTranslationItem),
|
||||||
compareHeader);
|
compareHeader);
|
||||||
return (pItem ? pItem->pszGSWeb : NULL);
|
return (pItem ? pItem->pszGSWeb : NULL);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWHTTPRequest.h - GSWeb: GSWeb Request
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -43,45 +43,45 @@ typedef enum
|
||||||
|
|
||||||
typedef struct _GSWHTTPRequest
|
typedef struct _GSWHTTPRequest
|
||||||
{
|
{
|
||||||
ERequestMethod eMethod; // Method
|
ERequestMethod eMethod; // Method
|
||||||
char* pszRequest; // Request String
|
char *pszRequest; // Request String
|
||||||
GSWDict* pHeaders; // Headers
|
GSWDict *pHeaders; // Headers
|
||||||
void* pServerHandle; // Server Handle
|
void *pServerHandle; // Server Handle
|
||||||
unsigned uContentLength; // Content Length
|
unsigned uContentLength; // Content Length
|
||||||
void* pContent; // Content
|
void *pContent; // Content
|
||||||
} GSWHTTPRequest;
|
} GSWHTTPRequest;
|
||||||
|
|
||||||
|
|
||||||
GSWHTTPRequest* GSWHTTPRequest_New(CONST char* pszMethod,
|
GSWHTTPRequest *GSWHTTPRequest_New(CONST char *pszMethod,
|
||||||
char* p_pszURI,
|
char *p_pszURI,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
void GSWHTTPRequest_Free(GSWHTTPRequest* p_pHTTPRequest,
|
void GSWHTTPRequest_Free(GSWHTTPRequest *p_pHTTPRequest,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
|
|
||||||
// Return error message (NULL if ok)
|
// Return error message (NULL if ok)
|
||||||
CONST char*GSWHTTPRequest_ValidateMethod(GSWHTTPRequest* p_pHTTPRequest,
|
CONST char *GSWHTTPRequest_ValidateMethod(GSWHTTPRequest *p_pHTTPRequest,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
|
|
||||||
// HTTP Request -> GSWeb App Request
|
// HTTP Request -> GSWeb App Request
|
||||||
void GSWHTTPRequest_HTTPToAppRequest(GSWHTTPRequest* p_pHTTPRequest,
|
void GSWHTTPRequest_HTTPToAppRequest(GSWHTTPRequest *p_pHTTPRequest,
|
||||||
GSWAppRequest* p_pAppRequest,
|
GSWAppRequest *p_pAppRequest,
|
||||||
GSWURLComponents* p_pURLComponents,
|
GSWURLComponents *p_pURLComponents,
|
||||||
CONST char* p_pszHTTPVersion,
|
CONST char *p_pszHTTPVersion,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
|
|
||||||
// Add Header
|
// Add Header
|
||||||
void GSWHTTPRequest_AddHeader(GSWHTTPRequest* p_pHTTPRequest,
|
void GSWHTTPRequest_AddHeader(GSWHTTPRequest *p_pHTTPRequest,
|
||||||
CONST char* p_pszKey,
|
CONST char *p_pszKey,
|
||||||
CONST char* p_pszValue);
|
CONST char *p_pszValue);
|
||||||
|
|
||||||
// Get Header (case insensitive)
|
// Get Header (case insensitive)
|
||||||
CONST char* GSWHTTPRequest_HeaderForKey(GSWHTTPRequest* p_pHTTPRequest,
|
CONST char *GSWHTTPRequest_HeaderForKey(GSWHTTPRequest *p_pHTTPRequest,
|
||||||
CONST char* p_pszKey);
|
CONST char *p_pszKey);
|
||||||
|
|
||||||
// Handle Request (send it to Application)
|
// Handle Request (send it to Application)
|
||||||
BOOL GSWHTTPRequest_SendRequest(GSWHTTPRequest* p_pHTTPRequest,
|
BOOL GSWHTTPRequest_SendRequest(GSWHTTPRequest *p_pHTTPRequest,
|
||||||
AppConnectHandle p_socket,
|
AppConnectHandle p_socket,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWHTTPResponse.c - GSWeb: Adaptors: HTTP Response
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -42,92 +42,100 @@
|
||||||
#include "GSWTemplates.h"
|
#include "GSWTemplates.h"
|
||||||
|
|
||||||
|
|
||||||
static char* g_pszLocalHostName = NULL;
|
static char *g_pszLocalHostName = NULL;
|
||||||
|
|
||||||
#define STATUS "Status"
|
#define STATUS "Status"
|
||||||
#define HTTP_SLASH "HTTP/"
|
#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;
|
BOOL fOk=FALSE;
|
||||||
// Accept "HTTP/1.0 200 OK GSWeb..." and "HTTP/1.0 200 OK GNUstep GSWeb..."
|
// Accept "HTTP/1.0 200 OK GSWeb..." and "HTTP/1.0 200 OK GNUstep GSWeb..."
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
GSWLog(GSW_INFO,p_pLogServerData,"p_pszStatus=%s",p_pszStatus);
|
GSWLog(GSW_INFO,p_pLogServerData,"p_pszStatus=%s",p_pszStatus);
|
||||||
#endif
|
#endif
|
||||||
if (strncmp(p_pszStatus,HTTP_SLASH,strlen(HTTP_SLASH))==0)
|
if (strncmp(p_pszStatus,HTTP_SLASH,strlen(HTTP_SLASH))==0)
|
||||||
|
{
|
||||||
|
// Status Code
|
||||||
|
CONST char *pszSpace=strchr(p_pszStatus,' ');
|
||||||
|
if (pszSpace)
|
||||||
{
|
{
|
||||||
// Status Code
|
unsigned int uStatus=0;
|
||||||
CONST char* pszSpace=strchr(p_pszStatus,' ');
|
fOk=TRUE;
|
||||||
if (pszSpace)
|
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;
|
pszSpace=strchr(pszSpace,' ');
|
||||||
fOk=TRUE;
|
if (pszSpace)
|
||||||
pszSpace++;
|
pHTTPResponse->pszStatusMessage=strdup(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);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
if (!fOk)
|
if (!fOk)
|
||||||
GSWLog(GSW_ERROR,p_pLogServerData,"Invalid response");
|
GSWLog(GSW_ERROR,p_pLogServerData,"Invalid response");
|
||||||
return pHTTPResponse;
|
return pHTTPResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
GSWHTTPResponse* GSWHTTPResponse_BuildErrorResponse(GSWAppRequest* p_pAppRequest,
|
GSWHTTPResponse *
|
||||||
CONST char* p_pszMessage,
|
GSWHTTPResponse_BuildErrorResponse(GSWAppRequest *p_pAppRequest,
|
||||||
void* p_pLogServerData)
|
CONST char *p_pszMessage,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
char szBuffer[128]="";
|
char szBuffer[128]="";
|
||||||
GSWApp* pApp=NULL;
|
GSWApp *pApp=NULL;
|
||||||
GSWString* pBuffer=GSWString_New();
|
GSWString *pBuffer=GSWString_New();
|
||||||
GSWString* pBufferMessage=GSWString_New();
|
GSWString *pBufferMessage=GSWString_New();
|
||||||
GSWHTTPResponse* pHTTPResponse=calloc(1,sizeof(GSWHTTPResponse));
|
GSWHTTPResponse *pHTTPResponse=calloc(1,sizeof(GSWHTTPResponse));
|
||||||
char* pszString=NULL;
|
char *pszString=NULL;
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPResponse_BuildErrorResponse");
|
|
||||||
|
GSWLog(GSW_DEBUG,p_pLogServerData,
|
||||||
|
"Start GSWHTTPResponse_BuildErrorResponse");
|
||||||
if (p_pAppRequest && p_pAppRequest->pAppInstance)
|
if (p_pAppRequest && p_pAppRequest->pAppInstance)
|
||||||
pApp=p_pAppRequest->pAppInstance->pApp;
|
pApp=p_pAppRequest->pAppInstance->pApp;
|
||||||
#ifdef DEBUG
|
#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
|
#endif
|
||||||
pHTTPResponse->uStatus = 200;
|
pHTTPResponse->uStatus = 200;
|
||||||
pHTTPResponse->pszStatusMessage = strdup(g_szOKGSWeb[GSWNAMES_INDEX]);
|
pHTTPResponse->pszStatusMessage = strdup(g_szOKGSWeb[GSWNAMES_INDEX]);
|
||||||
pHTTPResponse->pHeaders = GSWDict_New(2);
|
pHTTPResponse->pHeaders = GSWDict_New(2);
|
||||||
GSWDict_Add(pHTTPResponse->pHeaders,
|
GSWDict_Add(pHTTPResponse->pHeaders,
|
||||||
g_szHeader_ContentType,
|
g_szHeader_ContentType,
|
||||||
g_szContentType_TextHtml,
|
g_szContentType_TextHtml,
|
||||||
FALSE);
|
FALSE);
|
||||||
GSWString_Append(pBufferMessage,p_pszMessage);
|
GSWString_Append(pBufferMessage,p_pszMessage);
|
||||||
if (p_pAppRequest)
|
if (p_pAppRequest)
|
||||||
{
|
{
|
||||||
GSWString_SearchReplace(pBufferMessage,"##APP_NAME##",p_pAppRequest->pszName);
|
GSWString_SearchReplace(pBufferMessage,"##APP_NAME##",
|
||||||
sprintf(szBuffer,"%d",p_pAppRequest->iInstance);
|
p_pAppRequest->pszName);
|
||||||
GSWString_SearchReplace(pBufferMessage,"##APP_INSTANCE##",szBuffer);
|
sprintf(szBuffer,"%d",p_pAppRequest->iInstance);
|
||||||
GSWString_SearchReplace(pBufferMessage,"##APP_HOST##",p_pAppRequest->pszHost);
|
GSWString_SearchReplace(pBufferMessage,"##APP_INSTANCE##",szBuffer);
|
||||||
sprintf(szBuffer,"%d",p_pAppRequest->iPort);
|
GSWString_SearchReplace(pBufferMessage,"##APP_HOST##",
|
||||||
GSWString_SearchReplace(pBufferMessage,"##APP_PORT##",szBuffer);
|
p_pAppRequest->pszHost);
|
||||||
};
|
sprintf(szBuffer,"%d",p_pAppRequest->iPort);
|
||||||
|
GSWString_SearchReplace(pBufferMessage,"##APP_PORT##",szBuffer);
|
||||||
|
};
|
||||||
GSWTemplate_ReplaceStd(pBufferMessage,pApp);
|
GSWTemplate_ReplaceStd(pBufferMessage,pApp);
|
||||||
|
|
||||||
pszString=GSWTemplate_ErrorResponseText(TRUE,pApp);
|
pszString=GSWTemplate_ErrorResponseText(TRUE,pApp);
|
||||||
|
@ -142,179 +150,203 @@ GSWHTTPResponse* GSWHTTPResponse_BuildErrorResponse(GSWAppRequest* p_pAppRequest
|
||||||
GSWString_Free(pBuffer);
|
GSWString_Free(pBuffer);
|
||||||
pBuffer=NULL;
|
pBuffer=NULL;
|
||||||
|
|
||||||
|
|
||||||
GSWString_Free(pBufferMessage);
|
GSWString_Free(pBufferMessage);
|
||||||
pBufferMessage=NULL;
|
pBufferMessage=NULL;
|
||||||
sprintf(szBuffer,"%d",pHTTPResponse->uContentLength);
|
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");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPResponse_BuildErrorResponse");
|
||||||
return pHTTPResponse;
|
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));
|
GSWHTTPResponse *pHTTPResponse=calloc(1,sizeof(GSWHTTPResponse));
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPResponse_BuildRedirectedResponse");
|
GSWLog(GSW_DEBUG,p_pLogServerData,
|
||||||
|
"Start GSWHTTPResponse_BuildRedirectedResponse");
|
||||||
pHTTPResponse->uStatus = 302;
|
pHTTPResponse->uStatus = 302;
|
||||||
pHTTPResponse->pszStatusMessage = strdup(g_szOKGSWeb[GSWNAMES_INDEX]);
|
pHTTPResponse->pszStatusMessage = strdup(g_szOKGSWeb[GSWNAMES_INDEX]);
|
||||||
pHTTPResponse->pHeaders=GSWDict_New(2);
|
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);
|
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;
|
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");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPResponse_Free");
|
||||||
if (p_pHTTPResponse)
|
if (p_pHTTPResponse)
|
||||||
|
{
|
||||||
|
if (p_pHTTPResponse->pHeaders)
|
||||||
{
|
{
|
||||||
if (p_pHTTPResponse->pHeaders)
|
GSWDict_Free(p_pHTTPResponse->pHeaders);
|
||||||
{
|
p_pHTTPResponse->pHeaders=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;
|
|
||||||
};
|
};
|
||||||
|
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");
|
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 *pszKey=NULL;
|
||||||
char* pszValue=NULL;
|
char *pszValue=NULL;
|
||||||
|
|
||||||
for (pszKey=p_pszHeader,pszValue=pszKey;*pszValue!=':';pszValue++)
|
for (pszKey=p_pszHeader,pszValue=pszKey;*pszValue!=':';pszValue++)
|
||||||
{
|
{
|
||||||
if (isupper(*pszValue))
|
if (isupper(*pszValue))
|
||||||
*pszValue = tolower(*pszValue);
|
*pszValue = tolower(*pszValue);
|
||||||
};
|
};
|
||||||
if (*pszValue==':')
|
if (*pszValue==':')
|
||||||
{
|
{
|
||||||
*pszValue++='\0';
|
*pszValue++='\0';
|
||||||
while (*pszValue && isspace(*pszValue))
|
while (*pszValue && isspace(*pszValue))
|
||||||
pszValue++;
|
pszValue++;
|
||||||
GSWDict_AddStringDup(p_pHTTPResponse->pHeaders,pszKey,pszValue);
|
GSWDict_AddStringDup(p_pHTTPResponse->pHeaders,pszKey,pszValue);
|
||||||
|
|
||||||
if (p_pHTTPResponse->uContentLength==0 && strcmp(g_szHeader_ContentLength,pszKey)==0)
|
if (p_pHTTPResponse->uContentLength==0 &&
|
||||||
p_pHTTPResponse->uContentLength = atoi(pszValue);
|
strcmp(g_szHeader_ContentLength,pszKey)==0)
|
||||||
}
|
p_pHTTPResponse->uContentLength = atoi(pszValue);
|
||||||
|
}
|
||||||
else
|
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];
|
char szResponseBuffer[RESPONSE__LINE_MAX_SIZE];
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPResponse_GetResponse");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPResponse_GetResponse");
|
||||||
|
|
||||||
// Get the 1st Line
|
// 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);
|
pHTTPResponse = GSWHTTPResponse_New(szResponseBuffer,p_pLogServerData);
|
||||||
#ifdef DEBUG
|
#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
|
#endif
|
||||||
|
|
||||||
if (!pHTTPResponse) //Error
|
if (!pHTTPResponse) //Error
|
||||||
pHTTPResponse=GSWHTTPResponse_BuildErrorResponse(NULL,"Invalid Response",p_pLogServerData);
|
pHTTPResponse=GSWHTTPResponse_BuildErrorResponse(NULL,"Invalid Response",
|
||||||
|
p_pLogServerData);
|
||||||
else
|
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
|
#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
|
#endif
|
||||||
GSWHTTPResponse_AddHeader(pHTTPResponse,szResponseBuffer);
|
GSWHTTPResponse_AddHeader(pHTTPResponse,szResponseBuffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Content
|
// Content
|
||||||
if (pHTTPResponse->uContentLength)
|
if (pHTTPResponse->uContentLength)
|
||||||
{
|
{
|
||||||
char* pszBuffer= malloc(pHTTPResponse->uContentLength);
|
char *pszBuffer= malloc(pHTTPResponse->uContentLength);
|
||||||
int iReceivedCount=GSWApp_ReceiveBlock(p_socket,pszBuffer,pHTTPResponse->uContentLength,p_pLogServerData);
|
int iReceivedCount=GSWApp_ReceiveBlock(p_socket,pszBuffer,
|
||||||
|
pHTTPResponse->uContentLength,
|
||||||
|
p_pLogServerData);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
GSWLog(GSW_INFO,p_pLogServerData,"iReceivedCount=%d",iReceivedCount);
|
GSWLog(GSW_INFO,p_pLogServerData,"iReceivedCount=%d",iReceivedCount);
|
||||||
#endif
|
#endif
|
||||||
if (iReceivedCount!= pHTTPResponse->uContentLength)
|
if (iReceivedCount!= pHTTPResponse->uContentLength)
|
||||||
{
|
{
|
||||||
pHTTPResponse->pContent = pszBuffer;//TODO: Verify this (Turbocat patch)
|
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,
|
free(pszBuffer);
|
||||||
"Content received doesn't equal to ContentLength. Too bad, same player shoot again !");
|
pszBuffer=NULL;
|
||||||
|
GSWHTTPResponse_Free(pHTTPResponse,p_pLogServerData);
|
||||||
|
pHTTPResponse=NULL;
|
||||||
|
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse(NULL,
|
||||||
|
"Invalid Response",p_pLogServerData);
|
||||||
|
|
||||||
free(pszBuffer);
|
}
|
||||||
pszBuffer=NULL;
|
else
|
||||||
GSWHTTPResponse_Free(pHTTPResponse,p_pLogServerData);
|
pHTTPResponse->pContent = pszBuffer;
|
||||||
pHTTPResponse=NULL;
|
}
|
||||||
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse(NULL,"Invalid Response",p_pLogServerData);
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
pHTTPResponse->pContent = pszBuffer;
|
|
||||||
}
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
/*
|
/*
|
||||||
if (pHTTPResponse->pContent)
|
if (pHTTPResponse->pContent)
|
||||||
{
|
{
|
||||||
char szTraceBuffer[pHTTPResponse->uContentLength+1];
|
char szTraceBuffer[pHTTPResponse->uContentLength+1];
|
||||||
GSWLog(GSW_INFO,p_pLogServerData,"\ncontent (%d Bytes)=\n",pHTTPResponse->uContentLength);
|
GSWLog(GSW_INFO,p_pLogServerData,"\ncontent (%d Bytes)=\n",
|
||||||
memcpy(szTraceBuffer,pHTTPResponse->pContent,pHTTPResponse->uContentLength);
|
pHTTPResponse->uContentLength);
|
||||||
szTraceBuffer[pHTTPResponse->uContentLength] = 0;
|
memcpy(szTraceBuffer,pHTTPResponse->pContent,
|
||||||
GSWLogSized(GSW_INFO,p_pLogServerData,
|
pHTTPResponse->uContentLength);
|
||||||
pHTTPResponse->uContentLength+1,
|
szTraceBuffer[pHTTPResponse->uContentLength] = 0;
|
||||||
"%.*s",
|
GSWLogSized(GSW_INFO,p_pLogServerData,
|
||||||
(int)pHTTPResponse->uContentLength,
|
pHTTPResponse->uContentLength+1,
|
||||||
szTraceBuffer);
|
"%.*s",
|
||||||
// GSWLog(GSW_INFO,p_pLogServerData,"\nEND\n");
|
(int)pHTTPResponse->uContentLength,
|
||||||
};
|
szTraceBuffer);
|
||||||
|
// GSWLog(GSW_INFO,p_pLogServerData,"\nEND\n");
|
||||||
|
};
|
||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPResponse_GetResponse");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPResponse_GetResponse");
|
||||||
return pHTTPResponse;
|
return pHTTPResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
static void GetHeaderLength(GSWDictElem* p_pElem,
|
static void
|
||||||
void* p_piAddTo)
|
GetHeaderLength(GSWDictElem *p_pElem,
|
||||||
|
void *p_piAddTo)
|
||||||
{
|
{
|
||||||
int* piAddTo=(int*)p_piAddTo;
|
int *piAddTo=(int *)p_piAddTo;
|
||||||
// +2=": "
|
// +2=": "
|
||||||
// +1="\r"
|
// +1="\r"
|
||||||
// +1="\n"
|
// +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,
|
static void
|
||||||
void* p_ppszBuffer)
|
FormatHeader(GSWDictElem *p_pElem,
|
||||||
|
void *p_ppszBuffer)
|
||||||
{
|
{
|
||||||
char** ppszBuffer=(char**)p_ppszBuffer;
|
char **ppszBuffer=(char **)p_ppszBuffer;
|
||||||
strcpy(*ppszBuffer,p_pElem->pszKey);
|
strcpy(*ppszBuffer,p_pElem->pszKey);
|
||||||
strcat(*ppszBuffer, ": ");
|
strcat(*ppszBuffer, ": ");
|
||||||
strcat(*ppszBuffer,(char*)p_pElem->pValue);
|
strcat(*ppszBuffer,(char *)p_pElem->pValue);
|
||||||
(*ppszBuffer)+= strlen(*ppszBuffer);
|
(*ppszBuffer)+= strlen(*ppszBuffer);
|
||||||
**ppszBuffer = '\r';
|
**ppszBuffer = '\r';
|
||||||
(*ppszBuffer)++;
|
(*ppszBuffer)++;
|
||||||
|
@ -323,78 +355,92 @@ static void FormatHeader(GSWDictElem* p_pElem,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
char *GSWHTTPResponse_PackageHeaders(GSWHTTPResponse* p_pHTTPResponse,
|
char *
|
||||||
char* p_pszBuffer,
|
GSWHTTPResponse_PackageHeaders(GSWHTTPResponse *p_pHTTPResponse,
|
||||||
int p_iBufferSize)
|
char *p_pszBuffer,
|
||||||
|
int p_iBufferSize)
|
||||||
{
|
{
|
||||||
int iHeaderLength=0;
|
int iHeaderLength=0;
|
||||||
char* pszBuffer=NULL;
|
char *pszBuffer=NULL;
|
||||||
char* pszTmp=NULL;
|
char *pszTmp=NULL;
|
||||||
|
|
||||||
GSWDict_PerformForAllElem(p_pHTTPResponse->pHeaders,
|
GSWDict_PerformForAllElem(p_pHTTPResponse->pHeaders,
|
||||||
GetHeaderLength,
|
GetHeaderLength,
|
||||||
(void*)&iHeaderLength);
|
(void *)&iHeaderLength);
|
||||||
pszBuffer = ((p_iBufferSize > (iHeaderLength)) ? p_pszBuffer : malloc(p_iBufferSize+1));
|
pszBuffer = ((p_iBufferSize > (iHeaderLength)) ?
|
||||||
|
p_pszBuffer : malloc(p_iBufferSize+1));
|
||||||
pszTmp = pszBuffer;
|
pszTmp = pszBuffer;
|
||||||
|
|
||||||
GSWDict_PerformForAllElem(p_pHTTPResponse->pHeaders,FormatHeader,&pszTmp);
|
GSWDict_PerformForAllElem(p_pHTTPResponse->pHeaders,FormatHeader,&pszTmp);
|
||||||
*pszTmp = '\0';
|
*pszTmp = '\0';
|
||||||
if (pszTmp-pszBuffer>1)
|
if (pszTmp-pszBuffer>1)
|
||||||
{
|
{
|
||||||
// Remove last \r\n
|
// Remove last \r\n
|
||||||
*(pszTmp-1) = 0;
|
*(pszTmp-1) = 0;
|
||||||
*(pszTmp-2) = 0;
|
*(pszTmp-2) = 0;
|
||||||
};
|
};
|
||||||
return pszBuffer;
|
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,p_pElem->pszKey);
|
||||||
GSWString_Append(pString,": ");
|
GSWString_Append(pString,": ");
|
||||||
GSWString_Append(pString,(char*)p_pElem->pValue);
|
GSWString_Append(pString,(char *)p_pElem->pValue);
|
||||||
GSWString_Append(pString,"<br>");
|
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);
|
GSWHTTPResponse *pHTTPResponse=
|
||||||
GSWDict* pRequestHeaders=NULL;
|
GSWHTTPResponse_New(g_szOKStatus[GSWNAMES_INDEX],p_pLogServerData);
|
||||||
GSWString* pContent=GSWString_New();
|
GSWDict *pRequestHeaders=NULL;
|
||||||
GSWString* pHeadersBuffer=GSWString_New();
|
GSWString *pContent=GSWString_New();
|
||||||
const char* pszRemoteAddr=NULL;
|
GSWString *pHeadersBuffer=GSWString_New();
|
||||||
const char* pszRemoteHost=NULL;
|
const char *pszRemoteAddr=NULL;
|
||||||
char* pszString=NULL;
|
const char *pszRemoteHost=NULL;
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWHTTPResponse_BuildStatusResponse");
|
char *pszString=NULL;
|
||||||
|
|
||||||
|
GSWLog(GSW_DEBUG,p_pLogServerData,
|
||||||
|
"Start GSWHTTPResponse_BuildStatusResponse");
|
||||||
GSWLog(GSW_INFO,p_pLogServerData,"Build Status Page.");
|
GSWLog(GSW_INFO,p_pLogServerData,"Build Status Page.");
|
||||||
GSWConfig_LoadConfiguration(p_pLogServerData);
|
GSWConfig_LoadConfiguration(p_pLogServerData);
|
||||||
GSWDict_AddString(pHTTPResponse->pHeaders,
|
GSWDict_AddString(pHTTPResponse->pHeaders,
|
||||||
g_szHeader_ContentType,
|
g_szHeader_ContentType,
|
||||||
g_szContentType_TextHtml,
|
g_szContentType_TextHtml,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
pRequestHeaders = (GSWDict*)(p_pHTTPRequest->pHeaders);
|
pRequestHeaders = (GSWDict *)(p_pHTTPRequest->pHeaders);
|
||||||
GSWDict_PerformForAllElem(pRequestHeaders,GSWHTTPResponse_AddHeaderToString,pHeadersBuffer);
|
GSWDict_PerformForAllElem(pRequestHeaders,
|
||||||
|
GSWHTTPResponse_AddHeaderToString,pHeadersBuffer);
|
||||||
if (GSWConfig_CanDumpStatus())
|
if (GSWConfig_CanDumpStatus())
|
||||||
pszString=GSWTemplate_StatusAllowedResponse(TRUE,NULL);
|
pszString=GSWTemplate_StatusAllowedResponse(TRUE,NULL);
|
||||||
else
|
else
|
||||||
pszString=GSWTemplate_StatusDeniedResponse(TRUE,NULL);
|
pszString=GSWTemplate_StatusDeniedResponse(TRUE,NULL);
|
||||||
GSWString_Append(pContent,pszString);
|
GSWString_Append(pContent,pszString);
|
||||||
free(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)
|
if (!pszRemoteAddr)
|
||||||
pszRemoteAddr="";
|
pszRemoteAddr="";
|
||||||
pszRemoteHost=(const char*)GSWDict_ValueForKey(pRequestHeaders,"x-gsweb-remote-host");
|
pszRemoteHost=(const char *)GSWDict_ValueForKey(pRequestHeaders,
|
||||||
|
"x-gsweb-remote-host");
|
||||||
if (!pszRemoteHost)
|
if (!pszRemoteHost)
|
||||||
pszRemoteHost="";
|
pszRemoteHost="";
|
||||||
GSWString_SearchReplace(pContent,"##REMOTE_ADDR##",pszRemoteAddr);
|
GSWString_SearchReplace(pContent,"##REMOTE_ADDR##",pszRemoteAddr);
|
||||||
GSWString_SearchReplace(pContent,"##REMOTE_HOST##",pszRemoteHost);
|
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,"##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,"##ADAPTOR_URL##",g_szGSWeb_AdaptorURL());
|
||||||
GSWString_SearchReplace(pContent,"##HEADERS##",pHeadersBuffer->pszData);
|
GSWString_SearchReplace(pContent,"##HEADERS##",pHeadersBuffer->pszData);
|
||||||
GSWTemplate_ReplaceStd(pContent,NULL);
|
GSWTemplate_ReplaceStd(pContent,NULL);
|
||||||
|
@ -405,42 +451,51 @@ GSWHTTPResponse* GSWHTTPResponse_BuildStatusResponse(GSWHTTPRequest* p_pHTTPRequ
|
||||||
pHTTPResponse->pContent = pContent->pszData;
|
pHTTPResponse->pContent = pContent->pszData;
|
||||||
GSWString_Detach(pContent);
|
GSWString_Detach(pContent);
|
||||||
GSWString_Free(pContent);
|
GSWString_Free(pContent);
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWHTTPResponse_BuildStatusResponse");
|
GSWLog(GSW_DEBUG,p_pLogServerData,
|
||||||
|
"Stop GSWHTTPResponse_BuildStatusResponse");
|
||||||
return pHTTPResponse;
|
return pHTTPResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
GSWHTTPResponse* GSWDumpConfigFile(GSWURLComponents* p_pURLComponents,void* p_pLogServerData)
|
GSWHTTPResponse *
|
||||||
|
GSWDumpConfigFile(GSWURLComponents *p_pURLComponents,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
GSWHTTPResponse* pHTTPResponse=NULL;
|
GSWHTTPResponse *pHTTPResponse=NULL;
|
||||||
GSWString* pContent=NULL;
|
GSWString *pContent=NULL;
|
||||||
char pszPrefix[MAXPATHLEN]="";
|
char pszPrefix[MAXPATHLEN]="";
|
||||||
char szReqAppName[MAXPATHLEN]="Unknown";
|
char szReqAppName[MAXPATHLEN]="Unknown";
|
||||||
|
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWDumpConfigFile");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWDumpConfigFile");
|
||||||
GSWLog(GSW_INFO,p_pLogServerData,"Creating Applications Page.");
|
GSWLog(GSW_INFO,p_pLogServerData,"Creating Applications Page.");
|
||||||
if (!g_pszLocalHostName)
|
if (!g_pszLocalHostName)
|
||||||
{
|
{
|
||||||
char szHostName[MAXHOSTNAMELEN+1];
|
char szHostName[MAXHOSTNAMELEN+1];
|
||||||
gethostname(szHostName, MAXHOSTNAMELEN);
|
gethostname(szHostName, MAXHOSTNAMELEN);
|
||||||
g_pszLocalHostName= strdup(szHostName);
|
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,
|
GSWDict_AddString(pHTTPResponse->pHeaders,
|
||||||
g_szHeader_ContentType,
|
g_szHeader_ContentType,
|
||||||
g_szContentType_TextHtml,
|
g_szContentType_TextHtml,
|
||||||
FALSE);
|
FALSE);
|
||||||
if (p_pURLComponents->stAppName.iLength>0 && p_pURLComponents->stAppName.pszStart)
|
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(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';
|
pszPrefix[p_pURLComponents->stPrefix.iLength] = '\0';
|
||||||
|
|
||||||
GSWConfig_LoadConfiguration(p_pLogServerData);
|
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);
|
GSWTemplate_ReplaceStd(pContent,NULL);
|
||||||
pHTTPResponse->uContentLength = pContent->iLen;
|
pHTTPResponse->uContentLength = pContent->iLen;
|
||||||
pHTTPResponse->pContent = pContent->pszData;
|
pHTTPResponse->pContent = pContent->pszData;
|
||||||
|
@ -449,6 +504,3 @@ GSWHTTPResponse* GSWDumpConfigFile(GSWURLComponents* p_pURLComponents,void* p_pL
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWDumpConfigFile");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWDumpConfigFile");
|
||||||
return pHTTPResponse;
|
return pHTTPResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWHTTPResponse.h - GSWeb: GSWeb Request
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -31,34 +31,42 @@ extern "C" {
|
||||||
typedef struct _GSWHTTPResponse
|
typedef struct _GSWHTTPResponse
|
||||||
{
|
{
|
||||||
unsigned int uStatus;
|
unsigned int uStatus;
|
||||||
char* pszStatusMessage;
|
char *pszStatusMessage;
|
||||||
GSWDict* pHeaders;
|
GSWDict *pHeaders;
|
||||||
unsigned int uContentLength;
|
unsigned int uContentLength;
|
||||||
void* pContent;
|
void *pContent;
|
||||||
} GSWHTTPResponse;
|
} GSWHTTPResponse;
|
||||||
|
|
||||||
GSWHTTPResponse* GSWHTTPResponse_New(CONST char* p_pszStatus,void* p_pLogServerData);
|
GSWHTTPResponse *GSWHTTPResponse_New(CONST char *p_pszStatus,
|
||||||
void GSWHTTPResponse_Free(GSWHTTPResponse* p_pHTTPResponse,void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
|
void GSWHTTPResponse_Free(GSWHTTPResponse *p_pHTTPResponse,
|
||||||
|
void *p_pLogServerData);
|
||||||
|
|
||||||
// Get The response from Application
|
// 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
|
// 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
|
// Redirect Response
|
||||||
GSWHTTPResponse* GSWHTTPResponse_BuildRedirectedResponse(CONST char* p_pszRedirectPath,void* p_pLogServerData);
|
GSWHTTPResponse *GSWHTTPResponse_BuildRedirectedResponse(CONST char *p_pszRedirectPath,
|
||||||
|
void *p_pLogServerData);
|
||||||
|
|
||||||
// Add Header
|
// Add Header
|
||||||
void GSWHTTPResponse_AddHeader(GSWHTTPResponse* p_pHTTPResponse,
|
void GSWHTTPResponse_AddHeader(GSWHTTPResponse *p_pHTTPResponse,
|
||||||
char* p_pszHeader);
|
char *p_pszHeader);
|
||||||
|
|
||||||
char* p_pszGSWHTTPResponse_PackageHeaders(GSWHTTPResponse* p_pHTTPResponse,
|
char *p_pszGSWHTTPResponse_PackageHeaders(GSWHTTPResponse *p_pHTTPResponse,
|
||||||
char* p_pszBuffer,
|
char *p_pszBuffer,
|
||||||
int iBufferSize);
|
int iBufferSize);
|
||||||
|
|
||||||
GSWHTTPResponse* GSWHTTPResponse_BuildStatusResponse(GSWHTTPRequest* p_pHTTPRequest,void* p_pLogServerData);
|
GSWHTTPResponse *GSWHTTPResponse_BuildStatusResponse(GSWHTTPRequest *p_pHTTPRequest,
|
||||||
GSWHTTPResponse* GSWDumpConfigFile(GSWURLComponents* p_pURLComponents,void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
|
GSWHTTPResponse* GSWDumpConfigFile(GSWURLComponents *p_pURLComponents,
|
||||||
|
void *p_pLogServerData);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWDict.c - GSWeb: Dictionary
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -29,112 +29,137 @@
|
||||||
#include "GSWUtil.h"
|
#include "GSWUtil.h"
|
||||||
#include "GSWList.h"
|
#include "GSWList.h"
|
||||||
|
|
||||||
unsigned int GSWList_Count(GSWList* p_pList)
|
unsigned int
|
||||||
|
GSWList_Count(GSWList *p_pList)
|
||||||
{
|
{
|
||||||
return p_pList->uCount;
|
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)
|
if (pList && p_uCapacity>0)
|
||||||
GSWList_SetCapacity(pList,p_uCapacity);
|
GSWList_SetCapacity(pList,p_uCapacity);
|
||||||
return pList;
|
return pList;
|
||||||
};
|
};
|
||||||
|
|
||||||
void GSWList_FreeElements(GSWList* p_pList)
|
void
|
||||||
|
GSWList_FreeElements(GSWList *p_pList)
|
||||||
{
|
{
|
||||||
if (p_pList)
|
if (p_pList)
|
||||||
|
{
|
||||||
|
unsigned int i=0;
|
||||||
|
for(i=0;i<p_pList->uCount;i++)
|
||||||
{
|
{
|
||||||
unsigned int i=0;
|
free(p_pList->ppElements[i]);
|
||||||
for(i=0;i<p_pList->uCount;i++)
|
p_pList->ppElements[i]=NULL;
|
||||||
{
|
|
||||||
free(p_pList->ppElements[i]);
|
|
||||||
p_pList->ppElements[i]=NULL;
|
|
||||||
};
|
|
||||||
p_pList->uCount=0;
|
|
||||||
};
|
};
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
if (p_pList->ppElements)
|
||||||
{
|
{
|
||||||
if (p_pList->ppElements)
|
if (p_fFreeElements)
|
||||||
{
|
GSWList_FreeElements(p_pList);
|
||||||
if (p_fFreeElements)
|
free(p_pList->ppElements);
|
||||||
GSWList_FreeElements(p_pList);
|
p_pList->ppElements=NULL;
|
||||||
free(p_pList->ppElements);
|
|
||||||
p_pList->ppElements=NULL;
|
|
||||||
};
|
|
||||||
free(p_pList);
|
|
||||||
};
|
};
|
||||||
|
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)
|
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->ppElements[p_pList->uCount] = p_pElement;
|
||||||
p_pList->uCount++;
|
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)
|
if (p_iIndex>=0 && p_iIndex<p_pList->uCount)
|
||||||
{
|
{
|
||||||
p_pList->uCount--;
|
p_pList->uCount--;
|
||||||
for (;p_iIndex<p_pList->uCount;p_iIndex++)
|
for (;p_iIndex<p_pList->uCount;p_iIndex++)
|
||||||
p_pList->ppElements[p_iIndex]=p_pList->ppElements[p_iIndex+1];
|
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;
|
int i;
|
||||||
for (i=0;i<p_pList->uCount;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_uCapacity>p_pList->uCapacity)
|
||||||
{
|
{
|
||||||
if (p_pList->ppElements)
|
if (p_pList->ppElements)
|
||||||
p_pList->ppElements=realloc(p_pList->ppElements,p_uCapacity*sizeof(void*));
|
p_pList->ppElements=realloc(p_pList->ppElements,
|
||||||
else
|
p_uCapacity*sizeof(void *));
|
||||||
p_pList->ppElements=calloc(p_uCapacity, sizeof(void*));
|
else
|
||||||
|
p_pList->ppElements=calloc(p_uCapacity, sizeof(void *));
|
||||||
p_pList->uCapacity=p_uCapacity;
|
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)
|
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)
|
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;
|
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)
|
if (p_iIndex>=0 && p_iIndex<p_pList->uCount)
|
||||||
return p_pList->ppElements[p_iIndex];
|
return p_pList->ppElements[p_iIndex];
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWList.h - GSWeb: List
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -33,22 +33,24 @@ typedef struct _GSWList
|
||||||
{
|
{
|
||||||
unsigned int uCount;
|
unsigned int uCount;
|
||||||
unsigned int uCapacity;
|
unsigned int uCapacity;
|
||||||
void** ppElements;
|
void **ppElements;
|
||||||
} GSWList;
|
} GSWList;
|
||||||
|
|
||||||
unsigned int GSWList_Count(GSWList* p_pList);
|
unsigned int GSWList_Count(GSWList *p_pList);
|
||||||
|
|
||||||
GSWList *GSWList_New(unsigned int p_uCapacity);
|
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_Add(GSWList *p_pList, void *p_pElement);
|
||||||
void GSWList_Remove(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_RemoveAtIndex(GSWList *p_pList, int p_iIndex);
|
||||||
void GSWList_SetCapacity(GSWList* p_pList,unsigned int p_uCapacity);
|
void GSWList_SetCapacity(GSWList *p_pList, unsigned int 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 *));
|
||||||
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* GSWList_ElementAtIndex(GSWList* p_pList,int p_iIndex);
|
void *GSWList_ElementAtIndex(GSWList *p_pList,int p_iIndex);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWLoadBalancing.c - GSWeb: Adaptors: Load Balancing
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -45,11 +45,13 @@
|
||||||
#include "GSWApp.h"
|
#include "GSWApp.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
BOOL GSWLoadBalancing_FindApp(GSWAppRequest* p_pAppRequest,
|
BOOL
|
||||||
void* p_pLogServerData, GSWURLComponents* p_pURLComponents)
|
GSWLoadBalancing_FindApp(GSWAppRequest *p_pAppRequest,
|
||||||
|
void *p_pLogServerData,
|
||||||
|
GSWURLComponents *p_pURLComponents)
|
||||||
{
|
{
|
||||||
BOOL fFound=FALSE;
|
BOOL fFound=FALSE;
|
||||||
GSWApp* pApp=NULL;
|
GSWApp *pApp=NULL;
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWLoadBalancing_FindApp");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWLoadBalancing_FindApp");
|
||||||
GSWLog(GSW_INFO,p_pLogServerData,"LoadBalance: looking for %s",
|
GSWLog(GSW_INFO,p_pLogServerData,"LoadBalance: looking for %s",
|
||||||
p_pAppRequest->pszName);
|
p_pAppRequest->pszName);
|
||||||
|
@ -57,191 +59,220 @@ BOOL GSWLoadBalancing_FindApp(GSWAppRequest* p_pAppRequest,
|
||||||
GSWLock_Lock(g_lockAppList);
|
GSWLock_Lock(g_lockAppList);
|
||||||
pApp = GSWConfig_GetApp(p_pAppRequest->pszName);
|
pApp = GSWConfig_GetApp(p_pAppRequest->pszName);
|
||||||
if (pApp)
|
if (pApp)
|
||||||
{
|
{
|
||||||
GSWList* pInstancesList=GSWDict_AllKeys(&pApp->stInstancesDict);
|
GSWList *pInstancesList=GSWDict_AllKeys(&pApp->stInstancesDict);
|
||||||
unsigned int uInstancesCount=GSWList_Count(pInstancesList);
|
unsigned int uInstancesCount=GSWList_Count(pInstancesList);
|
||||||
int iTries=uInstancesCount;
|
int iTries=uInstancesCount;
|
||||||
GSWAppInstance* pAppInstance=NULL;
|
GSWAppInstance *pAppInstance=NULL;
|
||||||
time_t curTime = (time_t)0;
|
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;
|
GSWLog(GSW_CRITICAL,p_pLogServerData,
|
||||||
pAppInstance=(GSWAppInstance*)GSWDict_ValueForKey(&pApp->stInstancesDict,
|
"AppInstance pApp is null pAppInstance=%p",
|
||||||
GSWList_ElementAtIndex(pInstancesList,pApp->iIndex));
|
pAppInstance);
|
||||||
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++;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
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);
|
GSWLock_Unlock(g_lockAppList);
|
||||||
|
|
||||||
if (fFound)
|
if (fFound)
|
||||||
GSWLog(GSW_INFO,p_pLogServerData,"LoadBalance: looking for %s, fFound instance %d on %s:%d",
|
GSWLog(GSW_INFO,p_pLogServerData,
|
||||||
p_pAppRequest->pszName,
|
"LoadBalance: looking for %s, fFound instance %d on %s:%d",
|
||||||
p_pAppRequest->iInstance,
|
p_pAppRequest->pszName,
|
||||||
p_pAppRequest->pszHost,
|
p_pAppRequest->iInstance,
|
||||||
p_pAppRequest->iPort);
|
p_pAppRequest->pszHost,
|
||||||
|
p_pAppRequest->iPort);
|
||||||
else
|
else
|
||||||
GSWLog(GSW_INFO,p_pLogServerData,"LoadBalance: looking for %s, Not Found",
|
GSWLog(GSW_INFO,p_pLogServerData,"LoadBalance: looking for %s, Not Found",
|
||||||
p_pAppRequest->pszName);
|
p_pAppRequest->pszName);
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWLoadBalancing_FindApp");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWLoadBalancing_FindApp");
|
||||||
return fFound;
|
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;
|
BOOL fFound=FALSE;
|
||||||
GSWApp* pApp=NULL;
|
GSWApp *pApp=NULL;
|
||||||
int i=0;
|
int i=0;
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWLoadBalancing_FindInstance");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Start GSWLoadBalancing_FindInstance");
|
||||||
GSWConfig_LoadConfiguration(p_pLogServerData);
|
GSWConfig_LoadConfiguration(p_pLogServerData);
|
||||||
GSWLock_Lock(g_lockAppList);
|
GSWLock_Lock(g_lockAppList);
|
||||||
pApp = (GSWApp*)GSWConfig_GetApp(p_pAppRequest->pszName);
|
pApp = (GSWApp *)GSWConfig_GetApp(p_pAppRequest->pszName);
|
||||||
if (pApp)
|
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;
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Instance Found");
|
||||||
char szInstanceNum[50]="";
|
if (pAppInstance->fValid)
|
||||||
sprintf(szInstanceNum,"%d",p_pAppRequest->iInstance);
|
{
|
||||||
pAppInstance=(GSWAppInstance*)GSWDict_ValueForKey(&pApp->stInstancesDict,szInstanceNum);
|
BOOL okay = TRUE;
|
||||||
if (pAppInstance)
|
// 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");
|
GSWAppInfo *thisAppInfo =
|
||||||
if (pAppInstance->fValid)
|
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;
|
thisAppInfo->isRefused = FALSE; // try it again
|
||||||
// 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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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);
|
GSWLock_Unlock(g_lockAppList);
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWLoadBalancing_FindInstance");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Stop GSWLoadBalancing_FindInstance");
|
||||||
return fFound;
|
return fFound;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWLoadBalancing_MarkNotRespondingApp(GSWAppRequest* p_pAppRequest,
|
void
|
||||||
void* p_pLogServerData)
|
GSWLoadBalancing_MarkNotRespondingApp(GSWAppRequest *p_pAppRequest,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
GSWAppInstance* pAppInstance;
|
GSWAppInstance *pAppInstance;
|
||||||
time_t now;
|
time_t now;
|
||||||
time(&now);
|
time(&now);
|
||||||
pAppInstance =p_pAppRequest->pAppInstance;
|
pAppInstance = p_pAppRequest->pAppInstance;
|
||||||
pAppInstance->uOpenedRequestsNb--;
|
pAppInstance->uOpenedRequestsNb--;
|
||||||
pAppInstance->timeNextRetryTime=now+APP_CONNECT_RETRY_DELAY;
|
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 (!pAppInstance->fValid)
|
||||||
{
|
{
|
||||||
if (GSWAppInstance_FreeIFND(pAppInstance))
|
if (GSWAppInstance_FreeIFND(pAppInstance))
|
||||||
pAppInstance=NULL;
|
pAppInstance=NULL;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWLoadBalancing_StartAppRequest(GSWAppRequest* p_pAppRequest,
|
void
|
||||||
void* p_pLogServerData)
|
GSWLoadBalancing_StartAppRequest(GSWAppRequest *p_pAppRequest,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
GSWAppInstance* pAppInstance=p_pAppRequest->pAppInstance;
|
GSWAppInstance *pAppInstance=p_pAppRequest->pAppInstance;
|
||||||
if (pAppInstance->timeNextRetryTime!=0)
|
if (pAppInstance->timeNextRetryTime!=0)
|
||||||
{
|
{
|
||||||
pAppInstance->timeNextRetryTime=0;
|
pAppInstance->timeNextRetryTime=0;
|
||||||
GSWLog(GSW_WARNING,p_pLogServerData,"Marking %s as alive",p_pAppRequest->pszName);
|
GSWLog(GSW_WARNING,p_pLogServerData,
|
||||||
};
|
"Marking %s as alive",p_pAppRequest->pszName);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWLoadBalancing_StopAppRequest(GSWAppRequest *p_pAppRequest,
|
void
|
||||||
void* p_pLogServerData)
|
GSWLoadBalancing_StopAppRequest(GSWAppRequest *p_pAppRequest,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
GSWAppInstance* pAppInstance=p_pAppRequest->pAppInstance;
|
GSWAppInstance *pAppInstance=p_pAppRequest->pAppInstance;
|
||||||
GSWLock_Lock(g_lockAppList);
|
GSWLock_Lock(g_lockAppList);
|
||||||
pAppInstance->uOpenedRequestsNb--;
|
pAppInstance->uOpenedRequestsNb--;
|
||||||
if (!pAppInstance->fValid)
|
if (!pAppInstance->fValid)
|
||||||
{
|
{
|
||||||
if (GSWAppInstance_FreeIFND(pAppInstance))
|
if (GSWAppInstance_FreeIFND(pAppInstance))
|
||||||
pAppInstance=NULL;
|
pAppInstance=NULL;
|
||||||
};
|
};
|
||||||
GSWLock_Unlock(g_lockAppList);
|
GSWLock_Unlock(g_lockAppList);
|
||||||
p_pAppRequest->pAppInstance = NULL;
|
p_pAppRequest->pAppInstance = NULL;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWLoadBalancing.h - GSWeb: GSWeb Load Balancing
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -24,11 +24,18 @@
|
||||||
#ifndef _GSWLoadBalancing_h__
|
#ifndef _GSWLoadBalancing_h__
|
||||||
#define _GSWLoadBalancing_h__
|
#define _GSWLoadBalancing_h__
|
||||||
|
|
||||||
BOOL GSWLoadBalancing_FindApp(GSWAppRequest* p_pAppRequest,void* p_pLogServerData, GSWURLComponents* p_pURLComponents);
|
BOOL GSWLoadBalancing_FindApp(GSWAppRequest *p_pAppRequest,
|
||||||
BOOL GSWLoadBalancing_FindInstance(GSWAppRequest* p_pAppRequest,void* p_pLogServerData, GSWURLComponents* p_pURLComponents);
|
void *p_pLogServerData,
|
||||||
void GSWLoadBalancing_MarkNotRespondingApp(GSWAppRequest* p_pAppRequest,void* p_pLogServerData);
|
GSWURLComponents *p_pURLComponents);
|
||||||
void GSWLoadBalancing_StartAppRequest(GSWAppRequest* p_pAppRequest,void* p_pLogServerData);
|
BOOL GSWLoadBalancing_FindInstance(GSWAppRequest *p_pAppRequest,
|
||||||
void GSWLoadBalancing_StopAppRequest(GSWAppRequest* p_pAppRequest,void* p_pLogServerData);
|
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
|
#endif // GSWLoadBalancing
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWLock.h - GSWeb: Lock
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWPropList.c - GSWeb: Adaptors: GSWPropList
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: March 2000
|
Date: March 2000
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -39,232 +39,249 @@
|
||||||
#include "GSWPropList.h"
|
#include "GSWPropList.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
CONST char* PLGetType(proplist_t pl)
|
CONST char *
|
||||||
|
PLGetType(proplist_t pl)
|
||||||
{
|
{
|
||||||
if (!pl)
|
if (!pl)
|
||||||
return "NULL";
|
return "NULL";
|
||||||
else if (PLIsDictionary(pl))
|
else if (PLIsDictionary(pl))
|
||||||
return "Dictionary";
|
return "Dictionary";
|
||||||
else if (PLIsArray(pl))
|
else if (PLIsArray(pl))
|
||||||
return "Array";
|
return "Array";
|
||||||
else if (PLIsString(pl))
|
else if (PLIsString(pl))
|
||||||
return "String";
|
return "String";
|
||||||
else if (PLIsData(pl))
|
else if (PLIsData(pl))
|
||||||
return "Data";
|
return "Data";
|
||||||
else if (PLIsSimple(pl))
|
else if (PLIsSimple(pl))
|
||||||
return "Simple";
|
return "Simple";
|
||||||
else if (PLIsCompound(pl))
|
else if (PLIsCompound(pl))
|
||||||
return "Compound";
|
return "Compound";
|
||||||
else
|
else
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
BOOL GSWPropList_TestDictionary(proplist_t pl,
|
BOOL
|
||||||
BOOL p_fErrorIfNotExists,
|
GSWPropList_TestDictionary(proplist_t pl,
|
||||||
CONST char* p_pszKey,
|
BOOL p_fErrorIfNotExists,
|
||||||
CONST char* p_pszParents,
|
CONST char *p_pszKey,
|
||||||
void* p_pLogServerData)
|
CONST char *p_pszParents,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
char* pszMsgInfo0=NULL;
|
char *pszMsgInfo0=NULL;
|
||||||
char* pszMsgInfo1=NULL;
|
char *pszMsgInfo1=NULL;
|
||||||
BOOL fOk=TRUE;
|
BOOL fOk=TRUE;
|
||||||
if (pl)
|
if (pl)
|
||||||
|
{
|
||||||
|
if (!PLIsDictionary(pl))
|
||||||
{
|
{
|
||||||
if (!PLIsDictionary(pl))
|
CONST char *pszType=PLGetType(pl);
|
||||||
{
|
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
|
||||||
CONST char* pszType=PLGetType(pl);
|
sprintf(pszMsgInfo0,"is not a dictionary its a %s:",pszType);
|
||||||
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
|
pszMsgInfo1=PLGetDescription(pl);//We have to free it
|
||||||
sprintf(pszMsgInfo0,"is not a dictionary its a %s:",pszType);
|
fOk=FALSE;
|
||||||
pszMsgInfo1=PLGetDescription(pl);//We have to free it
|
};
|
||||||
fOk=FALSE;
|
}
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (p_fErrorIfNotExists)
|
||||||
{
|
{
|
||||||
if (p_fErrorIfNotExists)
|
pszMsgInfo0=strdup("not found");
|
||||||
{
|
fOk=FALSE;
|
||||||
pszMsgInfo0=strdup("not found");
|
|
||||||
fOk=FALSE;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
if (!fOk)
|
if (!fOk)
|
||||||
{
|
{
|
||||||
GSWLogSized(GSW_CRITICAL,
|
GSWLogSized(GSW_CRITICAL,
|
||||||
p_pLogServerData,
|
p_pLogServerData,
|
||||||
256+SafeStrlen(p_pszParents)+SafeStrlen(p_pszKey)+SafeStrlen(pszMsgInfo0)+SafeStrlen(pszMsgInfo1),
|
256+SafeStrlen(p_pszParents)+SafeStrlen(p_pszKey)+
|
||||||
"%s/%s %s %s",
|
SafeStrlen(pszMsgInfo0)+SafeStrlen(pszMsgInfo1),
|
||||||
(p_pszParents ? p_pszParents : ""),
|
"%s/%s %s %s",
|
||||||
(p_pszKey ? p_pszKey : ""),
|
(p_pszParents ? p_pszParents : ""),
|
||||||
(pszMsgInfo0 ? pszMsgInfo0 : ""),
|
(p_pszKey ? p_pszKey : ""),
|
||||||
(pszMsgInfo1 ? pszMsgInfo1 : ""));
|
(pszMsgInfo0 ? pszMsgInfo0 : ""),
|
||||||
if (pszMsgInfo0)
|
(pszMsgInfo1 ? pszMsgInfo1 : ""));
|
||||||
free(pszMsgInfo0);
|
if (pszMsgInfo0)
|
||||||
if (pszMsgInfo1)
|
free(pszMsgInfo0);
|
||||||
free(pszMsgInfo1);
|
if (pszMsgInfo1)
|
||||||
};
|
free(pszMsgInfo1);
|
||||||
|
};
|
||||||
return fOk;
|
return fOk;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
BOOL GSWPropList_TestArray(proplist_t pl,
|
BOOL
|
||||||
BOOL p_fErrorIfNotExists,
|
GSWPropList_TestArray(proplist_t pl,
|
||||||
CONST char* p_pszKey,
|
BOOL p_fErrorIfNotExists,
|
||||||
CONST char* p_pszParents,
|
CONST char *p_pszKey,
|
||||||
void* p_pLogServerData)
|
CONST char *p_pszParents,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
char* pszMsgInfo0=NULL;
|
char *pszMsgInfo0=NULL;
|
||||||
char* pszMsgInfo1=NULL;
|
char *pszMsgInfo1=NULL;
|
||||||
BOOL fOk=TRUE;
|
BOOL fOk=TRUE;
|
||||||
if (pl)
|
if (pl)
|
||||||
|
{
|
||||||
|
if (!PLIsArray(pl))
|
||||||
{
|
{
|
||||||
if (!PLIsArray(pl))
|
CONST char *pszType=PLGetType(pl);
|
||||||
{
|
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
|
||||||
CONST char* pszType=PLGetType(pl);
|
sprintf(pszMsgInfo0,"is not an array its a %s:",pszType);
|
||||||
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
|
pszMsgInfo1=PLGetDescription(pl);//We have to free it
|
||||||
sprintf(pszMsgInfo0,"is not an array its a %s:",pszType);
|
fOk=FALSE;
|
||||||
pszMsgInfo1=PLGetDescription(pl);//We have to free it
|
};
|
||||||
fOk=FALSE;
|
}
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (p_fErrorIfNotExists)
|
||||||
{
|
{
|
||||||
if (p_fErrorIfNotExists)
|
pszMsgInfo0="not found";
|
||||||
{
|
fOk=FALSE;
|
||||||
pszMsgInfo0="not found";
|
|
||||||
fOk=FALSE;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
if (!fOk)
|
if (!fOk)
|
||||||
{
|
{
|
||||||
GSWLogSized(GSW_CRITICAL,
|
GSWLogSized(GSW_CRITICAL,
|
||||||
p_pLogServerData,
|
p_pLogServerData,
|
||||||
256+SafeStrlen(p_pszParents)+SafeStrlen(p_pszKey)+SafeStrlen(pszMsgInfo0)+SafeStrlen(pszMsgInfo1),
|
256+SafeStrlen(p_pszParents)+SafeStrlen(p_pszKey)+
|
||||||
"%s/%s %s %s",
|
SafeStrlen(pszMsgInfo0)+SafeStrlen(pszMsgInfo1),
|
||||||
(p_pszParents ? p_pszParents : ""),
|
"%s/%s %s %s",
|
||||||
(p_pszKey ? p_pszKey : ""),
|
(p_pszParents ? p_pszParents : ""),
|
||||||
(pszMsgInfo0 ? pszMsgInfo0 : ""),
|
(p_pszKey ? p_pszKey : ""),
|
||||||
(pszMsgInfo1 ? pszMsgInfo1 : ""));
|
(pszMsgInfo0 ? pszMsgInfo0 : ""),
|
||||||
if (pszMsgInfo0)
|
(pszMsgInfo1 ? pszMsgInfo1 : ""));
|
||||||
free(pszMsgInfo0);
|
if (pszMsgInfo0)
|
||||||
if (pszMsgInfo1)
|
free(pszMsgInfo0);
|
||||||
free(pszMsgInfo1);
|
if (pszMsgInfo1)
|
||||||
};
|
free(pszMsgInfo1);
|
||||||
|
};
|
||||||
return fOk;
|
return fOk;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
BOOL GSWPropList_TestString(proplist_t pl,
|
BOOL
|
||||||
BOOL p_fErrorIfNotExists,
|
GSWPropList_TestString(proplist_t pl,
|
||||||
CONST char* p_pszKey,
|
BOOL p_fErrorIfNotExists,
|
||||||
CONST char* p_pszParents,
|
CONST char *p_pszKey,
|
||||||
void* p_pLogServerData)
|
CONST char *p_pszParents,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
char* pszMsgInfo0=NULL;
|
char *pszMsgInfo0=NULL;
|
||||||
char* pszMsgInfo1=NULL;
|
char *pszMsgInfo1=NULL;
|
||||||
BOOL fOk=TRUE;
|
BOOL fOk=TRUE;
|
||||||
if (pl)
|
if (pl)
|
||||||
|
{
|
||||||
|
if (!PLIsString(pl))
|
||||||
{
|
{
|
||||||
if (!PLIsString(pl))
|
CONST char *pszType=PLGetType(pl);
|
||||||
{
|
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
|
||||||
CONST char* pszType=PLGetType(pl);
|
sprintf(pszMsgInfo0,"is not a string its a %s:",pszType);
|
||||||
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
|
pszMsgInfo1=PLGetDescription(pl);//We have to free it
|
||||||
sprintf(pszMsgInfo0,"is not a string its a %s:",pszType);
|
fOk=FALSE;
|
||||||
pszMsgInfo1=PLGetDescription(pl);//We have to free it
|
};
|
||||||
fOk=FALSE;
|
}
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (p_fErrorIfNotExists)
|
||||||
{
|
{
|
||||||
if (p_fErrorIfNotExists)
|
pszMsgInfo0="not found";
|
||||||
{
|
fOk=FALSE;
|
||||||
pszMsgInfo0="not found";
|
|
||||||
fOk=FALSE;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
if (!fOk)
|
if (!fOk)
|
||||||
{
|
{
|
||||||
GSWLogSized(GSW_CRITICAL,
|
GSWLogSized(GSW_CRITICAL,
|
||||||
p_pLogServerData,
|
p_pLogServerData,
|
||||||
256+SafeStrlen(p_pszParents)+SafeStrlen(p_pszKey)+SafeStrlen(pszMsgInfo0)+SafeStrlen(pszMsgInfo1),
|
256+SafeStrlen(p_pszParents)+SafeStrlen(p_pszKey)+
|
||||||
"%s/%s %s %s",
|
SafeStrlen(pszMsgInfo0)+SafeStrlen(pszMsgInfo1),
|
||||||
(p_pszParents ? p_pszParents : ""),
|
"%s/%s %s %s",
|
||||||
(p_pszKey ? p_pszKey : ""),
|
(p_pszParents ? p_pszParents : ""),
|
||||||
(pszMsgInfo0 ? pszMsgInfo0 : ""),
|
(p_pszKey ? p_pszKey : ""),
|
||||||
(pszMsgInfo1 ? pszMsgInfo1 : ""));
|
(pszMsgInfo0 ? pszMsgInfo0 : ""),
|
||||||
if (pszMsgInfo0)
|
(pszMsgInfo1 ? pszMsgInfo1 : ""));
|
||||||
free(pszMsgInfo0);
|
if (pszMsgInfo0)
|
||||||
if (pszMsgInfo1)
|
free(pszMsgInfo0);
|
||||||
free(pszMsgInfo1);
|
if (pszMsgInfo1)
|
||||||
};
|
free(pszMsgInfo1);
|
||||||
|
};
|
||||||
return fOk;
|
return fOk;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
//Do not destroy the returned proplist !
|
//Do not destroy the returned proplist !
|
||||||
proplist_t GSWPropList_GetDictionaryEntry(proplist_t p_propListDictionary,
|
proplist_t
|
||||||
CONST char* p_pszKey,
|
GSWPropList_GetDictionaryEntry(proplist_t p_propListDictionary,
|
||||||
CONST char* p_pszParents,
|
CONST char *p_pszKey,
|
||||||
BOOL p_fErrorIfNotExists,
|
CONST char *p_pszParents,
|
||||||
PLTypeTestFn p_pTestFn,
|
BOOL p_fErrorIfNotExists,
|
||||||
void* p_pLogServerData)
|
PLTypeTestFn p_pTestFn,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
proplist_t propListKey=PLMakeString((char*)p_pszKey);
|
proplist_t propListKey=PLMakeString((char *)p_pszKey);
|
||||||
proplist_t propList=NULL;
|
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)(propList,p_fErrorIfNotExists,
|
||||||
if (p_pTestFn)
|
p_pszKey,p_pszParents,p_pLogServerData))
|
||||||
{
|
propList=NULL;
|
||||||
if (!(*p_pTestFn)(propList,p_fErrorIfNotExists,p_pszKey,p_pszParents,p_pLogServerData))
|
|
||||||
propList=NULL;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
PLRelease(propListKey);
|
PLRelease(propListKey);
|
||||||
return propList;
|
return propList;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
//Do not destroy the returned proplist !
|
//Do not destroy the returned proplist !
|
||||||
proplist_t GSWPropList_GetArrayElement(proplist_t p_propListArray,
|
proplist_t
|
||||||
int p_iIndex,
|
GSWPropList_GetArrayElement(proplist_t p_propListArray,
|
||||||
CONST char* p_pszParents,
|
int p_iIndex,
|
||||||
BOOL p_fErrorIfNotExists,
|
CONST char *p_pszParents,
|
||||||
PLTypeTestFn p_pTestFn,
|
BOOL p_fErrorIfNotExists,
|
||||||
void* p_pLogServerData)
|
PLTypeTestFn p_pTestFn,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
proplist_t propList=NULL;
|
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);
|
char szKey[120]="";
|
||||||
if (p_pTestFn)
|
sprintf(szKey,"index: %d",p_iIndex);
|
||||||
{
|
if (!(*p_pTestFn)(propList,p_fErrorIfNotExists,szKey,
|
||||||
char szKey[120]="";
|
p_pszParents,p_pLogServerData))
|
||||||
sprintf(szKey,"index: %d",p_iIndex);
|
propList=NULL;
|
||||||
if (!(*p_pTestFn)(propList,p_fErrorIfNotExists,szKey,p_pszParents,p_pLogServerData))
|
|
||||||
propList=NULL;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
return propList;
|
return propList;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
//You have to free the returned proplist !
|
//You have to free the returned proplist !
|
||||||
proplist_t GSWPropList_GetAllDictionaryKeys(proplist_t p_propListDictionary,
|
proplist_t
|
||||||
CONST char* p_pszParents,
|
GSWPropList_GetAllDictionaryKeys(proplist_t p_propListDictionary,
|
||||||
BOOL p_fErrorIfNotExists,
|
CONST char *p_pszParents,
|
||||||
PLTypeTestFn p_pTestFn,
|
BOOL p_fErrorIfNotExists,
|
||||||
void* p_pLogServerData)
|
PLTypeTestFn p_pTestFn,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
proplist_t propList=NULL;
|
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)(propList,p_fErrorIfNotExists,NULL,
|
||||||
if (p_pTestFn)
|
p_pszParents,p_pLogServerData))
|
||||||
{
|
propList=NULL;
|
||||||
if (!(*p_pTestFn)(propList,p_fErrorIfNotExists,NULL,p_pszParents,p_pLogServerData))
|
|
||||||
propList=NULL;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
return propList;
|
return propList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWPropList.h - GSWeb: PropList
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: March 2000
|
Date: March 2000
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -28,44 +28,48 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "GSWList.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);
|
CONST char *PLGetType(proplist_t pl);
|
||||||
BOOL GSWPropList_TestDictionary(proplist_t pl,
|
BOOL GSWPropList_TestDictionary(proplist_t pl,
|
||||||
BOOL p_fErrorIfNotExists,
|
BOOL p_fErrorIfNotExists,
|
||||||
CONST char* p_pszKey,
|
CONST char *p_pszKey,
|
||||||
CONST char* p_pszParents,
|
CONST char *p_pszParents,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
BOOL GSWPropList_TestArray(proplist_t pl,
|
BOOL GSWPropList_TestArray(proplist_t pl,
|
||||||
BOOL p_fErrorIfNotExists,
|
BOOL p_fErrorIfNotExists,
|
||||||
CONST char* p_pszKey,
|
CONST char *p_pszKey,
|
||||||
CONST char* p_pszParents,
|
CONST char *p_pszParents,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
BOOL GSWPropList_TestString(proplist_t pl,
|
BOOL GSWPropList_TestString(proplist_t pl,
|
||||||
BOOL p_fErrorIfNotExists,
|
BOOL p_fErrorIfNotExists,
|
||||||
CONST char* p_pszKey,
|
CONST char *p_pszKey,
|
||||||
CONST char* p_pszParents,
|
CONST char *p_pszParents,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
|
|
||||||
//Do not destroy the returned proplist !
|
//Do not destroy the returned proplist !
|
||||||
proplist_t GSWPropList_GetDictionaryEntry(proplist_t p_propListDictionary,
|
proplist_t GSWPropList_GetDictionaryEntry(proplist_t p_propListDictionary,
|
||||||
CONST char* p_pszKey,
|
CONST char *p_pszKey,
|
||||||
CONST char* p_pszParents,
|
CONST char *p_pszParents,
|
||||||
BOOL p_fErrorIfNotExists,
|
BOOL p_fErrorIfNotExists,
|
||||||
PLTypeTestFn p_pTestFn,
|
PLTypeTestFn p_pTestFn,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
//Do not destroy the returned proplist !
|
//Do not destroy the returned proplist !
|
||||||
proplist_t GSWPropList_GetArrayElement(proplist_t p_propListArray,
|
proplist_t GSWPropList_GetArrayElement(proplist_t p_propListArray,
|
||||||
int p_iIndex,
|
int p_iIndex,
|
||||||
CONST char* p_pszParents,
|
CONST char *p_pszParents,
|
||||||
BOOL p_fErrorIfNotExists,
|
BOOL p_fErrorIfNotExists,
|
||||||
PLTypeTestFn p_pTestFn,
|
PLTypeTestFn p_pTestFn,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
//You have to free the returned proplist !
|
//You have to free the returned proplist !
|
||||||
proplist_t GSWPropList_GetAllDictionaryKeys(proplist_t p_propListDictionary,
|
proplist_t GSWPropList_GetAllDictionaryKeys(proplist_t p_propListDictionary,
|
||||||
CONST char* p_pszParents,
|
CONST char *p_pszParents,
|
||||||
BOOL p_fErrorIfNotExists,
|
BOOL p_fErrorIfNotExists,
|
||||||
PLTypeTestFn p_pTestFn,
|
PLTypeTestFn p_pTestFn,
|
||||||
void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
|
|
||||||
#endif //_GSWPropList_h__
|
#endif //_GSWPropList_h__
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWString.c - GSWeb: Adaptors: String
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: Jully 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
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));
|
memset(pString,0,sizeof(GSWString));
|
||||||
return pString;
|
return pString;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWString_Free(GSWString* p_pString)
|
void
|
||||||
|
GSWString_Free(GSWString *p_pString)
|
||||||
{
|
{
|
||||||
if (p_pString)
|
if (p_pString)
|
||||||
|
{
|
||||||
|
if (p_pString->pszData)
|
||||||
{
|
{
|
||||||
if (p_pString->pszData)
|
free(p_pString->pszData);
|
||||||
{
|
p_pString->pszData=NULL;
|
||||||
free(p_pString->pszData);
|
|
||||||
p_pString->pszData=NULL;
|
|
||||||
};
|
|
||||||
free(p_pString);
|
|
||||||
};
|
};
|
||||||
|
free(p_pString);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
int GSWString_Len(GSWString* p_pString)
|
int
|
||||||
|
GSWString_Len(GSWString *p_pString)
|
||||||
{
|
{
|
||||||
return p_pString->iLen;
|
return p_pString->iLen;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWString_Detach(GSWString* p_pString)
|
void
|
||||||
|
GSWString_Detach(GSWString *p_pString)
|
||||||
{
|
{
|
||||||
memset(p_pString,0,sizeof(GSWString));
|
memset(p_pString,0,sizeof(GSWString));
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWString_GrowUpToSize(GSWString* p_pString,
|
void
|
||||||
int p_iSize)
|
GSWString_GrowUpToSize(GSWString *p_pString,
|
||||||
|
int p_iSize)
|
||||||
{
|
{
|
||||||
if (p_iSize>p_pString->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);
|
||||||
p_pString->iSize=max(p_iSize,4096);
|
}
|
||||||
p_pString->pszData=malloc(p_pString->iSize);
|
else
|
||||||
}
|
{
|
||||||
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=realloc(p_pString->pszData,p_pString->iSize);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWString_Append(GSWString* p_pString,
|
void
|
||||||
CONST char* p_pszString)
|
GSWString_Append(GSWString *p_pString,
|
||||||
|
CONST char *p_pszString)
|
||||||
{
|
{
|
||||||
int iLen = strlen(p_pszString);
|
int iLen = strlen(p_pszString);
|
||||||
GSWString_GrowUpToSize(p_pString,p_pString->iLen+iLen+1);
|
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,
|
void
|
||||||
CONST char* p_pszSearch,
|
GSWString_SearchReplace(GSWString *p_pString,
|
||||||
CONST char* p_pszReplace)
|
CONST char *p_pszSearch,
|
||||||
|
CONST char *p_pszReplace)
|
||||||
{
|
{
|
||||||
int iSearchLen=SafeStrlen(p_pszSearch);
|
int iSearchLen=SafeStrlen(p_pszSearch);
|
||||||
if (iSearchLen>0)
|
if (iSearchLen>0)
|
||||||
|
{
|
||||||
|
char *p=strstr(p_pString->pszData,p_pszSearch);
|
||||||
|
if (p)
|
||||||
{
|
{
|
||||||
char* p=strstr(p_pString->pszData,p_pszSearch);
|
int iIndex=0;
|
||||||
if (p)
|
int iReplaceLen=SafeStrlen(p_pszReplace);
|
||||||
{
|
int iDiff=iReplaceLen-iSearchLen;
|
||||||
int iIndex=0;
|
while(p)
|
||||||
int iReplaceLen=SafeStrlen(p_pszReplace);
|
{
|
||||||
int iDiff=iReplaceLen-iSearchLen;
|
iIndex=p-p_pString->pszData;
|
||||||
while(p)
|
if (iDiff>0)
|
||||||
{
|
GSWString_GrowUpToSize(p_pString,p_pString->iSize+iDiff);
|
||||||
iIndex=p-p_pString->pszData;
|
if (iDiff!=0)
|
||||||
if (iDiff>0)
|
memmove(p_pString->pszData+iIndex+iReplaceLen,
|
||||||
GSWString_GrowUpToSize(p_pString,p_pString->iSize+iDiff);
|
p_pString->pszData+iIndex+iSearchLen,
|
||||||
if (iDiff!=0)
|
p_pString->iLen-iIndex-iSearchLen+1);
|
||||||
memmove(p_pString->pszData+iIndex+iReplaceLen,
|
if (iReplaceLen>0)
|
||||||
p_pString->pszData+iIndex+iSearchLen,
|
memcpy(p_pString->pszData+iIndex,p_pszReplace,iReplaceLen);
|
||||||
p_pString->iLen-iIndex-iSearchLen+1);
|
p_pString->iLen+=iDiff;
|
||||||
if (iReplaceLen>0)
|
p=strstr(p_pString->pszData+iIndex+iReplaceLen,p_pszSearch);
|
||||||
memcpy(p_pString->pszData+iIndex,p_pszReplace,iReplaceLen);
|
};
|
||||||
p_pString->iLen+=iDiff;
|
|
||||||
p=strstr(p_pString->pszData+iIndex+iReplaceLen,p_pszSearch);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWString.h - GSWeb: String
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -30,20 +30,20 @@ extern "C" {
|
||||||
|
|
||||||
typedef struct _GSWString
|
typedef struct _GSWString
|
||||||
{
|
{
|
||||||
int iSize;
|
int iSize;
|
||||||
int iLen;
|
int iLen;
|
||||||
char* pszData;
|
char *pszData;
|
||||||
} GSWString;
|
} GSWString;
|
||||||
|
|
||||||
GSWString* GSWString_New();
|
GSWString *GSWString_New();
|
||||||
int GSWString_Len(GSWString* p_pString);
|
int GSWString_Len(GSWString *p_pString);
|
||||||
void GSWString_Free(GSWString* p_pString);
|
void GSWString_Free(GSWString *p_pString);
|
||||||
void GSWString_Detach(GSWString* p_pString);
|
void GSWString_Detach(GSWString *p_pString);
|
||||||
void GSWString_Append(GSWString* p_pString,
|
void GSWString_Append(GSWString *p_pString,
|
||||||
CONST char* p_pszString);
|
CONST char *p_pszString);
|
||||||
void GSWString_SearchReplace(GSWString* p_pString,
|
void GSWString_SearchReplace(GSWString *p_pString,
|
||||||
CONST char* p_pszSearch,
|
CONST char *p_pszSearch,
|
||||||
CONST char* p_pszReplace);
|
CONST char *p_pszReplace);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // end of C header
|
} // end of C header
|
||||||
#endif //_cplusplus
|
#endif //_cplusplus
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWTemplates.c - GSWeb: GSWTemplates
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: March 2000
|
Date: March 2000
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
#include "GSWTemplates.h"
|
#include "GSWTemplates.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
const char* g_szErrorResponseTextTemplate[2]={
|
const char *g_szErrorResponseTextTemplate[2]={
|
||||||
"##TEXT##",
|
"##TEXT##",
|
||||||
"<HTML><BODY BGCOLOR=\"#FFFFFF\">\n"
|
"<HTML><BODY BGCOLOR=\"#FFFFFF\">\n"
|
||||||
"<CENTER><H1>##TEXT##</H1></CENTER>\n"
|
"<CENTER><H1>##TEXT##</H1></CENTER>\n"
|
||||||
|
@ -43,12 +43,12 @@ const char* g_szErrorResponseTextTemplate[2]={
|
||||||
"</BODY></HTML>\n"};
|
"</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",
|
||||||
"##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 Status\n"
|
||||||
"##SERVER_INFO## ##SERVER_URL##\n"
|
"##SERVER_INFO## ##SERVER_URL##\n"
|
||||||
"##ADAPTOR_INFO## ##ADAPTOR_URL##\n"
|
"##ADAPTOR_INFO## ##ADAPTOR_URL##\n"
|
||||||
|
@ -66,7 +66,7 @@ const char* g_szStatusResponseAllowedTemplate[2]={
|
||||||
"</BODY></HTML>\n"};
|
"</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",
|
"Don't play with me ##REMOTE_ADDR## ##REMOTE_HOST##, I'll win!\n",
|
||||||
|
|
||||||
"<HTML><HEAD><TITLE>Server Status</TITLE></HEAD>\n"
|
"<HTML><HEAD><TITLE>Server Status</TITLE></HEAD>\n"
|
||||||
|
@ -77,7 +77,7 @@ const char* g_szStatusResponseDeniedTemplate[2]={
|
||||||
"</BODY></HTML>\n"};
|
"</BODY></HTML>\n"};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
const char* g_szDump_HeadTemplate[2]={
|
const char *g_szDump_HeadTemplate[2]={
|
||||||
"GNUstepWeb Application\n",
|
"GNUstepWeb Application\n",
|
||||||
"<HTML><HEAD><TITLE>Index of GNUstepWeb Applications</TITLE></HEAD>\n"
|
"<HTML><HEAD><TITLE>Index of GNUstepWeb Applications</TITLE></HEAD>\n"
|
||||||
"<BODY BGCOLOR=\"#FFFFFF\">"
|
"<BODY BGCOLOR=\"#FFFFFF\">"
|
||||||
|
@ -96,7 +96,7 @@ const char* g_szDump_HeadTemplate[2]={
|
||||||
"</tr>\n"};
|
"</tr>\n"};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
const char* g_szDump_FootTemplate[2]={
|
const char *g_szDump_FootTemplate[2]={
|
||||||
"",
|
"",
|
||||||
"</table></CENTER>\n"
|
"</table></CENTER>\n"
|
||||||
"<BR>\n"
|
"<BR>\n"
|
||||||
|
@ -104,7 +104,7 @@ const char* g_szDump_FootTemplate[2]={
|
||||||
"</BODY></HTML>"};
|
"</BODY></HTML>"};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
char* g_szDump_AppTemplate[2]={
|
char *g_szDump_AppTemplate[2]={
|
||||||
"AppName: ##NAME##\n"
|
"AppName: ##NAME##\n"
|
||||||
"URL: ##URL##\n"
|
"URL: ##URL##\n"
|
||||||
"Instances:\n"
|
"Instances:\n"
|
||||||
|
@ -119,7 +119,7 @@ char* g_szDump_AppTemplate[2]={
|
||||||
"</TR>\n"};
|
"</TR>\n"};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
char* g_szDump_AppInstanceTemplate[2]={
|
char *g_szDump_AppInstanceTemplate[2]={
|
||||||
"Instance ##NUM##\n"
|
"Instance ##NUM##\n"
|
||||||
"URL: ##URL##\n"
|
"URL: ##URL##\n"
|
||||||
"HOST: ##HOST##\n"
|
"HOST: ##HOST##\n"
|
||||||
|
@ -132,36 +132,45 @@ char* g_szDump_AppInstanceTemplate[2]={
|
||||||
"</TR>"};
|
"</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)
|
if (pApp && pApp->pszAdaptorTemplatesPath && p_pszTemplateName)
|
||||||
{
|
{
|
||||||
FILE* fd=NULL;
|
FILE *fd=NULL;
|
||||||
GSWConfig* gswConfig=GSWConfig_GetConfig();
|
GSWConfig *gswConfig=GSWConfig_GetConfig();
|
||||||
int applen=strlen(pApp->pszAdaptorTemplatesPath)+strlen(p_pszTemplateName);
|
int applen=strlen(pApp->pszAdaptorTemplatesPath)+
|
||||||
int globallen=strlen(gswConfig->pszAdaptorTemplatesPath)+strlen(p_pszTemplateName);
|
strlen(p_pszTemplateName);
|
||||||
|
int globallen=strlen(gswConfig->pszAdaptorTemplatesPath)+
|
||||||
|
strlen(p_pszTemplateName);
|
||||||
int maxlen=(applen > globallen ? applen : globallen)+20;
|
int maxlen=(applen > globallen ? applen : globallen)+20;
|
||||||
{
|
{
|
||||||
char* pathName=malloc(maxlen);
|
char *pathName=malloc(maxlen);
|
||||||
memset(pathName,0,maxlen);
|
memset(pathName,0,maxlen);
|
||||||
if (p_fHTML)
|
if (p_fHTML)
|
||||||
sprintf(pathName,"%s/%s.html",pApp->pszAdaptorTemplatesPath,p_pszTemplateName);
|
sprintf(pathName,"%s/%s.html",pApp->pszAdaptorTemplatesPath,
|
||||||
|
p_pszTemplateName);
|
||||||
else
|
else
|
||||||
sprintf(pathName,"%s/%s.txt",pApp->pszAdaptorTemplatesPath,p_pszTemplateName);
|
sprintf(pathName,"%s/%s.txt",pApp->pszAdaptorTemplatesPath,
|
||||||
|
p_pszTemplateName);
|
||||||
fd=fopen(pathName,"r");
|
fd=fopen(pathName,"r");
|
||||||
if (!fd)
|
if (!fd)
|
||||||
{
|
{
|
||||||
if (p_fHTML)
|
if (p_fHTML)
|
||||||
sprintf(pathName,"%s/%s.html",gswConfig->pszAdaptorTemplatesPath,p_pszTemplateName);
|
sprintf(pathName,"%s/%s.html",
|
||||||
|
gswConfig->pszAdaptorTemplatesPath,p_pszTemplateName);
|
||||||
else
|
else
|
||||||
sprintf(pathName,"%s/%s.txt",gswConfig->pszAdaptorTemplatesPath,p_pszTemplateName);
|
sprintf(pathName,"%s/%s.txt",
|
||||||
|
gswConfig->pszAdaptorTemplatesPath,p_pszTemplateName);
|
||||||
fd=fopen(pathName,"r");
|
fd=fopen(pathName,"r");
|
||||||
}
|
}
|
||||||
if (fd)
|
if (fd)
|
||||||
{
|
{
|
||||||
char buff[4096]="";
|
char buff[4096]="";
|
||||||
GSWString* pBuffer=GSWString_New();
|
GSWString *pBuffer=GSWString_New();
|
||||||
while(fgets(buff,4096,fd))
|
while(fgets(buff,4096,fd))
|
||||||
{
|
{
|
||||||
GSWString_Append(pBuffer,buff);
|
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");
|
pszString=GSWTemplate_GetTemplate(p_fHTML,pApp,"ErrorResponseText");
|
||||||
if (!pszString)
|
if (!pszString)
|
||||||
pszString=strdup(g_szErrorResponseTextTemplate[p_fHTML ? 1 : 0]);
|
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");
|
pszString=GSWTemplate_GetTemplate(p_fHTML,pApp,"ErrorNoResponse");
|
||||||
if (!pszString)
|
if (!pszString)
|
||||||
pszString=strdup(g_szErrorNoResponseMessageTemplate[p_fHTML ? 1 : 0]);
|
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");
|
pszString=GSWTemplate_GetTemplate(p_fHTML,pApp,"StatusAllowedResponse");
|
||||||
if (!pszString)
|
if (!pszString)
|
||||||
pszString=strdup(g_szStatusResponseAllowedTemplate[p_fHTML ? 1 : 0]);
|
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");
|
pszString=GSWTemplate_GetTemplate(p_fHTML,pApp,"StatusDeniedResponse");
|
||||||
if (!pszString)
|
if (!pszString)
|
||||||
pszString=strdup(g_szStatusResponseDeniedTemplate[p_fHTML ? 1 : 0]);
|
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");
|
/* pszString=GSWTemplate_GetTemplate(p_fHTML,pApp,"DumpHead");
|
||||||
if (!pszString)*/
|
if (!pszString)*/
|
||||||
pszString=strdup(g_szDump_HeadTemplate[p_fHTML ? 1 : 0]);
|
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");
|
/* pszString=GSWTemplate_GetTemplate(p_fHTML,pApp,"DumpFoot");
|
||||||
if (!pszString)*/
|
if (!pszString)*/
|
||||||
pszString=strdup(g_szDump_FootTemplate[p_fHTML ? 1 : 0]);
|
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");
|
/* pszString=GSWTemplate_GetTemplate(p_fHTML,pApp,"DumpApp");
|
||||||
if (!pszString)*/
|
if (!pszString)*/
|
||||||
pszString=strdup(g_szDump_AppTemplate[p_fHTML ? 1 : 0]);
|
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");
|
/* pszString=GSWTemplate_GetTemplate(p_fHTML,pApp,"DumpAppInstance");
|
||||||
if (!pszString)*/
|
if (!pszString)*/
|
||||||
pszString=strdup(g_szDump_AppInstanceTemplate[p_fHTML ? 1 : 0]);
|
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)
|
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)
|
if (p_pApp && p_pApp->pszGSWExtensionsFrameworkWebServerResources)
|
||||||
GSWString_SearchReplace(p_pString,"##GSWEXTFWKWSR##",
|
GSWString_SearchReplace(p_pString,"##GSWEXTFWKWSR##",
|
||||||
p_pApp->pszGSWExtensionsFrameworkWebServerResources);
|
p_pApp->pszGSWExtensionsFrameworkWebServerResources);
|
||||||
else
|
else
|
||||||
GSWString_SearchReplace(p_pString,"##GSWEXTFWKWSR##",
|
GSWString_SearchReplace(p_pString,"##GSWEXTFWKWSR##",
|
||||||
GSWConfig_GetConfig()->pszGSWExtensionsFrameworkWebServerResources);
|
GSWConfig_GetConfig()->pszGSWExtensionsFrameworkWebServerResources);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWTemplates.h - GSWeb: GSWTemplates
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: March 2000
|
Date: March 2000
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -27,14 +27,14 @@
|
||||||
#include "GSWApp.h"
|
#include "GSWApp.h"
|
||||||
|
|
||||||
//You need to free returned char
|
//You need to free returned char
|
||||||
char* GSWTemplate_ErrorResponseText(BOOL p_fHTML,GSWApp* pApp);
|
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* GSWTemplate_StatusAllowedResponse(BOOL p_fHTML,GSWApp* pApp);
|
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* GSWTemplate_GetDumpHead(BOOL p_fHTML);
|
char *GSWTemplate_GetDumpHead(BOOL p_fHTML);
|
||||||
char* GSWTemplate_GetDumpFoot(BOOL p_fHTML);
|
char *GSWTemplate_GetDumpFoot(BOOL p_fHTML);
|
||||||
char* GSWTemplate_GetDumpApp(BOOL p_fHTML);
|
char *GSWTemplate_GetDumpApp(BOOL p_fHTML);
|
||||||
char* GSWTemplate_GetDumpAppInstance(BOOL p_fHTML);
|
char *GSWTemplate_GetDumpAppInstance(BOOL p_fHTML);
|
||||||
void GSWTemplate_ReplaceStd(GSWString* p_pString,GSWApp* p_pApp);
|
void GSWTemplate_ReplaceStd(GSWString *p_pString, GSWApp *p_pApp);
|
||||||
|
|
||||||
#endif //_GSWTemplates_h__
|
#endif //_GSWTemplates_h__
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWURLUtil.c - GSWeb: Adaptors: URL Utils
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -36,225 +36,244 @@
|
||||||
#include "GSWURLUtil.h"
|
#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;
|
GSWURLError eError=GSWURLError_OK;
|
||||||
GSWURLComponent* pURLCPrefix=&p_pURLComponents->stPrefix;
|
GSWURLComponent *pURLCPrefix=&p_pURLComponents->stPrefix;
|
||||||
GSWURLComponent* pURLCVersion=&p_pURLComponents->stVersion;
|
GSWURLComponent *pURLCVersion=&p_pURLComponents->stVersion;
|
||||||
GSWURLComponent* pURLCAppName=&p_pURLComponents->stAppName;
|
GSWURLComponent *pURLCAppName=&p_pURLComponents->stAppName;
|
||||||
GSWURLComponent* pURLCAppNum=&p_pURLComponents->stAppNumber;
|
GSWURLComponent *pURLCAppNum=&p_pURLComponents->stAppNumber;
|
||||||
GSWURLComponent* pURLCReqHandlerKey=&p_pURLComponents->stRequestHandlerKey;
|
GSWURLComponent *pURLCReqHandlerKey=&p_pURLComponents->stRequestHandlerKey;
|
||||||
GSWURLComponent* pURLCReqHandlerPath=&p_pURLComponents->stRequestHandlerPath;
|
GSWURLComponent *pURLCReqHandlerPath=&p_pURLComponents->stRequestHandlerPath;
|
||||||
GSWURLComponent* pURLCQueryString=&p_pURLComponents->stQueryString;
|
GSWURLComponent *pURLCQueryString=&p_pURLComponents->stQueryString;
|
||||||
int iURLLen=p_pszURL ? strlen(p_pszURL) : 0;
|
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 *pszStop=NULL;
|
||||||
CONST char *pszNext=NULL;
|
CONST char *pszNext=NULL;
|
||||||
CONST char* pszPrefix=NULL;
|
CONST char *pszPrefix=NULL;
|
||||||
CONST char *pszS=NULL;
|
CONST char *pszS=NULL;
|
||||||
CONST char* pszURLEnd=p_pszURL+iURLLen;
|
CONST char *pszURLEnd=p_pszURL+iURLLen;
|
||||||
CONST char* pszQueryStringMark=strchr(pszStart,'?');
|
CONST char *pszQueryStringMark=strchr(pszStart,'?');
|
||||||
CONST char* pszTmpStop=(pszQueryStringMark && pszQueryStringMark<pszURLEnd) ? pszQueryStringMark : pszURLEnd;
|
CONST char *pszTmpStop=(pszQueryStringMark && pszQueryStringMark<pszURLEnd) ?
|
||||||
|
pszQueryStringMark : pszURLEnd;
|
||||||
int i, j;
|
int i, j;
|
||||||
memset(p_pURLComponents,0,sizeof(GSWURLComponents));
|
memset(p_pURLComponents,0,sizeof(GSWURLComponents));
|
||||||
|
|
||||||
// First, get URL prefix
|
// First, get URL prefix
|
||||||
pszPrefix=strcasestr(pszStart,g_szGSWeb_Prefix);
|
pszPrefix=strcasestr(pszStart,g_szGSWeb_Prefix);
|
||||||
if (pszPrefix && pszQueryStringMark && pszQueryStringMark<=pszPrefix)
|
if (pszPrefix && pszQueryStringMark && pszQueryStringMark<=pszPrefix)
|
||||||
pszPrefix=NULL;
|
pszPrefix=NULL;
|
||||||
|
|
||||||
if (pszPrefix)
|
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;
|
pszAppExtension=strcasestr(pszStart,
|
||||||
CONST char* pszfoundExtension=NULL;
|
g_szGSWeb_AppExtention[WONAMES_INDEX]);
|
||||||
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];
|
|
||||||
};
|
|
||||||
if (pszAppExtension)
|
if (pszAppExtension)
|
||||||
{
|
pszfoundExtension=g_szGSWeb_AppExtention[WONAMES_INDEX];
|
||||||
if (pszQueryStringMark && pszQueryStringMark<=pszAppExtension)
|
};
|
||||||
{
|
if (pszAppExtension)
|
||||||
pszAppExtension=NULL;
|
{
|
||||||
pszStop=pszURLEnd;
|
if (pszQueryStringMark && pszQueryStringMark<=pszAppExtension)
|
||||||
pszNext=pszStop;
|
{
|
||||||
}
|
pszAppExtension=NULL;
|
||||||
else
|
pszStop=pszURLEnd;
|
||||||
{
|
pszNext=pszStop;
|
||||||
pszStop=pszAppExtension;
|
}
|
||||||
pszNext=pszStop+strlen(pszfoundExtension);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pszStop=strchr(pszStart,'/');
|
pszStop=pszAppExtension;
|
||||||
if (pszStop && pszQueryStringMark && pszQueryStringMark<=pszStop)
|
pszNext=pszStop+strlen(pszfoundExtension);
|
||||||
pszStop=pszQueryStringMark-1;
|
};
|
||||||
if (pszStop)
|
}
|
||||||
pszNext=pszStop+1;
|
else
|
||||||
else
|
{
|
||||||
{
|
pszStop=strchr(pszStart,'/');
|
||||||
pszStop=pszTmpStop;
|
if (pszStop && pszQueryStringMark && pszQueryStringMark<=pszStop)
|
||||||
pszNext=NULL;
|
pszStop=pszQueryStringMark-1;
|
||||||
};
|
if (pszStop)
|
||||||
};
|
pszNext=pszStop+1;
|
||||||
pURLCAppName->pszStart = pszStart;
|
else
|
||||||
pURLCAppName->iLength = pszStop-pszStart;
|
{
|
||||||
pURLCAppName->iLength = max(pURLCAppName->iLength,0);
|
pszStop=pszTmpStop;
|
||||||
// Drop trailing slashes
|
pszNext=NULL;
|
||||||
while(pURLCAppName->iLength && pURLCAppName->pszStart[pURLCAppName->iLength-1]== '/')
|
};
|
||||||
pURLCAppName->iLength--;
|
};
|
||||||
pURLCAppName->iLength = max(pURLCAppName->iLength,0);
|
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
|
// Find
|
||||||
pszStart = pszNext;
|
for (pszS=pszStart;pszS<pszTmpStop && *pszS!='/';pszS++);
|
||||||
if (!pszStart)
|
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->pszStart="";
|
||||||
pURLCAppNum->iLength=0;
|
pURLCAppNum->iLength=0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
pszStart=pszNext;
|
||||||
// Skip slashes
|
// Skip slashes
|
||||||
while(*pszStart=='/')
|
while(*pszStart=='/')
|
||||||
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++);
|
|
||||||
|
|
||||||
if (pszS!=pszStop)
|
for (pszS=pszStart;pszS<pszTmpStop && *pszS!='/';pszS++);
|
||||||
{
|
|
||||||
// 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++);
|
|
||||||
pszStop = pszS;
|
pszStop = pszS;
|
||||||
pURLCReqHandlerPath->pszStart = pszStart;
|
pURLCReqHandlerKey->pszStart = pszStart;
|
||||||
pURLCReqHandlerPath->iLength = pszStop-pszStart;
|
pURLCReqHandlerKey->iLength = pszStop-pszStart;
|
||||||
pURLCReqHandlerPath->iLength = max(pURLCReqHandlerPath->iLength,0);
|
pURLCReqHandlerKey->iLength =
|
||||||
|
max(pURLCReqHandlerKey->iLength,0);
|
||||||
pszNext=(pszStop<pszTmpStop) ? pszStop+1 : pszStop;
|
pszNext=(pszStop<pszTmpStop) ? pszStop+1 : pszStop;
|
||||||
pszStart=pszNext;
|
|
||||||
};
|
};
|
||||||
// Query String
|
};
|
||||||
if (!pszStart)
|
// Get Request Handler Path
|
||||||
pszStart=pszTmpStop;
|
pszStart = pszNext;
|
||||||
pURLCQueryString->pszStart = pszStart;
|
for (pszS=pszStart;pszS<pszTmpStop;pszS++);
|
||||||
pURLCQueryString->iLength = pszURLEnd - pszStart;
|
pszStop = pszS;
|
||||||
pURLCQueryString->iLength = max(pURLCQueryString->iLength,0);
|
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)
|
if (!pURLCPrefix->pszStart || pURLCPrefix->iLength<=0)
|
||||||
{
|
{
|
||||||
eError=GSWURLError_InvalidPrefix;
|
eError=GSWURLError_InvalidPrefix;
|
||||||
GSWLog(GSW_ERROR,p_pLogServerData,"ParseURL GSWURLError_InvalidPrefix");
|
GSWLog(GSW_ERROR,p_pLogServerData,"ParseURL GSWURLError_InvalidPrefix");
|
||||||
}
|
}
|
||||||
else
|
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,
|
GSWLog(GSW_DEBUG,p_pLogServerData,
|
||||||
"pURLCPrefix=%.*s",
|
"pURLCAppName=%.*s",
|
||||||
pURLCPrefix->iLength,pURLCPrefix->pszStart);
|
pURLCAppName->iLength,pURLCAppName->pszStart);
|
||||||
if (!pURLCAppName->pszStart || pURLCAppName->iLength<=0)
|
if (!pURLCAppNum->pszStart)
|
||||||
{
|
{
|
||||||
eError=GSWURLError_InvalidAppName;
|
eError=GSWURLError_InvalidAppNumber;
|
||||||
GSWLog(GSW_ERROR,p_pLogServerData,"ParseURL GSWURLError_InvalidAppName");
|
GSWLog(GSW_ERROR,p_pLogServerData,
|
||||||
}
|
"ParseURL GSWURLError_InvalidAppNumber");
|
||||||
|
}
|
||||||
else
|
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,
|
GSWLog(GSW_DEBUG,p_pLogServerData,
|
||||||
"pURLCAppName=%.*s",
|
"pURLCReqHandlerPath=%.*s",
|
||||||
pURLCAppName->iLength,pURLCAppName->pszStart);
|
pURLCReqHandlerPath->iLength,
|
||||||
if (!pURLCAppNum->pszStart)
|
pURLCReqHandlerPath->pszStart);
|
||||||
{
|
/*
|
||||||
eError=GSWURLError_InvalidAppNumber;
|
if (!pURLCReqHandlerPath->pszStart ||
|
||||||
GSWLog(GSW_ERROR,p_pLogServerData,"ParseURL GSWURLError_InvalidAppNumber");
|
pURLCReqHandlerPath->iLength<=0)
|
||||||
}
|
eError=GSWURLError_InvalidRequestHandlerPath;
|
||||||
else
|
else if (!pURLCQueryString->pszStart ||
|
||||||
{
|
pURLCQueryString->iLength<=0)
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,
|
eError=GSWURLError_InvalidQueryString;
|
||||||
"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;
|
|
||||||
*/
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"End ParseURL eError=%d",eError);
|
GSWLog(GSW_DEBUG,p_pLogServerData,"End ParseURL eError=%d",eError);
|
||||||
return 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 *pURLCPrefix=&p_pURLComponents->stPrefix;
|
||||||
GSWURLComponent* pURLCAppName=&p_pURLComponents->stAppName;
|
GSWURLComponent *pURLCAppName=&p_pURLComponents->stAppName;
|
||||||
GSWURLComponent* pURLCAppNum=&p_pURLComponents->stAppNumber;
|
GSWURLComponent *pURLCAppNum=&p_pURLComponents->stAppNumber;
|
||||||
GSWURLComponent* pURLCReqHandlerKey=&p_pURLComponents->stRequestHandlerKey;
|
GSWURLComponent *pURLCReqHandlerKey=&p_pURLComponents->stRequestHandlerKey;
|
||||||
GSWURLComponent* pURLCReqHandlerPath=&p_pURLComponents->stRequestHandlerPath;
|
GSWURLComponent *pURLCReqHandlerPath=&p_pURLComponents->stRequestHandlerPath;
|
||||||
GSWURLComponent* pURLCQueryString=&p_pURLComponents->stQueryString;
|
GSWURLComponent *pURLCQueryString=&p_pURLComponents->stQueryString;
|
||||||
|
|
||||||
strncpy(p_pszURL,pURLCPrefix->pszStart, pURLCPrefix->iLength);
|
strncpy(p_pszURL,pURLCPrefix->pszStart, pURLCPrefix->iLength);
|
||||||
p_pszURL+=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]);
|
p_pszURL+=strlen(g_szGSWeb_AppExtention[GSWNAMES_INDEX]);
|
||||||
|
|
||||||
if (pURLCAppNum->iLength>0)
|
if (pURLCAppNum->iLength>0)
|
||||||
{
|
{
|
||||||
*p_pszURL++='/';
|
*p_pszURL++='/';
|
||||||
strncpy(p_pszURL,pURLCAppNum->pszStart,pURLCAppNum->iLength);
|
strncpy(p_pszURL,pURLCAppNum->pszStart,pURLCAppNum->iLength);
|
||||||
p_pszURL+= pURLCAppNum->iLength;
|
p_pszURL+= pURLCAppNum->iLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (pURLCReqHandlerKey->iLength>0)
|
if (pURLCReqHandlerKey->iLength>0)
|
||||||
{
|
{
|
||||||
*p_pszURL++='/';
|
*p_pszURL++='/';
|
||||||
strncpy(p_pszURL, pURLCReqHandlerKey->pszStart,pURLCReqHandlerKey->iLength);
|
strncpy(p_pszURL, pURLCReqHandlerKey->pszStart,
|
||||||
p_pszURL+= pURLCReqHandlerKey->iLength;
|
pURLCReqHandlerKey->iLength);
|
||||||
|
p_pszURL+= pURLCReqHandlerKey->iLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (pURLCReqHandlerPath->iLength>0)
|
if (pURLCReqHandlerPath->iLength>0)
|
||||||
{
|
{
|
||||||
*p_pszURL++='/';
|
*p_pszURL++='/';
|
||||||
strncpy(p_pszURL, pURLCReqHandlerPath->pszStart,pURLCReqHandlerPath->iLength);
|
strncpy(p_pszURL, pURLCReqHandlerPath->pszStart,
|
||||||
|
pURLCReqHandlerPath->iLength);
|
||||||
p_pszURL+= pURLCReqHandlerPath->iLength;
|
p_pszURL+= pURLCReqHandlerPath->iLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (pURLCQueryString->iLength>0)
|
if (pURLCQueryString->iLength>0)
|
||||||
{
|
{
|
||||||
*p_pszURL++='?';
|
*p_pszURL++='?';
|
||||||
strncpy(p_pszURL,pURLCQueryString->pszStart,pURLCQueryString->iLength);
|
strncpy(p_pszURL,pURLCQueryString->pszStart,
|
||||||
|
pURLCQueryString->iLength);
|
||||||
p_pszURL+= pURLCQueryString->iLength;
|
p_pszURL+= pURLCQueryString->iLength;
|
||||||
};
|
};
|
||||||
*p_pszURL=0;
|
*p_pszURL=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
int GSWComposeURLLen(GSWURLComponents* p_pURLComponents,void* p_pLogServerData)
|
int
|
||||||
|
GSWComposeURLLen(GSWURLComponents *p_pURLComponents,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
int iLength=0;
|
int iLength=0;
|
||||||
GSWURLComponent* pURLCPrefix=&p_pURLComponents->stPrefix;
|
GSWURLComponent *pURLCPrefix=&p_pURLComponents->stPrefix;
|
||||||
GSWURLComponent* pURLCAppName=&p_pURLComponents->stAppName;
|
GSWURLComponent *pURLCAppName=&p_pURLComponents->stAppName;
|
||||||
GSWURLComponent* pURLCAppNum=&p_pURLComponents->stAppNumber;
|
GSWURLComponent *pURLCAppNum=&p_pURLComponents->stAppNumber;
|
||||||
GSWURLComponent* pURLCReqHandlerKey=&p_pURLComponents->stRequestHandlerKey;
|
GSWURLComponent *pURLCReqHandlerKey=&p_pURLComponents->stRequestHandlerKey;
|
||||||
GSWURLComponent* pURLCReqHandlerPath=&p_pURLComponents->stRequestHandlerPath;
|
GSWURLComponent *pURLCReqHandlerPath=&p_pURLComponents->stRequestHandlerPath;
|
||||||
GSWURLComponent* pURLCQueryString=&p_pURLComponents->stQueryString;
|
GSWURLComponent *pURLCQueryString=&p_pURLComponents->stQueryString;
|
||||||
|
|
||||||
iLength+=pURLCPrefix->iLength;
|
iLength+=pURLCPrefix->iLength;
|
||||||
iLength+=1+pURLCAppName->iLength;
|
iLength+=1+pURLCAppName->iLength;
|
||||||
iLength+=strlen(g_szGSWeb_AppExtention[GSWNAMES_INDEX]);
|
iLength+=strlen(g_szGSWeb_AppExtention[GSWNAMES_INDEX]);
|
||||||
if (pURLCAppNum->iLength>0)
|
if (pURLCAppNum->iLength>0)
|
||||||
iLength+= 1+pURLCAppNum->iLength;
|
iLength+= 1+pURLCAppNum->iLength;
|
||||||
if (pURLCReqHandlerKey->iLength>0)
|
if (pURLCReqHandlerKey->iLength>0)
|
||||||
iLength+=1+pURLCReqHandlerKey->iLength;
|
iLength+=1+pURLCReqHandlerKey->iLength;
|
||||||
if (pURLCReqHandlerPath->iLength>0)
|
if (pURLCReqHandlerPath->iLength>0)
|
||||||
iLength+= 1+pURLCReqHandlerPath->iLength;
|
iLength+= 1+pURLCReqHandlerPath->iLength;
|
||||||
if (pURLCQueryString->iLength>0)
|
if (pURLCQueryString->iLength>0)
|
||||||
iLength+=1+pURLCQueryString->iLength;
|
iLength+=1+pURLCQueryString->iLength;
|
||||||
return iLength;
|
return iLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
CONST char* szGSWURLErrorMessage[]=
|
CONST char *szGSWURLErrorMessage[]=
|
||||||
{
|
{
|
||||||
"", // GSWURLError_OK
|
"", //GSWURLError_OK
|
||||||
"Invalid prefix in URL", // GSWURLError_InvalidPrefix
|
"Invalid prefix in URL", //GSWURLError_InvalidPrefix
|
||||||
"Invalid version in URL", // GSWURLError_InvalidVersion
|
"Invalid version in URL", //GSWURLError_InvalidVersion
|
||||||
"Invalid application name", // GSWURLError_InvalidAppName
|
"Invalid application name", //GSWURLError_InvalidAppName
|
||||||
"Invalid application number in URL", // GSWURLError_InvalidAppNumber,
|
"Invalid application number in URL", //GSWURLError_InvalidAppNumber,
|
||||||
"Invalid request handler key in URL", // GSWURLError_InvalidRequestHandlerKey,
|
"Invalid request handler key in URL", //GSWURLError_InvalidRequestHandlerKey,
|
||||||
"Invalid request handler path in URL", // GSWURLError_InvalidRequestHandlerPath,
|
"Invalid request handler path in URL",//GSWURLError_InvalidRequestHandlerPath,
|
||||||
"Invalid application host name in URL", // GSWURLError_InvalidAppHost,
|
"Invalid application host name in URL",//GSWURLError_InvalidAppHost,
|
||||||
"Invalid page name in URL", // GSWURLError_InvalidPageName,
|
"Invalid page name in URL", //GSWURLError_InvalidPageName,
|
||||||
"Invalid session ID in URL", // GSWURLError_InvalidSessionID,
|
"Invalid session ID in URL", //GSWURLError_InvalidSessionID,
|
||||||
"Invalid context ID in URL", // GSWURLError_InvalidContextID,
|
"Invalid context ID in URL", //GSWURLError_InvalidContextID,
|
||||||
"Invalid sender ID in URL", // GSWURLError_InvalidSenderID,
|
"Invalid sender ID in URL", //GSWURLError_InvalidSenderID,
|
||||||
"Invalid query string in URL", // GSWURLError_InvalidQueryString,
|
"Invalid query string in URL", //GSWURLError_InvalidQueryString,
|
||||||
"Invalid suffix in URL" // GSWURLError_InvalidSuffix
|
"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]))
|
if (p_eError>=0 &&
|
||||||
return szGSWURLErrorMessage[p_eError];
|
p_eError<sizeof(szGSWURLErrorMessage)/sizeof(szGSWURLErrorMessage[0]))
|
||||||
|
return szGSWURLErrorMessage[p_eError];
|
||||||
else
|
else
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWURLUtil.h - GSWeb: Adaptors: URL Utils
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ extern "C" {
|
||||||
|
|
||||||
typedef struct _GSWURLComponent
|
typedef struct _GSWURLComponent
|
||||||
{
|
{
|
||||||
CONST char* pszStart;
|
CONST char *pszStart;
|
||||||
int iLength;
|
int iLength;
|
||||||
} GSWURLComponent;
|
} GSWURLComponent;
|
||||||
|
|
||||||
typedef struct _GSWURLComponents
|
typedef struct _GSWURLComponents
|
||||||
|
@ -69,10 +69,20 @@ typedef enum
|
||||||
GSWURLError_InvalidSuffix
|
GSWURLError_InvalidSuffix
|
||||||
} GSWURLError;
|
} GSWURLError;
|
||||||
|
|
||||||
GSWURLError GSWParseURL(GSWURLComponents* p_pURLComponents,CONST char* p_pszURL,void* p_pLogServerData);
|
GSWURLError GSWParseURL(GSWURLComponents *p_pURLComponents,
|
||||||
void GSWComposeURL(char* p_pszURL,GSWURLComponents* p_pURLComponents,void* p_pLogServerData);
|
CONST char *p_pszURL,
|
||||||
int GSWComposeURLLen(GSWURLComponents* p_pURLComponents,void* p_pLogServerData);
|
void *p_pLogServerData);
|
||||||
CONST char* GSWURLErrorMessage(GSWURLError p_eError,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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif //_cplusplus
|
#endif //_cplusplus
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWUtil.c - GSWeb: Util
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -53,29 +53,32 @@
|
||||||
|
|
||||||
|
|
||||||
// Hosts Cache
|
// 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,
|
void
|
||||||
int line,
|
VGSWLogSizedIntern(char *file,
|
||||||
char* fn,
|
int line,
|
||||||
int p_iLevel,
|
char *fn,
|
||||||
|
int p_iLevel,
|
||||||
#if defined(Apache)
|
#if defined(Apache)
|
||||||
server_rec* p_pLogServerData,
|
server_rec *p_pLogServerData,
|
||||||
#else
|
#else
|
||||||
void* p_pLogServerData,
|
void *p_pLogServerData,
|
||||||
#endif
|
#endif
|
||||||
int p_iBufferSize,
|
int p_iBufferSize,
|
||||||
CONST char* p_pszFormat,
|
CONST char *p_pszFormat,
|
||||||
va_list ap)
|
va_list ap)
|
||||||
{
|
{
|
||||||
FILE* pLog = NULL;
|
FILE *pLog = NULL;
|
||||||
char szBuffer[p_iBufferSize+512];
|
char szBuffer[p_iBufferSize+512];
|
||||||
|
|
||||||
szBuffer[0] = 0;
|
szBuffer[0] = 0;
|
||||||
|
@ -89,228 +92,244 @@ void VGSWLogSizedIntern(char* file,
|
||||||
#if defined(Apache)
|
#if defined(Apache)
|
||||||
#if defined(Apache2)
|
#if defined(Apache2)
|
||||||
ap_log_error(APLOG_MARK,p_iLevel,0,
|
ap_log_error(APLOG_MARK,p_iLevel,0,
|
||||||
(server_rec*)p_pLogServerData,
|
(server_rec *)p_pLogServerData,
|
||||||
"%s",szBuffer);
|
"%s",szBuffer);
|
||||||
#else
|
#else
|
||||||
ap_log_error(APLOG_MARK,p_iLevel,
|
ap_log_error(APLOG_MARK,p_iLevel,
|
||||||
(server_rec*)p_pLogServerData,
|
(server_rec *)p_pLogServerData,
|
||||||
"%s",szBuffer);
|
"%s",szBuffer);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWLog(int p_iLevel,
|
void
|
||||||
|
GSWLog(int p_iLevel,
|
||||||
#if defined(Apache)
|
#if defined(Apache)
|
||||||
server_rec* p_pLogServerData,
|
server_rec *p_pLogServerData,
|
||||||
#else
|
#else
|
||||||
void* p_pLogServerData,
|
void *p_pLogServerData,
|
||||||
#endif
|
#endif
|
||||||
CONST char *p_pszFormat, ...)
|
CONST char *p_pszFormat, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap,p_pszFormat);
|
va_start(ap,p_pszFormat);
|
||||||
VGSWLogSizedIntern(NULL,
|
VGSWLogSizedIntern(NULL,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
p_iLevel,
|
p_iLevel,
|
||||||
p_pLogServerData,
|
p_pLogServerData,
|
||||||
4096,
|
4096,
|
||||||
p_pszFormat,
|
p_pszFormat,
|
||||||
ap);
|
ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWLogSized(int p_iLevel,
|
void
|
||||||
|
GSWLogSized(int p_iLevel,
|
||||||
#if defined(Apache)
|
#if defined(Apache)
|
||||||
server_rec* p_pLogServerData,
|
server_rec *p_pLogServerData,
|
||||||
#else
|
#else
|
||||||
void* p_pLogServerData,
|
void *p_pLogServerData,
|
||||||
#endif
|
#endif
|
||||||
int p_iBufferSize,
|
int p_iBufferSize,
|
||||||
CONST char *p_pszFormat, ...)
|
CONST char *p_pszFormat, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap,p_pszFormat);
|
va_start(ap,p_pszFormat);
|
||||||
VGSWLogSizedIntern(NULL,
|
VGSWLogSizedIntern(NULL,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
p_iLevel,
|
p_iLevel,
|
||||||
p_pLogServerData,
|
p_pLogServerData,
|
||||||
p_iBufferSize,
|
p_iBufferSize,
|
||||||
p_pszFormat,
|
p_pszFormat,
|
||||||
ap);
|
ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWLogIntern(char* file,
|
void
|
||||||
int line,
|
GSWLogIntern(char *file,
|
||||||
char* fn,
|
int line,
|
||||||
int p_iLevel,
|
char *fn,
|
||||||
|
int p_iLevel,
|
||||||
#if defined(Apache)
|
#if defined(Apache)
|
||||||
server_rec* p_pLogServerData,
|
server_rec *p_pLogServerData,
|
||||||
#else
|
#else
|
||||||
void* p_pLogServerData,
|
void *p_pLogServerData,
|
||||||
#endif
|
#endif
|
||||||
CONST char* p_pszFormat,...)
|
CONST char *p_pszFormat,...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap,p_pszFormat);
|
va_start(ap,p_pszFormat);
|
||||||
VGSWLogSizedIntern(file,
|
VGSWLogSizedIntern(file,
|
||||||
line,
|
line,
|
||||||
fn,
|
fn,
|
||||||
p_iLevel,
|
p_iLevel,
|
||||||
p_pLogServerData,
|
p_pLogServerData,
|
||||||
4096,
|
4096,
|
||||||
p_pszFormat,
|
p_pszFormat,
|
||||||
ap);
|
ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWLogSizedIntern(char* file,
|
void
|
||||||
int line,
|
GSWLogSizedIntern(char *file,
|
||||||
char* fn,
|
int line,
|
||||||
int p_iLevel,
|
char *fn,
|
||||||
|
int p_iLevel,
|
||||||
#if defined(Apache)
|
#if defined(Apache)
|
||||||
server_rec* p_pLogServerData,
|
server_rec *p_pLogServerData,
|
||||||
#else
|
#else
|
||||||
void* p_pLogServerData,
|
void *p_pLogServerData,
|
||||||
#endif
|
#endif
|
||||||
int p_iBufferSize,
|
int p_iBufferSize,
|
||||||
CONST char* p_pszFormat,...)
|
CONST char *p_pszFormat,...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap,p_pszFormat);
|
va_start(ap,p_pszFormat);
|
||||||
VGSWLogSizedIntern(file,
|
VGSWLogSizedIntern(file,
|
||||||
line,
|
line,
|
||||||
fn,
|
fn,
|
||||||
p_iLevel,
|
p_iLevel,
|
||||||
p_pLogServerData,
|
p_pLogServerData,
|
||||||
p_iBufferSize,
|
p_iBufferSize,
|
||||||
p_pszFormat,
|
p_pszFormat,
|
||||||
ap);
|
ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// return new len
|
// return new len
|
||||||
int DeleteTrailingCRNL(char* p_pszString)
|
int
|
||||||
|
DeleteTrailingCRNL(char *p_pszString)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
if (p_pszString)
|
if (p_pszString)
|
||||||
{
|
{
|
||||||
i=strlen(p_pszString)-1;
|
i=strlen(p_pszString)-1;
|
||||||
while (i>=0 && p_pszString[i] && (p_pszString[i]=='\r' || p_pszString[i]=='\n'))
|
while (i>=0 && p_pszString[i] &&
|
||||||
p_pszString[i--]=0;
|
(p_pszString[i]=='\r' || p_pszString[i]=='\n'))
|
||||||
i++;
|
p_pszString[i--]=0;
|
||||||
};
|
i++;
|
||||||
|
};
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
int DeleteTrailingSlash(char* p_pszString)
|
int
|
||||||
|
DeleteTrailingSlash(char *p_pszString)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
if (p_pszString)
|
if (p_pszString)
|
||||||
{
|
{
|
||||||
i=strlen(p_pszString)-1;
|
i=strlen(p_pszString)-1;
|
||||||
while (i>=0 && p_pszString[i] && p_pszString[i]=='/')
|
while (i>=0 && p_pszString[i] && p_pszString[i]=='/')
|
||||||
p_pszString[i--]=0;
|
p_pszString[i--]=0;
|
||||||
i++;
|
i++;
|
||||||
};
|
};
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
int DeleteTrailingSpaces(char* p_pszString)
|
int
|
||||||
|
DeleteTrailingSpaces(char *p_pszString)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
if (p_pszString)
|
if (p_pszString)
|
||||||
{
|
{
|
||||||
i=strlen(p_pszString)-1;
|
i=strlen(p_pszString)-1;
|
||||||
while (i>=0 && p_pszString[i] && p_pszString[i]==' ')
|
while (i>=0 && p_pszString[i] && p_pszString[i]==' ')
|
||||||
p_pszString[i--]=0;
|
p_pszString[i--]=0;
|
||||||
i++;
|
i++;
|
||||||
};
|
};
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
int SafeStrlen(CONST char* p_pszString)
|
int
|
||||||
|
SafeStrlen(CONST char *p_pszString)
|
||||||
{
|
{
|
||||||
return (p_pszString ? strlen(p_pszString) : 0);
|
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);
|
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)
|
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;
|
char ch1stUpper=toupper(p_pszSearchedString[0]);
|
||||||
int iStringLen=strlen(p_pszString);
|
for(i=0;i<iStringLen-iSearchedStringLen+1;i++)
|
||||||
int iSearchedStringLen=strlen(p_pszSearchedString);
|
{
|
||||||
if (iStringLen>0 && iSearchedStringLen>0)
|
if (toupper(p_pszString[i])==ch1stUpper)
|
||||||
{
|
{
|
||||||
char ch1stUpper=toupper(p_pszSearchedString[0]);
|
BOOL fSame=TRUE;
|
||||||
for(i=0;i<iStringLen-iSearchedStringLen+1;i++)
|
int j=0;
|
||||||
{
|
for(j=1;j<iSearchedStringLen && fSame;j++)
|
||||||
if (toupper(p_pszString[i])==ch1stUpper)
|
fSame=toupper(p_pszString[i+j]) ==
|
||||||
{
|
toupper(p_pszSearchedString[j]);
|
||||||
BOOL fSame=TRUE;
|
if (fSame)
|
||||||
int j=0;
|
return p_pszString+i;
|
||||||
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;
|
return NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(HAS_REENTRANT_GETHOSTENT) && !defined(_REENTRANT)
|
#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
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWUtil_ClearHostCache()
|
void
|
||||||
|
GSWUtil_ClearHostCache()
|
||||||
{
|
{
|
||||||
if (g_pHostCache)
|
if (g_pHostCache)
|
||||||
{
|
{
|
||||||
GSWDict_Free(g_pHostCache);
|
GSWDict_Free(g_pHostCache);
|
||||||
g_pHostCache=NULL;
|
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;
|
PSTHostent pHost=NULL;
|
||||||
if (!p_pszHost)
|
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)
|
if (!pHost)
|
||||||
|
{
|
||||||
|
pHost = GSWUtil_HostLookup(p_pszHost,p_pLogServerData);
|
||||||
|
if (pHost)
|
||||||
{
|
{
|
||||||
pHost = GSWUtil_HostLookup(p_pszHost,p_pLogServerData);
|
if (!g_pHostCache)
|
||||||
if (pHost)
|
g_pHostCache = GSWDict_New(32);
|
||||||
{
|
GSWDict_Add(g_pHostCache,p_pszHost,pHost,TRUE);
|
||||||
if (!g_pHostCache)
|
GSWLog(GSW_INFO,p_pLogServerData,"Caching hostent for %s",p_pszHost);
|
||||||
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;
|
return pHost;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -325,99 +344,107 @@ PSTHostent GSWUtil_FindHost(CONST char* p_pszHost,void* p_pLogServerData)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
CONST char* hstrerror(int herr)
|
CONST char *
|
||||||
|
hstrerror(int herr)
|
||||||
{
|
{
|
||||||
if (herr == -1) // see errno
|
if (herr == -1) // see errno
|
||||||
return strerror(errno);
|
return strerror(errno);
|
||||||
else if (herr == HOST_NOT_FOUND)
|
else if (herr == HOST_NOT_FOUND)
|
||||||
return "Host not found";
|
return "Host not found";
|
||||||
else if (herr == TRY_AGAIN)
|
else if (herr == TRY_AGAIN)
|
||||||
return "Try again"; // ?
|
return "Try again"; // ?
|
||||||
else if (herr == NO_RECOVERY)
|
else if (herr == NO_RECOVERY)
|
||||||
return "Non recoverable error";
|
return "Non recoverable error";
|
||||||
else if (herr == NO_DATA)
|
else if (herr == NO_DATA)
|
||||||
return "No data";
|
return "No data";
|
||||||
else if (herr == NO_ADDRESS)
|
else if (herr == NO_ADDRESS)
|
||||||
return "No address"; // same as no data
|
return "No address"; // same as no data
|
||||||
else if (herr == NETDB_SUCCESS)
|
else if (herr == NETDB_SUCCESS)
|
||||||
return "No error"; // Gag !
|
return "No error"; // Gag !
|
||||||
else
|
else
|
||||||
return "unknown error";
|
return "unknown error";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
static PSTHostent GSWUtil_CopyHostent(PSTHostent p_pHost)
|
static PSTHostent
|
||||||
|
GSWUtil_CopyHostent(PSTHostent p_pHost)
|
||||||
{
|
{
|
||||||
PSTHostent pNewHost=NULL;
|
PSTHostent pNewHost=NULL;
|
||||||
int iSize=(ROUND_UP(sizeof(struct hostent), sizeof(void *)))+strlen(p_pHost->h_name)+1;
|
int iSize=(ROUND_UP(sizeof(struct hostent),
|
||||||
int iAliasNb=0;
|
sizeof(void *)))+strlen(p_pHost->h_name)+1;
|
||||||
int iAddressesNb = 0;
|
int iAliasNb=0;
|
||||||
char** ppszAliasOrAddress=NULL;
|
int iAddressesNb = 0;
|
||||||
char** ppszNewHostAliasOrAddress=NULL;
|
char **ppszAliasOrAddress=NULL;
|
||||||
void* pTmp=NULL;
|
char **ppszNewHostAliasOrAddress=NULL;
|
||||||
|
void *pTmp=NULL;
|
||||||
|
|
||||||
// Aliases
|
// Aliases
|
||||||
for (ppszAliasOrAddress=p_pHost->h_aliases;
|
for (ppszAliasOrAddress=p_pHost->h_aliases;
|
||||||
ppszAliasOrAddress && *ppszAliasOrAddress;
|
ppszAliasOrAddress && *ppszAliasOrAddress;
|
||||||
ppszAliasOrAddress++)
|
ppszAliasOrAddress++)
|
||||||
{
|
{
|
||||||
iSize+=strlen(*ppszAliasOrAddress)+1;
|
iSize+=strlen(*ppszAliasOrAddress)+1;
|
||||||
iAliasNb++;
|
iAliasNb++;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Aliases Pointers Null Terminated List
|
// Aliases Pointers Null Terminated List
|
||||||
iSize=ROUND_UP(iSize,sizeof(char *));
|
iSize=ROUND_UP(iSize,sizeof(char *));
|
||||||
iSize+=(iAliasNb+1)*sizeof(char*);
|
iSize+=(iAliasNb+1)*sizeof(char *);
|
||||||
|
|
||||||
for (ppszAliasOrAddress=p_pHost->h_addr_list;
|
for (ppszAliasOrAddress=p_pHost->h_addr_list;
|
||||||
ppszAliasOrAddress && *ppszAliasOrAddress;
|
ppszAliasOrAddress && *ppszAliasOrAddress;
|
||||||
ppszAliasOrAddress++)
|
ppszAliasOrAddress++)
|
||||||
iAddressesNb++;
|
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;
|
pTmp=pNewHost;
|
||||||
pNewHost->h_addrtype = p_pHost->h_addrtype;
|
pNewHost->h_addrtype = p_pHost->h_addrtype;
|
||||||
pNewHost->h_length = p_pHost->h_length;
|
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;
|
pNewHost->h_aliases = (char **)pTmp;
|
||||||
pTmp+=(iAliasNb+1)*sizeof(char*);
|
pTmp+=(iAliasNb+1)*sizeof(char *);
|
||||||
pNewHost->h_addr_list = (char**)pTmp;
|
pNewHost->h_addr_list = (char **)pTmp;
|
||||||
pTmp+=(iAddressesNb+1)*sizeof(char*);
|
pTmp+=(iAddressesNb+1)*sizeof(char *);
|
||||||
|
|
||||||
pNewHost->h_name = pTmp;
|
pNewHost->h_name = pTmp;
|
||||||
strcpy(pNewHost->h_name,p_pHost->h_name);
|
strcpy(pNewHost->h_name,p_pHost->h_name);
|
||||||
pTmp+=strlen(pNewHost->h_name)+1;
|
pTmp+=strlen(pNewHost->h_name)+1;
|
||||||
|
|
||||||
// Copy Aliases
|
// Copy Aliases
|
||||||
for (ppszAliasOrAddress=p_pHost->h_aliases,ppszNewHostAliasOrAddress=pNewHost->h_aliases;
|
for (ppszAliasOrAddress=p_pHost->h_aliases,
|
||||||
ppszAliasOrAddress && *ppszAliasOrAddress;
|
ppszNewHostAliasOrAddress=pNewHost->h_aliases;
|
||||||
ppszAliasOrAddress++,ppszNewHostAliasOrAddress++)
|
ppszAliasOrAddress && *ppszAliasOrAddress;
|
||||||
{
|
ppszAliasOrAddress++,ppszNewHostAliasOrAddress++)
|
||||||
*ppszNewHostAliasOrAddress = (char*)pTmp;
|
{
|
||||||
strcpy((char*)pTmp,*ppszAliasOrAddress);
|
*ppszNewHostAliasOrAddress = (char *)pTmp;
|
||||||
pTmp+=strlen(*ppszAliasOrAddress) + 1;
|
strcpy((char *)pTmp,*ppszAliasOrAddress);
|
||||||
};
|
pTmp+=strlen(*ppszAliasOrAddress) + 1;
|
||||||
|
};
|
||||||
*ppszNewHostAliasOrAddress=NULL;
|
*ppszNewHostAliasOrAddress=NULL;
|
||||||
|
|
||||||
pTmp=(void *)ROUND_UP(pTmp,pNewHost->h_length);
|
pTmp=(void *)ROUND_UP(pTmp,pNewHost->h_length);
|
||||||
for (ppszAliasOrAddress=p_pHost->h_addr_list,ppszNewHostAliasOrAddress=pNewHost->h_addr_list;
|
for (ppszAliasOrAddress=p_pHost->h_addr_list,
|
||||||
ppszAliasOrAddress && *ppszAliasOrAddress;
|
ppszNewHostAliasOrAddress=pNewHost->h_addr_list;
|
||||||
ppszAliasOrAddress++,ppszNewHostAliasOrAddress++)
|
ppszAliasOrAddress && *ppszAliasOrAddress;
|
||||||
{
|
ppszAliasOrAddress++,ppszNewHostAliasOrAddress++)
|
||||||
*ppszNewHostAliasOrAddress=(char*)pTmp;
|
{
|
||||||
memcpy(*ppszNewHostAliasOrAddress,*ppszAliasOrAddress,pNewHost->h_length);
|
*ppszNewHostAliasOrAddress=(char *)pTmp;
|
||||||
pTmp+=pNewHost->h_length;
|
memcpy(*ppszNewHostAliasOrAddress,*ppszAliasOrAddress,
|
||||||
};
|
pNewHost->h_length);
|
||||||
|
pTmp+=pNewHost->h_length;
|
||||||
|
};
|
||||||
*ppszNewHostAliasOrAddress=NULL;
|
*ppszNewHostAliasOrAddress=NULL;
|
||||||
return pNewHost;
|
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;
|
PSTHostent pHost=NULL;
|
||||||
struct in_addr hostaddr;
|
struct in_addr hostaddr;
|
||||||
|
@ -433,76 +460,79 @@ PSTHostent GSWUtil_HostLookup(CONST char *p_pszHost,void* p_pLogServerData)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!p_pszHost)
|
if (!p_pszHost)
|
||||||
p_pszHost="localhost";
|
p_pszHost="localhost";
|
||||||
|
|
||||||
if (isdigit(*p_pszHost))
|
if (isdigit(*p_pszHost))
|
||||||
hostaddr.s_addr=inet_addr(p_pszHost);
|
hostaddr.s_addr=inet_addr(p_pszHost);
|
||||||
|
|
||||||
#if defined(HAS_REENTRANT_GETHOSTENT)
|
#if defined(HAS_REENTRANT_GETHOSTENT)
|
||||||
if (isdigit(*p_pszHost))
|
if (isdigit(*p_pszHost))
|
||||||
{
|
{
|
||||||
#if defined(SOLARIS)
|
#if defined(SOLARIS)
|
||||||
pHost = gethostbyaddr_r((char *)&hostaddr.s_addr,
|
pHost = gethostbyaddr_r((char *)&hostaddr.s_addr,
|
||||||
sizeof(hostaddr.s_addr),
|
sizeof(hostaddr.s_addr),
|
||||||
AF_INET,
|
AF_INET,
|
||||||
pHost,
|
pHost,
|
||||||
szBuffer,
|
szBuffer,
|
||||||
BUFLEN, &error);
|
BUFLEN, &error);
|
||||||
#else // !SOLARIS
|
#else // !SOLARIS
|
||||||
if (gethostbyaddr_r((char *)&hostaddr.s_addr,
|
if (gethostbyaddr_r((char *)&hostaddr.s_addr,
|
||||||
sizeof(hostaddr.s_addr),
|
sizeof(hostaddr.s_addr),
|
||||||
AF_INET,
|
AF_INET,
|
||||||
&stTmpHost,
|
&stTmpHost,
|
||||||
szBuffer) == 0)
|
szBuffer) == 0)
|
||||||
{
|
{
|
||||||
pHost = &stTmpHost;
|
pHost = &stTmpHost;
|
||||||
error = 0;
|
error = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pHost=NULL;
|
pHost=NULL;
|
||||||
error = h_errno;
|
error = h_errno;
|
||||||
};
|
};
|
||||||
#endif // SOLARIS
|
#endif // SOLARIS
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined(SOLARIS)
|
#if defined(SOLARIS)
|
||||||
pHost = gethostbyname_r(p_pszHost,
|
pHost = gethostbyname_r(p_pszHost,
|
||||||
&stTmpHost,
|
&stTmpHost,
|
||||||
szBuffer,
|
szBuffer,
|
||||||
BUFLEN,
|
BUFLEN,
|
||||||
&error);
|
&error);
|
||||||
#else // !SOLARIS
|
#else // !SOLARIS
|
||||||
pHost = (gethostbyname_r(p_pszHost,&stTmpHost,szBuffer)==0) ? &stTmpHost : NULL;
|
pHost = (gethostbyname_r(p_pszHost,&stTmpHost,szBuffer)==0) ?
|
||||||
error = (pHost) ? 0 : h_errno;
|
&stTmpHost : NULL;
|
||||||
|
error = (pHost) ? 0 : h_errno;
|
||||||
#endif // SOLARIS
|
#endif // SOLARIS
|
||||||
};
|
};
|
||||||
#else // !HAS_REENTRANT_GETHOSTENT
|
#else // !HAS_REENTRANT_GETHOSTENT
|
||||||
if (isdigit(*p_pszHost))
|
if (isdigit(*p_pszHost))
|
||||||
{
|
{
|
||||||
pHost = gethostbyaddr((char *)&hostaddr.s_addr, sizeof(hostaddr.s_addr), AF_INET);
|
pHost = gethostbyaddr((char *)&hostaddr.s_addr, sizeof(hostaddr.s_addr),
|
||||||
error = (pHost) ? 0 : h_errno;
|
AF_INET);
|
||||||
}
|
error = (pHost) ? 0 : h_errno;
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
pHost = gethostbyname(p_pszHost);
|
{
|
||||||
error = (pHost) ? 0 : h_errno;
|
pHost = gethostbyname(p_pszHost);
|
||||||
}
|
error = (pHost) ? 0 : h_errno;
|
||||||
|
}
|
||||||
#endif // HAS_REENTRANT_GETHOSTENT
|
#endif // HAS_REENTRANT_GETHOSTENT
|
||||||
|
|
||||||
if (!pHost)
|
if (!pHost)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_ERROR,p_pLogServerData,"gethostbyname(%s) returns no host: %s",
|
GSWLog(GSW_ERROR,p_pLogServerData,
|
||||||
p_pszHost,
|
"gethostbyname(%s) returns no host: %s",
|
||||||
hstrerror(error));
|
p_pszHost,
|
||||||
}
|
hstrerror(error));
|
||||||
else if (pHost->h_addrtype != AF_INET)
|
}
|
||||||
{
|
else if (pHost->h_addrtype != AF_INET)
|
||||||
GSWLog(GSW_ERROR,p_pLogServerData,"Wrong address type in hostptr for host %s",p_pszHost);
|
{
|
||||||
};
|
GSWLog(GSW_ERROR,p_pLogServerData,"Wrong address type in hostptr for host %s",p_pszHost);
|
||||||
if (pHost)
|
};
|
||||||
pHost=GSWUtil_CopyHostent(pHost);
|
if (pHost)
|
||||||
return pHost;
|
pHost=GSWUtil_CopyHostent(pHost);
|
||||||
|
return pHost;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWUtil.h - GSWeb: Adaptors: Util
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -62,65 +62,65 @@ extern "C" {
|
||||||
|
|
||||||
void GSWLog(int p_iLevel,
|
void GSWLog(int p_iLevel,
|
||||||
#if defined(Apache)
|
#if defined(Apache)
|
||||||
server_rec* p_pLogServerData,
|
server_rec *p_pLogServerData,
|
||||||
#else
|
#else
|
||||||
void* p_pLogServerData,
|
void *p_pLogServerData,
|
||||||
#endif
|
#endif
|
||||||
CONST char *p_pszFormat, ...);
|
CONST char *p_pszFormat, ...);
|
||||||
|
|
||||||
void GSWLogSized(int p_iLevel,
|
void GSWLogSized(int p_iLevel,
|
||||||
#if defined(Apache)
|
#if defined(Apache)
|
||||||
server_rec* p_pLogServerData,
|
server_rec *p_pLogServerData,
|
||||||
#else
|
#else
|
||||||
void* p_pLogServerData,
|
void *p_pLogServerData,
|
||||||
#endif
|
#endif
|
||||||
int p_iBufferSize,
|
int p_iBufferSize,
|
||||||
CONST char *p_pszFormat, ...);
|
CONST char *p_pszFormat, ...);
|
||||||
|
|
||||||
void GSWLogIntern(char* file,
|
void GSWLogIntern(char *file,
|
||||||
int line,
|
int line,
|
||||||
char* fn,
|
char *fn,
|
||||||
int p_iLevel,
|
int p_iLevel,
|
||||||
#if defined(Apache)
|
#if defined(Apache)
|
||||||
server_rec* p_pLogServerData,
|
server_rec *p_pLogServerData,
|
||||||
#else
|
#else
|
||||||
void* p_pLogServerData,
|
void *p_pLogServerData,
|
||||||
#endif
|
#endif
|
||||||
CONST char *p_pszFormat, ...);
|
CONST char *p_pszFormat, ...);
|
||||||
|
|
||||||
|
|
||||||
void GSWLogSizedIntern(char* file,
|
void GSWLogSizedIntern(char *file,
|
||||||
int line,
|
int line,
|
||||||
char* fn,
|
char *fn,
|
||||||
int p_iLevel,
|
int p_iLevel,
|
||||||
#if defined(Apache)
|
#if defined(Apache)
|
||||||
server_rec* p_pLogServerData,
|
server_rec *p_pLogServerData,
|
||||||
#else
|
#else
|
||||||
void* p_pLogServerData,
|
void *p_pLogServerData,
|
||||||
#endif
|
#endif
|
||||||
int p_iBufferSize,
|
int p_iBufferSize,
|
||||||
CONST char *p_pszFormat, ...);
|
CONST char *p_pszFormat, ...);
|
||||||
|
|
||||||
// return new len
|
// return new len
|
||||||
int DeleteTrailingCRNL(char* p_pszString);
|
int DeleteTrailingCRNL(char *p_pszString);
|
||||||
int DeleteTrailingSlash(char* p_pszString);
|
int DeleteTrailingSlash(char *p_pszString);
|
||||||
int DeleteTrailingSpaces(char* p_pszString);
|
int DeleteTrailingSpaces(char *p_pszString);
|
||||||
|
|
||||||
int SafeStrlen(CONST char* p_pszString);
|
int SafeStrlen(CONST char *p_pszString);
|
||||||
char* SafeStrdup(CONST char* p_pszString);
|
char *SafeStrdup(CONST char *p_pszString);
|
||||||
char* strcasestr(CONST char* p_pszString,CONST char* p_pszSearchedString);
|
char *strcasestr(CONST char *p_pszString, CONST char *p_pszSearchedString);
|
||||||
|
|
||||||
|
|
||||||
//#include <netdb.h>
|
//#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();
|
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"
|
#include "GSWDict.h"
|
||||||
|
|
||||||
void GSWLog_Init(GSWDict* p_pDict,int p_iLevel);
|
void GSWLog_Init(GSWDict *p_pDict, int p_iLevel);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
# Set all of the common environment variables.
|
# 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>
|
# Author: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* config.h - GSWeb: Adaptors: Config
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* config.h - GSWeb: Adaptors: Config
|
/* 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>
|
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||||
Date: Jully 1999
|
Date: July 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Web Library.
|
This file is part of the GNUstep Web Library.
|
||||||
|
|
||||||
|
@ -37,10 +37,10 @@ extern "C" {
|
||||||
#define CONST const
|
#define CONST const
|
||||||
#define DEBUG
|
#define DEBUG
|
||||||
|
|
||||||
#define GSWEB_SERVER_ADAPTOR_VERSION_MAJOR 1
|
#define GSWEB_SERVER_ADAPTOR_VERSION_MAJOR 1
|
||||||
#define GSWEB_SERVER_ADAPTOR_VERSION_MAJOR_STRING "1"
|
#define GSWEB_SERVER_ADAPTOR_VERSION_MAJOR_STRING "1"
|
||||||
#define GSWEB_SERVER_ADAPTOR_VERSION_MINOR 1
|
#define GSWEB_SERVER_ADAPTOR_VERSION_MINOR 1
|
||||||
#define GSWEB_SERVER_ADAPTOR_VERSION_MINOR_STRING "1"
|
#define GSWEB_SERVER_ADAPTOR_VERSION_MINOR_STRING "1"
|
||||||
|
|
||||||
#define GSWEB_VERSION_MAJOR 1
|
#define GSWEB_VERSION_MAJOR 1
|
||||||
#define GSWEB_VERSION_MINOR 0
|
#define GSWEB_VERSION_MINOR 0
|
||||||
|
@ -58,13 +58,13 @@ extern "C" {
|
||||||
#define GSWAPP_EXTENSION_GSW ".gswa"
|
#define GSWAPP_EXTENSION_GSW ".gswa"
|
||||||
|
|
||||||
// Time Outs ...
|
// Time Outs ...
|
||||||
#define APP_CONNECT_TIMEOUT 300
|
#define APP_CONNECT_TIMEOUT 300
|
||||||
#define RESPONSE__LINE_MAX_SIZE 8192
|
#define RESPONSE__LINE_MAX_SIZE 8192
|
||||||
#define APP_CONNECT_RETRY_DELAY 3
|
#define APP_CONNECT_RETRY_DELAY 3
|
||||||
#define APP_CONNECT_RETRIES_NB 10
|
#define APP_CONNECT_RETRIES_NB 10
|
||||||
|
|
||||||
|
|
||||||
#define HITS_PER_SECOND 80
|
#define HITS_PER_SECOND 80
|
||||||
#define CONFIG_FILE_STAT_INTERVAL 10
|
#define CONFIG_FILE_STAT_INTERVAL 10
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,19 +77,19 @@ extern "C" {
|
||||||
// Config File Keywords
|
// Config File Keywords
|
||||||
|
|
||||||
// All
|
// All
|
||||||
//#define GSWEB_CONF__DOC_ROOT "GSWeb_DocumentRoot"
|
//#define GSWEB_CONF__DOC_ROOT "GSWeb_DocumentRoot"
|
||||||
#define GSWEB_CONF__CONFIG_FILE_PATH "GSWeb_ConfigFilePath"
|
#define GSWEB_CONF__CONFIG_FILE_PATH "GSWeb_ConfigFilePath"
|
||||||
|
|
||||||
// Aapche
|
// Aapche
|
||||||
#if defined(Apache)
|
#if defined(Apache)
|
||||||
#define GSWEB_CONF__ALIAS "GSWeb_Alias"
|
#define GSWEB_CONF__ALIAS "GSWeb_Alias"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Netscape
|
// Netscape
|
||||||
#if defined(Netscape)
|
#if defined(Netscape)
|
||||||
#define GSWEB_CONF__PATH_TRANS "from" // NameTrans
|
#define GSWEB_CONF__PATH_TRANS "from" // NameTrans
|
||||||
#define GSWEB_CONF__APP_ROOT "dir" // NameTrans
|
#define GSWEB_CONF__APP_ROOT "dir" // NameTrans
|
||||||
#define GSWEB_CONF__NAME "name" // NameTrans, Object
|
#define GSWEB_CONF__NAME "name" // NameTrans, Object
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue