mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-06-02 01:50:59 +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
|
||||||
|
@ -100,30 +100,45 @@ 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,
|
||||||
|
@ -136,10 +151,12 @@ static void GSWeb_Init(server_rec* p_pServerRec, pool *p)
|
||||||
GSWDict_AddStringDup(pDict,
|
GSWDict_AddStringDup(pDict,
|
||||||
g_szGSWeb_Conf_ConfigFilePath,
|
g_szGSWeb_Conf_ConfigFilePath,
|
||||||
pConfig->pszConfigPath);
|
pConfig->pszConfigPath);
|
||||||
/* if (pConfig && pConfig->pszRoot)
|
/*
|
||||||
|
if (pConfig && pConfig->pszRoot)
|
||||||
GSWDict_AddStringDup(pDict,
|
GSWDict_AddStringDup(pDict,
|
||||||
g_szGSWeb_Conf_DocRoot,
|
g_szGSWeb_Conf_DocRoot,
|
||||||
pConfig->pszRoot);*/
|
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);
|
||||||
|
@ -151,12 +168,16 @@ static void GSWeb_Init(server_rec* p_pServerRec, pool *p)
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// 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,11 +240,13 @@ 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);
|
||||||
|
@ -226,7 +260,8 @@ int GSWeb_Translation(request_rec* p_pRequestRec)
|
||||||
p_pRequestRec->server);
|
p_pRequestRec->server);
|
||||||
if (eError!=GSWURLError_OK)
|
if (eError!=GSWURLError_OK)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_ERROR,p_pRequestRec->server,"GSWeb_Translation Declined (Error %d)",(int)eError);
|
GSWLog(GSW_ERROR,p_pRequestRec->server,
|
||||||
|
"GSWeb_Translation Declined (Error %d)",(int)eError);
|
||||||
iRetValue=DECLINED;
|
iRetValue=DECLINED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -238,7 +273,8 @@ int GSWeb_Translation(request_rec* p_pRequestRec)
|
||||||
p_pRequestRec->pool,
|
p_pRequestRec->pool,
|
||||||
g_szGSWeb_Handler,
|
g_szGSWeb_Handler,
|
||||||
pConfig->pszGSWeb);
|
pConfig->pszGSWeb);
|
||||||
p_pRequestRec->handler=(char*)ap_pstrdup(p_pRequestRec->pool,g_szGSWeb_Handler);
|
p_pRequestRec->handler=(char *)ap_pstrdup(p_pRequestRec->pool,
|
||||||
|
g_szGSWeb_Handler);
|
||||||
iRetValue=OK;
|
iRetValue=OK;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -254,15 +290,17 @@ int GSWeb_Translation(request_rec* p_pRequestRec)
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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,23 +392,30 @@ 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
|
||||||
|
@ -382,7 +432,7 @@ static void sendResponse(request_rec* p_pRequestRec,GSWHTTPResponse* p_pHTTPResp
|
||||||
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...
|
||||||
|
|
||||||
|
@ -393,7 +443,8 @@ static void sendResponse(request_rec* p_pRequestRec,GSWHTTPResponse* p_pHTTPResp
|
||||||
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,
|
||||||
|
p_pRequestRec);
|
||||||
ap_kill_timeout(p_pRequestRec);
|
ap_kill_timeout(p_pRequestRec);
|
||||||
};
|
};
|
||||||
GSWLog(GSW_DEBUG,pServerRec,"Stop sendResponse");
|
GSWLog(GSW_DEBUG,pServerRec,"Stop sendResponse");
|
||||||
|
@ -401,10 +452,14 @@ static void sendResponse(request_rec* p_pRequestRec,GSWHTTPResponse* p_pHTTPResp
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// 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");
|
||||||
|
@ -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,17 +592,20 @@ 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,
|
||||||
|
@ -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,14 +715,16 @@ 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_CONF__ALIAS, /* directive name */
|
||||||
GSWeb_SetScriptAlias, /* config action routine */
|
GSWeb_SetScriptAlias, /* config action routine */
|
||||||
NULL, /* argument to include in call */
|
NULL, /* argument to include in call */
|
||||||
RSRC_CONF, /* where available */
|
RSRC_CONF, /* where available */
|
||||||
"ScriptAlias for GSWeb" /* directive description */
|
"ScriptAlias for GSWeb" /* directive description */
|
||||||
),
|
);
|
||||||
AP_INIT_TAKE1(
|
AP_INIT_TAKE1
|
||||||
|
(
|
||||||
GSWEB_CONF__CONFIG_FILE_PATH, /* directive name */
|
GSWEB_CONF__CONFIG_FILE_PATH, /* directive name */
|
||||||
GSWeb_SetConfig, /* config action routine */
|
GSWeb_SetConfig, /* config action routine */
|
||||||
NULL, /* argument to include in call */
|
NULL, /* argument to include in call */
|
||||||
|
|
|
@ -1,35 +1,37 @@
|
||||||
<!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="/GSW/GSWExtensions/WebServerResources"; //URL of GSWExtensions Framework WebServerResources directory
|
GSWExtensionsFrameworkWebServerResources =
|
||||||
|
"/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;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -38,59 +40,63 @@
|
||||||
|
|
||||||
//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
|
||||||
|
GSWExtensionsFrameworkWebServerResources =
|
||||||
|
"/GSW/GSWExtensions/WebServerResources";
|
||||||
|
|
||||||
|
// YES to say that this application can be listed when the
|
||||||
|
// adaptor don't find an application
|
||||||
canDump = YES;
|
canDump = YES;
|
||||||
|
|
||||||
//Unused for the moment
|
//Unused for the moment
|
||||||
applicationHeaders = {
|
applicationHeaders = {
|
||||||
header1=1264;
|
header1 = 1264;
|
||||||
header2=4567;
|
header2 = 4567;
|
||||||
};
|
};
|
||||||
|
|
||||||
//Instances
|
//Instances
|
||||||
instances = {
|
instances = {
|
||||||
//1st instance
|
//1st instance
|
||||||
1 = {
|
1 = {
|
||||||
host=145.146.147.20;
|
host = 145.146.147.20;
|
||||||
port=9002;
|
port = 9002;
|
||||||
parameters= {
|
parameters = {
|
||||||
transport=socket;
|
transport = socket;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
MyAppVoid = {
|
MyAppVoid = {
|
||||||
//Here we have 3 instances
|
// Here we have 3 instances
|
||||||
instances = {
|
instances = {
|
||||||
1 = {
|
1 = {
|
||||||
host=145.146.147.20;
|
host = 145.146.147.20;
|
||||||
port=9001;
|
port = 9001;
|
||||||
parameters= {
|
parameters = {
|
||||||
transport=socket;
|
transport = socket;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
2 = {
|
2 = {
|
||||||
host=145.146.147.21;
|
host = 145.146.147.21;
|
||||||
port=9002;
|
port = 9002;
|
||||||
parameters= {
|
parameters = {
|
||||||
transport=socket;
|
transport=socket;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
5 ={
|
5 = {
|
||||||
host=145.146.147.22;
|
host = 145.146.147.22;
|
||||||
port=9003;
|
port = 9003;
|
||||||
parameters= {
|
parameters = {
|
||||||
transport=socket;
|
transport=socket;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
</PRE>
|
</PRE>
|
||||||
|
</body>
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* 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
|
||||||
|
@ -38,22 +38,24 @@
|
||||||
#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");
|
||||||
|
@ -61,7 +63,8 @@ void GSWApp_Free(GSWApp* p_pApp)
|
||||||
{
|
{
|
||||||
p_pApp->iUsageCounter--;
|
p_pApp->iUsageCounter--;
|
||||||
if (p_pApp->iUsageCounter<0)
|
if (p_pApp->iUsageCounter<0)
|
||||||
GSWLog(GSW_CRITICAL,NULL,"App seems to have been freed too much times");
|
GSWLog(GSW_CRITICAL,NULL,
|
||||||
|
"App seems to have been freed too much times");
|
||||||
if (p_pApp->iUsageCounter<=0)
|
if (p_pApp->iUsageCounter<=0)
|
||||||
{
|
{
|
||||||
if (p_pApp->pszName)
|
if (p_pApp->pszName)
|
||||||
|
@ -78,7 +81,10 @@ void GSWApp_Free(GSWApp* 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)
|
||||||
{
|
{
|
||||||
|
@ -98,15 +104,19 @@ void GSWApp_AddInstance(GSWApp* p_pApp,CONST char* p_pszInstanceNum,GSWAppInstan
|
||||||
p_pInstance->pApp=p_pApp;
|
p_pInstance->pApp=p_pApp;
|
||||||
p_pInstance->pApp->iUsageCounter++;
|
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);
|
||||||
|
@ -116,7 +126,8 @@ void GSWApp_InternFreeNotValidInstances(GSWDictElem* p_pElem,void* p_pData)
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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,
|
||||||
|
@ -124,16 +135,19 @@ void GSWApp_FreeNotValidInstances(GSWApp* p_pApp)
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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,
|
||||||
|
@ -142,9 +156,10 @@ void GSWApp_AppsClearInstances(GSWDict* p_pAppsDict)
|
||||||
|
|
||||||
//====================================================================
|
//====================================================================
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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",
|
||||||
|
@ -156,7 +171,8 @@ GSWAppInstance* GSWAppInstance_New(GSWApp* p_pApp)
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWAppInstance_Free(GSWAppInstance* p_pInstance)
|
void
|
||||||
|
GSWAppInstance_Free(GSWAppInstance *p_pInstance)
|
||||||
{
|
{
|
||||||
if (p_pInstance)
|
if (p_pInstance)
|
||||||
{
|
{
|
||||||
|
@ -166,7 +182,8 @@ void GSWAppInstance_Free(GSWAppInstance* p_pInstance)
|
||||||
{
|
{
|
||||||
char szBuffer[128]="";
|
char szBuffer[128]="";
|
||||||
sprintf(szBuffer,"%d",p_pInstance->iInstance);
|
sprintf(szBuffer,"%d",p_pInstance->iInstance);
|
||||||
if (GSWDict_ValueForKey(&p_pInstance->pApp->stInstancesDict,szBuffer)==p_pInstance)
|
if (GSWDict_ValueForKey(&p_pInstance->pApp->stInstancesDict,
|
||||||
|
szBuffer)==p_pInstance)
|
||||||
GSWDict_RemoveKey(&p_pInstance->pApp->stInstancesDict,szBuffer);
|
GSWDict_RemoveKey(&p_pInstance->pApp->stInstancesDict,szBuffer);
|
||||||
p_pInstance->pApp->iUsageCounter--;
|
p_pInstance->pApp->iUsageCounter--;
|
||||||
};
|
};
|
||||||
|
@ -175,7 +192,8 @@ void GSWAppInstance_Free(GSWAppInstance* p_pInstance)
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
BOOL GSWAppInstance_FreeIFND(GSWAppInstance* p_pInstance)
|
BOOL
|
||||||
|
GSWAppInstance_FreeIFND(GSWAppInstance *p_pInstance)
|
||||||
{
|
{
|
||||||
if (p_pInstance->uOpenedRequestsNb==0)
|
if (p_pInstance->uOpenedRequestsNb==0)
|
||||||
{
|
{
|
||||||
|
@ -187,97 +205,119 @@ BOOL GSWAppInstance_FreeIFND(GSWAppInstance* p_pInstance)
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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 (name = calloc(1,50))
|
||||||
if (pszName) {
|
{
|
||||||
|
if (pszName)
|
||||||
|
{
|
||||||
strncpy(name, pszName,45);
|
strncpy(name, pszName,45);
|
||||||
name[45]=0;
|
name[45]=0;
|
||||||
}
|
}
|
||||||
sprintf(name + strlen(name), "%d", iInstance);
|
sprintf(name + strlen(name), "%d", iInstance);
|
||||||
|
|
||||||
}
|
}
|
||||||
return name;
|
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();
|
GSWAppInfo_Init();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
name = GSWAppInfo_MakeDictKeyName(pszName, iInstance);
|
name = GSWAppInfo_MakeDictKeyName(pszName, iInstance);
|
||||||
if (name) {
|
if (name)
|
||||||
|
{
|
||||||
newInfo = GSWDict_ValueForKey(_gswAppInfoDict, name);
|
newInfo = GSWDict_ValueForKey(_gswAppInfoDict, name);
|
||||||
free(name); name = NULL;
|
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));
|
newInfo=(GSWAppInfo*)calloc(1,sizeof(GSWAppInfo));
|
||||||
addDict = TRUE;
|
addDict = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newInfo && (name = GSWAppInfo_MakeDictKeyName(pszName, iInstance) )) {
|
if (newInfo && (name = GSWAppInfo_MakeDictKeyName(pszName, iInstance) ))
|
||||||
|
{
|
||||||
newInfo->isRefused = isRefused;
|
newInfo->isRefused = isRefused;
|
||||||
time(&curTime);
|
time(&curTime);
|
||||||
newInfo->timeNextRetryTime = curTime + 10; // + 10 sec
|
newInfo->timeNextRetryTime = curTime + 10; // + 10 sec
|
||||||
|
|
||||||
if (addDict == TRUE) {
|
if (addDict == TRUE)
|
||||||
|
{
|
||||||
GSWAppInfo_Add(newInfo, name);
|
GSWAppInfo_Add(newInfo, name);
|
||||||
}
|
}
|
||||||
free(name); name = NULL;
|
free(name);
|
||||||
} else {
|
name = NULL;
|
||||||
if (newInfo) {
|
}
|
||||||
free(newInfo); newInfo = NULL;
|
else
|
||||||
|
{
|
||||||
|
if (newInfo)
|
||||||
|
{
|
||||||
|
free(newInfo);
|
||||||
|
newInfo = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWAppInfo_Remove(GSWAppInfo* _appInfo)
|
void
|
||||||
|
GSWAppInfo_Remove(GSWAppInfo *_appInfo)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* 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
|
||||||
|
@ -27,20 +27,20 @@
|
||||||
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;
|
||||||
|
@ -48,16 +48,18 @@ typedef struct _GSWAppInstance
|
||||||
} 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,8 +41,9 @@
|
||||||
|
|
||||||
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)
|
||||||
|
@ -50,14 +51,17 @@ AppConnectHandle GSWApp_Open(GSWAppRequest* p_pAppRequest,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct hostent* pHost=hl_find(p_pAppRequest->pszHost);
|
struct hostent *pHost=hl_find(p_pAppRequest->pszHost);
|
||||||
if (!pHost)
|
if (!pHost)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_ERROR, "gethostbyname(%s) returns no host",p_pAppRequest->pszHost);
|
GSWLog(GSW_ERROR, p_pLogServerData,
|
||||||
|
"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,"Host %s has bad address type",p_pAppRequest->pszHost);
|
GSWLog(GSW_ERROR, p_pLogServerData, "Host %s has bad address type",
|
||||||
|
p_pAppRequest->pszHost);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -68,13 +72,14 @@ AppConnectHandle GSWApp_Open(GSWAppRequest* p_pAppRequest,
|
||||||
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,
|
||||||
|
"Can't Create socket to %s:%d. Error=%d (%s)",
|
||||||
p_pAppRequest->pszHost,
|
p_pAppRequest->pszHost,
|
||||||
p_pAppRequest->iPort,
|
p_pAppRequest->iPort,
|
||||||
errno,
|
errno,
|
||||||
|
@ -82,9 +87,10 @@ AppConnectHandle GSWApp_Open(GSWAppRequest* p_pAppRequest,
|
||||||
}
|
}
|
||||||
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)",
|
GSWLog(GSW_ERROR, p_pLogServerData,
|
||||||
|
"Can't connect to %s:%d. Error=%d (%s)",
|
||||||
p_pAppRequest->pszHost,
|
p_pAppRequest->pszHost,
|
||||||
p_pAppRequest->iPort,
|
p_pAppRequest->iPort,
|
||||||
errno,
|
errno,
|
||||||
|
@ -98,8 +104,9 @@ AppConnectHandle GSWApp_Open(GSWAppRequest* p_pAppRequest,
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -109,9 +116,10 @@ void GSWApp_Close(AppConnectHandle p_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)
|
||||||
|
@ -119,10 +127,11 @@ int GSWApp_SendLine(AppConnectHandle p_handle,
|
||||||
return iRetValue;
|
return iRetValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GSWApp_SendBlock(AppConnectHandle p_handle,
|
int
|
||||||
CONST char* p_pszBuffer,
|
GSWApp_SendBlock(AppConnectHandle p_handle,
|
||||||
|
CONST char *p_pszBuffer,
|
||||||
int p_iSize,
|
int p_iSize,
|
||||||
void* p_pLogServerData)
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
int iRetValue=-1;
|
int iRetValue=-1;
|
||||||
if (p_handle)
|
if (p_handle)
|
||||||
|
@ -132,9 +141,10 @@ int GSWApp_SendBlock(AppConnectHandle p_handle,
|
||||||
int iRemainingSize = p_iSize;
|
int iRemainingSize = p_iSize;
|
||||||
while (iRemainingSize>0 && iSent>=0)
|
while (iRemainingSize>0 && iSent>=0)
|
||||||
{
|
{
|
||||||
iSent=net_write(handle,(char*)p_pszBuffer,iRemainingSize);
|
iSent=net_write(handle,(char *)p_pszBuffer,iRemainingSize);
|
||||||
if (iSent<0)
|
if (iSent<0)
|
||||||
GSWLog(GSW_ERROR,"send failed. Error=%d (%s)",
|
GSWLog(GSW_ERROR, p_pLogServerData,
|
||||||
|
"send failed. Error=%d (%s)",
|
||||||
errno,
|
errno,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
else
|
else
|
||||||
|
@ -148,10 +158,11 @@ int GSWApp_SendBlock(AppConnectHandle p_handle,
|
||||||
return iRetValue;
|
return iRetValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GSWApp_ReceiveLine(AppConnectHandle p_handle,
|
int
|
||||||
char* p_pszBuffer,
|
GSWApp_ReceiveLine(AppConnectHandle p_handle,
|
||||||
|
char *p_pszBuffer,
|
||||||
int p_iBufferSize,
|
int p_iBufferSize,
|
||||||
void* p_pLogServerData)
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
int iRetValue=-1;
|
int iRetValue=-1;
|
||||||
if (p_handle)
|
if (p_handle)
|
||||||
|
@ -166,7 +177,8 @@ int GSWApp_ReceiveLine(AppConnectHandle p_handle,
|
||||||
iReaden=net_read(handle,&c,1,APP_CONNECT_TIMEOUT);
|
iReaden=net_read(handle,&c,1,APP_CONNECT_TIMEOUT);
|
||||||
if (iReaden<1)
|
if (iReaden<1)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_ERROR,"GSWApp_ReceiveLine. Error=%d (%s)",
|
GSWLog(GSW_ERROR, p_pLogServerData,
|
||||||
|
"GSWApp_ReceiveLine. Error=%d (%s)",
|
||||||
errno,
|
errno,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
iRetValue=0; //??
|
iRetValue=0; //??
|
||||||
|
@ -186,10 +198,11 @@ int GSWApp_ReceiveLine(AppConnectHandle p_handle,
|
||||||
return iRetValue;
|
return iRetValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
int GSWApp_ReceiveBlock(AppConnectHandle p_handle,
|
int
|
||||||
char* p_pszBuffer,
|
GSWApp_ReceiveBlock(AppConnectHandle p_handle,
|
||||||
|
char *p_pszBuffer,
|
||||||
int p_iBufferSize,
|
int p_iBufferSize,
|
||||||
void* p_pLogServerData)
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
int iRetValue=-1;
|
int iRetValue=-1;
|
||||||
if (p_handle)
|
if (p_handle)
|
||||||
|
@ -200,10 +213,12 @@ int GSWApp_ReceiveBlock(AppConnectHandle p_handle,
|
||||||
BOOL fOk=TRUE;
|
BOOL fOk=TRUE;
|
||||||
while (iRemainingSize>0 && fOk)
|
while (iRemainingSize>0 && fOk)
|
||||||
{
|
{
|
||||||
iReceived=net_read(handle,p_pszBuffer,iRemainingSize,APP_CONNECT_TIMEOUT);
|
iReceived=net_read(handle,p_pszBuffer,
|
||||||
|
iRemainingSize,APP_CONNECT_TIMEOUT);
|
||||||
if (iReceived<0)
|
if (iReceived<0)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_ERROR,"GSWApp_ReceiveBlock failed. Error=%d %s",
|
GSWLog(GSW_ERROR, p_pLogServerData,
|
||||||
|
"GSWApp_ReceiveBlock failed. Error=%d %s",
|
||||||
errno,
|
errno,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
fOk=FALSE;
|
fOk=FALSE;
|
||||||
|
|
|
@ -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,13 +60,14 @@ 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;
|
||||||
|
@ -77,9 +78,13 @@ GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequ
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -101,7 +106,8 @@ GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequ
|
||||||
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,
|
||||||
|
@ -133,11 +139,13 @@ GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequ
|
||||||
appInstance = p_pAppRequest->iInstance;
|
appInstance = p_pAppRequest->iInstance;
|
||||||
|
|
||||||
p_pAppRequest->pRequest = NULL;
|
p_pAppRequest->pRequest = NULL;
|
||||||
pHTTPResponse = GSWHTTPResponse_GetResponse(hConnect,p_pLogServerData);
|
pHTTPResponse = GSWHTTPResponse_GetResponse(hConnect,
|
||||||
|
p_pLogServerData);
|
||||||
p_pAppRequest->pResponse = pHTTPResponse;
|
p_pAppRequest->pResponse = pHTTPResponse;
|
||||||
|
|
||||||
if (p_pAppRequest->eType == EAppType_LoadBalanced)
|
if (p_pAppRequest->eType == EAppType_LoadBalanced)
|
||||||
GSWLoadBalancing_StopAppRequest(p_pAppRequest,p_pLogServerData);
|
GSWLoadBalancing_StopAppRequest(p_pAppRequest,
|
||||||
|
p_pLogServerData);
|
||||||
|
|
||||||
GSWApp_Close(hConnect,p_pLogServerData);
|
GSWApp_Close(hConnect,p_pLogServerData);
|
||||||
hConnect=NULL;
|
hConnect=NULL;
|
||||||
|
@ -145,10 +153,15 @@ GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequ
|
||||||
glbResponsesNb++;
|
glbResponsesNb++;
|
||||||
if (pHTTPResponse)
|
if (pHTTPResponse)
|
||||||
{
|
{
|
||||||
char *value = GSWDict_ValueForKey(pHTTPResponse->pHeaders,"x-gsweb-refusing-redirection");
|
char *value =
|
||||||
if (value && (strncmp(value,"YES",3)==0)) {
|
GSWDict_ValueForKey(pHTTPResponse->pHeaders,
|
||||||
|
"x-gsweb-refusing-redirection");
|
||||||
|
if (value && (strncmp(value,"YES",3)==0))
|
||||||
|
{
|
||||||
// refuseNewSessions == YES in app
|
// refuseNewSessions == YES in app
|
||||||
GSWLog(GSW_INFO,p_pLogServerData,"### This app (%s / %d) is refusing all new sessions ###", appName, appInstance);
|
GSWLog(GSW_INFO,p_pLogServerData,
|
||||||
|
"### This app (%s / %d) is refusing all new sessions ###",
|
||||||
|
appName, appInstance);
|
||||||
GSWAppInfo_Set(appName, appInstance, TRUE);
|
GSWAppInfo_Set(appName, appInstance, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,15 +170,18 @@ GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequ
|
||||||
pHTTPResponse->uStatus,
|
pHTTPResponse->uStatus,
|
||||||
pHTTPResponse->pszStatusMessage);
|
pHTTPResponse->pszStatusMessage);
|
||||||
};
|
};
|
||||||
if (appName) {
|
if (appName)
|
||||||
free(appName); appName = NULL;
|
{
|
||||||
|
free(appName);
|
||||||
|
appName = NULL;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fAppNotResponding=TRUE;
|
fAppNotResponding=TRUE;
|
||||||
GSWLog(GSW_WARNING,p_pLogServerData,"%s:%d NOT LISTENING on %s:%d",
|
GSWLog(GSW_WARNING,p_pLogServerData,
|
||||||
|
"%s:%d NOT LISTENING on %s:%d",
|
||||||
p_pAppRequest->pszName,
|
p_pAppRequest->pszName,
|
||||||
p_pAppRequest->iInstance,
|
p_pAppRequest->iInstance,
|
||||||
p_pAppRequest->pszHost,
|
p_pAppRequest->pszHost,
|
||||||
|
@ -173,20 +189,26 @@ GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequ
|
||||||
//TODO
|
//TODO
|
||||||
/*
|
/*
|
||||||
if (p_pAppRequest->eType == EAppType_Auto)
|
if (p_pAppRequest->eType == EAppType_Auto)
|
||||||
GSWLoadBalancing_MarkNotRespondingApp(p_pAppRequest,p_pLogServerData);
|
GSWLoadBalancing_MarkNotRespondingApp(p_pAppRequest,
|
||||||
|
p_pLogServerData);
|
||||||
|
|
||||||
else*/ if (p_pAppRequest->eType==EAppType_LoadBalanced)
|
else*/ if (p_pAppRequest->eType==EAppType_LoadBalanced)
|
||||||
{
|
{
|
||||||
GSWLoadBalancing_MarkNotRespondingApp(p_pAppRequest,p_pLogServerData);
|
GSWLoadBalancing_MarkNotRespondingApp(p_pAppRequest,
|
||||||
|
p_pLogServerData);
|
||||||
if (iAttemptsRemaining-->0)
|
if (iAttemptsRemaining-->0)
|
||||||
fAppFound=GSWLoadBalancing_FindApp(p_pAppRequest,p_pLogServerData, p_pURLComponents);
|
fAppFound=GSWLoadBalancing_FindApp(p_pAppRequest,
|
||||||
|
p_pLogServerData,
|
||||||
|
p_pURLComponents);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
if (fAppNotResponding)
|
if (fAppNotResponding)
|
||||||
{
|
{
|
||||||
GSWApp* pApp=(p_pAppRequest ? (p_pAppRequest->pAppInstance ? p_pAppRequest->pAppInstance->pApp : NULL) : NULL);
|
GSWApp *pApp=(p_pAppRequest ?
|
||||||
char* pszString=GSWTemplate_ErrorNoResponseMessage(TRUE,pApp);
|
(p_pAppRequest->pAppInstance ?
|
||||||
|
p_pAppRequest->pAppInstance->pApp : NULL) : NULL);
|
||||||
|
char *pszString=GSWTemplate_ErrorNoResponseMessage(TRUE,pApp);
|
||||||
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse(p_pAppRequest,
|
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse(p_pAppRequest,
|
||||||
pszString,
|
pszString,
|
||||||
p_pLogServerData);
|
p_pLogServerData);
|
||||||
|
@ -200,7 +222,9 @@ GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequ
|
||||||
pHTTPResponse = GSWDumpConfigFile(p_pURLComponents,p_pLogServerData);
|
pHTTPResponse = GSWDumpConfigFile(p_pURLComponents,p_pLogServerData);
|
||||||
if (!pHTTPResponse)
|
if (!pHTTPResponse)
|
||||||
{
|
{
|
||||||
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse(p_pAppRequest,"No App Found",p_pLogServerData);
|
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse(p_pAppRequest,
|
||||||
|
"No App Found",
|
||||||
|
p_pLogServerData);
|
||||||
pHTTPResponse->uStatus = 404;
|
pHTTPResponse->uStatus = 404;
|
||||||
if (pHTTPResponse->pszStatusMessage)
|
if (pHTTPResponse->pszStatusMessage)
|
||||||
{
|
{
|
||||||
|
@ -217,26 +241,30 @@ 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
|
if (p_pURLComponents->stAppName.iLength<=0
|
||||||
|| !p_pURLComponents->stAppName.pszStart)
|
|| !p_pURLComponents->stAppName.pszStart)
|
||||||
{
|
{
|
||||||
pHTTPResponse=GSWHTTPResponse_BuildErrorResponse(NULL,"No Application Name",p_pLogServerData);
|
pHTTPResponse=GSWHTTPResponse_BuildErrorResponse(NULL,
|
||||||
|
"No Application Name",
|
||||||
|
p_pLogServerData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -254,12 +282,14 @@ GSWHTTPResponse* GSWAppRequest_HandleRequest(GSWHTTPRequest** p_ppHTTPRequest,
|
||||||
|
|
||||||
DeleteTrailingSlash(szAppName);
|
DeleteTrailingSlash(szAppName);
|
||||||
if (strcmp(szAppName,p_pszTestAppName)==0)
|
if (strcmp(szAppName,p_pszTestAppName)==0)
|
||||||
pHTTPResponse=GSWHTTPResponse_BuildStatusResponse(*p_ppHTTPRequest,p_pLogServerData);
|
pHTTPResponse=GSWHTTPResponse_BuildStatusResponse(*p_ppHTTPRequest,
|
||||||
|
p_pLogServerData);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Get HostByName");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Get HostByName");
|
||||||
// Get Host Name
|
// Get Host Name
|
||||||
if (p_pURLComponents->stAppHost.iLength>0 && p_pURLComponents->stAppHost.pszStart)
|
if (p_pURLComponents->stAppHost.iLength>0 &&
|
||||||
|
p_pURLComponents->stAppHost.pszStart)
|
||||||
{
|
{
|
||||||
strncpy(szHost,
|
strncpy(szHost,
|
||||||
p_pURLComponents->stAppHost.pszStart,
|
p_pURLComponents->stAppHost.pszStart,
|
||||||
|
@ -271,30 +301,41 @@ GSWHTTPResponse* GSWAppRequest_HandleRequest(GSWHTTPRequest** p_ppHTTPRequest,
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Get Request Instance Number");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Get Request Instance Number");
|
||||||
|
|
||||||
// in URL ?
|
// in URL ?
|
||||||
if (p_pURLComponents->stAppNumber.iLength>0 && p_pURLComponents->stAppNumber.pszStart)
|
if (p_pURLComponents->stAppNumber.iLength>0 &&
|
||||||
stAppRequest.iInstance = atoi(p_pURLComponents->stAppNumber.pszStart);
|
p_pURLComponents->stAppNumber.pszStart)
|
||||||
|
stAppRequest.iInstance =
|
||||||
|
atoi(p_pURLComponents->stAppNumber.pszStart);
|
||||||
|
|
||||||
// In Cookie ?
|
// In Cookie ?
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CONST char* pszCookie=GSWHTTPRequest_HeaderForKey(*p_ppHTTPRequest,g_szHeader_Cookie);
|
CONST char *pszCookie=
|
||||||
|
GSWHTTPRequest_HeaderForKey(*p_ppHTTPRequest,
|
||||||
|
g_szHeader_Cookie);
|
||||||
if (pszCookie)
|
if (pszCookie)
|
||||||
{
|
{
|
||||||
CONST char* pszInstanceCookie=strstr(pszCookie, g_szGSWeb_InstanceCookie[GSWNAMES_INDEX]);
|
CONST char *pszInstanceCookie =
|
||||||
|
strstr(pszCookie,
|
||||||
|
g_szGSWeb_InstanceCookie[GSWNAMES_INDEX]);
|
||||||
if (pszInstanceCookie)
|
if (pszInstanceCookie)
|
||||||
{
|
{
|
||||||
stAppRequest.iInstance = atoi(pszInstanceCookie + strlen(g_szGSWeb_InstanceCookie[GSWNAMES_INDEX]));
|
stAppRequest.iInstance = atoi(pszInstanceCookie +
|
||||||
GSWLog(GSW_INFO,p_pLogServerData,"Cookie instance %d from %s",
|
strlen(g_szGSWeb_InstanceCookie[GSWNAMES_INDEX]));
|
||||||
|
GSWLog(GSW_INFO,p_pLogServerData,
|
||||||
|
"Cookie instance %d from %s",
|
||||||
stAppRequest.iInstance,
|
stAppRequest.iInstance,
|
||||||
pszCookie);
|
pszCookie);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pszInstanceCookie=strstr(pszCookie, g_szGSWeb_InstanceCookie[WONAMES_INDEX]);
|
pszInstanceCookie=strstr(pszCookie,
|
||||||
|
g_szGSWeb_InstanceCookie[WONAMES_INDEX]);
|
||||||
if (pszInstanceCookie)
|
if (pszInstanceCookie)
|
||||||
{
|
{
|
||||||
stAppRequest.iInstance = atoi(pszInstanceCookie + strlen(g_szGSWeb_InstanceCookie[WONAMES_INDEX]));
|
stAppRequest.iInstance = atoi(pszInstanceCookie +
|
||||||
GSWLog(GSW_INFO,p_pLogServerData,"Cookie instance %d from %s",
|
strlen(g_szGSWeb_InstanceCookie[WONAMES_INDEX]));
|
||||||
|
GSWLog(GSW_INFO,p_pLogServerData,
|
||||||
|
"Cookie instance %d from %s",
|
||||||
stAppRequest.iInstance,
|
stAppRequest.iInstance,
|
||||||
pszCookie);
|
pszCookie);
|
||||||
};
|
};
|
||||||
|
@ -306,15 +347,18 @@ GSWHTTPResponse* GSWAppRequest_HandleRequest(GSWHTTPRequest** p_ppHTTPRequest,
|
||||||
stAppRequest.pszHost = szHost;
|
stAppRequest.pszHost = szHost;
|
||||||
stAppRequest.pszDocRoot = p_pszDocRoot;
|
stAppRequest.pszDocRoot = p_pszDocRoot;
|
||||||
stAppRequest.pRequest = *p_ppHTTPRequest;
|
stAppRequest.pRequest = *p_ppHTTPRequest;
|
||||||
stAppRequest.uURLVersion = (p_pURLComponents->stVersion.pszStart) ?
|
stAppRequest.uURLVersion =
|
||||||
atoi(p_pURLComponents->stVersion.pszStart) : GSWEB_VERSION_MAJOR;
|
(p_pURLComponents->stVersion.pszStart) ?
|
||||||
|
atoi(p_pURLComponents->stVersion.pszStart) :
|
||||||
|
GSWEB_VERSION_MAJOR;
|
||||||
|
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Add Header");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Add Header");
|
||||||
GSWHTTPRequest_AddHeader(*p_ppHTTPRequest,
|
GSWHTTPRequest_AddHeader(*p_ppHTTPRequest,
|
||||||
g_szHeader_GSWeb_ServerAdaptor,
|
g_szHeader_GSWeb_ServerAdaptor,
|
||||||
g_szGSWeb_ServerAndAdaptorVersion);
|
g_szGSWeb_ServerAndAdaptorVersion);
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"SendAppRequestToApp");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"SendAppRequestToApp");
|
||||||
pHTTPResponse=GSWAppRequest_SendAppRequestToApp(p_ppHTTPRequest,
|
pHTTPResponse =
|
||||||
|
GSWAppRequest_SendAppRequestToApp(p_ppHTTPRequest,
|
||||||
p_pURLComponents,
|
p_pURLComponents,
|
||||||
&stAppRequest,
|
&stAppRequest,
|
||||||
p_pszHTTPVersion,
|
p_pszHTTPVersion,
|
||||||
|
|
|
@ -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.
|
||||||
|
|
||||||
|
@ -41,17 +41,17 @@ typedef enum {
|
||||||
// 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;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* GSWConfig.c - GSWeb: Adaptors: Config
|
/* GSWConfig.c - 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.
|
||||||
|
|
||||||
|
@ -50,40 +50,40 @@ static const char g_szAdaptorBuilt[] = "unknown";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
const char* g_szGSWeb_AdaptorVersion=GSWEB_SERVER_ADAPTOR_VERSION_MAJOR_STRING "." GSWEB_SERVER_ADAPTOR_VERSION_MINOR_STRING;
|
const char *g_szGSWeb_AdaptorVersion=GSWEB_SERVER_ADAPTOR_VERSION_MAJOR_STRING "." GSWEB_SERVER_ADAPTOR_VERSION_MINOR_STRING;
|
||||||
|
|
||||||
const char* g_szGSWeb_Prefix=GSWEB_PREFIX;
|
const char *g_szGSWeb_Prefix=GSWEB_PREFIX;
|
||||||
const char* g_szGSWeb_Handler=GSWEB_HANDLER;
|
const char *g_szGSWeb_Handler=GSWEB_HANDLER;
|
||||||
const char* g_szGSWeb_StatusResponseAppName=GSWEB_STATUS_RESPONSE_APP_NAME;
|
const char *g_szGSWeb_StatusResponseAppName=GSWEB_STATUS_RESPONSE_APP_NAME;
|
||||||
const char* g_szGSWeb_AppExtention[2]={ GSWAPP_EXTENSION_GSW, GSWAPP_EXTENSION_WO };
|
const char *g_szGSWeb_AppExtention[2]={ GSWAPP_EXTENSION_GSW, GSWAPP_EXTENSION_WO };
|
||||||
|
|
||||||
const char* g_szGSWeb_MimeType=GSWEB__MIME_TYPE;
|
const char *g_szGSWeb_MimeType=GSWEB__MIME_TYPE;
|
||||||
//const char* g_szGSWeb_Conf_DocRoot=GSWEB_CONF__DOC_ROOT;
|
//const char *g_szGSWeb_Conf_DocRoot=GSWEB_CONF__DOC_ROOT;
|
||||||
const char* g_szGSWeb_Conf_ConfigFilePath=GSWEB_CONF__CONFIG_FILE_PATH;
|
const char *g_szGSWeb_Conf_ConfigFilePath=GSWEB_CONF__CONFIG_FILE_PATH;
|
||||||
|
|
||||||
|
|
||||||
// Apache
|
// Apache
|
||||||
#if defined(Apache)
|
#if defined(Apache)
|
||||||
const char* g_szGSWeb_Conf_Alias=GSWEB_CONF__ALIAS;
|
const char *g_szGSWeb_Conf_Alias=GSWEB_CONF__ALIAS;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Netscape
|
// Netscape
|
||||||
#if defined(Netscape)
|
#if defined(Netscape)
|
||||||
const char* g_szGSWeb_Conf_PathTrans=GSWEB_CONF__PATH_TRANS;
|
const char *g_szGSWeb_Conf_PathTrans=GSWEB_CONF__PATH_TRANS;
|
||||||
const char* g_szGSWeb_Conf_AppRoot=GSWEB_CONF__APP_ROOT;
|
const char *g_szGSWeb_Conf_AppRoot=GSWEB_CONF__APP_ROOT;
|
||||||
const char* g_szGSWeb_Conf_Name=GSWEB_CONF__NAME;
|
const char *g_szGSWeb_Conf_Name=GSWEB_CONF__NAME;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* g_szGSWeb_InstanceCookie[2]={ GSWEB_INSTANCE_COOKIE_GSW, GSWEB_INSTANCE_COOKIE_WO };
|
const char *g_szGSWeb_InstanceCookie[2]={ GSWEB_INSTANCE_COOKIE_GSW, GSWEB_INSTANCE_COOKIE_WO };
|
||||||
|
|
||||||
const char* g_szGSWeb_Server=SERVER;
|
const char *g_szGSWeb_Server=SERVER;
|
||||||
const char* g_szGSWeb_ServerAndAdaptorVersion=SERVER "/" GSWEB_SERVER_ADAPTOR_VERSION_MAJOR_STRING "." GSWEB_SERVER_ADAPTOR_VERSION_MINOR_STRING;
|
const char *g_szGSWeb_ServerAndAdaptorVersion=SERVER "/" GSWEB_SERVER_ADAPTOR_VERSION_MAJOR_STRING "." GSWEB_SERVER_ADAPTOR_VERSION_MINOR_STRING;
|
||||||
|
|
||||||
|
|
||||||
const char* const g_szGNUstep = "GNUstep";
|
const char *const g_szGNUstep = "GNUstep";
|
||||||
|
|
||||||
const char* const g_szOKGSWeb[2] = { "OK GSWeb", "OK Apple"};
|
const char *const g_szOKGSWeb[2] = { "OK GSWeb", "OK Apple"};
|
||||||
const char* const g_szOKStatus[2] = { "HTTP/1.0 200 OK GNUstep GSWeb", "HTTP/1.0 200 OK Apple GSWeb"};
|
const char *const g_szOKStatus[2] = { "HTTP/1.0 200 OK GNUstep GSWeb", "HTTP/1.0 200 OK Apple GSWeb"};
|
||||||
|
|
||||||
#if defined(Apache)
|
#if defined(Apache)
|
||||||
#define GSWServerVersion ap_get_server_version()
|
#define GSWServerVersion ap_get_server_version()
|
||||||
|
@ -97,16 +97,17 @@ const char* const g_szOKStatus[2] = { "HTTP/1.0 200 OK GNUstep GSWeb", "HTTP/1.0
|
||||||
|
|
||||||
//====================================================================
|
//====================================================================
|
||||||
GSWLock g_lockAppList=NULL;
|
GSWLock g_lockAppList=NULL;
|
||||||
static GSWDict* g_pAppDict = NULL;
|
static GSWDict *g_pAppDict = NULL;
|
||||||
static time_t config_mtime = (time_t)0;
|
static time_t config_mtime = (time_t)0;
|
||||||
static GSWConfig g_gswConfig;
|
static GSWConfig g_gswConfig;
|
||||||
static char g_szServerStringInfo[1024]="";
|
static char g_szServerStringInfo[1024]="";
|
||||||
static char g_szAdaptorStringInfo[1024]="";
|
static char g_szAdaptorStringInfo[1024]="";
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWConfig_Init(GSWDict* p_pDict,
|
void
|
||||||
void* p_pLogServerData)
|
GSWConfig_Init(GSWDict *p_pDict,
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
CONST char* pszPath=NULL;
|
CONST char *pszPath=NULL;
|
||||||
memset(&g_gswConfig,0,sizeof(g_gswConfig));
|
memset(&g_gswConfig,0,sizeof(g_gswConfig));
|
||||||
sprintf(g_szServerStringInfo,"%s v %s built %s",
|
sprintf(g_szServerStringInfo,"%s v %s built %s",
|
||||||
g_szGSWeb_Server,
|
g_szGSWeb_Server,
|
||||||
|
@ -127,27 +128,33 @@ void GSWConfig_Init(GSWDict* p_pDict,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
GSWConfig* GSWConfig_GetConfig()
|
GSWConfig *
|
||||||
|
GSWConfig_GetConfig()
|
||||||
{
|
{
|
||||||
return &g_gswConfig;
|
return &g_gswConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
BOOL GSWConfig_CanDumpStatus()
|
BOOL
|
||||||
|
GSWConfig_CanDumpStatus()
|
||||||
{
|
{
|
||||||
return g_gswConfig.fCanDumpStatus;
|
return g_gswConfig.fCanDumpStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWConfig_SetConfigFilePath(CONST char* p_pszConfigFilePath)
|
void
|
||||||
|
GSWConfig_SetConfigFilePath(CONST char *p_pszConfigFilePath)
|
||||||
{
|
{
|
||||||
if (g_gswConfig.pszConfigFilePath)
|
if (g_gswConfig.pszConfigFilePath)
|
||||||
{
|
{
|
||||||
free(g_gswConfig.pszConfigFilePath);
|
free(g_gswConfig.pszConfigFilePath);
|
||||||
g_gswConfig.pszConfigFilePath=NULL;
|
g_gswConfig.pszConfigFilePath=NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (p_pszConfigFilePath)
|
if (p_pszConfigFilePath)
|
||||||
|
{
|
||||||
g_gswConfig.pszConfigFilePath=strdup(p_pszConfigFilePath);
|
g_gswConfig.pszConfigFilePath=strdup(p_pszConfigFilePath);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GSWLog(GSW_CRITICAL,NULL,
|
GSWLog(GSW_CRITICAL,NULL,
|
||||||
|
@ -157,43 +164,40 @@ void GSWConfig_SetConfigFilePath(CONST char* p_pszConfigFilePath)
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
CONST char* GSWConfig_GetConfigFilePath()
|
CONST char *
|
||||||
|
GSWConfig_GetConfigFilePath()
|
||||||
{
|
{
|
||||||
return g_gswConfig.pszConfigFilePath;
|
return g_gswConfig.pszConfigFilePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
/*{
|
{
|
||||||
canDumpStatus=NO;
|
canDumpStatus=NO;
|
||||||
GSWExtensionsFrameworkWebServerResources="/GSW/GSWExtensions/Resources/WebServer"
|
GSWExtensionsFrameworkWebServerResources =
|
||||||
applications= {
|
"/GSW/GSWExtensions/Resources/WebServer"
|
||||||
|
applications = {
|
||||||
MyApp1 = {
|
MyApp1 = {
|
||||||
GSWExtensionsFrameworkWebServerResources="/GSW/GSWExtensions/Resources/WebServer"
|
GSWExtensionsFrameworkWebServerResources=
|
||||||
|
"/GSW/GSWExtensions/Resources/WebServer"
|
||||||
instances = {
|
instances = {
|
||||||
1 = {
|
1 = {
|
||||||
host=12.13.14.15;
|
host = 12.13.14.15;
|
||||||
port=9001;
|
port = 9001;
|
||||||
parameters= {
|
parameters = { transport = socket; };
|
||||||
transport=socket;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
2 = {
|
2 = {
|
||||||
host=12.13.14.21;
|
host = 12.13.14.21;
|
||||||
port=9001;
|
port = 9001;
|
||||||
parameters= {
|
parameters = { transport = socket; };
|
||||||
transport=socket;
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
MyApp2 = {
|
MyApp2 = {
|
||||||
instances = {
|
instances = {
|
||||||
1 = {
|
1 = {
|
||||||
host=12.13.14.15;
|
host = 12.13.14.15;
|
||||||
port=9001;
|
port = 9001;
|
||||||
parameters= {
|
parameters = { transport=socket; };
|
||||||
transport=socket;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -201,11 +205,9 @@ CONST char* GSWConfig_GetConfigFilePath()
|
||||||
canDump = YES;
|
canDump = YES;
|
||||||
instances = {
|
instances = {
|
||||||
1 = {
|
1 = {
|
||||||
host=12.13.14.15;
|
host = 12.13.14.15;
|
||||||
port=9002;
|
port = 9002;
|
||||||
parameters= {
|
parameters = { transport=socket; };
|
||||||
transport=socket;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -214,12 +216,13 @@ CONST char* GSWConfig_GetConfigFilePath()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
//Read configuration from p_pszConfigPath if the file changed since p_pLastReadTime
|
//Read configuration from p_pszConfigPath if the file changed since
|
||||||
// and return the config into p_ppPropList
|
// p_pLastReadTime and return the config into p_ppPropList
|
||||||
EGSWConfigResult GSWConfig_ReadIFND(CONST char* p_pszConfigPath,
|
EGSWConfigResult
|
||||||
time_t* p_pLastReadTime,
|
GSWConfig_ReadIFND(CONST char *p_pszConfigPath,
|
||||||
proplist_t* p_ppPropList,//Please, PLRelease it after used !
|
time_t *p_pLastReadTime,
|
||||||
void* p_pLogServerData)
|
proplist_t *p_ppPropList, //Please, PLRelease it after used!
|
||||||
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
EGSWConfigResult eResult=EGSWConfigResult__Ok;
|
EGSWConfigResult eResult=EGSWConfigResult__Ok;
|
||||||
p_pLogServerData=NULL;//General Log
|
p_pLogServerData=NULL;//General Log
|
||||||
|
@ -287,15 +290,17 @@ EGSWConfigResult GSWConfig_ReadIFND(CONST char* p_pszConfigPath,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
GSWLog(GSW_INFO,p_pLogServerData,"GSWeb: GSWConfig_ReadIFND: result= %d",(int)eResult);
|
GSWLog(GSW_INFO,p_pLogServerData,"GSWeb: GSWConfig_ReadIFND: result= %d",
|
||||||
|
(int)eResult);
|
||||||
return eResult;
|
return eResult;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
BOOL GSWConfig_PropListHeadersToHeaders(GSWDict* p_pHeaders,
|
BOOL
|
||||||
|
GSWConfig_PropListHeadersToHeaders(GSWDict *p_pHeaders,
|
||||||
proplist_t p_propListHeaders,
|
proplist_t p_propListHeaders,
|
||||||
CONST char* p_pszParents,
|
CONST char *p_pszParents,
|
||||||
void* p_pLogServerData)
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
BOOL fOk=TRUE;
|
BOOL fOk=TRUE;
|
||||||
char pszParents[4096]="";
|
char pszParents[4096]="";
|
||||||
|
@ -313,7 +318,8 @@ BOOL GSWConfig_PropListHeadersToHeaders(GSWDict* p_pHeaders,
|
||||||
//Next get Array Of Headers Names
|
//Next get Array Of Headers Names
|
||||||
//header1,header2
|
//header1,header2
|
||||||
//We'll have to destroy propListHeadersNames
|
//We'll have to destroy propListHeadersNames
|
||||||
propListHeadersNames=GSWPropList_GetAllDictionaryKeys(p_propListHeaders,
|
propListHeadersNames =
|
||||||
|
GSWPropList_GetAllDictionaryKeys(p_propListHeaders,
|
||||||
pszParents,
|
pszParents,
|
||||||
TRUE,
|
TRUE,
|
||||||
GSWPropList_TestArray,
|
GSWPropList_TestArray,
|
||||||
|
@ -324,7 +330,8 @@ BOOL GSWConfig_PropListHeadersToHeaders(GSWDict* p_pHeaders,
|
||||||
for(iHeaderIndex=0;iHeaderIndex<uHeaderNb;iHeaderIndex++)
|
for(iHeaderIndex=0;iHeaderIndex<uHeaderNb;iHeaderIndex++)
|
||||||
{
|
{
|
||||||
//Get Header Name Key
|
//Get Header Name Key
|
||||||
proplist_t propListHeaderKey=GSWPropList_GetArrayElement(propListHeadersNames,
|
proplist_t propListHeaderKey =
|
||||||
|
GSWPropList_GetArrayElement(propListHeadersNames,
|
||||||
iHeaderIndex,
|
iHeaderIndex,
|
||||||
pszParents,
|
pszParents,
|
||||||
TRUE,
|
TRUE,
|
||||||
|
@ -337,8 +344,10 @@ BOOL GSWConfig_PropListHeadersToHeaders(GSWDict* p_pHeaders,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Get Headerlication Name (MyHeader1)
|
//Get Headerlication Name (MyHeader1)
|
||||||
CONST char* pszHeaderName=PLGetString(propListHeaderKey);//Do Not Free It
|
CONST char *pszHeaderName=PLGetString(propListHeaderKey);
|
||||||
proplist_t propListHeader=GSWPropList_GetDictionaryEntry(p_propListHeaders,
|
//Do Not Free It
|
||||||
|
proplist_t propListHeader =
|
||||||
|
GSWPropList_GetDictionaryEntry(p_propListHeaders,
|
||||||
pszHeaderName,
|
pszHeaderName,
|
||||||
pszParents,
|
pszParents,
|
||||||
TRUE,//Error If Not Exists
|
TRUE,//Error If Not Exists
|
||||||
|
@ -347,8 +356,10 @@ BOOL GSWConfig_PropListHeadersToHeaders(GSWDict* p_pHeaders,
|
||||||
if (propListHeader)
|
if (propListHeader)
|
||||||
{
|
{
|
||||||
//Get Header Value (1234)
|
//Get Header Value (1234)
|
||||||
CONST char* pszHeaderValue=PLGetString(propListHeader);//Do Not Free It
|
CONST char *pszHeaderValue=PLGetString(propListHeader);
|
||||||
GSWDict_AddStringDup(p_pHeaders,pszHeaderName,pszHeaderValue);
|
//Do Not Free It
|
||||||
|
GSWDict_AddStringDup(p_pHeaders,pszHeaderName,
|
||||||
|
pszHeaderValue);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -358,12 +369,13 @@ BOOL GSWConfig_PropListHeadersToHeaders(GSWDict* p_pHeaders,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
BOOL GSWConfig_PropListInstanceToInstance(GSWAppInstance* p_pInstance,
|
BOOL
|
||||||
|
GSWConfig_PropListInstanceToInstance(GSWAppInstance *p_pInstance,
|
||||||
proplist_t p_propListInstance,
|
proplist_t p_propListInstance,
|
||||||
GSWApp* p_pApp,
|
GSWApp *p_pApp,
|
||||||
int p_iInstanceNum,
|
int p_iInstanceNum,
|
||||||
CONST char* p_pszParents,
|
CONST char *p_pszParents,
|
||||||
void* p_pLogServerData)
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
BOOL fOk=TRUE;
|
BOOL fOk=TRUE;
|
||||||
proplist_t pValue=NULL;
|
proplist_t pValue=NULL;
|
||||||
|
@ -386,8 +398,11 @@ BOOL GSWConfig_PropListInstanceToInstance(GSWAppInstance* p_pInstance,
|
||||||
if (pValue)
|
if (pValue)
|
||||||
{
|
{
|
||||||
if (p_pInstance->pszHostName)
|
if (p_pInstance->pszHostName)
|
||||||
|
{
|
||||||
free(p_pInstance->pszHostName);
|
free(p_pInstance->pszHostName);
|
||||||
p_pInstance->pszHostName=SafeStrdup(PLGetString(pValue));//Do Not Free It PLGetStringValue, so strdup it
|
}
|
||||||
|
p_pInstance->pszHostName=SafeStrdup(PLGetString(pValue));
|
||||||
|
//Do Not Free It PLGetStringValue, so strdup it
|
||||||
};
|
};
|
||||||
|
|
||||||
// Port
|
// Port
|
||||||
|
@ -400,7 +415,7 @@ BOOL GSWConfig_PropListInstanceToInstance(GSWAppInstance* p_pInstance,
|
||||||
p_pLogServerData);
|
p_pLogServerData);
|
||||||
if (pValue)
|
if (pValue)
|
||||||
{
|
{
|
||||||
char* pszPort=PLGetString(pValue);//Do Not Free It
|
char *pszPort=PLGetString(pValue);//Do Not Free It
|
||||||
if (pszPort)
|
if (pszPort)
|
||||||
{
|
{
|
||||||
p_pInstance->iPort=atoi(pszPort);
|
p_pInstance->iPort=atoi(pszPort);
|
||||||
|
@ -420,18 +435,21 @@ BOOL GSWConfig_PropListInstanceToInstance(GSWAppInstance* p_pInstance,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
BOOL GSWConfig_PropListApplicationToApplication(GSWApp* p_pApp,
|
BOOL
|
||||||
|
GSWConfig_PropListApplicationToApplication(GSWApp *p_pApp,
|
||||||
proplist_t p_propListApp,
|
proplist_t p_propListApp,
|
||||||
CONST char* p_pszAppName,
|
CONST char *p_pszAppName,
|
||||||
CONST char* p_pszParents,
|
CONST char *p_pszParents,
|
||||||
void* p_pLogServerData)
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
BOOL fOk=TRUE;
|
BOOL fOk=TRUE;
|
||||||
char pszParents[4096]="";
|
char pszParents[4096]="";
|
||||||
proplist_t pValueCanDump=NULL;
|
proplist_t pValueCanDump=NULL;
|
||||||
proplist_t pValueAdaptorTemplatesPath=NULL;
|
proplist_t pValueAdaptorTemplatesPath=NULL;
|
||||||
if (p_pApp->pszName)
|
if (p_pApp->pszName)
|
||||||
|
{
|
||||||
free(p_pApp->pszName);
|
free(p_pApp->pszName);
|
||||||
|
}
|
||||||
p_pApp->pszName=SafeStrdup(p_pszAppName);//We'll own the AppName
|
p_pApp->pszName=SafeStrdup(p_pszAppName);//We'll own the AppName
|
||||||
// CanDump
|
// CanDump
|
||||||
sprintf(pszParents,"%s/%s",p_pszParents,p_pszAppName);
|
sprintf(pszParents,"%s/%s",p_pszParents,p_pszAppName);
|
||||||
|
@ -444,11 +462,12 @@ BOOL GSWConfig_PropListApplicationToApplication(GSWApp* p_pApp,
|
||||||
p_pApp->fCanDump=NO;
|
p_pApp->fCanDump=NO;
|
||||||
if (pValueCanDump)
|
if (pValueCanDump)
|
||||||
{
|
{
|
||||||
CONST char* pszCanDump=PLGetString(pValueCanDump);//Do Not Free It
|
CONST char *pszCanDump=PLGetString(pValueCanDump);//Do Not Free It
|
||||||
p_pApp->fCanDump=(strcasecmp(pszCanDump,"YES")==0);
|
p_pApp->fCanDump=(strcasecmp(pszCanDump,"YES")==0);
|
||||||
};
|
};
|
||||||
//adaptorTemplates
|
//adaptorTemplates
|
||||||
pValueAdaptorTemplatesPath=GSWPropList_GetDictionaryEntry(p_propListApp,
|
pValueAdaptorTemplatesPath =
|
||||||
|
GSWPropList_GetDictionaryEntry(p_propListApp,
|
||||||
"adaptorTemplatesPath",
|
"adaptorTemplatesPath",
|
||||||
pszParents,
|
pszParents,
|
||||||
FALSE,//No Error If Not Exists
|
FALSE,//No Error If Not Exists
|
||||||
|
@ -461,7 +480,8 @@ BOOL GSWConfig_PropListApplicationToApplication(GSWApp* p_pApp,
|
||||||
};
|
};
|
||||||
if (pValueAdaptorTemplatesPath)
|
if (pValueAdaptorTemplatesPath)
|
||||||
{
|
{
|
||||||
CONST char* pszPath=PLGetString(pValueAdaptorTemplatesPath);//Do Not Free It
|
CONST char *pszPath=PLGetString(pValueAdaptorTemplatesPath);
|
||||||
|
//Do Not Free It
|
||||||
p_pApp->pszAdaptorTemplatesPath=SafeStrdup(pszPath);
|
p_pApp->pszAdaptorTemplatesPath=SafeStrdup(pszPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -473,7 +493,8 @@ BOOL GSWConfig_PropListApplicationToApplication(GSWApp* p_pApp,
|
||||||
free(p_pApp->pszGSWExtensionsFrameworkWebServerResources);
|
free(p_pApp->pszGSWExtensionsFrameworkWebServerResources);
|
||||||
p_pApp->pszGSWExtensionsFrameworkWebServerResources=NULL;
|
p_pApp->pszGSWExtensionsFrameworkWebServerResources=NULL;
|
||||||
};
|
};
|
||||||
pValuePath=GSWPropList_GetDictionaryEntry(p_propListApp,
|
pValuePath =
|
||||||
|
GSWPropList_GetDictionaryEntry(p_propListApp,
|
||||||
"GSWExtensionsFrameworkWebServerResources",
|
"GSWExtensionsFrameworkWebServerResources",
|
||||||
NULL,
|
NULL,
|
||||||
FALSE,//No Error If Not Exists
|
FALSE,//No Error If Not Exists
|
||||||
|
@ -481,13 +502,15 @@ BOOL GSWConfig_PropListApplicationToApplication(GSWApp* p_pApp,
|
||||||
p_pLogServerData);
|
p_pLogServerData);
|
||||||
if (pValuePath)
|
if (pValuePath)
|
||||||
{
|
{
|
||||||
CONST char* pszPath=PLGetString(pValuePath);//Do Not Free It
|
CONST char *pszPath=PLGetString(pValuePath);//Do Not Free It
|
||||||
p_pApp->pszGSWExtensionsFrameworkWebServerResources=SafeStrdup(pszPath);
|
p_pApp->pszGSWExtensionsFrameworkWebServerResources =
|
||||||
|
SafeStrdup(pszPath);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
/* // LogFilePath
|
/* // LogFilePath
|
||||||
sprintf(pszParents,"%s/%s",p_pszParents,p_pszAppName);
|
sprintf(pszParents,"%s/%s",p_pszParents,p_pszAppName);
|
||||||
pValueLogFilePath=GSWPropList_GetDictionaryEntry(p_propListApp,
|
pValueLogFilePath =
|
||||||
|
GSWPropList_GetDictionaryEntry(p_propListApp,
|
||||||
"logFilePath",
|
"logFilePath",
|
||||||
pszParents,
|
pszParents,
|
||||||
FALSE,//No Error If Not Exists
|
FALSE,//No Error If Not Exists
|
||||||
|
@ -507,7 +530,8 @@ BOOL GSWConfig_PropListApplicationToApplication(GSWApp* p_pApp,
|
||||||
{
|
{
|
||||||
proplist_t propListHeaders=NULL;
|
proplist_t propListHeaders=NULL;
|
||||||
sprintf(pszParents,"%s/%s",p_pszParents,p_pszAppName);
|
sprintf(pszParents,"%s/%s",p_pszParents,p_pszAppName);
|
||||||
propListHeaders=GSWPropList_GetDictionaryEntry(p_propListApp,
|
propListHeaders =
|
||||||
|
GSWPropList_GetDictionaryEntry(p_propListApp,
|
||||||
"headers",
|
"headers",
|
||||||
pszParents,
|
pszParents,
|
||||||
FALSE,//No Error If Not Exists
|
FALSE,//No Error If Not Exists
|
||||||
|
@ -525,14 +549,14 @@ BOOL GSWConfig_PropListApplicationToApplication(GSWApp* p_pApp,
|
||||||
// 1 = {
|
// 1 = {
|
||||||
// host=12.13.14.15;
|
// host=12.13.14.15;
|
||||||
// port=9001;
|
// port=9001;
|
||||||
// parameters= {
|
// parameters = {
|
||||||
// transport=socket;
|
// transport=socket;
|
||||||
// };
|
// };
|
||||||
// };
|
// };
|
||||||
// 2 = {
|
// 2 = {
|
||||||
// host=12.13.14.21;
|
// host=12.13.14.21;
|
||||||
// port=9001;
|
// port=9001;
|
||||||
// parameters= {
|
// parameters = {
|
||||||
// transport=socket;
|
// transport=socket;
|
||||||
// };
|
// };
|
||||||
// }
|
// }
|
||||||
|
@ -541,7 +565,8 @@ BOOL GSWConfig_PropListApplicationToApplication(GSWApp* p_pApp,
|
||||||
{
|
{
|
||||||
proplist_t propListInstances=NULL;
|
proplist_t propListInstances=NULL;
|
||||||
sprintf(pszParents,"%s/%s",p_pszParents,p_pszAppName);
|
sprintf(pszParents,"%s/%s",p_pszParents,p_pszAppName);
|
||||||
propListInstances=GSWPropList_GetDictionaryEntry(p_propListApp,
|
propListInstances =
|
||||||
|
GSWPropList_GetDictionaryEntry(p_propListApp,
|
||||||
"instances",
|
"instances",
|
||||||
pszParents,
|
pszParents,
|
||||||
TRUE,//Error If Not Exists
|
TRUE,//Error If Not Exists
|
||||||
|
@ -553,7 +578,8 @@ BOOL GSWConfig_PropListApplicationToApplication(GSWApp* p_pApp,
|
||||||
//Next get Array Of Instances Names
|
//Next get Array Of Instances Names
|
||||||
//1,3,5
|
//1,3,5
|
||||||
//We'll have to destroy propListInstancesNums
|
//We'll have to destroy propListInstancesNums
|
||||||
proplist_t propListInstancesNums=GSWPropList_GetAllDictionaryKeys(propListInstances,
|
proplist_t propListInstancesNums =
|
||||||
|
GSWPropList_GetAllDictionaryKeys(propListInstances,
|
||||||
pszParents,//Parents
|
pszParents,//Parents
|
||||||
TRUE,//Error If Not Exists
|
TRUE,//Error If Not Exists
|
||||||
GSWPropList_TestArray,//TestFn
|
GSWPropList_TestArray,//TestFn
|
||||||
|
@ -561,12 +587,14 @@ BOOL GSWConfig_PropListApplicationToApplication(GSWApp* p_pApp,
|
||||||
if (propListInstancesNums)
|
if (propListInstancesNums)
|
||||||
{
|
{
|
||||||
//Nb Of Instances
|
//Nb Of Instances
|
||||||
unsigned int uInstancesNb=PLGetNumberOfElements(propListInstancesNums);
|
unsigned int uInstancesNb =
|
||||||
|
PLGetNumberOfElements(propListInstancesNums);
|
||||||
//For Each Instance
|
//For Each Instance
|
||||||
for(iInstanceIndex=0;iInstanceIndex<uInstancesNb;iInstanceIndex++)
|
for(iInstanceIndex=0;iInstanceIndex<uInstancesNb;iInstanceIndex++)
|
||||||
{
|
{
|
||||||
//Get Instance Num Key
|
//Get Instance Num Key
|
||||||
proplist_t propListInstanceNumKey=GSWPropList_GetArrayElement(propListInstancesNums,
|
proplist_t propListInstanceNumKey =
|
||||||
|
GSWPropList_GetArrayElement(propListInstancesNums,
|
||||||
iInstanceIndex,
|
iInstanceIndex,
|
||||||
pszParents,
|
pszParents,
|
||||||
TRUE,
|
TRUE,
|
||||||
|
@ -575,18 +603,18 @@ BOOL GSWConfig_PropListApplicationToApplication(GSWApp* p_pApp,
|
||||||
if (propListInstanceNumKey)
|
if (propListInstanceNumKey)
|
||||||
{
|
{
|
||||||
//Get Instance Num (1)
|
//Get Instance Num (1)
|
||||||
CONST char* pszInstanceNum=PLGetString(propListInstanceNumKey);//Do Not Free It
|
CONST char *pszInstanceNum =
|
||||||
|
PLGetString(propListInstanceNumKey);//Do Not Free It
|
||||||
proplist_t propListInstance=NULL;
|
proplist_t propListInstance=NULL;
|
||||||
|
|
||||||
//Get Instance PropList
|
//Get Instance PropList
|
||||||
// {
|
// {
|
||||||
// host=12.13.14.15;
|
// host = 12.13.14.15;
|
||||||
// port=9001;
|
// port = 9001;
|
||||||
// parameters= {
|
// parameters = { transport=socket; };
|
||||||
// transport=socket;
|
|
||||||
// };
|
// };
|
||||||
// };
|
propListInstance =
|
||||||
propListInstance=GSWPropList_GetDictionaryEntry(propListInstances,
|
GSWPropList_GetDictionaryEntry(propListInstances,
|
||||||
pszInstanceNum,
|
pszInstanceNum,
|
||||||
pszParents,
|
pszParents,
|
||||||
TRUE,
|
TRUE,
|
||||||
|
@ -596,7 +624,8 @@ BOOL GSWConfig_PropListApplicationToApplication(GSWApp* p_pApp,
|
||||||
if (propListInstance)
|
if (propListInstance)
|
||||||
{
|
{
|
||||||
BOOL fNew=NO;
|
BOOL fNew=NO;
|
||||||
GSWAppInstance* pInstance=(GSWAppInstance*)GSWDict_ValueForKey(&p_pApp->stInstancesDict,
|
GSWAppInstance *pInstance = (GSWAppInstance*)
|
||||||
|
GSWDict_ValueForKey(&p_pApp->stInstancesDict,
|
||||||
pszInstanceNum);
|
pszInstanceNum);
|
||||||
if (!pInstance)
|
if (!pInstance)
|
||||||
{
|
{
|
||||||
|
@ -610,11 +639,16 @@ BOOL GSWConfig_PropListApplicationToApplication(GSWApp* p_pApp,
|
||||||
pszParents,
|
pszParents,
|
||||||
p_pLogServerData);
|
p_pLogServerData);
|
||||||
if (fNew)
|
if (fNew)
|
||||||
GSWApp_AddInstance(p_pApp,pszInstanceNum,pInstance);
|
{
|
||||||
|
GSWApp_AddInstance(p_pApp,
|
||||||
|
pszInstanceNum,
|
||||||
|
pInstance);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
PLRelease(propListInstancesNums);//Because it's a newly created proplist
|
PLRelease(propListInstancesNums);
|
||||||
|
//Because it's a newly created proplist
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -624,7 +658,8 @@ BOOL GSWConfig_PropListApplicationToApplication(GSWApp* p_pApp,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
BOOL GSWConfig_LoadConfiguration(void* p_pLogServerData)
|
BOOL
|
||||||
|
GSWConfig_LoadConfiguration(void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
BOOL fOk=TRUE;
|
BOOL fOk=TRUE;
|
||||||
proplist_t propListConfig=NULL;
|
proplist_t propListConfig=NULL;
|
||||||
|
@ -633,7 +668,9 @@ BOOL GSWConfig_LoadConfiguration(void* p_pLogServerData)
|
||||||
"GSWeb: GSWConfig_LoadConfiguration");
|
"GSWeb: GSWConfig_LoadConfiguration");
|
||||||
GSWLock_Lock(g_lockAppList);
|
GSWLock_Lock(g_lockAppList);
|
||||||
if (!g_pAppDict)
|
if (!g_pAppDict)
|
||||||
|
{
|
||||||
g_pAppDict = GSWDict_New(16);
|
g_pAppDict = GSWDict_New(16);
|
||||||
|
}
|
||||||
|
|
||||||
if (GSWConfig_ReadIFND(GSWConfig_GetConfigFilePath(),
|
if (GSWConfig_ReadIFND(GSWConfig_GetConfigFilePath(),
|
||||||
&config_mtime,
|
&config_mtime,
|
||||||
|
@ -647,7 +684,8 @@ BOOL GSWConfig_LoadConfiguration(void* p_pLogServerData)
|
||||||
{
|
{
|
||||||
proplist_t pValueCanDumpStatus=NULL;
|
proplist_t pValueCanDumpStatus=NULL;
|
||||||
g_gswConfig.fCanDumpStatus=NO;
|
g_gswConfig.fCanDumpStatus=NO;
|
||||||
pValueCanDumpStatus=GSWPropList_GetDictionaryEntry(propListConfig,
|
pValueCanDumpStatus =
|
||||||
|
GSWPropList_GetDictionaryEntry(propListConfig,
|
||||||
"canDumpStatus",
|
"canDumpStatus",
|
||||||
NULL,
|
NULL,
|
||||||
FALSE,//No Error If Not Exists
|
FALSE,//No Error If Not Exists
|
||||||
|
@ -655,7 +693,8 @@ BOOL GSWConfig_LoadConfiguration(void* p_pLogServerData)
|
||||||
p_pLogServerData);
|
p_pLogServerData);
|
||||||
if (pValueCanDumpStatus)
|
if (pValueCanDumpStatus)
|
||||||
{
|
{
|
||||||
CONST char* pszCanDumpStatus=PLGetString(pValueCanDumpStatus);//Do Not Free It
|
CONST char *pszCanDumpStatus=PLGetString(pValueCanDumpStatus);
|
||||||
|
//Do Not Free It
|
||||||
g_gswConfig.fCanDumpStatus=(strcasecmp(pszCanDumpStatus,"YES")==0);
|
g_gswConfig.fCanDumpStatus=(strcasecmp(pszCanDumpStatus,"YES")==0);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -668,7 +707,8 @@ BOOL GSWConfig_LoadConfiguration(void* p_pLogServerData)
|
||||||
free(g_gswConfig.pszAdaptorTemplatesPath);
|
free(g_gswConfig.pszAdaptorTemplatesPath);
|
||||||
g_gswConfig.pszAdaptorTemplatesPath=NULL;
|
g_gswConfig.pszAdaptorTemplatesPath=NULL;
|
||||||
};
|
};
|
||||||
pValueAdaptorTemplatesPath=GSWPropList_GetDictionaryEntry(propListConfig,
|
pValueAdaptorTemplatesPath =
|
||||||
|
GSWPropList_GetDictionaryEntry(propListConfig,
|
||||||
"adaptorTemplatesPath",
|
"adaptorTemplatesPath",
|
||||||
NULL,
|
NULL,
|
||||||
FALSE,//No Error If Not Exists
|
FALSE,//No Error If Not Exists
|
||||||
|
@ -676,7 +716,8 @@ BOOL GSWConfig_LoadConfiguration(void* p_pLogServerData)
|
||||||
p_pLogServerData);
|
p_pLogServerData);
|
||||||
if (pValueAdaptorTemplatesPath)
|
if (pValueAdaptorTemplatesPath)
|
||||||
{
|
{
|
||||||
CONST char* pszPath=PLGetString(pValueAdaptorTemplatesPath);//Do Not Free It
|
CONST char *pszPath=PLGetString(pValueAdaptorTemplatesPath);
|
||||||
|
//Do Not Free It
|
||||||
g_gswConfig.pszAdaptorTemplatesPath=SafeStrdup(pszPath);
|
g_gswConfig.pszAdaptorTemplatesPath=SafeStrdup(pszPath);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -689,7 +730,8 @@ BOOL GSWConfig_LoadConfiguration(void* p_pLogServerData)
|
||||||
free(g_gswConfig.pszGSWExtensionsFrameworkWebServerResources);
|
free(g_gswConfig.pszGSWExtensionsFrameworkWebServerResources);
|
||||||
g_gswConfig.pszGSWExtensionsFrameworkWebServerResources=NULL;
|
g_gswConfig.pszGSWExtensionsFrameworkWebServerResources=NULL;
|
||||||
};
|
};
|
||||||
pValuePath=GSWPropList_GetDictionaryEntry(propListConfig,
|
pValuePath =
|
||||||
|
GSWPropList_GetDictionaryEntry(propListConfig,
|
||||||
"GSWExtensionsFrameworkWebServerResources",
|
"GSWExtensionsFrameworkWebServerResources",
|
||||||
NULL,
|
NULL,
|
||||||
FALSE,//No Error If Not Exists
|
FALSE,//No Error If Not Exists
|
||||||
|
@ -697,43 +739,38 @@ BOOL GSWConfig_LoadConfiguration(void* p_pLogServerData)
|
||||||
p_pLogServerData);
|
p_pLogServerData);
|
||||||
if (pValuePath)
|
if (pValuePath)
|
||||||
{
|
{
|
||||||
CONST char* pszPath=PLGetString(pValuePath);//Do Not Free It
|
CONST char *pszPath=PLGetString(pValuePath);//Do Not Free It
|
||||||
g_gswConfig.pszGSWExtensionsFrameworkWebServerResources=SafeStrdup(pszPath);
|
g_gswConfig.pszGSWExtensionsFrameworkWebServerResources =
|
||||||
|
SafeStrdup(pszPath);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//Get Dictionary Of Applications
|
//Get Dictionary Of Applications
|
||||||
// {
|
// {
|
||||||
// MyApp1 = {
|
// MyApp1 = (
|
||||||
// instances = (
|
// instances = (
|
||||||
// {
|
// {
|
||||||
// instanceNum=1;
|
// instanceNum = 1;
|
||||||
// host=12.13.14.15;
|
// host = 12.13.14.15;
|
||||||
// port=9001;
|
// port = 9001;
|
||||||
// parameters= {
|
// parameters = { transport=socket; };
|
||||||
// transport=socket;
|
|
||||||
// };
|
|
||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// instanceNum=2;
|
// instanceNum = 2;
|
||||||
// host=12.13.14.21;
|
// host = 12.13.14.21;
|
||||||
// port=9001;
|
// port = 9001;
|
||||||
// parameters= {
|
// parameters = { transport=socket; };
|
||||||
// transport=socket;
|
|
||||||
// };
|
// };
|
||||||
// }
|
|
||||||
// );
|
// );
|
||||||
// };
|
// );
|
||||||
// MyApp2 = {
|
// MyApp2 = (
|
||||||
// instances = (
|
// instances = (
|
||||||
// {
|
// {
|
||||||
// instanceNum=1;
|
// instanceNum = 1;
|
||||||
// host=12.13.14.15;
|
// host = 12.13.14.15;
|
||||||
// port=9001;
|
// port = 9001;
|
||||||
// parameters= {
|
// parameters = { transport=socket; };
|
||||||
// transport=socket;
|
|
||||||
// };
|
|
||||||
// }
|
// }
|
||||||
// );
|
// );
|
||||||
// };
|
// };
|
||||||
|
@ -741,16 +778,15 @@ BOOL GSWConfig_LoadConfiguration(void* p_pLogServerData)
|
||||||
// canDump = YES;
|
// canDump = YES;
|
||||||
// instances = (
|
// instances = (
|
||||||
// {
|
// {
|
||||||
// instanceNum=1;
|
// instanceNum = 1;
|
||||||
// host=12.13.14.15;
|
// host = 12.13.14.15;
|
||||||
// port=9002;
|
// port = 9002;
|
||||||
// parameters= {
|
// parameters = { transport=socket; };
|
||||||
// transport=socket;
|
|
||||||
// };
|
|
||||||
// }
|
// }
|
||||||
// );
|
// );
|
||||||
// };
|
// };
|
||||||
propListApps=GSWPropList_GetDictionaryEntry(propListConfig,//Dictionary
|
propListApps =
|
||||||
|
GSWPropList_GetDictionaryEntry(propListConfig,//Dictionary
|
||||||
"applications",//Key
|
"applications",//Key
|
||||||
NULL,//No Parents
|
NULL,//No Parents
|
||||||
TRUE,//Error If Not Exists
|
TRUE,//Error If Not Exists
|
||||||
|
@ -762,7 +798,8 @@ BOOL GSWConfig_LoadConfiguration(void* p_pLogServerData)
|
||||||
//Next get Array Of App Names
|
//Next get Array Of App Names
|
||||||
//MyApp1,MyApp2,MyApp3
|
//MyApp1,MyApp2,MyApp3
|
||||||
//We'll have to destroy propListAppsNames
|
//We'll have to destroy propListAppsNames
|
||||||
proplist_t propListAppsNames=GSWPropList_GetAllDictionaryKeys(propListApps,
|
proplist_t propListAppsNames =
|
||||||
|
GSWPropList_GetAllDictionaryKeys(propListApps,
|
||||||
"applications",//Parents
|
"applications",//Parents
|
||||||
TRUE,//Error If Not Exists
|
TRUE,//Error If Not Exists
|
||||||
GSWPropList_TestArray,//TestFn
|
GSWPropList_TestArray,//TestFn
|
||||||
|
@ -775,7 +812,8 @@ BOOL GSWConfig_LoadConfiguration(void* p_pLogServerData)
|
||||||
for(iAppIndex=0;iAppIndex<uAppNb;iAppIndex++)
|
for(iAppIndex=0;iAppIndex<uAppNb;iAppIndex++)
|
||||||
{
|
{
|
||||||
//Get Application Name Key
|
//Get Application Name Key
|
||||||
proplist_t propListAppKey=GSWPropList_GetArrayElement(propListAppsNames,
|
proplist_t propListAppKey =
|
||||||
|
GSWPropList_GetArrayElement(propListAppsNames,
|
||||||
iAppIndex,
|
iAppIndex,
|
||||||
"applications",
|
"applications",
|
||||||
TRUE,
|
TRUE,
|
||||||
|
@ -784,31 +822,29 @@ BOOL GSWConfig_LoadConfiguration(void* p_pLogServerData)
|
||||||
if (propListAppKey)
|
if (propListAppKey)
|
||||||
{
|
{
|
||||||
//Get Application Name (MyApp1)
|
//Get Application Name (MyApp1)
|
||||||
CONST char* pszAppName=PLGetString(propListAppKey);//Do Not Free It
|
CONST char *pszAppName=PLGetString(propListAppKey);
|
||||||
|
//Do Not Free It
|
||||||
proplist_t propListApp=NULL;
|
proplist_t propListApp=NULL;
|
||||||
|
|
||||||
//Get Application PropList
|
//Get Application PropList
|
||||||
// {
|
// {
|
||||||
// instances = (
|
// instances = (
|
||||||
// {
|
// {
|
||||||
// instanceNum=1;
|
// instanceNum = 1;
|
||||||
// host=12.13.14.15;
|
// host = 12.13.14.15;
|
||||||
// port=9001;
|
// port = 9001;
|
||||||
// parameters= {
|
// parameters = { transport=socket; };
|
||||||
// transport=socket;
|
|
||||||
// };
|
|
||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// instanceNum=2;
|
// instanceNum = 2;
|
||||||
// host=12.13.14.21;
|
// host = 12.13.14.21;
|
||||||
// port=9001;
|
// port = 9001;
|
||||||
// parameters= {
|
// parameters = { transport=socket; };
|
||||||
// transport=socket;
|
|
||||||
// };
|
|
||||||
// }
|
// }
|
||||||
// );
|
// );
|
||||||
// };
|
// };
|
||||||
propListApp=GSWPropList_GetDictionaryEntry(propListApps,
|
propListApp =
|
||||||
|
GSWPropList_GetDictionaryEntry(propListApps,
|
||||||
pszAppName,
|
pszAppName,
|
||||||
"applications",
|
"applications",
|
||||||
TRUE,
|
TRUE,
|
||||||
|
@ -816,8 +852,10 @@ BOOL GSWConfig_LoadConfiguration(void* p_pLogServerData)
|
||||||
p_pLogServerData);
|
p_pLogServerData);
|
||||||
if (propListApp)
|
if (propListApp)
|
||||||
{
|
{
|
||||||
BOOL fNew=NO;
|
BOOL fNew = NO;
|
||||||
GSWApp* pApp=(GSWApp*)GSWDict_ValueForKey(g_pAppDict,pszAppName);
|
GSWApp *pApp =
|
||||||
|
(GSWApp *)GSWDict_ValueForKey(g_pAppDict,
|
||||||
|
pszAppName);
|
||||||
if (!pApp)
|
if (!pApp)
|
||||||
{
|
{
|
||||||
fNew=YES;
|
fNew=YES;
|
||||||
|
@ -838,20 +876,24 @@ BOOL GSWConfig_LoadConfiguration(void* p_pLogServerData)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (fNew)
|
if (fNew)
|
||||||
GSWDict_Add(g_pAppDict,pApp->pszName,pApp,FALSE);//NotOwner
|
GSWDict_Add(g_pAppDict,pApp->pszName,pApp,
|
||||||
|
FALSE);//NotOwner
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
PLRelease(propListAppsNames);//Because it's a newly created proplist
|
PLRelease(propListAppsNames);
|
||||||
|
//Because it's a newly created proplist
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
if (propListConfig)
|
if (propListConfig)
|
||||||
PLRelease(propListConfig);
|
PLRelease(propListConfig);
|
||||||
{
|
{
|
||||||
GSWString* pString=GSWConfig_DumpGSWApps(NULL,g_szGSWeb_Prefix,TRUE,FALSE,p_pLogServerData);
|
GSWString *pString=GSWConfig_DumpGSWApps(NULL,g_szGSWeb_Prefix,
|
||||||
GSWLogSized(GSW_INFO,p_pLogServerData,SafeStrlen(pString->pszData),"Config: %s",pString->pszData);
|
TRUE,FALSE,p_pLogServerData);
|
||||||
|
GSWLogSized(GSW_INFO,p_pLogServerData,SafeStrlen(pString->pszData),
|
||||||
|
"Config: %s",pString->pszData);
|
||||||
GSWString_Free(pString);
|
GSWString_Free(pString);
|
||||||
};
|
};
|
||||||
GSWLock_Unlock(g_lockAppList);
|
GSWLock_Unlock(g_lockAppList);
|
||||||
|
@ -861,23 +903,25 @@ BOOL GSWConfig_LoadConfiguration(void* p_pLogServerData)
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
typedef struct _GSWDumpParams
|
typedef struct _GSWDumpParams
|
||||||
{
|
{
|
||||||
GSWString* pBuffer;
|
GSWString *pBuffer;
|
||||||
GSWApp* pApp;
|
GSWApp *pApp;
|
||||||
CONST char* pszPrefix;
|
CONST char *pszPrefix;
|
||||||
BOOL fForceDump;
|
BOOL fForceDump;
|
||||||
BOOL fHTML;
|
BOOL fHTML;
|
||||||
void* pLogServerData;
|
void *pLogServerData;
|
||||||
} GSWDumpParams;
|
} GSWDumpParams;
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWConfig_DumpGSWAppInstanceIntern(GSWDictElem* p_pElem,void* p_pData)
|
void
|
||||||
|
GSWConfig_DumpGSWAppInstanceIntern(GSWDictElem *p_pElem,
|
||||||
|
void *p_pData)
|
||||||
{
|
{
|
||||||
GSWString* pBuffer=GSWString_New();
|
GSWString *pBuffer=GSWString_New();
|
||||||
char szBuffer[4096]="";
|
char szBuffer[4096]="";
|
||||||
GSWAppInstance* pAppInstance=(GSWAppInstance*)p_pElem->pValue;
|
GSWAppInstance *pAppInstance=(GSWAppInstance *)p_pElem->pValue;
|
||||||
GSWDumpParams* pParams=(GSWDumpParams*)p_pData;
|
GSWDumpParams *pParams=(GSWDumpParams *)p_pData;
|
||||||
char* pszString=NULL;
|
char *pszString=NULL;
|
||||||
|
|
||||||
//Template
|
//Template
|
||||||
pszString=GSWTemplate_GetDumpAppInstance(pParams->fHTML);
|
pszString=GSWTemplate_GetDumpAppInstance(pParams->fHTML);
|
||||||
|
@ -914,15 +958,18 @@ void GSWConfig_DumpGSWAppInstanceIntern(GSWDictElem* p_pElem,void* p_pData)
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWConfig_DumpGSWAppIntern(GSWDictElem* p_pElem,void* p_pData)
|
void
|
||||||
|
GSWConfig_DumpGSWAppIntern(GSWDictElem *p_pElem,
|
||||||
|
void *p_pData)
|
||||||
{
|
{
|
||||||
GSWApp* pApp=(GSWApp*)(p_pElem->pValue);
|
GSWApp *pApp=(GSWApp *)(p_pElem->pValue);
|
||||||
GSWDumpParams* pParams=(GSWDumpParams*)p_pData;
|
GSWDumpParams *pParams=(GSWDumpParams *)p_pData;
|
||||||
|
|
||||||
if (pParams->fForceDump || pApp->fCanDump)
|
if (pParams->fForceDump || pApp->fCanDump)
|
||||||
{
|
{
|
||||||
GSWString* pBuffer=GSWString_New();
|
GSWString *pBuffer=GSWString_New();
|
||||||
char szBuffer[4096]="";
|
char szBuffer[4096]="";
|
||||||
char* pszString=NULL;
|
char *pszString=NULL;
|
||||||
|
|
||||||
//Template
|
//Template
|
||||||
pszString=GSWTemplate_GetDumpApp(pParams->fHTML);
|
pszString=GSWTemplate_GetDumpApp(pParams->fHTML);
|
||||||
|
@ -941,14 +988,15 @@ void GSWConfig_DumpGSWAppIntern(GSWDictElem* p_pElem,void* p_pData)
|
||||||
|
|
||||||
//AppInstances
|
//AppInstances
|
||||||
{
|
{
|
||||||
GSWString* pInstancesBuffer=GSWString_New();
|
GSWString *pInstancesBuffer=GSWString_New();
|
||||||
GSWString* pParamsBuffer=pParams->pBuffer;
|
GSWString *pParamsBuffer=pParams->pBuffer;
|
||||||
pParams->pBuffer=pInstancesBuffer;
|
pParams->pBuffer=pInstancesBuffer;
|
||||||
pParams->pApp=pApp;
|
pParams->pApp=pApp;
|
||||||
GSWDict_PerformForAllElem(&pApp->stInstancesDict,
|
GSWDict_PerformForAllElem(&pApp->stInstancesDict,
|
||||||
GSWConfig_DumpGSWAppInstanceIntern,
|
GSWConfig_DumpGSWAppInstanceIntern,
|
||||||
pParams);
|
pParams);
|
||||||
GSWString_SearchReplace(pBuffer,"##INSTANCES##",pInstancesBuffer->pszData);
|
GSWString_SearchReplace(pBuffer,"##INSTANCES##",
|
||||||
|
pInstancesBuffer->pszData);
|
||||||
pParams->pBuffer=pParamsBuffer;
|
pParams->pBuffer=pParamsBuffer;
|
||||||
GSWString_Free(pInstancesBuffer);
|
GSWString_Free(pInstancesBuffer);
|
||||||
pInstancesBuffer=NULL;
|
pInstancesBuffer=NULL;
|
||||||
|
@ -965,15 +1013,17 @@ void GSWConfig_DumpGSWAppIntern(GSWDictElem* p_pElem,void* p_pData)
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
GSWString* GSWConfig_DumpGSWApps(const char* p_pszReqApp,
|
GSWString *
|
||||||
const char* p_pszPrefix,
|
GSWConfig_DumpGSWApps(const char *p_pszReqApp,
|
||||||
|
const char *p_pszPrefix,
|
||||||
BOOL p_fForceDump,
|
BOOL p_fForceDump,
|
||||||
BOOL p_fHTML,
|
BOOL p_fHTML,
|
||||||
void* p_pLogServerData)
|
void *p_pLogServerData)
|
||||||
{
|
{
|
||||||
GSWString* pBuffer=GSWString_New();
|
GSWString *pBuffer=GSWString_New();
|
||||||
GSWDumpParams stParams;
|
GSWDumpParams stParams;
|
||||||
char* pszString=NULL;
|
char *pszString=NULL;
|
||||||
|
|
||||||
GSWLock_Lock(g_lockAppList);
|
GSWLock_Lock(g_lockAppList);
|
||||||
|
|
||||||
stParams.pBuffer=GSWString_New();
|
stParams.pBuffer=GSWString_New();
|
||||||
|
@ -1012,37 +1062,43 @@ GSWString* GSWConfig_DumpGSWApps(const char* p_pszReqApp,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
GSWApp* GSWConfig_GetApp(CONST char* p_pszAppName)
|
GSWApp *
|
||||||
|
GSWConfig_GetApp(CONST char *p_pszAppName)
|
||||||
{
|
{
|
||||||
return (GSWApp*)GSWDict_ValueForKey(g_pAppDict,p_pszAppName);
|
return (GSWApp *)GSWDict_ValueForKey(g_pAppDict,p_pszAppName);
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
CONST char* GSWConfig_AdaptorBuilt()
|
CONST char *
|
||||||
|
GSWConfig_AdaptorBuilt()
|
||||||
{
|
{
|
||||||
return g_szAdaptorBuilt;
|
return g_szAdaptorBuilt;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
CONST char* GSWConfig_ServerStringInfo()
|
CONST char *
|
||||||
|
GSWConfig_ServerStringInfo()
|
||||||
{
|
{
|
||||||
return g_szServerStringInfo;
|
return g_szServerStringInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
CONST char* g_szGSWeb_AdaptorStringInfo()
|
CONST char *
|
||||||
|
g_szGSWeb_AdaptorStringInfo()
|
||||||
{
|
{
|
||||||
return g_szAdaptorStringInfo;
|
return g_szAdaptorStringInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
CONST char* GSWConfig_ServerURL()
|
CONST char *
|
||||||
|
GSWConfig_ServerURL()
|
||||||
{
|
{
|
||||||
return GSWServerURL;
|
return GSWServerURL;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
CONST char* g_szGSWeb_AdaptorURL()
|
CONST char *
|
||||||
|
g_szGSWeb_AdaptorURL()
|
||||||
{
|
{
|
||||||
return "http://www.gnustepweb.org";
|
return "http://www.gnustepweb.org";
|
||||||
};
|
};
|
||||||
|
|
|
@ -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.
|
||||||
|
|
||||||
|
@ -39,45 +39,45 @@
|
||||||
|
|
||||||
|
|
||||||
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,7 +29,8 @@
|
||||||
#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)
|
||||||
{
|
{
|
||||||
|
@ -41,7 +42,8 @@ void GSWDict_SetCapacity(GSWDict* p_pDict,unsigned int p_uCapacity)
|
||||||
if (p_uCapacity>p_pDict->uCapacity)
|
if (p_uCapacity>p_pDict->uCapacity)
|
||||||
{
|
{
|
||||||
if (p_pDict->pElems)
|
if (p_pDict->pElems)
|
||||||
p_pDict->pElems = realloc(p_pDict->pElems,p_uCapacity*sizeof(GSWDictElem));
|
p_pDict->pElems = realloc(p_pDict->pElems,
|
||||||
|
p_uCapacity*sizeof(GSWDictElem));
|
||||||
else
|
else
|
||||||
p_pDict->pElems = malloc(p_uCapacity*sizeof(GSWDictElem));
|
p_pDict->pElems = malloc(p_uCapacity*sizeof(GSWDictElem));
|
||||||
p_pDict->uCapacity = p_uCapacity;
|
p_pDict->uCapacity = p_uCapacity;
|
||||||
|
@ -49,15 +51,17 @@ void GSWDict_SetCapacity(GSWDict* p_pDict,unsigned int 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)
|
||||||
{
|
{
|
||||||
|
@ -67,23 +71,25 @@ void GSWDict_FreeElem(GSWDictElem* p_pElem,void* p_pData)
|
||||||
{
|
{
|
||||||
if (p_pElem->pszKey)
|
if (p_pElem->pszKey)
|
||||||
{
|
{
|
||||||
free((char*)p_pElem->pszKey);
|
free((char *)p_pElem->pszKey);
|
||||||
p_pElem->pszKey=NULL;
|
p_pElem->pszKey=NULL;
|
||||||
};
|
};
|
||||||
if (p_pElem->pValue && p_pElem->fValueOwner)
|
if (p_pElem->pValue && p_pElem->fValueOwner)
|
||||||
{
|
{
|
||||||
free((void*)p_pElem->pValue);
|
free((void *)p_pElem->pValue);
|
||||||
};
|
};
|
||||||
p_pElem->pValue=NULL;
|
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)
|
||||||
{
|
{
|
||||||
|
@ -99,17 +105,19 @@ void GSWDict_Free(GSWDict* 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)
|
||||||
|
@ -119,7 +127,7 @@ unsigned int GSWDict_Count(GSWDict* p_pDict)
|
||||||
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++;
|
||||||
|
@ -127,9 +135,13 @@ unsigned int GSWDict_Count(GSWDict* p_pDict)
|
||||||
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");
|
||||||
|
@ -161,20 +173,29 @@ void GSWDict_Add(GSWDict* p_pDict,CONST char* p_pszKey,CONST void* p_pValue,BOOL
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
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");
|
||||||
|
@ -188,22 +209,27 @@ static GSWDictElem* GSWDict_FindKey(GSWDict* p_pDict,CONST char* p_pszKey)
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -212,7 +238,7 @@ void GSWDict_PerformForAllElem(GSWDict* p_pDict,
|
||||||
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)
|
||||||
|
@ -221,9 +247,10 @@ void GSWDict_PerformForAllElem(GSWDict* p_pDict,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
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");
|
||||||
|
@ -231,7 +258,7 @@ GSWList* GSWDict_AllKeys(GSWDict* p_pDict)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
GSWDictElem* pElem=NULL;
|
GSWDictElem *pElem=NULL;
|
||||||
pList=GSWList_New(p_pDict->uCount);
|
pList=GSWList_New(p_pDict->uCount);
|
||||||
for (pElem=p_pDict->pElems;i<p_pDict->uCount;i++,pElem++)
|
for (pElem=p_pDict->pElems;i<p_pDict->uCount;i++,pElem++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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,7 +33,7 @@ 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;
|
||||||
|
|
||||||
|
@ -41,28 +41,38 @@ 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);
|
/*
|
||||||
|
GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTableItemsNb=%d",
|
||||||
|
GSWHeaderTranslationTableItemsNb);
|
||||||
for(i=0;i<GSWHeaderTranslationTableItemsNb-1;i++)
|
for(i=0;i<GSWHeaderTranslationTableItemsNb-1;i++)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTable[i].pszHTTP=%s",GSWHeaderTranslationTable[i].pszHTTP);
|
GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTable[i].pszHTTP=%s",
|
||||||
GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTable[i].pszGSWeb=%s",GSWHeaderTranslationTable[i].pszGSWeb);
|
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,14 +132,14 @@ 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 },
|
||||||
|
@ -149,7 +149,7 @@ static const GSWHeaderTranslationItem GSWHeaderTranslationTable[] =
|
||||||
{ 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 },
|
||||||
|
|
|
@ -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,7 +59,9 @@ 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)
|
||||||
|
@ -83,13 +88,16 @@ void GSWHTTPRequest_Free(GSWHTTPRequest* p_pHTTPRequest,void* p_pLogServerData)
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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,
|
||||||
|
"No Request in GSWHTTPRequest_ValidateMethod");
|
||||||
pszMsg="No Request in GSWHTTPRequest_ValidateMethod";
|
pszMsg="No Request in GSWHTTPRequest_ValidateMethod";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -115,15 +123,17 @@ CONST char* GSWHTTPRequest_ValidateMethod(GSWHTTPRequest* p_pHTTPRequest,void* p
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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);
|
||||||
|
@ -140,18 +150,21 @@ void GSWHTTPRequest_HTTPToAppRequest(GSWHTTPRequest* p_pHTTPRequest,
|
||||||
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,
|
||||||
|
@ -163,17 +176,19 @@ void GSWHTTPRequest_HTTPToAppRequest(GSWHTTPRequest* p_pHTTPRequest,
|
||||||
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);
|
||||||
|
@ -188,7 +203,9 @@ void GSWHTTPRequest_AddHeader(GSWHTTPRequest* p_pHTTPRequest,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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);
|
||||||
|
@ -197,23 +214,25 @@ CONST char* GSWHTTPRequest_HeaderForKey(GSWHTTPRequest* p_pHTTPRequest,CONST cha
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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;
|
||||||
|
@ -257,7 +279,7 @@ BOOL GSWHTTPRequest_SendRequest(GSWHTTPRequest* p_pHTTPRequest,AppConnectHandle
|
||||||
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';
|
||||||
|
|
||||||
|
@ -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,
|
||||||
|
char *p_pszBuffer,
|
||||||
int p_iBufferSize)
|
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,7 +332,8 @@ static char* GSWHTTPRequest_PackageHeaders(GSWHTTPRequest* p_pHTTPRequest,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
static ERequestMethod GetHTTPRequestMethod(CONST char* pszMethod)
|
static ERequestMethod
|
||||||
|
GetHTTPRequestMethod(CONST char *pszMethod)
|
||||||
{
|
{
|
||||||
if (pszMethod)
|
if (pszMethod)
|
||||||
{
|
{
|
||||||
|
@ -328,21 +353,25 @@ static ERequestMethod GetHTTPRequestMethod(CONST char* pszMethod)
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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
|
||||||
|
@ -350,9 +379,10 @@ static int compareHeader(CONST void* p_pKey0,CONST void* p_pKey1)
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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,
|
||||||
|
@ -362,3 +392,4 @@ static CONST char* GSWebHeaderForHTTPHeader(CONST char* p_pszHTTPHeader)
|
||||||
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.
|
||||||
|
|
||||||
|
@ -44,44 +44,44 @@ 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,15 +42,17 @@
|
||||||
#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
|
||||||
|
@ -59,7 +61,7 @@ GSWHTTPResponse* GSWHTTPResponse_New(CONST char* p_pszStatus,void* p_pLogServerD
|
||||||
if (strncmp(p_pszStatus,HTTP_SLASH,strlen(HTTP_SLASH))==0)
|
if (strncmp(p_pszStatus,HTTP_SLASH,strlen(HTTP_SLASH))==0)
|
||||||
{
|
{
|
||||||
// Status Code
|
// Status Code
|
||||||
CONST char* pszSpace=strchr(p_pszStatus,' ');
|
CONST char *pszSpace=strchr(p_pszStatus,' ');
|
||||||
if (pszSpace)
|
if (pszSpace)
|
||||||
{
|
{
|
||||||
unsigned int uStatus=0;
|
unsigned int uStatus=0;
|
||||||
|
@ -95,21 +97,25 @@ GSWHTTPResponse* GSWHTTPResponse_New(CONST char* p_pszStatus,void* p_pLogServerD
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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]);
|
||||||
|
@ -121,10 +127,12 @@ GSWHTTPResponse* GSWHTTPResponse_BuildErrorResponse(GSWAppRequest* p_pAppRequest
|
||||||
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##",
|
||||||
|
p_pAppRequest->pszName);
|
||||||
sprintf(szBuffer,"%d",p_pAppRequest->iInstance);
|
sprintf(szBuffer,"%d",p_pAppRequest->iInstance);
|
||||||
GSWString_SearchReplace(pBufferMessage,"##APP_INSTANCE##",szBuffer);
|
GSWString_SearchReplace(pBufferMessage,"##APP_INSTANCE##",szBuffer);
|
||||||
GSWString_SearchReplace(pBufferMessage,"##APP_HOST##",p_pAppRequest->pszHost);
|
GSWString_SearchReplace(pBufferMessage,"##APP_HOST##",
|
||||||
|
p_pAppRequest->pszHost);
|
||||||
sprintf(szBuffer,"%d",p_pAppRequest->iPort);
|
sprintf(szBuffer,"%d",p_pAppRequest->iPort);
|
||||||
GSWString_SearchReplace(pBufferMessage,"##APP_PORT##",szBuffer);
|
GSWString_SearchReplace(pBufferMessage,"##APP_PORT##",szBuffer);
|
||||||
};
|
};
|
||||||
|
@ -142,31 +150,38 @@ 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)
|
||||||
|
@ -193,10 +208,12 @@ void GSWHTTPResponse_Free(GSWHTTPResponse* p_pHTTPResponse,void* p_pLogServerDat
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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++)
|
||||||
{
|
{
|
||||||
|
@ -210,7 +227,8 @@ void GSWHTTPResponse_AddHeader(GSWHTTPResponse* p_pHTTPResponse,char* p_pszHeade
|
||||||
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 &&
|
||||||
|
strcmp(g_szHeader_ContentLength,pszKey)==0)
|
||||||
p_pHTTPResponse->uContentLength = atoi(pszValue);
|
p_pHTTPResponse->uContentLength = atoi(pszValue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -220,30 +238,37 @@ void GSWHTTPResponse_AddHeader(GSWHTTPResponse* p_pHTTPResponse,char* p_pszHeade
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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;
|
int iHeader=0;
|
||||||
// Headers
|
// Headers
|
||||||
while (GSWApp_ReceiveLine(p_socket,szResponseBuffer,RESPONSE__LINE_MAX_SIZE,p_pLogServerData)>0
|
while (GSWApp_ReceiveLine(p_socket,szResponseBuffer,
|
||||||
|
RESPONSE__LINE_MAX_SIZE,p_pLogServerData)>0
|
||||||
&& szResponseBuffer[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);
|
||||||
};
|
};
|
||||||
|
@ -251,14 +276,16 @@ GSWHTTPResponse* GSWHTTPResponse_GetResponse(AppConnectHandle p_socket,void* p_p
|
||||||
// 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,
|
GSWLog(GSW_ERROR,p_pLogServerData,
|
||||||
"Content received doesn't equal to ContentLength. Too bad, same player shoot again !");
|
"Content received doesn't equal to ContentLength. Too bad, same player shoot again !");
|
||||||
|
@ -267,7 +294,8 @@ pHTTPResponse->pContent = pszBuffer;//TODO: Verify this (Turbocat patch)
|
||||||
pszBuffer=NULL;
|
pszBuffer=NULL;
|
||||||
GSWHTTPResponse_Free(pHTTPResponse,p_pLogServerData);
|
GSWHTTPResponse_Free(pHTTPResponse,p_pLogServerData);
|
||||||
pHTTPResponse=NULL;
|
pHTTPResponse=NULL;
|
||||||
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse(NULL,"Invalid Response",p_pLogServerData);
|
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse(NULL,
|
||||||
|
"Invalid Response",p_pLogServerData);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -278,8 +306,10 @@ pHTTPResponse->pContent = pszBuffer;//TODO: Verify this (Turbocat patch)
|
||||||
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);
|
||||||
|
memcpy(szTraceBuffer,pHTTPResponse->pContent,
|
||||||
|
pHTTPResponse->uContentLength);
|
||||||
szTraceBuffer[pHTTPResponse->uContentLength] = 0;
|
szTraceBuffer[pHTTPResponse->uContentLength] = 0;
|
||||||
GSWLogSized(GSW_INFO,p_pLogServerData,
|
GSWLogSized(GSW_INFO,p_pLogServerData,
|
||||||
pHTTPResponse->uContentLength+1,
|
pHTTPResponse->uContentLength+1,
|
||||||
|
@ -297,24 +327,26 @@ pHTTPResponse->pContent = pszBuffer;//TODO: Verify this (Turbocat patch)
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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,18 +355,20 @@ static void FormatHeader(GSWDictElem* p_pElem,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
char *GSWHTTPResponse_PackageHeaders(GSWHTTPResponse* p_pHTTPResponse,
|
char *
|
||||||
char* p_pszBuffer,
|
GSWHTTPResponse_PackageHeaders(GSWHTTPResponse *p_pHTTPResponse,
|
||||||
|
char *p_pszBuffer,
|
||||||
int p_iBufferSize)
|
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);
|
||||||
|
@ -349,26 +383,33 @@ char *GSWHTTPResponse_PackageHeaders(GSWHTTPResponse* p_pHTTPResponse,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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,
|
||||||
|
@ -376,25 +417,30 @@ GSWHTTPResponse* GSWHTTPResponse_BuildStatusResponse(GSWHTTPRequest* p_pHTTPRequ
|
||||||
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,17 +451,21 @@ 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)
|
||||||
|
@ -425,22 +475,27 @@ GSWHTTPResponse* GSWDumpConfigFile(GSWURLComponents* p_pURLComponents,void* p_pL
|
||||||
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);
|
strncpy(szReqAppName,p_pURLComponents->stAppName.pszStart,
|
||||||
|
p_pURLComponents->stAppName.iLength);
|
||||||
szReqAppName[p_pURLComponents->stAppName.iLength]=0;
|
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,20 +29,23 @@
|
||||||
#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)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +59,9 @@ void GSWList_FreeElements(GSWList* p_pList)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
void GSWList_Free(GSWList* p_pList,BOOL p_fFreeElements)
|
void
|
||||||
|
GSWList_Free(GSWList *p_pList,
|
||||||
|
BOOL p_fFreeElements)
|
||||||
{
|
{
|
||||||
if (p_pList)
|
if (p_pList)
|
||||||
{
|
{
|
||||||
|
@ -72,15 +77,20 @@ 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)
|
||||||
{
|
{
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -90,7 +100,9 @@ void GSWList_RemoveAtIndex(GSWList* p_pList,int p_iIndex)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
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++)
|
||||||
|
@ -104,37 +116,50 @@ void GSWList_Remove(GSWList* p_pList,void* p_pElement)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
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,
|
||||||
|
p_uCapacity*sizeof(void *));
|
||||||
else
|
else
|
||||||
p_pList->ppElements=calloc(p_uCapacity, sizeof(void*));
|
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);
|
||||||
|
@ -58,16 +60,17 @@ BOOL GSWLoadBalancing_FindApp(GSWAppRequest* p_pAppRequest,
|
||||||
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;
|
pApp->iIndex = (pApp->iIndex+1) % uInstancesCount;
|
||||||
pAppInstance=(GSWAppInstance*)GSWDict_ValueForKey(&pApp->stInstancesDict,
|
pAppInstance =
|
||||||
|
(GSWAppInstance *)GSWDict_ValueForKey(&pApp->stInstancesDict,
|
||||||
GSWList_ElementAtIndex(pInstancesList,pApp->iIndex));
|
GSWList_ElementAtIndex(pInstancesList,pApp->iIndex));
|
||||||
if (pAppInstance)
|
if (pAppInstance)
|
||||||
{
|
{
|
||||||
|
@ -96,21 +99,30 @@ BOOL GSWLoadBalancing_FindApp(GSWAppRequest* p_pAppRequest,
|
||||||
{
|
{
|
||||||
BOOL okay = TRUE;
|
BOOL okay = TRUE;
|
||||||
// check if refused, time to try again ?
|
// check if refused, time to try again ?
|
||||||
if (p_pURLComponents->stRequestHandlerKey.iLength==0 || p_pURLComponents->stRequestHandlerKey.pszStart==NULL) {
|
if (p_pURLComponents->stRequestHandlerKey.iLength==0 ||
|
||||||
GSWAppInfo *thisAppInfo = GSWAppInfo_Find(p_pAppRequest->pszName, pAppInstance->iInstance);
|
p_pURLComponents->stRequestHandlerKey.pszStart==NULL)
|
||||||
if (thisAppInfo && thisAppInfo->isRefused) {
|
{
|
||||||
|
GSWAppInfo *thisAppInfo =
|
||||||
|
GSWAppInfo_Find(p_pAppRequest->pszName,
|
||||||
|
pAppInstance->iInstance);
|
||||||
|
if (thisAppInfo && thisAppInfo->isRefused)
|
||||||
|
{
|
||||||
time_t actTime = (time_t)0;
|
time_t actTime = (time_t)0;
|
||||||
// this instance refuses new sessions
|
// this instance refuses new sessions
|
||||||
time(&actTime);
|
time(&actTime);
|
||||||
if (actTime > thisAppInfo->timeNextRetryTime) {
|
if (actTime > thisAppInfo->timeNextRetryTime)
|
||||||
|
{
|
||||||
thisAppInfo->isRefused = FALSE; // try it again
|
thisAppInfo->isRefused = FALSE; // try it again
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
okay = FALSE; // try an other instance
|
okay = FALSE; // try an other instance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (okay == TRUE) {
|
if (okay == TRUE)
|
||||||
|
{
|
||||||
fFound = TRUE;
|
fFound = TRUE;
|
||||||
strcpy(p_pAppRequest->pszName,pApp->pszName);
|
strcpy(p_pAppRequest->pszName,pApp->pszName);
|
||||||
p_pAppRequest->iInstance = pAppInstance->iInstance;
|
p_pAppRequest->iInstance = pAppInstance->iInstance;
|
||||||
|
@ -128,7 +140,8 @@ BOOL GSWLoadBalancing_FindApp(GSWAppRequest* p_pAppRequest,
|
||||||
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,
|
||||||
|
"LoadBalance: looking for %s, fFound instance %d on %s:%d",
|
||||||
p_pAppRequest->pszName,
|
p_pAppRequest->pszName,
|
||||||
p_pAppRequest->iInstance,
|
p_pAppRequest->iInstance,
|
||||||
p_pAppRequest->pszHost,
|
p_pAppRequest->pszHost,
|
||||||
|
@ -141,21 +154,26 @@ BOOL GSWLoadBalancing_FindApp(GSWAppRequest* p_pAppRequest,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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;
|
GSWAppInstance *pAppInstance=NULL;
|
||||||
char szInstanceNum[50]="";
|
char szInstanceNum[50]="";
|
||||||
sprintf(szInstanceNum,"%d",p_pAppRequest->iInstance);
|
sprintf(szInstanceNum,"%d",p_pAppRequest->iInstance);
|
||||||
pAppInstance=(GSWAppInstance*)GSWDict_ValueForKey(&pApp->stInstancesDict,szInstanceNum);
|
pAppInstance =
|
||||||
|
(GSWAppInstance *)GSWDict_ValueForKey(&pApp->stInstancesDict,
|
||||||
|
szInstanceNum);
|
||||||
if (pAppInstance)
|
if (pAppInstance)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,"Instance Found");
|
GSWLog(GSW_DEBUG,p_pLogServerData,"Instance Found");
|
||||||
|
@ -163,22 +181,30 @@ BOOL GSWLoadBalancing_FindInstance(GSWAppRequest *p_pAppRequest,void* p_pLogServ
|
||||||
{
|
{
|
||||||
BOOL okay = TRUE;
|
BOOL okay = TRUE;
|
||||||
// check if refused, time to try again ?
|
// check if refused, time to try again ?
|
||||||
if (p_pURLComponents->stRequestHandlerKey.iLength==0 || p_pURLComponents->stRequestHandlerKey.pszStart==NULL) {
|
if (p_pURLComponents->stRequestHandlerKey.iLength==0 ||
|
||||||
GSWAppInfo *thisAppInfo = GSWAppInfo_Find(p_pAppRequest->pszName, pAppInstance->iInstance);
|
p_pURLComponents->stRequestHandlerKey.pszStart==NULL)
|
||||||
if (thisAppInfo && thisAppInfo->isRefused) {
|
{
|
||||||
|
GSWAppInfo *thisAppInfo =
|
||||||
|
GSWAppInfo_Find(p_pAppRequest->pszName,
|
||||||
|
pAppInstance->iInstance);
|
||||||
|
if (thisAppInfo && thisAppInfo->isRefused)
|
||||||
|
{
|
||||||
time_t actTime = (time_t)0;
|
time_t actTime = (time_t)0;
|
||||||
// this instance refuses new sessions
|
// this instance refuses new sessions
|
||||||
time(&actTime);
|
time(&actTime);
|
||||||
if (actTime > thisAppInfo->timeNextRetryTime) {
|
if (actTime > thisAppInfo->timeNextRetryTime)
|
||||||
|
{
|
||||||
thisAppInfo->isRefused = FALSE; // try it again
|
thisAppInfo->isRefused = FALSE; // try it again
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
okay = FALSE; // try an other instance
|
okay = FALSE; // try an other instance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (okay == TRUE) {
|
if (okay == TRUE)
|
||||||
|
{
|
||||||
fFound=TRUE;
|
fFound=TRUE;
|
||||||
p_pAppRequest->iInstance = pAppInstance->iInstance;
|
p_pAppRequest->iInstance = pAppInstance->iInstance;
|
||||||
p_pAppRequest->pszHost = pAppInstance->pszHostName;
|
p_pAppRequest->pszHost = pAppInstance->pszHostName;
|
||||||
|
@ -201,16 +227,18 @@ BOOL GSWLoadBalancing_FindInstance(GSWAppRequest *p_pAppRequest,void* p_pLogServ
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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))
|
||||||
|
@ -219,22 +247,25 @@ void GSWLoadBalancing_MarkNotRespondingApp(GSWAppRequest* p_pAppRequest,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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)
|
||||||
|
|
|
@ -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,5 +1,5 @@
|
||||||
/* 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
|
||||||
|
@ -39,7 +39,8 @@
|
||||||
#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";
|
||||||
|
@ -60,20 +61,21 @@ 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)
|
||||||
{
|
{
|
||||||
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);
|
CONST char *pszType=PLGetType(pl);
|
||||||
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
|
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
|
||||||
sprintf(pszMsgInfo0,"is not a dictionary its a %s:",pszType);
|
sprintf(pszMsgInfo0,"is not a dictionary its a %s:",pszType);
|
||||||
pszMsgInfo1=PLGetDescription(pl);//We have to free it
|
pszMsgInfo1=PLGetDescription(pl);//We have to free it
|
||||||
|
@ -92,7 +94,8 @@ BOOL GSWPropList_TestDictionary(proplist_t pl,
|
||||||
{
|
{
|
||||||
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)+
|
||||||
|
SafeStrlen(pszMsgInfo0)+SafeStrlen(pszMsgInfo1),
|
||||||
"%s/%s %s %s",
|
"%s/%s %s %s",
|
||||||
(p_pszParents ? p_pszParents : ""),
|
(p_pszParents ? p_pszParents : ""),
|
||||||
(p_pszKey ? p_pszKey : ""),
|
(p_pszKey ? p_pszKey : ""),
|
||||||
|
@ -107,20 +110,21 @@ BOOL GSWPropList_TestDictionary(proplist_t pl,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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)
|
||||||
{
|
{
|
||||||
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);
|
CONST char *pszType=PLGetType(pl);
|
||||||
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
|
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
|
||||||
sprintf(pszMsgInfo0,"is not an array its a %s:",pszType);
|
sprintf(pszMsgInfo0,"is not an array its a %s:",pszType);
|
||||||
pszMsgInfo1=PLGetDescription(pl);//We have to free it
|
pszMsgInfo1=PLGetDescription(pl);//We have to free it
|
||||||
|
@ -139,7 +143,8 @@ BOOL GSWPropList_TestArray(proplist_t pl,
|
||||||
{
|
{
|
||||||
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)+
|
||||||
|
SafeStrlen(pszMsgInfo0)+SafeStrlen(pszMsgInfo1),
|
||||||
"%s/%s %s %s",
|
"%s/%s %s %s",
|
||||||
(p_pszParents ? p_pszParents : ""),
|
(p_pszParents ? p_pszParents : ""),
|
||||||
(p_pszKey ? p_pszKey : ""),
|
(p_pszKey ? p_pszKey : ""),
|
||||||
|
@ -154,20 +159,21 @@ BOOL GSWPropList_TestArray(proplist_t pl,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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)
|
||||||
{
|
{
|
||||||
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);
|
CONST char *pszType=PLGetType(pl);
|
||||||
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
|
pszMsgInfo0=calloc(256+SafeStrlen(pszType),sizeof(char));
|
||||||
sprintf(pszMsgInfo0,"is not a string its a %s:",pszType);
|
sprintf(pszMsgInfo0,"is not a string its a %s:",pszType);
|
||||||
pszMsgInfo1=PLGetDescription(pl);//We have to free it
|
pszMsgInfo1=PLGetDescription(pl);//We have to free it
|
||||||
|
@ -186,7 +192,8 @@ BOOL GSWPropList_TestString(proplist_t pl,
|
||||||
{
|
{
|
||||||
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)+
|
||||||
|
SafeStrlen(pszMsgInfo0)+SafeStrlen(pszMsgInfo1),
|
||||||
"%s/%s %s %s",
|
"%s/%s %s %s",
|
||||||
(p_pszParents ? p_pszParents : ""),
|
(p_pszParents ? p_pszParents : ""),
|
||||||
(p_pszKey ? p_pszKey : ""),
|
(p_pszKey ? p_pszKey : ""),
|
||||||
|
@ -202,21 +209,24 @@ BOOL GSWPropList_TestString(proplist_t pl,
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
//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,
|
||||||
|
CONST char *p_pszParents,
|
||||||
BOOL p_fErrorIfNotExists,
|
BOOL p_fErrorIfNotExists,
|
||||||
PLTypeTestFn p_pTestFn,
|
PLTypeTestFn p_pTestFn,
|
||||||
void* p_pLogServerData)
|
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);
|
propList=PLGetDictionaryEntry(p_propListDictionary,propListKey);
|
||||||
if (p_pTestFn)
|
if (p_pTestFn)
|
||||||
{
|
{
|
||||||
if (!(*p_pTestFn)(propList,p_fErrorIfNotExists,p_pszKey,p_pszParents,p_pLogServerData))
|
if (!(*p_pTestFn)(propList,p_fErrorIfNotExists,
|
||||||
|
p_pszKey,p_pszParents,p_pLogServerData))
|
||||||
propList=NULL;
|
propList=NULL;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -226,22 +236,25 @@ proplist_t GSWPropList_GetDictionaryEntry(proplist_t p_propListDictionary,
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
//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)
|
||||||
{
|
{
|
||||||
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);
|
propList=PLGetArrayElement(p_propListArray,p_iIndex);
|
||||||
if (p_pTestFn)
|
if (p_pTestFn)
|
||||||
{
|
{
|
||||||
char szKey[120]="";
|
char szKey[120]="";
|
||||||
sprintf(szKey,"index: %d",p_iIndex);
|
sprintf(szKey,"index: %d",p_iIndex);
|
||||||
if (!(*p_pTestFn)(propList,p_fErrorIfNotExists,szKey,p_pszParents,p_pLogServerData))
|
if (!(*p_pTestFn)(propList,p_fErrorIfNotExists,szKey,
|
||||||
|
p_pszParents,p_pLogServerData))
|
||||||
propList=NULL;
|
propList=NULL;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -250,21 +263,25 @@ proplist_t GSWPropList_GetArrayElement(proplist_t p_propListArray,
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
//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,
|
||||||
|
CONST char *p_pszParents,
|
||||||
BOOL p_fErrorIfNotExists,
|
BOOL p_fErrorIfNotExists,
|
||||||
PLTypeTestFn p_pTestFn,
|
PLTypeTestFn p_pTestFn,
|
||||||
void* p_pLogServerData)
|
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);
|
propList=PLGetAllDictionaryKeys(p_propListDictionary);
|
||||||
if (p_pTestFn)
|
if (p_pTestFn)
|
||||||
{
|
{
|
||||||
if (!(*p_pTestFn)(propList,p_fErrorIfNotExists,NULL,p_pszParents,p_pLogServerData))
|
if (!(*p_pTestFn)(propList,p_fErrorIfNotExists,NULL,
|
||||||
|
p_pszParents,p_pLogServerData))
|
||||||
propList=NULL;
|
propList=NULL;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
return propList;
|
return propList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* 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
|
||||||
|
@ -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,5 +1,5 @@
|
||||||
/* 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
|
||||||
|
@ -33,15 +33,17 @@
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -55,19 +57,22 @@ void GSWString_Free(GSWString* 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
|
||||||
|
GSWString_GrowUpToSize(GSWString *p_pString,
|
||||||
int p_iSize)
|
int p_iSize)
|
||||||
{
|
{
|
||||||
if (p_iSize>p_pString->iSize)
|
if (p_iSize>p_pString->iSize)
|
||||||
|
@ -86,8 +91,9 @@ void GSWString_GrowUpToSize(GSWString* p_pString,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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,14 +102,15 @@ 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);
|
char *p=strstr(p_pString->pszData,p_pszSearch);
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
int iIndex=0;
|
int iIndex=0;
|
||||||
|
|
|
@ -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.
|
||||||
|
|
||||||
|
@ -32,18 +32,18 @@ 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,5 +1,5 @@
|
||||||
/* 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
|
||||||
|
@ -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,9 +281,12 @@ 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);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* 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
|
||||||
|
@ -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,25 +36,29 @@
|
||||||
#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));
|
||||||
|
|
||||||
|
@ -65,8 +69,8 @@ GSWURLError GSWParseURL(GSWURLComponents* p_pURLComponents,CONST char* p_pszURL,
|
||||||
|
|
||||||
if (pszPrefix)
|
if (pszPrefix)
|
||||||
{
|
{
|
||||||
CONST char* pszAppExtension=NULL;
|
CONST char *pszAppExtension=NULL;
|
||||||
CONST char* pszfoundExtension=NULL;
|
CONST char *pszfoundExtension=NULL;
|
||||||
pszStop=pszPrefix+strlen(g_szGSWeb_Prefix);
|
pszStop=pszPrefix+strlen(g_szGSWeb_Prefix);
|
||||||
pszNext=*pszStop ? pszStop+1 : pszStop; // Drop the trailing /
|
pszNext=*pszStop ? pszStop+1 : pszStop; // Drop the trailing /
|
||||||
pURLCPrefix->pszStart = pszPrefix;
|
pURLCPrefix->pszStart = pszPrefix;
|
||||||
|
@ -77,12 +81,14 @@ GSWURLError GSWParseURL(GSWURLComponents* p_pURLComponents,CONST char* p_pszURL,
|
||||||
|
|
||||||
// Get Application Name
|
// Get Application Name
|
||||||
pszStart=pszNext;
|
pszStart=pszNext;
|
||||||
pszAppExtension=strcasestr(pszStart,g_szGSWeb_AppExtention[GSWNAMES_INDEX]);
|
pszAppExtension=strcasestr(pszStart,
|
||||||
|
g_szGSWeb_AppExtention[GSWNAMES_INDEX]);
|
||||||
if (pszAppExtension)
|
if (pszAppExtension)
|
||||||
pszfoundExtension=g_szGSWeb_AppExtention[GSWNAMES_INDEX];
|
pszfoundExtension=g_szGSWeb_AppExtention[GSWNAMES_INDEX];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pszAppExtension=strcasestr(pszStart,g_szGSWeb_AppExtention[WONAMES_INDEX]);
|
pszAppExtension=strcasestr(pszStart,
|
||||||
|
g_szGSWeb_AppExtention[WONAMES_INDEX]);
|
||||||
if (pszAppExtension)
|
if (pszAppExtension)
|
||||||
pszfoundExtension=g_szGSWeb_AppExtention[WONAMES_INDEX];
|
pszfoundExtension=g_szGSWeb_AppExtention[WONAMES_INDEX];
|
||||||
};
|
};
|
||||||
|
@ -117,7 +123,8 @@ GSWURLError GSWParseURL(GSWURLComponents* p_pURLComponents,CONST char* p_pszURL,
|
||||||
pURLCAppName->iLength = pszStop-pszStart;
|
pURLCAppName->iLength = pszStop-pszStart;
|
||||||
pURLCAppName->iLength = max(pURLCAppName->iLength,0);
|
pURLCAppName->iLength = max(pURLCAppName->iLength,0);
|
||||||
// Drop trailing slashes
|
// Drop trailing slashes
|
||||||
while(pURLCAppName->iLength && pURLCAppName->pszStart[pURLCAppName->iLength-1]== '/')
|
while(pURLCAppName->iLength &&
|
||||||
|
pURLCAppName->pszStart[pURLCAppName->iLength-1]== '/')
|
||||||
pURLCAppName->iLength--;
|
pURLCAppName->iLength--;
|
||||||
pURLCAppName->iLength = max(pURLCAppName->iLength,0);
|
pURLCAppName->iLength = max(pURLCAppName->iLength,0);
|
||||||
|
|
||||||
|
@ -155,7 +162,8 @@ GSWURLError GSWParseURL(GSWURLComponents* p_pURLComponents,CONST char* p_pszURL,
|
||||||
// not all digits, so it's the request handler key !
|
// not all digits, so it's the request handler key !
|
||||||
pURLCReqHandlerKey->pszStart = pURLCAppNum->pszStart;
|
pURLCReqHandlerKey->pszStart = pURLCAppNum->pszStart;
|
||||||
pURLCReqHandlerKey->iLength = pURLCAppNum->iLength;
|
pURLCReqHandlerKey->iLength = pURLCAppNum->iLength;
|
||||||
pURLCReqHandlerKey->iLength = max(pURLCReqHandlerKey->iLength,0);
|
pURLCReqHandlerKey->iLength =
|
||||||
|
max(pURLCReqHandlerKey->iLength,0);
|
||||||
pURLCAppNum->pszStart="";
|
pURLCAppNum->pszStart="";
|
||||||
pURLCAppNum->iLength=0;
|
pURLCAppNum->iLength=0;
|
||||||
}
|
}
|
||||||
|
@ -170,7 +178,8 @@ GSWURLError GSWParseURL(GSWURLComponents* p_pURLComponents,CONST char* p_pszURL,
|
||||||
pszStop = pszS;
|
pszStop = pszS;
|
||||||
pURLCReqHandlerKey->pszStart = pszStart;
|
pURLCReqHandlerKey->pszStart = pszStart;
|
||||||
pURLCReqHandlerKey->iLength = pszStop-pszStart;
|
pURLCReqHandlerKey->iLength = pszStop-pszStart;
|
||||||
pURLCReqHandlerKey->iLength = max(pURLCReqHandlerKey->iLength,0);
|
pURLCReqHandlerKey->iLength =
|
||||||
|
max(pURLCReqHandlerKey->iLength,0);
|
||||||
pszNext=(pszStop<pszTmpStop) ? pszStop+1 : pszStop;
|
pszNext=(pszStop<pszTmpStop) ? pszStop+1 : pszStop;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -204,7 +213,8 @@ GSWURLError GSWParseURL(GSWURLComponents* p_pURLComponents,CONST char* p_pszURL,
|
||||||
if (!pURLCAppName->pszStart || pURLCAppName->iLength<=0)
|
if (!pURLCAppName->pszStart || pURLCAppName->iLength<=0)
|
||||||
{
|
{
|
||||||
eError=GSWURLError_InvalidAppName;
|
eError=GSWURLError_InvalidAppName;
|
||||||
GSWLog(GSW_ERROR,p_pLogServerData,"ParseURL GSWURLError_InvalidAppName");
|
GSWLog(GSW_ERROR,p_pLogServerData,
|
||||||
|
"ParseURL GSWURLError_InvalidAppName");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -214,28 +224,34 @@ GSWURLError GSWParseURL(GSWURLComponents* p_pURLComponents,CONST char* p_pszURL,
|
||||||
if (!pURLCAppNum->pszStart)
|
if (!pURLCAppNum->pszStart)
|
||||||
{
|
{
|
||||||
eError=GSWURLError_InvalidAppNumber;
|
eError=GSWURLError_InvalidAppNumber;
|
||||||
GSWLog(GSW_ERROR,p_pLogServerData,"ParseURL GSWURLError_InvalidAppNumber");
|
GSWLog(GSW_ERROR,p_pLogServerData,
|
||||||
|
"ParseURL GSWURLError_InvalidAppNumber");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,
|
GSWLog(GSW_DEBUG,p_pLogServerData,
|
||||||
"pURLCAppNum=%.*s",
|
"pURLCAppNum=%.*s",
|
||||||
pURLCAppNum->iLength,pURLCAppNum->pszStart);
|
pURLCAppNum->iLength,pURLCAppNum->pszStart);
|
||||||
if ((!pURLCReqHandlerKey->pszStart || pURLCReqHandlerKey->iLength<=0)
|
if ((!pURLCReqHandlerKey->pszStart ||
|
||||||
|
pURLCReqHandlerKey->iLength<=0)
|
||||||
&& pURLCReqHandlerPath->iLength>0)
|
&& pURLCReqHandlerPath->iLength>0)
|
||||||
{
|
{
|
||||||
eError=GSWURLError_InvalidRequestHandlerKey;
|
eError=GSWURLError_InvalidRequestHandlerKey;
|
||||||
GSWLog(GSW_ERROR,p_pLogServerData,"ParseURL GSWURLError_InvalidRequestHandlerKey");
|
GSWLog(GSW_ERROR,p_pLogServerData,
|
||||||
|
"ParseURL GSWURLError_InvalidRequestHandlerKey");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GSWLog(GSW_DEBUG,p_pLogServerData,
|
GSWLog(GSW_DEBUG,p_pLogServerData,
|
||||||
"pURLCReqHandlerPath=%.*s",
|
"pURLCReqHandlerPath=%.*s",
|
||||||
pURLCReqHandlerPath->iLength,pURLCReqHandlerPath->pszStart);
|
pURLCReqHandlerPath->iLength,
|
||||||
|
pURLCReqHandlerPath->pszStart);
|
||||||
/*
|
/*
|
||||||
if (!pURLCReqHandlerPath->pszStart || pURLCReqHandlerPath->iLength<=0)
|
if (!pURLCReqHandlerPath->pszStart ||
|
||||||
|
pURLCReqHandlerPath->iLength<=0)
|
||||||
eError=GSWURLError_InvalidRequestHandlerPath;
|
eError=GSWURLError_InvalidRequestHandlerPath;
|
||||||
else if (!pURLCQueryString->pszStart || pURLCQueryString->iLength<=0)
|
else if (!pURLCQueryString->pszStart ||
|
||||||
|
pURLCQueryString->iLength<=0)
|
||||||
eError=GSWURLError_InvalidQueryString;
|
eError=GSWURLError_InvalidQueryString;
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
@ -247,14 +263,17 @@ GSWURLError GSWParseURL(GSWURLComponents* p_pURLComponents,CONST char* p_pszURL,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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;
|
||||||
|
@ -275,36 +294,41 @@ void GSWComposeURL(char* p_pszURL,GSWURLComponents* p_pURLComponents,void* p_pLo
|
||||||
if (pURLCReqHandlerKey->iLength>0)
|
if (pURLCReqHandlerKey->iLength>0)
|
||||||
{
|
{
|
||||||
*p_pszURL++='/';
|
*p_pszURL++='/';
|
||||||
strncpy(p_pszURL, pURLCReqHandlerKey->pszStart,pURLCReqHandlerKey->iLength);
|
strncpy(p_pszURL, pURLCReqHandlerKey->pszStart,
|
||||||
|
pURLCReqHandlerKey->iLength);
|
||||||
p_pszURL+= 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;
|
||||||
|
@ -321,27 +345,30 @@ int GSWComposeURLLen(GSWURLComponents* p_pURLComponents,void* p_pLogServerData)
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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 &&
|
||||||
|
p_eError<sizeof(szGSWURLErrorMessage)/sizeof(szGSWURLErrorMessage[0]))
|
||||||
return szGSWURLErrorMessage[p_eError];
|
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,7 +30,7 @@ extern "C" {
|
||||||
|
|
||||||
typedef struct _GSWURLComponent
|
typedef struct _GSWURLComponent
|
||||||
{
|
{
|
||||||
CONST char* pszStart;
|
CONST char *pszStart;
|
||||||
int iLength;
|
int iLength;
|
||||||
} GSWURLComponent;
|
} GSWURLComponent;
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
VGSWLogSizedIntern(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,
|
||||||
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,22 +92,23 @@ 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, ...)
|
||||||
{
|
{
|
||||||
|
@ -122,11 +126,12 @@ void GSWLog(int p_iLevel,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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, ...)
|
||||||
|
@ -145,16 +150,17 @@ void GSWLogSized(int p_iLevel,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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,...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap,p_pszFormat);
|
va_start(ap,p_pszFormat);
|
||||||
|
@ -170,17 +176,18 @@ void GSWLogIntern(char* file,
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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,...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap,p_pszFormat);
|
va_start(ap,p_pszFormat);
|
||||||
|
@ -198,13 +205,15 @@ void GSWLogSizedIntern(char* file,
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// 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]=='\r' || p_pszString[i]=='\n'))
|
||||||
p_pszString[i--]=0;
|
p_pszString[i--]=0;
|
||||||
i++;
|
i++;
|
||||||
};
|
};
|
||||||
|
@ -212,7 +221,8 @@ int DeleteTrailingCRNL(char* p_pszString)
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
int DeleteTrailingSlash(char* p_pszString)
|
int
|
||||||
|
DeleteTrailingSlash(char *p_pszString)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
if (p_pszString)
|
if (p_pszString)
|
||||||
|
@ -226,7 +236,8 @@ int DeleteTrailingSlash(char* p_pszString)
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
int DeleteTrailingSpaces(char* p_pszString)
|
int
|
||||||
|
DeleteTrailingSpaces(char *p_pszString)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
if (p_pszString)
|
if (p_pszString)
|
||||||
|
@ -240,18 +251,21 @@ int DeleteTrailingSpaces(char* p_pszString)
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -268,7 +282,8 @@ char* strcasestr(CONST char* p_pszString,CONST char* p_pszSearchedString)
|
||||||
BOOL fSame=TRUE;
|
BOOL fSame=TRUE;
|
||||||
int j=0;
|
int j=0;
|
||||||
for(j=1;j<iSearchedStringLen && fSame;j++)
|
for(j=1;j<iSearchedStringLen && fSame;j++)
|
||||||
fSame=toupper(p_pszString[i+j])==toupper(p_pszSearchedString[j]);
|
fSame=toupper(p_pszString[i+j]) ==
|
||||||
|
toupper(p_pszSearchedString[j]);
|
||||||
if (fSame)
|
if (fSame)
|
||||||
return p_pszString+i;
|
return p_pszString+i;
|
||||||
};
|
};
|
||||||
|
@ -283,7 +298,8 @@ char* strcasestr(CONST char* p_pszString,CONST char* p_pszSearchedString)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
void GSWUtil_ClearHostCache()
|
void
|
||||||
|
GSWUtil_ClearHostCache()
|
||||||
{
|
{
|
||||||
if (g_pHostCache)
|
if (g_pHostCache)
|
||||||
{
|
{
|
||||||
|
@ -293,13 +309,16 @@ void GSWUtil_ClearHostCache()
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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);
|
pHost = GSWUtil_HostLookup(p_pszHost,p_pLogServerData);
|
||||||
|
@ -325,7 +344,8 @@ 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);
|
||||||
|
@ -347,15 +367,17 @@ CONST char* hstrerror(int herr)
|
||||||
#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),
|
||||||
|
sizeof(void *)))+strlen(p_pHost->h_name)+1;
|
||||||
int iAliasNb=0;
|
int iAliasNb=0;
|
||||||
int iAddressesNb = 0;
|
int iAddressesNb = 0;
|
||||||
char** ppszAliasOrAddress=NULL;
|
char **ppszAliasOrAddress=NULL;
|
||||||
char** ppszNewHostAliasOrAddress=NULL;
|
char **ppszNewHostAliasOrAddress=NULL;
|
||||||
void* pTmp=NULL;
|
void *pTmp=NULL;
|
||||||
|
|
||||||
// Aliases
|
// Aliases
|
||||||
for (ppszAliasOrAddress=p_pHost->h_aliases;
|
for (ppszAliasOrAddress=p_pHost->h_aliases;
|
||||||
|
@ -368,48 +390,51 @@ static PSTHostent GSWUtil_CopyHostent(PSTHostent p_pHost)
|
||||||
|
|
||||||
// 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,
|
||||||
|
ppszNewHostAliasOrAddress=pNewHost->h_aliases;
|
||||||
ppszAliasOrAddress && *ppszAliasOrAddress;
|
ppszAliasOrAddress && *ppszAliasOrAddress;
|
||||||
ppszAliasOrAddress++,ppszNewHostAliasOrAddress++)
|
ppszAliasOrAddress++,ppszNewHostAliasOrAddress++)
|
||||||
{
|
{
|
||||||
*ppszNewHostAliasOrAddress = (char*)pTmp;
|
*ppszNewHostAliasOrAddress = (char *)pTmp;
|
||||||
strcpy((char*)pTmp,*ppszAliasOrAddress);
|
strcpy((char *)pTmp,*ppszAliasOrAddress);
|
||||||
pTmp+=strlen(*ppszAliasOrAddress) + 1;
|
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,
|
||||||
|
ppszNewHostAliasOrAddress=pNewHost->h_addr_list;
|
||||||
ppszAliasOrAddress && *ppszAliasOrAddress;
|
ppszAliasOrAddress && *ppszAliasOrAddress;
|
||||||
ppszAliasOrAddress++,ppszNewHostAliasOrAddress++)
|
ppszAliasOrAddress++,ppszNewHostAliasOrAddress++)
|
||||||
{
|
{
|
||||||
*ppszNewHostAliasOrAddress=(char*)pTmp;
|
*ppszNewHostAliasOrAddress=(char *)pTmp;
|
||||||
memcpy(*ppszNewHostAliasOrAddress,*ppszAliasOrAddress,pNewHost->h_length);
|
memcpy(*ppszNewHostAliasOrAddress,*ppszAliasOrAddress,
|
||||||
|
pNewHost->h_length);
|
||||||
pTmp+=pNewHost->h_length;
|
pTmp+=pNewHost->h_length;
|
||||||
};
|
};
|
||||||
*ppszNewHostAliasOrAddress=NULL;
|
*ppszNewHostAliasOrAddress=NULL;
|
||||||
|
@ -417,7 +442,9 @@ static PSTHostent GSWUtil_CopyHostent(PSTHostent p_pHost)
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
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;
|
||||||
|
@ -474,14 +501,16 @@ PSTHostent GSWUtil_HostLookup(CONST char *p_pszHost,void* p_pLogServerData)
|
||||||
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) ?
|
||||||
|
&stTmpHost : NULL;
|
||||||
error = (pHost) ? 0 : h_errno;
|
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),
|
||||||
|
AF_INET);
|
||||||
error = (pHost) ? 0 : h_errno;
|
error = (pHost) ? 0 : h_errno;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -493,7 +522,8 @@ PSTHostent GSWUtil_HostLookup(CONST char *p_pszHost,void* p_pLogServerData)
|
||||||
|
|
||||||
if (!pHost)
|
if (!pHost)
|
||||||
{
|
{
|
||||||
GSWLog(GSW_ERROR,p_pLogServerData,"gethostbyname(%s) returns no host: %s",
|
GSWLog(GSW_ERROR,p_pLogServerData,
|
||||||
|
"gethostbyname(%s) returns no host: %s",
|
||||||
p_pszHost,
|
p_pszHost,
|
||||||
hstrerror(error));
|
hstrerror(error));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue