mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-02-15 16:11:24 +00:00
Initial revision
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@5815 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
commit
a0b34ee1ee
376 changed files with 69720 additions and 0 deletions
0
ChangeLog
Normal file
0
ChangeLog
Normal file
44
GNUmakefile
Normal file
44
GNUmakefile
Normal file
|
@ -0,0 +1,44 @@
|
|||
# Main Makefile for GNUstep Web
|
||||
#
|
||||
# Copyright (C) 1999-2000 Free Software Foundation, Inc.
|
||||
#
|
||||
# Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
#
|
||||
# This file is part of GNUstep Web
|
||||
#
|
||||
# This file is part of the GNUstep Web Library.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT)
|
||||
GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Makefiles
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
include ./Version
|
||||
include ./config.mak
|
||||
|
||||
#
|
||||
# The list of subproject directories
|
||||
#
|
||||
SUBPROJECTS = GSWeb.framework GSWExtensions.framework GSWExtensionsGSW.framework
|
||||
#GSWAdaptors
|
||||
|
||||
-include Makefile.preamble
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/aggregate.make
|
||||
|
||||
-include Makefile.postamble
|
||||
|
82
GSWAdaptors/Apache/GNUmakefile
Normal file
82
GSWAdaptors/Apache/GNUmakefile
Normal file
|
@ -0,0 +1,82 @@
|
|||
# Makefile for Apache GNUstepWeb module
|
||||
# Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
#
|
||||
# Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
# Date: Jully 1999
|
||||
#
|
||||
# This file is part of the GNUstep Web Library.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
# The result of this is mod_gsweb.so.
|
||||
# Newt, run
|
||||
# apxs -i -a -n gsweb mod_gsweb.so
|
||||
#
|
||||
|
||||
#Solaris, Linux, FreeBSD
|
||||
|
||||
OSNAME := "$(shell uname)"
|
||||
APXS := "$(shell which apxs)"
|
||||
|
||||
ifeq ("",$(strip $(APXS)))
|
||||
ifeq ("FreeBSD",$(strip $(OSNAME)))
|
||||
APXS = /usr/local/sbin/apxs
|
||||
else
|
||||
APXS = /usr/apache/sbin/apxs
|
||||
endif
|
||||
else
|
||||
ifneq (,$(findstring no apxs,$(APXS)))
|
||||
APXS = "/usr/apache/sbin/apxs"
|
||||
endif
|
||||
endif
|
||||
|
||||
APACHEHEADERS := -I/usr/apache/include -I/usr/local/include/apache -I/usr/lib/apache/include
|
||||
|
||||
APXS := $(APXS) -l PropList -L/usr/local/lib
|
||||
|
||||
SRCROOT = ..
|
||||
DSTROOT = .
|
||||
OBJROOT = .
|
||||
|
||||
# Directory
|
||||
SERVERAPI = Apache
|
||||
|
||||
ADAPTOR = $(DSTROOT)/mod_gsweb.so
|
||||
|
||||
LOADBALANCING = roundrobin
|
||||
ADAPTORLIB = $(OBJROOT)/libAdaptor.a
|
||||
COMMON = $(SRCROOT)/common
|
||||
|
||||
INCLUDE = -I$(COMMON) $(APACHEHEADERS)
|
||||
|
||||
CFLAGS = -O2 $(RC_CFLAGS) $(INCLUDE) -D$(SERVERAPI) -DREENTRANT
|
||||
|
||||
all:: $(ADAPTOR)
|
||||
|
||||
include $(COMMON)/common.make
|
||||
|
||||
OFILES = $(COMMONOBJS) $(OBJROOT)/mod_gsweb.o
|
||||
|
||||
install: $(ADAPTOR)
|
||||
-cp -f $(ADAPTOR) $(DSTROOT)
|
||||
|
||||
$(ADAPTOR):: $(OFILES)
|
||||
$(APXS) -c $(OTHER_LDFLAGS) -o $@ $(OFILES)
|
||||
|
||||
$(OBJROOT)/mod_gsweb.o: $(SRCROOT)/$(SERVERAPI)/mod_gsweb.c
|
||||
$(CC) $(CFLAGS) -c -o $*.o $<
|
||||
|
||||
clean:
|
||||
rm -f $(COMMONOBJS) $(OFILES) $(ADAPTOR) $(ADAPTORLIB) core
|
518
GSWAdaptors/Apache/mod_gsweb.c
Normal file
518
GSWAdaptors/Apache/mod_gsweb.c
Normal file
|
@ -0,0 +1,518 @@
|
|||
/* mod_gsweb.c - GSWeb: Apache Module
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#include "GSWUtil.h"
|
||||
#include "GSWDict.h"
|
||||
#include "GSWConfig.h"
|
||||
#include "GSWURLUtil.h"
|
||||
#include "GSWHTTPHeaders.h"
|
||||
|
||||
#include "GSWAppRequestStruct.h"
|
||||
#include "GSWAppConnect.h"
|
||||
#include "GSWHTTPRequest.h"
|
||||
#include "GSWHTTPResponse.h"
|
||||
#include "GSWAppRequest.h"
|
||||
|
||||
#include "httpd.h"
|
||||
#include <http_config.h>
|
||||
#include <http_request.h>
|
||||
#include <http_core.h>
|
||||
|
||||
|
||||
// Module Definition:
|
||||
|
||||
// Declare the module
|
||||
module GSWeb_Module;
|
||||
|
||||
|
||||
typedef struct _GSWeb_Config
|
||||
{
|
||||
const char* pszGSWeb; // default = GSWeb
|
||||
const char* pszConfigPath; // path to GSWeb.conf
|
||||
const char* pszRoot; // normally htdocs/GSWeb
|
||||
} GSWeb_Config;
|
||||
|
||||
|
||||
//TODO: remove ??
|
||||
struct table
|
||||
{
|
||||
/* This has to be first to promote backwards compatibility with
|
||||
* older modules which cast a table * to an array_header *...
|
||||
* they should use the table_elts() function for most of the
|
||||
* cases they do this for.
|
||||
*/
|
||||
array_header a;
|
||||
#ifdef MAKE_TABLE_PROFILE
|
||||
void *creator;
|
||||
#endif
|
||||
};
|
||||
|
||||
static CONST char* GSWeb_SetDocRoot(cmd_parms* p_pCmdParams,void* p_pUnused,char *p_pszArg);
|
||||
static CONST char* GSWeb_SetScriptAlias(cmd_parms *p_pCmdParams, void *p_pUnused, char *p_pszArg);
|
||||
static CONST char *GSWeb_SetConfig(cmd_parms *p_pCmdParams, void *p_pUnused, char *p_pszArg);
|
||||
static int GSWeb_Handler(request_rec* p_pRequestRec);
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Init
|
||||
static void GSWeb_Init(server_rec* p_pServerRec, pool *p)
|
||||
{
|
||||
GSWDict* pDict=GSWDict_New(0);
|
||||
GSWeb_Config* pConfig=NULL;
|
||||
GSWConfig_Init();
|
||||
pConfig=(GSWeb_Config*)ap_get_module_config(p_pServerRec->module_config,
|
||||
&GSWeb_Module);
|
||||
GSWLog_Init(NULL,GSW_INFO);
|
||||
|
||||
if (pConfig && pConfig->pszConfigPath)
|
||||
GSWDict_AddStringDup(pDict,
|
||||
g_szGSWeb_Conf_ConfigFilePath,
|
||||
pConfig->pszConfigPath);
|
||||
if (pConfig && pConfig->pszRoot)
|
||||
GSWDict_AddStringDup(pDict,
|
||||
g_szGSWeb_Conf_DocRoot,
|
||||
pConfig->pszRoot);
|
||||
GSWLoadBalancing_Init(pDict);
|
||||
|
||||
GSWLog(GSW_INFO,p_pServerRec,"GSWeb Init" GSWEB_HANDLER);
|
||||
GSWDict_Free(pDict);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Create Config
|
||||
static void *GSWeb_CreateConfig(pool* p_pPool,
|
||||
server_rec* p_pServerRec)
|
||||
{
|
||||
GSWeb_Config *pConfig = (GSWeb_Config*)ap_palloc(p_pPool,sizeof(GSWeb_Config));
|
||||
pConfig->pszGSWeb = g_szGSWeb_Prefix;
|
||||
pConfig->pszConfigPath = NULL;
|
||||
pConfig->pszRoot = NULL;
|
||||
return pConfig;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Set Param: DocRoot
|
||||
static CONST char* GSWeb_SetDocRoot(cmd_parms* p_pCmdParams,void* p_pUnused,char *p_pszArg)
|
||||
{
|
||||
server_rec* pServerRec = p_pCmdParams->server;
|
||||
GSWeb_Config* pConfig = (GSWeb_Config *)ap_get_module_config(pServerRec->module_config,
|
||||
&GSWeb_Module);
|
||||
pConfig->pszRoot = p_pszArg;
|
||||
return NULL;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Set Param: ScriptAlias
|
||||
static CONST char* GSWeb_SetScriptAlias(cmd_parms *p_pCmdParams, void *p_pUnused, char *p_pszArg)
|
||||
{
|
||||
server_rec* pServerRec = p_pCmdParams->server;
|
||||
GSWeb_Config* pConfig = (GSWeb_Config *)ap_get_module_config(pServerRec->module_config,
|
||||
&GSWeb_Module);
|
||||
pConfig->pszGSWeb = p_pszArg;
|
||||
return NULL;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Set Param: ConfigFile
|
||||
static CONST char *GSWeb_SetConfig(cmd_parms *p_pCmdParams, void *p_pUnused, char *p_pszArg)
|
||||
{
|
||||
server_rec* pServerRec = p_pCmdParams->server;
|
||||
GSWeb_Config* pConfig = (GSWeb_Config *)ap_get_module_config(pServerRec->module_config,
|
||||
&GSWeb_Module);
|
||||
pConfig->pszConfigPath = p_pszArg;
|
||||
return NULL;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Translate
|
||||
int GSWeb_Translation(request_rec* p_pRequestRec)
|
||||
{
|
||||
int iRetValue=OK;
|
||||
GSWeb_Config *pConfig= (GSWeb_Config *)ap_get_module_config(p_pRequestRec->server->module_config,
|
||||
&GSWeb_Module);
|
||||
GSWURLComponents stURL;
|
||||
// Is this for us ?
|
||||
if (strncmp(pConfig->pszGSWeb,
|
||||
p_pRequestRec->uri,
|
||||
strlen(pConfig->pszGSWeb))==0)
|
||||
{
|
||||
GSWURLError eError=GSWParseURL(&stURL,p_pRequestRec->uri);
|
||||
GSWLog(GSW_ERROR,p_pRequestRec->server,"==>GSWeb_Translation Error=%d",eError);
|
||||
/* if (eError!=GSWURLError_OK)
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pRequestRec->server,"==>GSWeb_Translation Decliend");
|
||||
iRetValue=DECLINED;
|
||||
}
|
||||
else
|
||||
{*/
|
||||
GSWLog(GSW_INFO,
|
||||
p_pRequestRec->server,
|
||||
"GSWeb_Translation Handler p_pRequestRec->handler=%s pool=%p handler=%s pConfig->pszGSWeb=%s",
|
||||
p_pRequestRec->handler,
|
||||
p_pRequestRec->pool,
|
||||
g_szGSWeb_Handler,
|
||||
pConfig->pszGSWeb);
|
||||
p_pRequestRec->handler=(char*)ap_pstrdup(p_pRequestRec->pool,g_szGSWeb_Handler);
|
||||
iRetValue=OK;
|
||||
/* };*/
|
||||
}
|
||||
else
|
||||
{
|
||||
GSWLog(GSW_INFO,p_pRequestRec->server,"GSWeb_Translation Decliend");
|
||||
iRetValue=DECLINED;
|
||||
};
|
||||
return iRetValue;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static void copyHeaders(request_rec* p_pRequestRec,GSWHTTPRequest* p_pGSWHTTPRequest)
|
||||
{
|
||||
server_rec* pServerRec = p_pRequestRec->server;
|
||||
conn_rec* pConnection = p_pRequestRec->connection;
|
||||
table* pHeadersIn = p_pRequestRec->headers_in;
|
||||
table_entry* pHeader=NULL;
|
||||
int i;
|
||||
char szPort[40]="";
|
||||
CONST char* pszRemoteLogName=NULL;
|
||||
|
||||
// copy p_pRequestRec headers
|
||||
pHeader = (table_entry*)(&pHeadersIn->a)->elts;
|
||||
for (i=0;i<(&pHeadersIn->a)->nelts;i++)
|
||||
{
|
||||
if (pHeader->key)
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,pHeader->key,pHeader->val);
|
||||
pHeader++;
|
||||
};
|
||||
|
||||
// Add server headers
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_ServerSoftware,
|
||||
SERVER_VERSION);
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_ServerName,
|
||||
pServerRec->server_hostname);
|
||||
ap_snprintf(szPort,
|
||||
sizeof(szPort),
|
||||
"%u",
|
||||
pServerRec->port);
|
||||
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_ServerPort,
|
||||
szPort);
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_RemoteHost,
|
||||
(CONST char*)ap_get_remote_host(pConnection,p_pRequestRec->per_dir_config,REMOTE_NAME));
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_RemoteAddress,
|
||||
pConnection->remote_ip);
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_DocumentRoot,
|
||||
(char*)ap_document_root(p_pRequestRec));
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_ServerAdmin,
|
||||
pServerRec->server_admin);
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_ScriptFileName,
|
||||
p_pRequestRec->filename);
|
||||
ap_snprintf(szPort,
|
||||
sizeof(szPort),
|
||||
"%d",
|
||||
ntohs(pConnection->remote_addr.sin_port));
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_RemotePort,
|
||||
szPort);
|
||||
|
||||
if (pConnection->user)
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_RemoteUser,
|
||||
pConnection->user);
|
||||
if (pConnection->ap_auth_type)
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_AuthType,//"auth_type",
|
||||
pConnection->ap_auth_type);
|
||||
pszRemoteLogName = (char*)ap_get_remote_logname(p_pRequestRec);
|
||||
if (pszRemoteLogName)
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_RemoteIdent,
|
||||
pszRemoteLogName);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// callback finction to copy an header into p_pRequest
|
||||
static void getHeader(GSWDictElem* p_pElem,void* p_pRequestRec)
|
||||
{
|
||||
request_rec* pRequestRec = (request_rec*)p_pRequestRec;
|
||||
|
||||
if (!pRequestRec->content_type && strcasecmp(p_pElem->pszKey,g_szHeader_ContentType)==0)
|
||||
pRequestRec->content_type = (char*)ap_pstrdup(pRequestRec->pool,(char*)p_pElem->pValue);
|
||||
else
|
||||
ap_table_add(pRequestRec->headers_out,p_pElem->pszKey,(char*)p_pElem->pValue);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// send response
|
||||
|
||||
static void sendResponse(request_rec* p_pRequestRec,GSWHTTPResponse* p_pHTTPResponse)
|
||||
{
|
||||
char szStatusBuffer[512]="";
|
||||
|
||||
// Process Headers
|
||||
GSWDict_PerformForAllElem(p_pHTTPResponse->pHeaders,getHeader,p_pRequestRec);
|
||||
|
||||
ap_snprintf(szStatusBuffer,sizeof(szStatusBuffer),"%u %s",
|
||||
p_pHTTPResponse->uStatus,
|
||||
p_pHTTPResponse->pszStatusMessage);
|
||||
p_pRequestRec->status_line = szStatusBuffer;
|
||||
p_pRequestRec->status = p_pHTTPResponse->uStatus;
|
||||
|
||||
// Set content type if none
|
||||
if (!p_pRequestRec->content_type)
|
||||
p_pRequestRec->content_type = g_szContentType_TextHtml;
|
||||
|
||||
// Set content length
|
||||
ap_set_content_length(p_pRequestRec, p_pHTTPResponse->uContentLength);
|
||||
|
||||
// Now Send response...
|
||||
|
||||
// send Headers
|
||||
ap_send_http_header(p_pRequestRec);
|
||||
|
||||
// If not headers only
|
||||
if (!p_pRequestRec->header_only)
|
||||
{
|
||||
ap_soft_timeout("Send GSWeb response",p_pRequestRec);
|
||||
ap_rwrite(p_pHTTPResponse->pContent,p_pHTTPResponse->uContentLength,p_pRequestRec);
|
||||
ap_kill_timeout(p_pRequestRec);
|
||||
};
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// die/send response
|
||||
static int dieSendResponse(request_rec* p_pRequestRec,GSWHTTPResponse** p_ppHTTPResponse,BOOL p_fDecline)
|
||||
{
|
||||
sendResponse(p_pRequestRec,*p_ppHTTPResponse);
|
||||
GSWHTTPResponse_Free(*p_ppHTTPResponse);
|
||||
*p_ppHTTPResponse=NULL;
|
||||
return p_fDecline ? DECLINED : OK;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// die with a message
|
||||
static int dieWithMessage(request_rec* p_pRequestRec,CONST char* p_pszMessage,BOOL p_fDecline)
|
||||
{
|
||||
GSWHTTPResponse* pResponse=NULL;
|
||||
server_rec* pServerRec = p_pRequestRec->server;
|
||||
GSWLog(GSW_ERROR,pServerRec,"Send Error Response: %s",p_pszMessage);
|
||||
pResponse = GSWHTTPResponse_BuildErrorResponse(p_pszMessage);
|
||||
return dieSendResponse(p_pRequestRec,&pResponse,p_fDecline);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// GSWeb Request Handler
|
||||
static int GSWeb_Handler(request_rec* p_pRequestRec)
|
||||
{
|
||||
int iRetVal=OK;
|
||||
GSWURLComponents stURLComponents;
|
||||
GSWHTTPResponse* pResponse = NULL;
|
||||
GSWURLError eError=GSWURLError_OK;
|
||||
CONST char* pszURLError=NULL;
|
||||
server_rec* pServerRec = p_pRequestRec->server;
|
||||
memset(&stURLComponents,0,sizeof(stURLComponents));
|
||||
|
||||
// Log the request
|
||||
GSWLog(GSW_INFO,
|
||||
pServerRec,
|
||||
"GNUstepWeb New request: %s",
|
||||
p_pRequestRec->uri);
|
||||
|
||||
// Parse the uri
|
||||
eError=GSWParseURL(&stURLComponents,p_pRequestRec->uri);
|
||||
if (eError!=GSWURLError_OK)
|
||||
{
|
||||
pszURLError=GSWURLErrorMessage(eError);
|
||||
GSWLog(GSW_INFO,pServerRec,"URL Parsing Error: %s", pszURLError);
|
||||
if (eError==GSWURLError_InvalidAppName && GSWDumpConfigFile_CanDump())
|
||||
{
|
||||
pResponse = GSWDumpConfigFile(p_pRequestRec->server,&stURLComponents);
|
||||
iRetVal=dieSendResponse(p_pRequestRec,&pResponse,NO);
|
||||
}
|
||||
else
|
||||
iRetVal=dieWithMessage(p_pRequestRec,pszURLError,NO);
|
||||
}
|
||||
else
|
||||
{
|
||||
iRetVal = ap_setup_client_block(p_pRequestRec,REQUEST_CHUNKED_ERROR);
|
||||
if (iRetVal==0) // OK Continue
|
||||
{
|
||||
// Build the GSWHTTPRequest with the method
|
||||
GSWHTTPRequest* pRequest=GSWHTTPRequest_New(p_pRequestRec->method,NULL);
|
||||
|
||||
// validate the method
|
||||
CONST char* pszRequestError=GSWHTTPRequest_ValidateMethod(pRequest);
|
||||
if (pszRequestError)
|
||||
{
|
||||
iRetVal=dieWithMessage(p_pRequestRec,pszRequestError,NO);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSWeb_Config* pConfig = NULL;
|
||||
CONST char* pszDocRoot=NULL;
|
||||
|
||||
// copy headers
|
||||
copyHeaders(p_pRequestRec,pRequest);
|
||||
|
||||
// Get Form data if any
|
||||
// POST Method
|
||||
if (pRequest->eMethod==ERequestMethod_Post
|
||||
&& pRequest->uContentLength>0
|
||||
&& ap_should_client_block(p_pRequestRec))
|
||||
{
|
||||
int iReadLength=0;
|
||||
int iRemainingLength = pRequest->uContentLength;
|
||||
char* pszBuffer = malloc(pRequest->uContentLength);
|
||||
char* pszData = pszBuffer;
|
||||
|
||||
while (iRemainingLength>0)
|
||||
{
|
||||
ap_soft_timeout("reading GSWeb request",p_pRequestRec);
|
||||
iReadLength=ap_get_client_block(p_pRequestRec,pszData,iRemainingLength);
|
||||
ap_kill_timeout(p_pRequestRec);
|
||||
pszData += iReadLength;
|
||||
iRemainingLength-=iReadLength;
|
||||
};
|
||||
GSWLog(GSW_INFO,pServerRec,"pszBuffer(%p)=%.*s",
|
||||
(void*)pszBuffer,
|
||||
(int)pRequest->uContentLength,
|
||||
pszBuffer);
|
||||
pRequest->pContent = pszBuffer;
|
||||
}
|
||||
else if (pRequest->eMethod==ERequestMethod_Get)
|
||||
{
|
||||
// Get the QueryString
|
||||
stURLComponents.stQueryString.pszStart = p_pRequestRec->args;
|
||||
stURLComponents.stQueryString.iLength = p_pRequestRec->args ? strlen(p_pRequestRec->args) : 0;
|
||||
};
|
||||
|
||||
// get the document root
|
||||
pConfig=(GSWeb_Config*)ap_get_module_config(p_pRequestRec->per_dir_config,&GSWeb_Module);
|
||||
if (pConfig && pConfig->pszRoot)
|
||||
pszDocRoot = pConfig->pszRoot;
|
||||
else
|
||||
pszDocRoot=(char*)ap_document_root(p_pRequestRec);
|
||||
|
||||
// Build the response (Beware: tr_handleRequest free pRequest)
|
||||
ap_soft_timeout("Call GSWeb Application",p_pRequestRec);
|
||||
pRequest->pServerHandle = p_pRequestRec;
|
||||
pResponse=GSWAppRequest_HandleRequest(&pRequest,
|
||||
&stURLComponents,
|
||||
p_pRequestRec->protocol,
|
||||
pszDocRoot,
|
||||
"SB", //TODO AppTest name
|
||||
(void*)p_pRequestRec->server);
|
||||
ap_kill_timeout(p_pRequestRec);
|
||||
|
||||
// Send the response (if any)
|
||||
if (pResponse)
|
||||
{
|
||||
sendResponse(p_pRequestRec,pResponse);
|
||||
GSWHTTPResponse_Free(pResponse);
|
||||
iRetVal = OK;
|
||||
}
|
||||
else
|
||||
iRetVal = DECLINED;
|
||||
};
|
||||
};
|
||||
};
|
||||
return iRetVal;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Module definitions
|
||||
|
||||
|
||||
static command_rec GSWeb_Commands[20] =
|
||||
{
|
||||
{
|
||||
GSWEB_CONF__DOC_ROOT, // Command keyword
|
||||
GSWeb_SetDocRoot, // Function
|
||||
NULL, // Fixed Arg
|
||||
RSRC_CONF, // Type
|
||||
TAKE1, // Args Descr
|
||||
"RootDirectory for GSWeb"
|
||||
},
|
||||
{
|
||||
GSWEB_CONF__ALIAS, // Command keyword
|
||||
GSWeb_SetScriptAlias, // Function
|
||||
NULL, // Fixed Arg
|
||||
RSRC_CONF, // Type
|
||||
TAKE1, // Args Descr
|
||||
"ScriptAlias for GSWeb"
|
||||
},
|
||||
{
|
||||
GSWEB_CONF__CONFIG_FILE_PATH, // Command keyword
|
||||
GSWeb_SetConfig, // Function
|
||||
NULL, // Fixed Arg
|
||||
RSRC_CONF, // Type
|
||||
TAKE1, // Args Descr
|
||||
"Configuration File Path for GSWeb"
|
||||
},
|
||||
{
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
handler_rec GSWeb_Handlers[] =
|
||||
{
|
||||
{ GSWEB__MIME_TYPE, GSWeb_Handler },
|
||||
{ GSWEB_HANDLER, GSWeb_Handler },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
module GSWeb_Module =
|
||||
{
|
||||
STANDARD_MODULE_STUFF,
|
||||
GSWeb_Init, // Init
|
||||
NULL, // Create DirectoryConfig
|
||||
NULL, // Merge DirectoryConfig
|
||||
GSWeb_CreateConfig, // Create ServerConfig
|
||||
NULL, // Merge ServerConfig
|
||||
GSWeb_Commands, // Commands List
|
||||
GSWeb_Handlers, // Handlers List
|
||||
GSWeb_Translation, // Fn to Translatie Filename/URI
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
38
GSWAdaptors/common/GNUmakefile
Normal file
38
GSWAdaptors/common/GNUmakefile
Normal file
|
@ -0,0 +1,38 @@
|
|||
|
||||
|
||||
#Defaults
|
||||
|
||||
#Directories
|
||||
SRCROOT = ..
|
||||
DSTROOT = .
|
||||
OBJROOT = .
|
||||
|
||||
#Load Balancing (Not used yet)
|
||||
LOADBALANCING = random
|
||||
|
||||
#Library Name
|
||||
ADAPTORLIB = $(OBJROOT)/libAdaptor.a
|
||||
|
||||
|
||||
# Common Source Files
|
||||
COMMON = $(SRCROOT)/common
|
||||
INCLUDE = -I$(COMMON)
|
||||
|
||||
ifeq "solaris" "$(PLATFORM_OS)"
|
||||
CFLAGS = -O2 $(RC_CFLAGS) $(INCLUDE) -DCGI -DSOLARIS -DNEEDS_HSTRERR
|
||||
else
|
||||
CFLAGS = -O2 $(RC_CFLAGS) $(INCLUDE) -DCGI
|
||||
endif
|
||||
|
||||
|
||||
all:: $(ADAPTORLIB)
|
||||
|
||||
include $(COMMON)/common.make
|
||||
|
||||
install: $(ADAPTORLIB)
|
||||
mv $(ADAPTORLIB) $(DSTROOT)
|
||||
|
||||
clean:
|
||||
rm -f $(COMMONOBJS) $(ADAPTORLIB) core
|
||||
|
||||
|
60
GSWAdaptors/common/GSWAppConnect.h
Normal file
60
GSWAdaptors/common/GSWAppConnect.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
/* GSWAppConnect.h - GSWeb: GSWeb App Connect
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWAppConnect_h__
|
||||
#define _GSWAppConnect_h__
|
||||
|
||||
typedef struct _STAppConnectHandle
|
||||
{
|
||||
void* foo;
|
||||
} STAppConnectHandle;
|
||||
|
||||
typedef STAppConnectHandle* AppConnectHandle;
|
||||
|
||||
|
||||
AppConnectHandle GSWApp_Open(void* p_pLogServerData,
|
||||
GSWAppRequest* p_pAppRequest);
|
||||
void GSWApp_Close(void* p_pLogServerData,
|
||||
AppConnectHandle p_handle);
|
||||
|
||||
int GSWApp_SendBlock(void* p_pLogServerData,
|
||||
AppConnectHandle p_handle,
|
||||
CONST char* p_pszBuffer,
|
||||
int p_iSize);
|
||||
int GSWApp_ReceiveBlock(void* p_pLogServerData,
|
||||
AppConnectHandle p_handle,
|
||||
char* p_pszBuffer,
|
||||
int p_iBufferSize);
|
||||
|
||||
int GSWApp_SendLine(void* p_pLogServerData,
|
||||
AppConnectHandle p_handle,
|
||||
CONST char* p_pszBuffer);
|
||||
int GSWApp_ReceiveLine(void* p_pLogServerData,
|
||||
AppConnectHandle p_handle,
|
||||
char* p_pszBuffer,
|
||||
int p_iBufferSize);
|
||||
|
||||
|
||||
#endif // _GSWAppConnect_h__
|
||||
|
||||
|
214
GSWAdaptors/common/GSWAppConnectNSSocket.c
Normal file
214
GSWAdaptors/common/GSWAppConnectNSSocket.c
Normal file
|
@ -0,0 +1,214 @@
|
|||
/* GSWAppConnectNSSocket.c - GSWeb: Adaptors: App Connection by Netscape Sockets
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "GSWUtil.h"
|
||||
#include "GSWDict.h"
|
||||
#include "GSWURLUtil.h"
|
||||
#include "GSWAppRequest.h"
|
||||
#include "GSWAppConnect.h"
|
||||
|
||||
typedef SYS_NETFD AppConnectNSSocketHandle;
|
||||
|
||||
AppConnectHandle GSWApp_Open(void* p_pLogServerData,
|
||||
GSWAppRequest* p_pAppRequest)
|
||||
{
|
||||
AppConnectHandle handle=NULL;
|
||||
if (!p_pAppRequest)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
struct hostent* pHost=hl_find(p_pAppRequest->pszHost);
|
||||
if (!pHost)
|
||||
{
|
||||
GSWLog(GSW_ERROR, "gethostbyname(%s) returns no host",p_pAppRequest->pszHost);
|
||||
}
|
||||
else if (pHost->h_addrtype!=AF_INET)
|
||||
{
|
||||
GSWLog(GSW_ERROR,"Host %s has bad address type",p_pAppRequest->pszHost);
|
||||
}
|
||||
else
|
||||
{
|
||||
AppConnectNSSocketHandle nshandle=NULL;
|
||||
struct sockaddr_in sin;
|
||||
memset(&sin,0,sizeof(sin));
|
||||
sin.sin_family = pHost->h_addrtype;
|
||||
sin.sin_port = htons(p_pAppRequest->iPort);
|
||||
memcpy(&sin.sin_addr, pHost->h_addr_list[0] , pHost->h_length);
|
||||
|
||||
GSWLog(GSW_INFO, "Try contacting %s on port %d...",
|
||||
p_pAppRequest->pszHost,
|
||||
p_pAppRequest->iPort);
|
||||
nshandle = net_socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
|
||||
if (nshandle<0)
|
||||
{
|
||||
GSWLog(GSW_ERROR,"Can't Create socket to %s:%d. Error=%d (%s)",
|
||||
p_pAppRequest->pszHost,
|
||||
p_pAppRequest->iPort,
|
||||
errno,
|
||||
strerror(errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (net_connect(nshandle,(struct sockaddr*)&sin,sizeof(sin))<0)
|
||||
{
|
||||
GSWLog(GSW_ERROR,"Can't connect to %s:%d. Error=%d (%s)",
|
||||
p_pAppRequest->pszHost,
|
||||
p_pAppRequest->iPort,
|
||||
errno,
|
||||
strerror(errno));
|
||||
net_close(nshandle);
|
||||
};
|
||||
};
|
||||
handle=(AppConnectHandle)nshandle;
|
||||
};
|
||||
};
|
||||
return handle;
|
||||
};
|
||||
|
||||
void GSWApp_Close(void* p_pLogServerData,
|
||||
AppConnectHandle p_handle)
|
||||
{
|
||||
if (p_handle)
|
||||
{
|
||||
AppConnectNSSocketHandle handle=(AppConnectNSSocketHandle)p_handle;
|
||||
if (handle && handle>(AppConnectNSSocketHandle)1)
|
||||
net_close(handle);
|
||||
};
|
||||
};
|
||||
|
||||
int GSWApp_SendLine(void* p_pLogServerData,
|
||||
AppConnectHandle p_handle,
|
||||
CONST char* p_pszBuffer)
|
||||
{
|
||||
int iRetValue=-1;
|
||||
if (p_handle)
|
||||
iRetValue=sendbytes(p_handle,p_pszBuffer,strlen(p_pszBuffer));
|
||||
return iRetValue;
|
||||
}
|
||||
|
||||
int GSWApp_SendBlock(void* p_pLogServerData,
|
||||
AppConnectHandle p_handle,
|
||||
CONST char* p_pszBuffer,
|
||||
int p_iSize)
|
||||
{
|
||||
int iRetValue=-1;
|
||||
if (p_handle)
|
||||
{
|
||||
AppConnectNSSocketHandle handle=(AppConnectNSSocketHandle)p_handle;
|
||||
int iSent=0;
|
||||
int iRemainingSize = p_iSize;
|
||||
while (iRemainingSize>0 && iSent>=0)
|
||||
{
|
||||
iSent=net_write(handle,(char*)p_pszBuffer,iRemainingSize);
|
||||
if (iSent<0)
|
||||
GSWLog(GSW_ERROR,"send failed. Error=%d (%s)",
|
||||
errno,
|
||||
strerror(errno));
|
||||
else
|
||||
{
|
||||
p_pszBuffer+=iSent;
|
||||
iRemainingSize-=iSent;
|
||||
};
|
||||
};
|
||||
iRetValue=(iRemainingSize>0) ? -1 : 0;
|
||||
};
|
||||
return iRetValue;
|
||||
}
|
||||
|
||||
int GSWApp_ReceiveLine(void* p_pLogServerData,
|
||||
AppConnectHandle p_handle,
|
||||
char* p_pszBuffer,
|
||||
int p_iBufferSize)
|
||||
{
|
||||
int iRetValue=-1;
|
||||
if (p_handle)
|
||||
{
|
||||
AppConnectNSSocketHandle handle=(AppConnectNSSocketHandle)p_handle;
|
||||
char c=0;
|
||||
int iReaden=0;
|
||||
int i = 0;
|
||||
BOOL fOk=TRUE;
|
||||
while (c!='\n' && i<p_iBufferSize-1 && fOk)
|
||||
{
|
||||
iReaden=net_read(handle,&c,1,APP_CONNECT_TIMEOUT);
|
||||
if (iReaden<1)
|
||||
{
|
||||
GSWLog(GSW_ERROR,"GSWApp_ReceiveLine. Error=%d (%s)",
|
||||
errno,
|
||||
strerror(errno));
|
||||
iRetValue=0; //??
|
||||
fOk=FALSE;
|
||||
}
|
||||
else
|
||||
p_pszBuffer[i++] = c;
|
||||
};
|
||||
if (i>0)
|
||||
{
|
||||
p_pszBuffer[i] = '\0';
|
||||
iRetValue=DeleteTrailingCRNL(p_pszBuffer);
|
||||
}
|
||||
else
|
||||
iRetValue=0; //??
|
||||
};
|
||||
return iRetValue;
|
||||
};
|
||||
|
||||
int GSWApp_ReceiveBlock(void* p_pLogServerData,
|
||||
AppConnectHandle p_handle,
|
||||
char* p_pszBuffer,
|
||||
int p_iBufferSize)
|
||||
{
|
||||
int iRetValue=-1;
|
||||
if (p_handle)
|
||||
{
|
||||
AppConnectNSSocketHandle handle=(AppConnectNSSocketHandle)p_handle;
|
||||
int iReceived=0;
|
||||
int iRemainingSize=p_iBufferSize;
|
||||
BOOL fOk=TRUE;
|
||||
while (iRemainingSize>0 && fOk)
|
||||
{
|
||||
iReceived=net_read(handle,p_pszBuffer,iRemainingSize,APP_CONNECT_TIMEOUT);
|
||||
if (iReceived<0)
|
||||
{
|
||||
GSWLog(GSW_ERROR,"GSWApp_ReceiveBlock failed. Error=%d %s",
|
||||
errno,
|
||||
strerror(errno));
|
||||
fOk=FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_pszBuffer+=iReceived;
|
||||
iRemainingSize-=iReceived;
|
||||
};
|
||||
};
|
||||
iRetValue=p_iBufferSize-iRemainingSize;
|
||||
};
|
||||
return iRetValue;
|
||||
};
|
261
GSWAdaptors/common/GSWAppConnectSocket.c
Normal file
261
GSWAdaptors/common/GSWAppConnectSocket.c
Normal file
|
@ -0,0 +1,261 @@
|
|||
/* GSWAppConnectSocket.c - GSWeb: Adaptors: App Connection by Socket
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "GSWUtil.h"
|
||||
#include "GSWDict.h"
|
||||
#include "GSWURLUtil.h"
|
||||
#include "GSWAppRequestStruct.h"
|
||||
#include "GSWAppConnect.h"
|
||||
|
||||
typedef struct _STAppConnectSocket
|
||||
{
|
||||
int iSocketDescr;
|
||||
FILE* pFileRead;
|
||||
FILE* pFileWrite;
|
||||
} STAppConnectSocket;
|
||||
typedef STAppConnectSocket* AppConnectSocketHandle;
|
||||
|
||||
AppConnectHandle GSWApp_Open(void* p_pLogServerData,GSWAppRequest* p_pAppRequest)
|
||||
{
|
||||
AppConnectHandle handle=NULL;
|
||||
if (!p_pAppRequest)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
PSTHostent pHost = GSWUtil_FindHost(p_pLogServerData,p_pAppRequest->pszHost);
|
||||
if (!pHost)
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,
|
||||
"gethostbyname(%s) returns no host",
|
||||
p_pAppRequest->pszHost);
|
||||
}
|
||||
else
|
||||
{
|
||||
int iSocketDescr = 0;
|
||||
struct sockaddr_in sin;
|
||||
memset(&sin,0,sizeof(sin));
|
||||
sin.sin_family = pHost->h_addrtype;
|
||||
sin.sin_port = htons(p_pAppRequest->iPort);
|
||||
memcpy(&sin.sin_addr,pHost->h_addr_list[0],pHost->h_length);
|
||||
GSWLog(GSW_INFO,
|
||||
p_pLogServerData,
|
||||
"Try contacting %s on port %d...",
|
||||
p_pAppRequest->pszHost,
|
||||
p_pAppRequest->iPort);
|
||||
iSocketDescr=socket(pHost->h_addrtype,SOCK_STREAM, 0);
|
||||
if (iSocketDescr<0)
|
||||
{
|
||||
GSWLog(GSW_ERROR,
|
||||
p_pLogServerData,
|
||||
"Can't Create socket to %s:%d. Error=%d (%s)",
|
||||
p_pAppRequest->pszHost,
|
||||
p_pAppRequest->iPort,
|
||||
errno,
|
||||
strerror(errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (connect(iSocketDescr,(struct sockaddr*)&sin,sizeof(sin))<0)
|
||||
{
|
||||
GSWLog(GSW_ERROR,
|
||||
p_pLogServerData,
|
||||
"Can't connect to %s:%d. Error=%d (%s)",
|
||||
p_pAppRequest->pszHost,
|
||||
p_pAppRequest->iPort,
|
||||
errno,
|
||||
strerror(errno));
|
||||
close(iSocketDescr);
|
||||
iSocketDescr=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
FILE* pFileRead=fdopen(iSocketDescr,"r");
|
||||
if (!pFileRead)
|
||||
{
|
||||
GSWLog(GSW_ERROR,
|
||||
p_pLogServerData,
|
||||
"Can't open for reading. Error=%d (%s)",
|
||||
errno,
|
||||
strerror(errno));
|
||||
close(iSocketDescr);
|
||||
iSocketDescr=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
FILE* pFileWrite=fdopen(iSocketDescr,"w");
|
||||
if (!pFileWrite)
|
||||
{
|
||||
GSWLog(GSW_ERROR,
|
||||
p_pLogServerData,
|
||||
"Can't open for writing. Error=%d (%s)",
|
||||
errno,
|
||||
strerror(errno));
|
||||
fclose(pFileRead);
|
||||
pFileRead=NULL;
|
||||
close(iSocketDescr);
|
||||
iSocketDescr=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
handle = calloc(1, sizeof(STAppConnectSocket));
|
||||
((AppConnectSocketHandle)handle)->iSocketDescr = iSocketDescr;
|
||||
((AppConnectSocketHandle)handle)->pFileRead = pFileRead;
|
||||
((AppConnectSocketHandle)handle)->pFileWrite = pFileWrite;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
return handle;
|
||||
};
|
||||
|
||||
void GSWApp_Close(void* p_pLogServerData,AppConnectHandle p_handle)
|
||||
{
|
||||
/*
|
||||
#ifdef DEBUG
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,"GSWApp_Close Start");
|
||||
#endif
|
||||
*/
|
||||
if (p_handle)
|
||||
{
|
||||
AppConnectSocketHandle handle=(AppConnectSocketHandle)p_handle;
|
||||
if (handle->iSocketDescr)
|
||||
{
|
||||
close(handle->iSocketDescr);
|
||||
fclose(handle->pFileRead);
|
||||
fclose(handle->pFileWrite);
|
||||
};
|
||||
free(handle);
|
||||
};
|
||||
/*
|
||||
#ifdef DEBUG
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,"GSWApp_Close Stop");
|
||||
#endif
|
||||
*/
|
||||
};
|
||||
|
||||
int GSWApp_SendLine(void* p_pLogServerData,AppConnectHandle p_handle, CONST char* p_pszBuffer)
|
||||
{
|
||||
int iRetValue=-1;
|
||||
if (p_handle)
|
||||
{
|
||||
AppConnectSocketHandle handle=(AppConnectSocketHandle)p_handle;
|
||||
if (fputs(p_pszBuffer,handle->pFileWrite)!=EOF)
|
||||
{
|
||||
fflush(handle->pFileWrite);
|
||||
iRetValue=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
GSWLog(GSW_ERROR,
|
||||
p_pLogServerData,
|
||||
"GSWApp_SendLine failed. Error=%d (%s)",
|
||||
errno,
|
||||
strerror(errno));
|
||||
iRetValue=-1;
|
||||
};
|
||||
};
|
||||
return iRetValue;
|
||||
}
|
||||
|
||||
|
||||
int GSWApp_SendBlock(void* p_pLogServerData,
|
||||
AppConnectHandle p_handle,
|
||||
CONST char* p_pszBuffer,
|
||||
int p_iSize)
|
||||
{
|
||||
int iRetValue=-1;
|
||||
int iBytesSent=0;
|
||||
if (p_handle)
|
||||
{
|
||||
AppConnectSocketHandle handle=(AppConnectSocketHandle)p_handle;
|
||||
iBytesSent = fwrite(p_pszBuffer,sizeof(char),p_iSize,handle->pFileWrite);
|
||||
fflush(handle->pFileWrite);
|
||||
|
||||
if (iBytesSent<0)
|
||||
{
|
||||
GSWLog(GSW_ERROR,
|
||||
p_pLogServerData,
|
||||
"send failed. Error=%d (%s)",
|
||||
errno,
|
||||
strerror(errno));
|
||||
iRetValue=-1;
|
||||
}
|
||||
else
|
||||
iRetValue=0;
|
||||
};
|
||||
return iRetValue;
|
||||
};
|
||||
|
||||
|
||||
int GSWApp_ReceiveLine(void* p_pLogServerData,
|
||||
AppConnectHandle p_handle,
|
||||
char* p_pszBuffer,
|
||||
int p_iBufferSize)
|
||||
{
|
||||
int iRetValue=-1;
|
||||
if (p_handle)
|
||||
{
|
||||
AppConnectSocketHandle handle=(AppConnectSocketHandle)p_handle;
|
||||
char* pszLine=fgets(p_pszBuffer,p_iBufferSize,handle->pFileRead);
|
||||
if (pszLine)
|
||||
{
|
||||
iRetValue=DeleteTrailingCRNL(p_pszBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
*p_pszBuffer=0;
|
||||
iRetValue=-1; //??
|
||||
};
|
||||
};
|
||||
return iRetValue;
|
||||
};
|
||||
|
||||
int GSWApp_ReceiveBlock(void* p_pLogServerData,
|
||||
AppConnectHandle p_handle,
|
||||
char* p_pszBuffer,
|
||||
int p_iBufferSize)
|
||||
{
|
||||
int iRetValue=-1;
|
||||
if (p_handle)
|
||||
{
|
||||
AppConnectSocketHandle handle=(AppConnectSocketHandle)p_handle;
|
||||
iRetValue=fread(p_pszBuffer,sizeof(char),p_iBufferSize,handle->pFileRead);
|
||||
};
|
||||
return iRetValue;
|
||||
};
|
||||
|
260
GSWAdaptors/common/GSWAppRequest.c
Normal file
260
GSWAdaptors/common/GSWAppRequest.c
Normal file
|
@ -0,0 +1,260 @@
|
|||
/* GSWAppRequest.c - GSWeb: Adaptors: App Request
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "GSWUtil.h"
|
||||
#include "GSWDict.h"
|
||||
#include "GSWConfig.h"
|
||||
#include "GSWURLUtil.h"
|
||||
#include "GSWAppRequestStruct.h"
|
||||
#include "GSWAppConnect.h"
|
||||
#include "GSWHTTPRequest.h"
|
||||
#include "GSWHTTPResponse.h"
|
||||
#include "GSWAppRequest.h"
|
||||
#include "GSWHTTPHeaders.h"
|
||||
#include "GSWLoadBalancing.h"
|
||||
|
||||
unsigned long glbRequestsNb = 0;
|
||||
unsigned long glbResponsesNb = 0;
|
||||
|
||||
|
||||
GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequest,
|
||||
GSWURLComponents* p_pURLComponents,
|
||||
GSWAppRequest* p_pAppRequest,
|
||||
CONST char* p_pszHTTPVersion,
|
||||
void* p_pLogServerData);
|
||||
|
||||
GSWHTTPResponse* GSWAppRequest_HandleRequest(GSWHTTPRequest** p_ppHTTPRequest,
|
||||
GSWURLComponents* p_pURLComponents,
|
||||
CONST char* p_pszHTTPVersion,
|
||||
CONST char* p_pszDocRoot,
|
||||
CONST char* p_pszTestAppName,
|
||||
void* p_pLogServerData)
|
||||
{
|
||||
GSWHTTPResponse* pHTTPResponse=NULL;
|
||||
glbRequestsNb++;
|
||||
|
||||
if (p_pURLComponents->stAppName.iLength<=0
|
||||
|| !p_pURLComponents->stAppName.pszStart)
|
||||
{
|
||||
pHTTPResponse=GSWHTTPResponse_BuildErrorResponse("No Application Name");
|
||||
}
|
||||
else
|
||||
{
|
||||
char szAppName[MAXPATHLEN+1]="";
|
||||
char szHost[MAXHOSTNAMELEN+1]="";
|
||||
GSWAppRequest stAppRequest;
|
||||
memset(&stAppRequest,0,sizeof(stAppRequest));
|
||||
|
||||
// Get App Name
|
||||
strncpy(szAppName,
|
||||
p_pURLComponents->stAppName.pszStart,
|
||||
p_pURLComponents->stAppName.iLength);
|
||||
szAppName[p_pURLComponents->stAppName.iLength]=0;
|
||||
|
||||
DeleteTrailingSlash(szAppName);
|
||||
if (strcmp(szAppName,p_pszTestAppName) == 0)
|
||||
pHTTPResponse=GSWHTTPResponse_BuildTestResponse(p_pLogServerData,*p_ppHTTPRequest);
|
||||
else
|
||||
{
|
||||
// Get Host Name
|
||||
if (p_pURLComponents->stAppHost.iLength>0 && p_pURLComponents->stAppHost.pszStart)
|
||||
{
|
||||
strncpy(szHost,
|
||||
p_pURLComponents->stAppHost.pszStart,
|
||||
p_pURLComponents->stAppHost.iLength);
|
||||
szHost[p_pURLComponents->stAppHost.iLength] = '\0';
|
||||
};
|
||||
|
||||
// Get Request Instance Number
|
||||
|
||||
// in URL ?
|
||||
if (p_pURLComponents->stAppNumber.iLength>0 && p_pURLComponents->stAppNumber.pszStart)
|
||||
stAppRequest.iInstance = atoi(p_pURLComponents->stAppNumber.pszStart);
|
||||
|
||||
// In Cookie ?
|
||||
else
|
||||
{
|
||||
CONST char* pszCookie=GSWHTTPRequest_HeaderForKey(*p_ppHTTPRequest,g_szHeader_Cookie);
|
||||
if (pszCookie)
|
||||
{
|
||||
CONST char* pszInstanceCookie=strstr(pszCookie, g_szGSWeb_InstanceCookie);
|
||||
if (pszInstanceCookie)
|
||||
{
|
||||
stAppRequest.iInstance = atoi(pszInstanceCookie + strlen(g_szGSWeb_InstanceCookie));
|
||||
GSWLog(GSW_INFO,p_pLogServerData,"Cookie instance %d from %s",
|
||||
stAppRequest.iInstance,
|
||||
pszCookie);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
stAppRequest.pszName = szAppName;
|
||||
stAppRequest.pszHost = szHost;
|
||||
stAppRequest.pszDocRoot = p_pszDocRoot;
|
||||
stAppRequest.pRequest = *p_ppHTTPRequest;
|
||||
stAppRequest.uURLVersion = (p_pURLComponents->stVersion.pszStart) ?
|
||||
atoi(p_pURLComponents->stVersion.pszStart) : GSWEB_VERSION_MAJOR;
|
||||
|
||||
GSWHTTPRequest_AddHeader(*p_ppHTTPRequest,
|
||||
g_szHeader_GSWeb_ServerAdaptor,
|
||||
g_szGSWeb_ServerAndAdaptorVersion);
|
||||
pHTTPResponse=GSWAppRequest_SendAppRequestToApp(p_ppHTTPRequest,
|
||||
p_pURLComponents,
|
||||
&stAppRequest,
|
||||
p_pszHTTPVersion,
|
||||
p_pLogServerData);
|
||||
};
|
||||
};
|
||||
return pHTTPResponse;
|
||||
}
|
||||
|
||||
GSWHTTPResponse* GSWAppRequest_SendAppRequestToApp(GSWHTTPRequest** p_ppHTTPRequest,
|
||||
GSWURLComponents* p_pURLComponents,
|
||||
GSWAppRequest* p_pAppRequest,
|
||||
CONST char* p_pszHTTPVersion,
|
||||
void* p_pLogServerData)
|
||||
{
|
||||
GSWHTTPResponse* pHTTPResponse=NULL;
|
||||
BOOL fAppFound=FALSE;
|
||||
int iAttemptsRemaining=APP_CONNECT_RETRIES_NB;
|
||||
AppConnectHandle hConnect=NULL;
|
||||
|
||||
if (p_pAppRequest->iInstance)
|
||||
fAppFound = GSWLoadBalancing_FindInstance(p_pLogServerData,p_pAppRequest);
|
||||
else
|
||||
fAppFound = GSWLoadBalancing_FindApp(p_pLogServerData,p_pAppRequest);
|
||||
|
||||
if (!fAppFound)
|
||||
{
|
||||
//TODO
|
||||
// Call AppStart daemon
|
||||
};
|
||||
|
||||
while (!pHTTPResponse && fAppFound && iAttemptsRemaining-->0)
|
||||
{
|
||||
GSWLog(GSW_INFO,p_pLogServerData,"Trying to contact %s:%d on %s(%d)",
|
||||
p_pAppRequest->pszName,
|
||||
p_pAppRequest->iInstance,
|
||||
p_pAppRequest->pszHost,
|
||||
p_pAppRequest->iPort);
|
||||
|
||||
hConnect = GSWApp_Open(p_pLogServerData,p_pAppRequest);
|
||||
if (hConnect)
|
||||
{
|
||||
if (p_pAppRequest->eType==EAppType_LoadBalanced)
|
||||
GSWLoadBalancing_StartAppRequest(p_pLogServerData,p_pAppRequest);
|
||||
|
||||
GSWLog(GSW_INFO,p_pLogServerData,"%s:%d on %s(%d) connected",
|
||||
p_pAppRequest->pszName,
|
||||
p_pAppRequest->iInstance,
|
||||
p_pAppRequest->pszHost,
|
||||
p_pAppRequest->iPort);
|
||||
|
||||
GSWHTTPRequest_HTTPToAppRequest(*p_ppHTTPRequest,
|
||||
p_pAppRequest,
|
||||
p_pURLComponents,
|
||||
p_pszHTTPVersion);
|
||||
if (GSWHTTPRequest_SendRequest(p_pLogServerData,*p_ppHTTPRequest, hConnect) != 0)
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,"Failed to send request");
|
||||
GSWApp_Close(p_pLogServerData,hConnect);
|
||||
hConnect=NULL;
|
||||
pHTTPResponse=GSWHTTPResponse_BuildErrorResponse("No Response");
|
||||
}
|
||||
else
|
||||
{
|
||||
GSWLog(GSW_INFO,p_pLogServerData,
|
||||
"Request %s sent, awaiting response",
|
||||
(*p_ppHTTPRequest)->pszRequest);
|
||||
|
||||
p_pAppRequest->pRequest = NULL;
|
||||
pHTTPResponse = GSWHTTPResponse_GetResponse(p_pLogServerData,hConnect);
|
||||
// GSWLog(GSW_INFO,p_pLogServerData,"GetResponse End pHTTPResponse=%p",pHTTPResponse);
|
||||
p_pAppRequest->pResponse = pHTTPResponse;
|
||||
|
||||
if (p_pAppRequest->eType == EAppType_LoadBalanced)
|
||||
GSWLoadBalancing_StopAppRequest(p_pLogServerData,p_pAppRequest);
|
||||
|
||||
GSWApp_Close(p_pLogServerData,hConnect);
|
||||
hConnect=NULL;
|
||||
|
||||
glbResponsesNb++;
|
||||
if (pHTTPResponse)
|
||||
{
|
||||
GSWLog(GSW_INFO,p_pLogServerData,
|
||||
"received: %d %s",
|
||||
pHTTPResponse->uStatus,
|
||||
pHTTPResponse->pszStatusMessage);
|
||||
};
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
GSWLog(GSW_INFO,p_pLogServerData,"%s:%d NOT LISTENING on %s(%d)",
|
||||
p_pAppRequest->pszName,
|
||||
p_pAppRequest->iInstance,
|
||||
p_pAppRequest->pszHost,
|
||||
p_pAppRequest->iPort);
|
||||
//TODO
|
||||
/*
|
||||
if (p_pAppRequest->eType == EAppType_Auto)
|
||||
GSWLoadBalancing_MarkNotRespondingApp(p_pLogServerData,p_pAppRequest);
|
||||
|
||||
else*/ if (p_pAppRequest->eType == EAppType_LoadBalanced)
|
||||
{
|
||||
GSWLoadBalancing_MarkNotRespondingApp(p_pLogServerData,p_pAppRequest);
|
||||
if (iAttemptsRemaining-- > 0)
|
||||
fAppFound = GSWLoadBalancing_FindApp(p_pLogServerData,p_pAppRequest);
|
||||
};
|
||||
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse("No Response");
|
||||
};
|
||||
};
|
||||
if (!pHTTPResponse)
|
||||
{
|
||||
GSWLog(GSW_INFO,p_pLogServerData,
|
||||
"Application %s not found or not responding",
|
||||
p_pAppRequest->pszName);
|
||||
pHTTPResponse = GSWDumpConfigFile(p_pLogServerData,p_pURLComponents);
|
||||
if (!pHTTPResponse)
|
||||
{
|
||||
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse("No App Found");
|
||||
pHTTPResponse->uStatus = 404;
|
||||
if (pHTTPResponse->pszStatusMessage)
|
||||
{
|
||||
free(pHTTPResponse->pszStatusMessage);
|
||||
pHTTPResponse->pszStatusMessage=NULL;
|
||||
};
|
||||
pHTTPResponse->pszStatusMessage = strdup("File Not found");
|
||||
}
|
||||
};
|
||||
GSWHTTPRequest_Free(*p_ppHTTPRequest);
|
||||
*p_ppHTTPRequest=NULL;
|
||||
return pHTTPResponse;
|
||||
};
|
41
GSWAdaptors/common/GSWAppRequest.h
Normal file
41
GSWAdaptors/common/GSWAppRequest.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* GSWAppRequest.h - GSWeb: GSWeb App Request
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWAppRequest_h__
|
||||
#define _GSWAppRequest_h__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
#define GSWAppRequest_INITIALIZER {NULL,NULL,NULL,0,0,AT_NONE,3,NULL,NULL,NULL,NULL}
|
||||
|
||||
GSWHTTPResponse* GSWAppRequest_HandleRequest(GSWHTTPRequest** p_ppHTTPRequest,
|
||||
GSWURLComponents* p_pURLComponents,
|
||||
CONST char* p_pszHTTPVersion,
|
||||
CONST char* p_pszDocRoot,
|
||||
CONST char* p_pszTestAppName,
|
||||
void* p_pLogServerData);
|
||||
|
||||
#endif //_GSWAppRequest_h__
|
||||
|
57
GSWAdaptors/common/GSWAppRequestStruct.h
Normal file
57
GSWAdaptors/common/GSWAppRequestStruct.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/* GSWAppRequestStruct.h - GSWeb: GSWeb App Request Struct
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWAppRequestStruct_h__
|
||||
#define _GSWAppRequestStruct_h__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
// Application Type
|
||||
typedef enum {
|
||||
EAppType_Unknown,
|
||||
EAppType_Auto, // autolaunched/co-hosted
|
||||
EAppType_LoadBalanced
|
||||
} EAppType;
|
||||
|
||||
|
||||
// AppRequest
|
||||
typedef struct _GSWAppRequest
|
||||
{
|
||||
char* pszName; // App Name relative to Prefix
|
||||
char* pszHost; // App Host
|
||||
void* pHostent; // App Host hostent
|
||||
int iPort; // AppPort
|
||||
int iInstance; // App Instance
|
||||
EAppType eType; // AppType
|
||||
unsigned char uURLVersion; // URL Version
|
||||
CONST char* pszDocRoot; // Doc Root
|
||||
void* pRequest; // HTTPRequest
|
||||
void* pResponse; // HTTPResponse
|
||||
void* pLoadBalancingData; // Load Balancing Data
|
||||
} GSWAppRequest;
|
||||
|
||||
|
||||
#endif //_GSWAppRequestStruct_h__
|
||||
|
568
GSWAdaptors/common/GSWConfig.c
Normal file
568
GSWAdaptors/common/GSWConfig.c
Normal file
|
@ -0,0 +1,568 @@
|
|||
/* GSWConfig.c - GSWeb: Adaptors: Config
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include "config.h"
|
||||
#include "GSWUtil.h"
|
||||
#include "GSWDict.h"
|
||||
#include "GSWURLUtil.h"
|
||||
#include "GSWUtil.h"
|
||||
#include "GSWConfig.h"
|
||||
|
||||
#define MAX_LENGTH_CONF_LINE 1024
|
||||
|
||||
static const int timeIntervalBetweenStats = CONFIG_FILE_STAT_INTERVAL;
|
||||
|
||||
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_Handler=GSWEB_HANDLER;
|
||||
const char* g_szGSWeb_AppExtention=GSWAPP_EXTENSION;
|
||||
|
||||
const char* g_szGSWeb_MimeType=GSWEB__MIME_TYPE;
|
||||
const char* g_szGSWeb_Conf_DocRoot=GSWEB_CONF__DOC_ROOT;
|
||||
const char* g_szGSWeb_Conf_ConfigFilePath=GSWEB_CONF__CONFIG_FILE_PATH;
|
||||
|
||||
|
||||
// Apache
|
||||
const char* g_szGSWeb_Conf_Alias=GSWEB_CONF__ALIAS;
|
||||
|
||||
// Netscape
|
||||
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_Name=GSWEB_CONF__NAME;
|
||||
|
||||
|
||||
|
||||
|
||||
const char* g_szGSWeb_DefaultConfigFilePath=DEFAULT_CONFIG_FILE_PATH;
|
||||
const char* g_szGSWeb_DefaultLogFilePath=DEFAULT_LOG_FILE_PATH;
|
||||
const char* g_szGSWeb_DefaultLogFlagPath=DEFAULT_LOG_FLAG_PATH;
|
||||
const char* g_szGSWeb_DefaultDumpFlagPath=DEFAULT_DUMP_FLAG_PATH;
|
||||
|
||||
const char* g_szGSWeb_DefaultGSWExtensionsFrameworkWebServerResources=DEFAULT_GSWEXTENSIONS_FRAMEWORK_WEB_SERVER_RESOURCES;
|
||||
|
||||
|
||||
const char* g_szGSWeb_InstanceCookie=GSWEB_INSTANCE_COOKIE;
|
||||
|
||||
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_szDumpConfFile_Head="<HTML><HEAD><TITLE>Index of GNUstepWeb Applications</TITLE></HEAD>\n"
|
||||
"<BODY BGCOLOR=\"#FFFFFF\">"
|
||||
"<CENTER><H3>Could not find the application specified in the URL (%s).</H3>\n"
|
||||
"<H4>Index of GNUstepWeb Applications in %s (some applications may be down)</H4>\n"
|
||||
"<table border=1>"
|
||||
"<tr>\n"
|
||||
"<td align=center rowspan=2>Name</td>"
|
||||
"<td align=center rowspan=2>Application Access</td>"
|
||||
"<td align=center colspan=3>Instances</td>"
|
||||
"</tr>\n"
|
||||
"<tr>\n"
|
||||
"<td align=center>#</td>"
|
||||
"<td align=center>Host</td>"
|
||||
"<td align=center>Port</td>"
|
||||
"</tr>\n";
|
||||
|
||||
const char* g_szDumpConfFile_Foot="</table></CENTER>\n"
|
||||
"<BR>\n"
|
||||
"<CENTER><A HREF=\"http://www.gnustep.org\"><IMG SRC=\"%s/PoweredByGNUstepWeb.gif\" ALT=\"Powered By GNUstepWeb\" BORDER=0></A></CENTER>\n"
|
||||
"</BODY></HTML>";
|
||||
|
||||
|
||||
const char* const g_szGNUstep = "GNUstep";
|
||||
const char* const g_szOKGSWeb = "OK GSWeb";
|
||||
const char* const g_szOKStatus = "HTTP/1.0 200 OK GNUstep GSWeb";
|
||||
|
||||
|
||||
const char* g_szErrorResponseHTMLTextTpl = "<HTML><BODY BGCOLOR=\"#FFFFFF\"><CENTER><H1>%s</H1></CENTER></BODY></HTML>\n";
|
||||
|
||||
static char *g_pszConfigFilePath = NULL;
|
||||
|
||||
proplist_t configKey__Applications=NULL;
|
||||
proplist_t configKey__Instances=NULL;
|
||||
proplist_t configKey__InstanceNum=NULL;
|
||||
proplist_t configKey__Host=NULL;
|
||||
proplist_t configKey__Port=NULL;
|
||||
proplist_t configKey__Parameters=NULL;
|
||||
|
||||
|
||||
void GSWConfig_Init()
|
||||
{
|
||||
if (!configKey__Applications)
|
||||
{
|
||||
configKey__Applications=PLMakeString("applications");
|
||||
configKey__Instances=PLMakeString("instances");
|
||||
configKey__InstanceNum=PLMakeString("instanceNum");
|
||||
configKey__Host=PLMakeString("host");
|
||||
configKey__Port=PLMakeString("port");
|
||||
configKey__Parameters=PLMakeString("parameters");
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
* parse: <appname>=[-]<instance_number>@<hostname>:<port> [<key>=<Value>]*
|
||||
*/
|
||||
static EGSWConfigResult GSWConfig_GetEntryComponentsFromLine(char* p_pszLine,char** p_ppszComponents)
|
||||
{
|
||||
EGSWConfigResult eResult=EGSWConfigResult__Ok;
|
||||
|
||||
// Skip Spaces
|
||||
while (*p_pszLine && isspace(*p_pszLine))
|
||||
p_pszLine++;
|
||||
|
||||
if (!*p_pszLine)
|
||||
eResult=EGSWConfigResult__Error;
|
||||
else
|
||||
{
|
||||
// AppName
|
||||
p_ppszComponents[0] = p_pszLine;
|
||||
while (*p_pszLine && *p_pszLine!='=')
|
||||
p_pszLine++;
|
||||
// Found End of AppName ?
|
||||
if (*p_pszLine!='=')
|
||||
eResult=EGSWConfigResult__Error;
|
||||
else
|
||||
{
|
||||
*p_pszLine++=0;
|
||||
DeleteTrailingSpaces(p_ppszComponents[0]);
|
||||
|
||||
// Skip Spaces
|
||||
while (*p_pszLine && isspace(*p_pszLine))
|
||||
p_pszLine++;
|
||||
if (!*p_pszLine)
|
||||
eResult=EGSWConfigResult__Error;
|
||||
else
|
||||
{
|
||||
p_ppszComponents[1]=p_pszLine;
|
||||
if (*p_pszLine=='-')
|
||||
p_pszLine++;
|
||||
while (*p_pszLine && isdigit(*p_pszLine))
|
||||
p_pszLine++;
|
||||
|
||||
if (!*p_pszLine)
|
||||
eResult=EGSWConfigResult__Error;
|
||||
else
|
||||
{
|
||||
// End of Instance
|
||||
*p_pszLine++ = '\0';
|
||||
while (*p_pszLine && isspace(*p_pszLine))
|
||||
p_pszLine++;
|
||||
|
||||
if (*p_pszLine!='@')
|
||||
eResult=EGSWConfigResult__Error;
|
||||
else
|
||||
{
|
||||
// Host
|
||||
p_ppszComponents[2]=p_pszLine;
|
||||
while (*p_pszLine && !isspace(*p_pszLine) && *p_pszLine!=':')
|
||||
p_pszLine++;
|
||||
if (!*p_pszLine)
|
||||
eResult=EGSWConfigResult__Error;
|
||||
else
|
||||
{
|
||||
// End of host
|
||||
*p_pszLine++ = '\0';
|
||||
};
|
||||
// Skip Spaces
|
||||
while (*p_pszLine && isspace(*p_pszLine))
|
||||
p_pszLine++;
|
||||
|
||||
if (*p_pszLine!=':')
|
||||
eResult=EGSWConfigResult__Error;
|
||||
else
|
||||
{
|
||||
p_pszLine++; // Skip :
|
||||
|
||||
// Port Number
|
||||
if (*p_pszLine && isdigit(*p_pszLine))
|
||||
{
|
||||
p_ppszComponents[3]=p_pszLine;
|
||||
while (*p_pszLine && isdigit(*p_pszLine))
|
||||
p_pszLine++;
|
||||
if (*p_pszLine)
|
||||
{
|
||||
*p_pszLine=0;
|
||||
p_pszLine++;
|
||||
|
||||
// Skip Spaces
|
||||
while (*p_pszLine && isspace(*p_pszLine))
|
||||
p_pszLine++;
|
||||
|
||||
if (*p_pszLine)
|
||||
p_ppszComponents[4] = p_pszLine;
|
||||
else
|
||||
p_ppszComponents[4] = NULL;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
return eResult;
|
||||
};
|
||||
|
||||
static int GSWConfig_ReadLine(FILE* p_pFile,char* p_pszBuffer,int p_iBufferSize)
|
||||
{
|
||||
int iReaden=0;
|
||||
if (fgets(p_pszBuffer,p_iBufferSize,p_pFile))
|
||||
{
|
||||
iReaden = strlen(p_pszBuffer);
|
||||
while (iReaden && isspace(p_pszBuffer[iReaden]))
|
||||
iReaden--;
|
||||
if (p_pszBuffer[iReaden] == '\\') // Continued ?
|
||||
iReaden+=GSWConfig_ReadLine(p_pFile,p_pszBuffer+iReaden,p_iBufferSize-iReaden);
|
||||
};
|
||||
return iReaden;
|
||||
};
|
||||
|
||||
static EGSWConfigResult GSWConfig_ReadEntries(CONST char* p_pszConfigPath,
|
||||
EGSWConfigResult (*p_pFNConfigEntry)(EGSWConfigCallType p_eCallType,
|
||||
STGSWConfigEntry* p_pConfigEntry,
|
||||
void* p_pLogServerData),
|
||||
void* p_pLogServerData)
|
||||
{
|
||||
EGSWConfigResult eResult=EGSWConfigResult__Ok;
|
||||
if (!p_pszConfigPath)
|
||||
{
|
||||
eResult=EGSWConfigResult__Error;
|
||||
}
|
||||
else
|
||||
{
|
||||
FILE* pFile=fopen(p_pszConfigPath,"r");
|
||||
if (!pFile)
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,
|
||||
"Can't open configuration file %s. Error=%d (%s)",
|
||||
p_pszConfigPath,
|
||||
errno,
|
||||
strerror(errno));
|
||||
eResult=EGSWConfigResult__Error;
|
||||
}
|
||||
else
|
||||
{
|
||||
eResult=p_pFNConfigEntry(EGSWConfigResult__Clear,NULL,p_pLogServerData);
|
||||
if (eResult==EGSWConfigResult__Ok)
|
||||
{
|
||||
STGSWConfigEntry stEntry;
|
||||
char* szComponents[5]={ "","","","",""};
|
||||
char szLine[MAX_LENGTH_CONF_LINE+1]="";
|
||||
int iLine = 0;
|
||||
while (GSWConfig_ReadLine(pFile,szLine,MAX_LENGTH_CONF_LINE)>0 && eResult==EGSWConfigResult__Ok)
|
||||
{
|
||||
memset(&stEntry,0,sizeof(stEntry));
|
||||
memset(szComponents,0,sizeof(szComponents)); //??
|
||||
memset(szLine,0,sizeof(szLine)); //??
|
||||
iLine++;
|
||||
if (szLine[0]!='#' && szLine[0] != '\n')
|
||||
{
|
||||
if (GSWConfig_GetEntryComponentsFromLine(szLine,szComponents)!=EGSWConfigResult__Ok)
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,
|
||||
"Invalid entry in configuration at line %d: (%s)",
|
||||
iLine,
|
||||
szLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
stEntry.pszAppName = szComponents[0];
|
||||
stEntry.iInstance = atoi(szComponents[1]);
|
||||
stEntry.pszHostName = szComponents[2];
|
||||
stEntry.iPort = atoi(szComponents[3]);
|
||||
if (szComponents[4])
|
||||
{
|
||||
// TODO
|
||||
GSWLog(GSW_WARNING,p_pLogServerData,
|
||||
"Parameter at line %d ignored. (%s)",
|
||||
iLine,
|
||||
szComponents[4]);
|
||||
};
|
||||
eResult=p_pFNConfigEntry(EGSWConfigResult__Add,
|
||||
&stEntry,
|
||||
p_pLogServerData);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
fclose(pFile);
|
||||
};
|
||||
return eResult;
|
||||
}
|
||||
|
||||
EGSWConfigResult GSWConfig_ReadIFND(CONST char* p_pszConfigPath,
|
||||
time_t* p_pLastReadTime,
|
||||
proplist_t* p_ppPropList,
|
||||
void* p_pLogServerData)
|
||||
{
|
||||
EGSWConfigResult eResult=EGSWConfigResult__Ok;
|
||||
if (!p_pszConfigPath)
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,"GSWeb: No path for config file.");
|
||||
eResult=EGSWConfigResult__Error;
|
||||
}
|
||||
else
|
||||
{
|
||||
time_t timeNow=(time_t)0;
|
||||
time_t timePrevious=*p_pLastReadTime;
|
||||
time(&timeNow);
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,"config file");
|
||||
|
||||
if (timeNow-timePrevious<timeIntervalBetweenStats)
|
||||
{
|
||||
GSWLog(GSW_INFO,p_pLogServerData,
|
||||
"GSWeb: GSWConfig_ReadIFND: Not Reading : Less than %d sec since last read config file.",
|
||||
timeIntervalBetweenStats);
|
||||
eResult=EGSWConfigResult__NotChanged;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct stat stStat;
|
||||
memset(&stStat,0,sizeof(stStat));
|
||||
if (stat(p_pszConfigPath, &stStat) == 0)
|
||||
{
|
||||
*p_pLastReadTime = timeNow;
|
||||
if (stStat.st_mtime>timePrevious)
|
||||
{
|
||||
GSWLog(GSW_INFO,p_pLogServerData,
|
||||
"GSWeb: GSWConfig_ReadIFND: Reading new configuration from %s",
|
||||
p_pszConfigPath);
|
||||
|
||||
*p_ppPropList=PLGetProplistWithPath(p_pszConfigPath);
|
||||
if (!*p_ppPropList)
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,
|
||||
"Can't read configuration file %s (PLGetProplistWithPath).",
|
||||
p_pszConfigPath);
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
GSWLog(GSW_INFO,p_pLogServerData,
|
||||
"GSWeb: GSWConfig_ReadIFND: Not Reading : config file not modified since last read.");
|
||||
eResult=EGSWConfigResult__NotChanged;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GSWLog(GSW_INFO,p_pLogServerData,
|
||||
"GSWeb: GSWConfig_ReadIFND: config file %s does not exist.",
|
||||
p_pszConfigPath);
|
||||
eResult=EGSWConfigResult__Error;
|
||||
};
|
||||
};
|
||||
};
|
||||
return eResult;
|
||||
};
|
||||
|
||||
proplist_t GSWConfig_GetApplicationsFromConfig(proplist_t p_propListConfig)
|
||||
{
|
||||
proplist_t propListApps=PLGetDictionaryEntry(p_propListConfig,configKey__Applications);
|
||||
if (!propListApps)
|
||||
{
|
||||
GSWLog(GSW_ERROR,NULL,"No propListApps");
|
||||
//TODO
|
||||
}
|
||||
else if (!PLIsDictionary(propListApps))
|
||||
{
|
||||
GSWLog(GSW_ERROR,NULL,"propListApps is not a dictionary");
|
||||
propListApps=NULL;
|
||||
//TODO
|
||||
};
|
||||
return propListApps;
|
||||
};
|
||||
|
||||
proplist_t GSWConfig_ApplicationKeyFromApplicationsKey(proplist_t p_propListApplicationsKeys,int p_iIndex)
|
||||
{
|
||||
proplist_t propListAppKey=PLGetArrayElement(p_propListApplicationsKeys,p_iIndex);
|
||||
if (!propListAppKey)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
else if (!PLIsString(propListAppKey))
|
||||
{
|
||||
//TODO
|
||||
propListAppKey=NULL;
|
||||
};
|
||||
return propListAppKey;
|
||||
};
|
||||
|
||||
proplist_t GSWConfig_InstancesFromApplication(proplist_t p_propListApplication)
|
||||
{
|
||||
proplist_t propListInstances=PLGetDictionaryEntry(p_propListApplication,configKey__Instances);
|
||||
if (!propListInstances)
|
||||
{
|
||||
GSWLog(GSW_ERROR,NULL,"no propListInstances");
|
||||
//TODO
|
||||
}
|
||||
else if (!PLIsArray(propListInstances))
|
||||
{
|
||||
GSWLog(GSW_ERROR,NULL,"propListInstances is not an array");
|
||||
propListInstances=NULL;
|
||||
};
|
||||
return propListInstances;
|
||||
};
|
||||
|
||||
proplist_t GSWConfig_ApplicationFromApplications(proplist_t p_propListApplications,proplist_t p_propListApplicationKey)
|
||||
{
|
||||
proplist_t propListApp=PLGetDictionaryEntry(p_propListApplications,p_propListApplicationKey);
|
||||
if (!propListApp)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
else if (!PLIsDictionary(propListApp))
|
||||
{
|
||||
//TODO
|
||||
propListApp=NULL;
|
||||
};
|
||||
return propListApp;
|
||||
};
|
||||
|
||||
proplist_t GSWConfig_ApplicationsKeysFromApplications(proplist_t p_propListApplications)
|
||||
{
|
||||
proplist_t propListAppsNames=NULL;
|
||||
if (p_propListApplications)
|
||||
{
|
||||
propListAppsNames=PLGetAllDictionaryKeys(p_propListApplications);
|
||||
};
|
||||
return propListAppsNames;
|
||||
};
|
||||
proplist_t GSWConfig_ApplicationsKeysFromConfig(proplist_t p_propListConfig)
|
||||
{
|
||||
proplist_t propListApps=GSWConfig_GetApplicationsFromConfig(p_propListConfig);
|
||||
proplist_t propListAppsNames=NULL;
|
||||
GSWLog(GSW_INFO,NULL,"propListApps=%p",(void*)propListApps);
|
||||
if (!propListApps)
|
||||
{
|
||||
GSWLog(GSW_ERROR,NULL,"No propListApps");
|
||||
//TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
propListAppsNames=GSWConfig_ApplicationsKeysFromApplications(propListApps);
|
||||
};
|
||||
return propListAppsNames;
|
||||
};
|
||||
|
||||
BOOL GSWConfig_PropListInstanceToInstanceEntry(STGSWConfigEntry* p_pInstanceEntry,
|
||||
proplist_t p_propListInstance,
|
||||
CONST char* p_pszAppName)
|
||||
{
|
||||
BOOL fOk=TRUE;
|
||||
proplist_t pValue=NULL;
|
||||
memset(p_pInstanceEntry,0,sizeof(STGSWConfigEntry));
|
||||
p_pInstanceEntry->pszAppName=p_pszAppName;
|
||||
GSWLog(GSW_INFO,NULL,"AppName=%s",p_pszAppName);
|
||||
|
||||
// Instance Num
|
||||
pValue=PLGetDictionaryEntry(p_propListInstance,configKey__InstanceNum);
|
||||
p_pInstanceEntry->iInstance=-1;
|
||||
if (!pValue)
|
||||
{
|
||||
fOk=FALSE;
|
||||
//TODO
|
||||
}
|
||||
else if (!PLIsString(pValue))
|
||||
{
|
||||
fOk=FALSE;
|
||||
//TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
char* pszInstanceNum=PLGetString(pValue);
|
||||
if (pszInstanceNum)
|
||||
{
|
||||
p_pInstanceEntry->iInstance=atoi(pszInstanceNum);
|
||||
};
|
||||
};
|
||||
GSWLog(GSW_INFO,NULL,"instance=%d",p_pInstanceEntry->iInstance);
|
||||
|
||||
// Host Name
|
||||
pValue=PLGetDictionaryEntry(p_propListInstance,configKey__Host);
|
||||
if (!pValue)
|
||||
{
|
||||
fOk=FALSE;
|
||||
//TODO
|
||||
}
|
||||
else if (!PLIsString(pValue))
|
||||
{
|
||||
fOk=FALSE;
|
||||
//TODO
|
||||
}
|
||||
else
|
||||
p_pInstanceEntry->pszHostName=PLGetString(pValue);
|
||||
GSWLog(GSW_INFO,NULL,"HostName=%s",
|
||||
p_pInstanceEntry->pszHostName);
|
||||
|
||||
// Port
|
||||
pValue=PLGetDictionaryEntry(p_propListInstance,configKey__Port);
|
||||
if (!pValue)
|
||||
{
|
||||
fOk=FALSE;
|
||||
//TODO
|
||||
}
|
||||
else if (!PLIsString(pValue))
|
||||
{
|
||||
fOk=FALSE;
|
||||
//TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
char* pszPort=PLGetString(pValue);
|
||||
if (pszPort)
|
||||
{
|
||||
p_pInstanceEntry->iPort=atoi(pszPort);
|
||||
};
|
||||
};
|
||||
GSWLog(GSW_INFO,NULL,"Port=%d",p_pInstanceEntry->iPort);
|
||||
return fOk;
|
||||
};
|
||||
|
||||
void GSWConfig_SetConfigFilePath(CONST char* p_pszConfigFilePath)
|
||||
{
|
||||
if (g_pszConfigFilePath)
|
||||
{
|
||||
free(g_pszConfigFilePath);
|
||||
g_pszConfigFilePath=NULL;
|
||||
};
|
||||
if (!p_pszConfigFilePath)
|
||||
p_pszConfigFilePath=g_szGSWeb_DefaultConfigFilePath;
|
||||
g_pszConfigFilePath=strdup(p_pszConfigFilePath);
|
||||
}
|
||||
|
||||
CONST char* GSWConfig_GetConfigFilePath()
|
||||
{
|
||||
return g_pszConfigFilePath;
|
||||
};
|
||||
|
142
GSWAdaptors/common/GSWConfig.h
Normal file
142
GSWAdaptors/common/GSWConfig.h
Normal file
|
@ -0,0 +1,142 @@
|
|||
/* GSWConfig.h - GSWeb: GSWeb Configuration Management
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWConfig_h__
|
||||
#define _GSWConfig_h__
|
||||
|
||||
#include <proplist.h>
|
||||
#include <time.h>
|
||||
#include "GSWList.h"
|
||||
|
||||
// AppName=Instance@Hostname:Port[ Key=Value]*
|
||||
|
||||
extern const char* g_szGSWeb_AdaptorVersion;
|
||||
|
||||
extern const char* g_szGSWeb_Prefix;
|
||||
extern const char* g_szGSWeb_Handler;
|
||||
extern const char* g_szGSWeb_AppExtention;
|
||||
|
||||
extern const char* g_szGSWeb_MimeType;
|
||||
extern const char* g_szGSWeb_Conf_DocRoot;
|
||||
extern const char* g_szGSWeb_Conf_ConfigFilePath;
|
||||
|
||||
|
||||
// Apache
|
||||
extern const char* g_szGSWeb_Conf_Alias;
|
||||
|
||||
// Netscape
|
||||
extern const char* g_szGSWeb_Conf_PathTrans;
|
||||
extern const char* g_szGSWeb_Conf_AppRoot;
|
||||
extern const char* g_szGSWeb_Conf_Name;
|
||||
|
||||
|
||||
extern const char* g_szGSWeb_DefaultConfigFilePath;
|
||||
extern const char* g_szGSWeb_DefaultLogFilePath;
|
||||
extern const char* g_szGSWeb_DefaultLogFlagPath;
|
||||
extern const char* g_szGSWeb_DefaultDumpFlagPath;
|
||||
|
||||
|
||||
extern const char* g_szGSWeb_DefaultGSWExtensionsFrameworkWebServerResources;
|
||||
|
||||
extern const char* g_szGSWeb_InstanceCookie;
|
||||
|
||||
extern const char* g_szGSWeb_Server;
|
||||
extern const char* g_szGSWeb_ServerAndAdaptorVersion;
|
||||
|
||||
extern const char* g_szDumpConfFile_Head;
|
||||
extern const char* g_szDumpConfFile_Foot;
|
||||
|
||||
extern const char* const g_szGNUstep;
|
||||
extern const char* const g_szOKGSWeb;
|
||||
extern const char* const g_szOKStatus;
|
||||
|
||||
extern const char* g_szErrorResponseHTMLTextTpl;
|
||||
|
||||
typedef struct _STGSWConfigEntry
|
||||
{
|
||||
const char* pszAppName;
|
||||
int iInstance;
|
||||
const char* pszHostName;
|
||||
int iPort;
|
||||
GSWDict* pParams;
|
||||
} STGSWConfigEntry;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EGSWConfigResult__Error = -1,
|
||||
EGSWConfigResult__Ok = 0,
|
||||
EGSWConfigResult__NotChanged = 1
|
||||
} EGSWConfigResult;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EGSWConfigResult__Clear = 0,
|
||||
EGSWConfigResult__Add = 1
|
||||
} EGSWConfigCallType;
|
||||
|
||||
typedef struct _GSWApp
|
||||
{
|
||||
char* pszName;
|
||||
int iIndex;
|
||||
GSWList stInstances;
|
||||
} GSWApp;
|
||||
|
||||
typedef struct _GSWAppInstance
|
||||
{
|
||||
int iInstance;
|
||||
char* pszHost;
|
||||
int iPort;
|
||||
time_t timeNextRetryTime; // Timer
|
||||
unsigned int uOpenedRequestsNb;
|
||||
BOOL fValid;
|
||||
} GSWAppInstance;
|
||||
|
||||
extern proplist_t configKey__Applications;
|
||||
extern proplist_t configKey__InstanceNum;
|
||||
extern proplist_t configKey__Host;
|
||||
extern proplist_t configKey__Port;
|
||||
extern proplist_t configKey__Parameters;
|
||||
|
||||
EGSWConfigResult GSWConfig_ReadIFND(CONST char* p_pszConfigPath,
|
||||
time_t* p_pLastReadTime,
|
||||
proplist_t* p_ppPropList,
|
||||
void* p_pLogServerData);
|
||||
|
||||
proplist_t GSWConfig_GetApplicationsFromConfig(proplist_t p_propListConfig);
|
||||
proplist_t GSWConfig_ApplicationKeyFromApplicationsKey(proplist_t p_propListApplicationsKeys,
|
||||
int p_iIndex);
|
||||
proplist_t GSWConfig_InstancesFromApplication(proplist_t p_propListApplication);
|
||||
proplist_t GSWConfig_ApplicationFromApplications(proplist_t p_propListApplications,
|
||||
proplist_t p_propListApplicationKey);
|
||||
proplist_t GSWConfig_ApplicationsKeysFromApplications(proplist_t p_propListApplications);
|
||||
proplist_t GSWConfig_ApplicationsKeysFromConfig(proplist_t p_propListConfig);
|
||||
BOOL GSWConfig_PropListInstanceToInstanceEntry(STGSWConfigEntry* p_pInstanceEntry,
|
||||
proplist_t p_propListInstance,
|
||||
CONST char* p_pszAppName);
|
||||
|
||||
CONST char* GSWConfig_GetConfigFilePath();
|
||||
void GSWConfig_SetConfigFilePath(CONST char* p_pszConfigFilePath);
|
||||
|
||||
|
||||
#endif // _GSWConfig_h__
|
||||
|
153
GSWAdaptors/common/GSWDict.c
Normal file
153
GSWAdaptors/common/GSWDict.c
Normal file
|
@ -0,0 +1,153 @@
|
|||
/* GSWDict.c - GSWeb: Dictionary
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "GSWUtil.h"
|
||||
#include "GSWDict.h"
|
||||
|
||||
|
||||
GSWDict *GSWDict_New(unsigned int p_uCapacity)
|
||||
{
|
||||
GSWDict* pDict = malloc(sizeof(GSWDict));
|
||||
memset(pDict,0,sizeof(GSWDict));
|
||||
pDict->uCapacity = (p_uCapacity==0) ? 16 : p_uCapacity;
|
||||
pDict->pElems = malloc(sizeof(GSWDictElem) * pDict->uCapacity);
|
||||
return pDict;
|
||||
};
|
||||
|
||||
void GSWDict_FreeElem(GSWDictElem* p_pElem,void* p_pData)
|
||||
{
|
||||
if (p_pElem->pszKey)
|
||||
{
|
||||
free((char*)p_pElem->pszKey);
|
||||
p_pElem->pszKey=NULL;
|
||||
};
|
||||
if (p_pElem->pValue && p_pElem->fValueOwner)
|
||||
{
|
||||
free((void*)p_pElem->pValue);
|
||||
};
|
||||
p_pElem->pValue=NULL;
|
||||
};
|
||||
|
||||
void GSWDict_Free(GSWDict* p_pDict)
|
||||
{
|
||||
GSWDict_PerformForAllElem(p_pDict,GSWDict_FreeElem,NULL);
|
||||
if (p_pDict->pElems)
|
||||
free(p_pDict->pElems);
|
||||
free(p_pDict);
|
||||
};
|
||||
|
||||
void GSWDict_SetCapacity(GSWDict* p_pDict,unsigned int p_uCapacity)
|
||||
{
|
||||
if (p_uCapacity>p_pDict->uCapacity)
|
||||
{
|
||||
if (p_pDict->pElems)
|
||||
p_pDict->pElems = realloc(p_pDict->pElems,p_uCapacity*sizeof(GSWDictElem));
|
||||
else
|
||||
p_pDict->pElems = malloc(p_uCapacity*sizeof(GSWDictElem));
|
||||
};
|
||||
p_pDict->uCapacity = p_uCapacity;
|
||||
};
|
||||
|
||||
static GSWDictElem* GSWDict_FindFirstNullKey(GSWDict* p_pDict)
|
||||
{
|
||||
int i=0;
|
||||
GSWDictElem* pElem=NULL;
|
||||
for (pElem=p_pDict->pElems;i<p_pDict->uCount;i++,pElem++)
|
||||
if (!pElem->pszKey)
|
||||
return pElem;
|
||||
return NULL;
|
||||
};
|
||||
|
||||
void GSWDict_Add(GSWDict* p_pDict,CONST char* p_pszKey,CONST void* p_pValue,BOOL p_fValueOwner)
|
||||
{
|
||||
GSWDictElem* pElem=NULL;
|
||||
if (p_pDict->uCount>=p_pDict->uCapacity)
|
||||
{
|
||||
pElem=GSWDict_FindFirstNullKey(p_pDict);
|
||||
if (!pElem)
|
||||
{
|
||||
GSWDict_SetCapacity(p_pDict,p_pDict->uCapacity*2);
|
||||
pElem=p_pDict->pElems+p_pDict->uCount;
|
||||
p_pDict->uCount++;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
pElem=p_pDict->pElems+p_pDict->uCount;
|
||||
p_pDict->uCount++;
|
||||
};
|
||||
pElem->pszKey=strdup(p_pszKey);
|
||||
pElem->pValue=p_pValue;
|
||||
pElem->fValueOwner=p_fValueOwner;
|
||||
};
|
||||
|
||||
void GSWDict_AddString(GSWDict* p_pDict,CONST char* p_pszKey,CONST char* p_pszValue,BOOL p_fValueOwner)
|
||||
{
|
||||
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)
|
||||
{
|
||||
GSWDict_Add(p_pDict,p_pszKey,strdup(p_pValue),TRUE);
|
||||
};
|
||||
|
||||
static GSWDictElem* GSWDict_FindKey(GSWDict* p_pDict,CONST char* p_pszKey)
|
||||
{
|
||||
int iIndex=0;
|
||||
GSWDictElem* pElem=NULL;
|
||||
for (pElem=p_pDict->pElems;iIndex<p_pDict->uCount;iIndex++,pElem++)
|
||||
if (pElem->pszKey && strcasecmp(pElem->pszKey,p_pszKey)==0)
|
||||
return pElem;
|
||||
return NULL;
|
||||
};
|
||||
|
||||
void GSWDict_RemoveKey(GSWDict* p_pDict,CONST char* p_pszKey)
|
||||
{
|
||||
GSWDictElem* pElem=GSWDict_FindKey(p_pDict,p_pszKey);
|
||||
if (pElem)
|
||||
GSWDict_FreeElem(pElem,NULL);
|
||||
}
|
||||
|
||||
CONST void* GSWDict_ValueForKey(GSWDict* p_pDict,CONST char* p_pszKey)
|
||||
{
|
||||
GSWDictElem* pElem=GSWDict_FindKey(p_pDict,p_pszKey);
|
||||
return (pElem) ? pElem->pValue : NULL;
|
||||
};
|
||||
|
||||
void GSWDict_PerformForAllElem(GSWDict* p_pDict,
|
||||
void (*pFN)(GSWDictElem* p_pElem,void* p_pData),
|
||||
void* p_pData)
|
||||
{
|
||||
int i=0;
|
||||
GSWDictElem* pElem=NULL;
|
||||
for (pElem=p_pDict->pElems;i<p_pDict->uCount;i++,pElem++)
|
||||
{
|
||||
if (pElem->pszKey)
|
||||
pFN(pElem,p_pData);
|
||||
};
|
||||
};
|
65
GSWAdaptors/common/GSWDict.h
Normal file
65
GSWAdaptors/common/GSWDict.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* GSWDict.h - GSWeb: Dictionary
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWDict_h__
|
||||
#define _GSWDict_h__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
typedef struct _GSWDictElem
|
||||
{
|
||||
CONST char *pszKey;
|
||||
CONST void* pValue;
|
||||
BOOL fValueOwner;
|
||||
} GSWDictElem;
|
||||
|
||||
typedef struct _GSWDict
|
||||
{
|
||||
unsigned int uCount;
|
||||
unsigned int uCapacity;
|
||||
GSWDictElem* pElems;
|
||||
} GSWDict;
|
||||
|
||||
#define GSWDict_Initialized() ((GSWDict){0,0,NULL})
|
||||
|
||||
GSWDict *GSWDict_New(unsigned int p_uCapacity);
|
||||
|
||||
void GSWDict_Free(GSWDict* p_pDict);
|
||||
void GSWDict_Add(GSWDict* p_pDict,CONST char* p_pszKey,CONST void* p_pValue,BOOL p_fValueOwner);
|
||||
void GSWDict_AddString(GSWDict* p_pDict,CONST char* p_pszKey,CONST char* p_pValue,BOOL p_fValueOwner);
|
||||
void GSWDict_AddStringDup(GSWDict* p_pDict,CONST char* p_pszKey,CONST char* p_pValue);
|
||||
void GSWDict_RemoveKey(GSWDict* p_pDict, CONST char* p_pszKey);
|
||||
CONST void* GSWDict_ValueForKey(GSWDict* p_pDict, CONST char* p_pszKey);
|
||||
|
||||
void GSWDict_PerformForAllElem(GSWDict* p_pDict,
|
||||
void (*pFN)(GSWDictElem* p_pElem,void* p_pData),
|
||||
void* p_pData);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of C header
|
||||
#endif //_cplusplus
|
||||
|
||||
#endif // _GSWDict_h__
|
||||
|
260
GSWAdaptors/common/GSWHTTPHeaders.c
Normal file
260
GSWAdaptors/common/GSWHTTPHeaders.c
Normal file
|
@ -0,0 +1,260 @@
|
|||
/* GSWHTTPHeaders.c - GSWeb: GSWeb HTTP Headers
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "GSWUtil.h"
|
||||
#include "GSWDict.h"
|
||||
#include "GSWURLUtil.h"
|
||||
#include "GSWUtil.h"
|
||||
#include "GSWConfig.h"
|
||||
#include "GSWHTTPHeaders.h"
|
||||
|
||||
const char* g_szHeader_GSWeb_ServerAdaptor="x-gsweb-adaptor-version";
|
||||
const char* g_szHeader_GSWeb_RequestMethod="x-gsweb-request-method";
|
||||
const char* g_szHeader_GSWeb_Recording="x-gsweb-recording";
|
||||
const char* g_szHeader_GSWeb_QueryString="x-gsweb-query-string";
|
||||
const char* g_szHeader_GSWeb_RemoteAddress="x-gsweb-remote-addr";
|
||||
const char* g_szHeader_GSWeb_RemoteHost="x-gsweb-remote-host";
|
||||
const char* g_szHeader_GSWeb_RemoteIdent="x-gsweb-remote-ident";
|
||||
const char* g_szHeader_GSWeb_RemoteUser="x-gsweb-remote-user";
|
||||
const char* g_szHeader_GSWeb_ServerName="x-gsweb-server-name";
|
||||
const char* g_szHeader_GSWeb_ServerPort="x-gsweb-server-port";
|
||||
const char* g_szHeader_GSWeb_ServerSoftware="x-gsweb-server-software";
|
||||
const char* g_szHeader_GSWeb_AnnotationServer="x-gsweb-annotation-server";
|
||||
const char* g_szHeader_GSWeb_AuthPass="x-gsweb-auth-pass";
|
||||
const char* g_szHeader_GSWeb_AuthType="x-gsweb-auth-type";
|
||||
const char* g_szHeader_GSWeb_DocumentRoot="x-gsweb-documentroot";
|
||||
const char* g_szHeader_GSWeb_GatewayInterface="x-gsweb-gateway-interface";
|
||||
|
||||
const char* g_szHeader_Accept="accept";
|
||||
const char* g_szHeader_AcceptEncoding="accept-encoding";
|
||||
const char* g_szHeader_AcceptLanguage="accept-language";
|
||||
const char* g_szHeader_Allow="allow";
|
||||
const char* g_szHeader_Authorization="authorization";
|
||||
const char* g_szHeader_AuthUser="auth-user";
|
||||
const char* g_szHeader_Cookie="cookie";
|
||||
const char* g_szHeader_ContentLength="content-length";
|
||||
const char* g_szHeader_ContentType="content-type";
|
||||
const char* g_szHeader_IfModifiedSince="if-modified-since";
|
||||
const char* g_szHeader_LastModified="last-modified";
|
||||
const char* g_szHeader_Method="method";
|
||||
const char* g_szHeader_PathInfo="path-info";
|
||||
const char* g_szHeader_Pragma="pragma";
|
||||
const char* g_szHeader_Protocol="protocol";
|
||||
const char* g_szHeader_Referer="referer";
|
||||
const char* g_szHeader_UserAgent="user-agent";
|
||||
const char* g_szHeader_Date="date";
|
||||
const char* g_szHeader_Expires="expires";
|
||||
const char* g_szHeader_From="from";
|
||||
const char* g_szHeader_MimeVersion="mime-version";
|
||||
const char* g_szHeader_ContentEncoding="content-encoding";
|
||||
|
||||
|
||||
|
||||
const char* g_szServerInfo_DocumentRoot="DOCUMENT_ROOT";
|
||||
const char* g_szServerInfo_HTTPAccept="HTTP_ACCEPT";
|
||||
const char* g_szServerInfo_HTTPAcceptEncoding="HTTP_ACCEPT_ENCODING";
|
||||
const char* g_szServerInfo_HTTPAllow="HTTP_ALLOW";
|
||||
const char* g_szServerInfo_HTTPDate="HTTP_DATE";
|
||||
const char* g_szServerInfo_HTTPExpires="HTTP_EXPIRES";
|
||||
const char* g_szServerInfo_HTTPFrom="HTTP_FROM";
|
||||
const char* g_szServerInfo_HTTPIfModifiedSince="HTTP_IF_MODIFIED_SINCE";
|
||||
const char* g_szServerInfo_HTTPLastModified="HTTP_LAST_MODIFIED";
|
||||
const char* g_szServerInfo_HTTPMimeVersion="HTTP_MIME_VERSION";
|
||||
const char* g_szServerInfo_HTTPPragma="HTTP_PRAGMA";
|
||||
const char* g_szServerInfo_HTTPReferer="HTTP_REFERER";
|
||||
const char* g_szServerInfo_RemoteIdent="REMOTE_IDENT";
|
||||
const char* g_szServerInfo_RequestMethod="REQUEST_METHOD";
|
||||
|
||||
const char* g_szServerInfo_AnnotationServer="ANNOTATION_SERVER";
|
||||
const char* g_szServerInfo_AuthPass="AUTH_PASS";
|
||||
const char* g_szServerInfo_AuthType="AUTH_TYPE";
|
||||
const char* g_szServerInfo_AuthUser="AUTH_USER";
|
||||
const char* g_szServerInfo_ClientCert="CLIENT_CERT";
|
||||
const char* g_szServerInfo_ContentEncoding="CONTENT_ENCODING";
|
||||
const char* g_szServerInfo_ContentLength="CONTENT_LENGTH";
|
||||
const char* g_szServerInfo_ContentType="CONTENT_TYPE";
|
||||
const char* g_szServerInfo_GatewayInterface="GATEWAY_INTERFACE";
|
||||
const char* g_szServerInfo_Host="HOST";
|
||||
const char* g_szServerInfo_HTTPAcceptLanguage="HTTP_ACCEPT_LANGUAGE";
|
||||
const char* g_szServerInfo_HTTPAuthorization="HTTP_AUTHORIZATION";
|
||||
const char* g_szServerInfo_HTTPCookie="HTTP_COOKIE";
|
||||
const char* g_szServerInfo_HTTPUserAgent="HTTP_USER_AGENT";
|
||||
const char* g_szServerInfo_HTTPS="HTTPS";
|
||||
const char* g_szServerInfo_HTTPSKeySize="HTTPS_KEYSIZE";
|
||||
const char* g_szServerInfo_HTTPSSecretKeySize="HTTPS_SECRETKEYSIZE";
|
||||
const char* g_szServerInfo_PathInfo="PATH_INFO";
|
||||
const char* g_szServerInfo_PathTranslated="PATH_TRANSLATED";
|
||||
const char* g_szServerInfo_Query="QUERY";
|
||||
const char* g_szServerInfo_QueryString="QUERY_STRING";
|
||||
const char* g_szServerInfo_RemoteAddress="REMOTE_ADDR";
|
||||
const char* g_szServerInfo_RemoteHost="REMOTE_HOST";
|
||||
const char* g_szServerInfo_RemoteUser="REMOTE_USER";
|
||||
const char* g_szServerInfo_ScriptName="SCRIPT_NAME";
|
||||
const char* g_szServerInfo_ServerID="SERVER_ID";
|
||||
const char* g_szServerInfo_ServerName="SERVER_NAME";
|
||||
const char* g_szServerInfo_ServerPort="SERVER_PORT";
|
||||
const char* g_szServerInfo_ServerProtocol="SERVER_PROTOCOL";
|
||||
const char* g_szServerInfo_ServerSoftware="SERVER_SOFTWARE";
|
||||
const char* g_szServerInfo_HTTPGSWebRecording="HTTP_X_GSWEB_RECORDING";
|
||||
const char* g_szServerInfo_ServerAdmin="SERVER_ADMIN";
|
||||
const char* g_szServerInfo_ScriptFileName="SCRIPT_FILENAME";
|
||||
const char* g_szServerInfo_RemotePort="REMOTE_PORT";
|
||||
|
||||
const char* g_szMethod_Get="GET";
|
||||
const char* g_szMethod_Post="POST";
|
||||
const char* g_szMethod_Head="HEAD";
|
||||
const char* g_szMethod_Put="PUT";
|
||||
|
||||
const char* g_szContentType_TextHtml="text/html";
|
||||
|
||||
|
||||
/*const*/ GSWHeaderTranslationItem GSWHeaderTranslationTable[50];
|
||||
int GSWHeaderTranslationTableItemsNb=0;
|
||||
|
||||
void GSWHeaderTranslationTable_Init()
|
||||
{
|
||||
int i=0;
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_AnnotationServer;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_GSWeb_AnnotationServer;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_AuthPass;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_GSWeb_AuthPass;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_AuthType;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_GSWeb_AuthType;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_ContentEncoding;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_ContentEncoding;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_ContentLength;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_ContentLength;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_ContentType;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_ContentType;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_DocumentRoot;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_GSWeb_DocumentRoot;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_GatewayInterface;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_GSWeb_GatewayInterface;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_HTTPAccept;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_Accept;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_HTTPAcceptEncoding;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_AcceptEncoding;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_HTTPAcceptLanguage;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_AcceptLanguage;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_HTTPAllow;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_Allow;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_HTTPAuthorization;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_Authorization;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_HTTPCookie;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_Cookie;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_HTTPDate;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_Date;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_HTTPExpires;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_Expires;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_HTTPFrom;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_From;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_HTTPIfModifiedSince;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_IfModifiedSince;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_HTTPLastModified;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_LastModified;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_HTTPMimeVersion;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_MimeVersion;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_HTTPPragma;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_Pragma;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_HTTPReferer;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_Referer;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_HTTPUserAgent;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_UserAgent;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_HTTPGSWebRecording;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_GSWeb_Recording;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_QueryString;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb= g_szHeader_GSWeb_QueryString;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_RemoteAddress;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_GSWeb_RemoteAddress;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_RemoteHost;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb= g_szHeader_GSWeb_RemoteHost;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_RemoteIdent;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_GSWeb_RemoteIdent;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_RemoteUser;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_GSWeb_RemoteUser;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_RequestMethod;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_GSWeb_RequestMethod;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_ServerName;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_GSWeb_ServerName;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_ServerPort;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_GSWeb_ServerPort;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=g_szServerInfo_ServerSoftware;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=g_szHeader_GSWeb_ServerSoftware;
|
||||
|
||||
GSWHeaderTranslationTable[i].pszHTTP=NULL;
|
||||
GSWHeaderTranslationTable[i++].pszGSWeb=NULL;
|
||||
|
||||
GSWHeaderTranslationTableItemsNb=i;
|
||||
/*GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTableItemsNb=%d",GSWHeaderTranslationTableItemsNb);
|
||||
for(i=0;i<GSWHeaderTranslationTableItemsNb-1;i++)
|
||||
{
|
||||
GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTable[i].pszHTTP=%s",GSWHeaderTranslationTable[i].pszHTTP);
|
||||
GSWLog(GSW_ERROR,NULL,"GSWHeaderTranslationTable[i].pszGSWeb=%s",GSWHeaderTranslationTable[i].pszGSWeb);
|
||||
};*/
|
||||
};
|
||||
|
||||
|
175
GSWAdaptors/common/GSWHTTPHeaders.h
Normal file
175
GSWAdaptors/common/GSWHTTPHeaders.h
Normal file
|
@ -0,0 +1,175 @@
|
|||
/* GSWHTTPHeaders.h - GSWeb: GSWeb HTTP Headers
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWHTTPHeaders_h__
|
||||
#define _GSWHTTPHeaders_h__
|
||||
|
||||
extern const char* g_szHeader_GSWeb_ServerAdaptor;
|
||||
extern const char* g_szHeader_GSWeb_RequestMethod;
|
||||
extern const char* g_szHeader_GSWeb_Recording;
|
||||
extern const char* g_szHeader_GSWeb_QueryString;
|
||||
extern const char* g_szHeader_GSWeb_RemoteAddress;
|
||||
extern const char* g_szHeader_GSWeb_RemoteHost;
|
||||
extern const char* g_szHeader_GSWeb_RemoteIdent;
|
||||
extern const char* g_szHeader_GSWeb_RemoteUser;
|
||||
extern const char* g_szHeader_GSWeb_ServerName;
|
||||
extern const char* g_szHeader_GSWeb_ServerPort;
|
||||
extern const char* g_szHeader_GSWeb_ServerSoftware;
|
||||
extern const char* g_szHeader_GSWeb_AnnotationServer;
|
||||
extern const char* g_szHeader_GSWeb_AuthPass;
|
||||
extern const char* g_szHeader_GSWeb_AuthType;
|
||||
extern const char* g_szHeader_GSWeb_DocumentRoot;
|
||||
extern const char* g_szHeader_GSWeb_GatewayInterface;
|
||||
|
||||
|
||||
extern const char* g_szHeader_Accept;
|
||||
extern const char* g_szHeader_AcceptEncoding;
|
||||
extern const char* g_szHeader_AcceptLanguage;
|
||||
extern const char* g_szHeader_Allow;
|
||||
extern const char* g_szHeader_Authorization;
|
||||
extern const char* g_szHeader_AuthUser;
|
||||
extern const char* g_szHeader_Cookie;
|
||||
extern const char* g_szHeader_ContentLength;
|
||||
extern const char* g_szHeader_ContentType;
|
||||
extern const char* g_szHeader_IfModifiedSince;
|
||||
extern const char* g_szHeader_LastModified;
|
||||
extern const char* g_szHeader_Method;
|
||||
extern const char* g_szHeader_PathInfo;
|
||||
extern const char* g_szHeader_Pragma;
|
||||
extern const char* g_szHeader_Protocol;
|
||||
extern const char* g_szHeader_Referer;
|
||||
extern const char* g_szHeader_UserAgent;
|
||||
extern const char* g_szHeader_Date;
|
||||
extern const char* g_szHeader_Expires;
|
||||
extern const char* g_szHeader_From;
|
||||
extern const char* g_szHeader_MimeVersion;
|
||||
extern const char* g_szHeader_ContentEncoding;
|
||||
|
||||
extern const char* g_szServerInfo_DocumentRoot;
|
||||
extern const char* g_szServerInfo_HTTPAccept;
|
||||
extern const char* g_szServerInfo_HTTPAcceptEncoding;
|
||||
extern const char* g_szServerInfo_HTTPAllow;
|
||||
extern const char* g_szServerInfo_HTTPDate;
|
||||
extern const char* g_szServerInfo_HTTPExpires;
|
||||
extern const char* g_szServerInfo_HTTPFrom;
|
||||
extern const char* g_szServerInfo_HTTPIfModifiedSince;
|
||||
extern const char* g_szServerInfo_HTTPLastModified;
|
||||
extern const char* g_szServerInfo_HTTPMimeVersion;
|
||||
extern const char* g_szServerInfo_HTTPPragma;
|
||||
extern const char* g_szServerInfo_HTTPReferer;
|
||||
extern const char* g_szServerInfo_RemoteIdent;
|
||||
extern const char* g_szServerInfo_RequestMethod;
|
||||
|
||||
extern const char* g_szServerInfo_AnnotationServer;
|
||||
extern const char* g_szServerInfo_AuthPass;
|
||||
extern const char* g_szServerInfo_AuthType;
|
||||
extern const char* g_szServerInfo_AuthUser;
|
||||
extern const char* g_szServerInfo_ClientCert;
|
||||
extern const char* g_szServerInfo_ContentEncoding;
|
||||
extern const char* g_szServerInfo_ContentLength;
|
||||
extern const char* g_szServerInfo_ContentType;
|
||||
extern const char* g_szServerInfo_GatewayInterface;
|
||||
extern const char* g_szServerInfo_Host;
|
||||
extern const char* g_szServerInfo_HTTPAcceptLanguage;
|
||||
extern const char* g_szServerInfo_HTTPAuthorization;
|
||||
extern const char* g_szServerInfo_HTTPCookie;
|
||||
extern const char* g_szServerInfo_HTTPUserAgent;
|
||||
extern const char* g_szServerInfo_HTTPS;
|
||||
extern const char* g_szServerInfo_HTTPSKeySize;
|
||||
extern const char* g_szServerInfo_HTTPSSecretKeySize;
|
||||
extern const char* g_szServerInfo_PathInfo;
|
||||
extern const char* g_szServerInfo_PathTranslated;
|
||||
extern const char* g_szServerInfo_Query;
|
||||
extern const char* g_szServerInfo_QueryString;
|
||||
extern const char* g_szServerInfo_RemoteAddress;
|
||||
extern const char* g_szServerInfo_RemoteHost;
|
||||
extern const char* g_szServerInfo_RemoteUser;
|
||||
extern const char* g_szServerInfo_ScriptName;
|
||||
extern const char* g_szServerInfo_ServerID;
|
||||
extern const char* g_szServerInfo_ServerName;
|
||||
extern const char* g_szServerInfo_ServerPort;
|
||||
extern const char* g_szServerInfo_ServerProtocol;
|
||||
extern const char* g_szServerInfo_ServerSoftware;
|
||||
extern const char* g_szServerInfo_HTTPGSWebRecording;
|
||||
extern const char* g_szServerInfo_ServerAdmin;
|
||||
extern const char* g_szServerInfo_ScriptFileName;
|
||||
extern const char* g_szServerInfo_RemotePort;
|
||||
|
||||
extern const char* g_szMethod_Get;
|
||||
extern const char* g_szMethod_Post;
|
||||
extern const char* g_szMethod_Head;
|
||||
extern const char* g_szMethod_Put;
|
||||
|
||||
extern const char* g_szContentType_TextHtml;
|
||||
|
||||
typedef struct _GSWHeaderTranslationItem {
|
||||
const char* /*const*/ pszHTTP;
|
||||
const char* /*const*/ pszGSWeb;
|
||||
} GSWHeaderTranslationItem;
|
||||
|
||||
extern /*const*/ GSWHeaderTranslationItem GSWHeaderTranslationTable[];
|
||||
extern int GSWHeaderTranslationTableItemsNb;
|
||||
/*
|
||||
static const GSWHeaderTranslationItem GSWHeaderTranslationTable[] =
|
||||
{
|
||||
{ g_szServerInfo_AnnotationServer, g_szHeader_GSWeb_AnnotationServer },
|
||||
{ g_szServerInfo_AuthPass, g_szHeader_GSWeb_AuthPass },
|
||||
{ g_szServerInfo_AuthType, g_szHeader_GSWeb_AuthType },
|
||||
{ g_szServerInfo_ContentEncoding, g_szHeader_ContentEncoding },
|
||||
{ g_szServerInfo_ContentLength, g_szHeader_ContentLength },
|
||||
{ g_szServerInfo_ContentType, g_szHeader_ContentType },
|
||||
{ g_szServerInfo_DocumentRoot, g_szHeader_GSWeb_DocumentRoot },
|
||||
{ g_szServerInfo_GatewayInterface, g_szHeader_GSWeb_GatewayInterface },
|
||||
{ g_szServerInfo_HTTPAccept, g_szHeader_Accept },
|
||||
{ g_szServerInfo_HTTPAcceptEncoding, g_szHeader_AcceptEncoding },
|
||||
{ g_szServerInfo_HTTPAcceptLanguage, g_szHeader_AcceptLanguage },
|
||||
{ g_szServerInfo_HTTPAllow, g_szHeader_Allow },
|
||||
{ g_szServerInfo_HTTPAuthorization, g_szHeader_Authorization },
|
||||
{ g_szServerInfo_HTTPCookie, g_szHeader_Cookie },
|
||||
{ g_szServerInfo_HTTPDate, g_szHeader_Date },
|
||||
{ g_szServerInfo_HTTPExpires, g_szHeader_Expires },
|
||||
{ g_szServerInfo_HTTPFrom, g_szHeader_From },
|
||||
{ g_szServerInfo_HTTPIfModifiedSince, g_szHeader_IfModifiedSince },
|
||||
{ g_szServerInfo_HTTPLastModified, g_szHeader_LastModified },
|
||||
{ g_szServerInfo_HTTPMimeVersion, g_szHeader_MimeVersion },
|
||||
{ g_szServerInfo_HTTPPragma, g_szHeader_Pragma },
|
||||
{ g_szServerInfo_HTTPReferer, g_szHeader_Referer },
|
||||
{ g_szServerInfo_HTTPUserAgent, g_szHeader_UserAgent },
|
||||
{ g_szServerInfo_HTTPGSWebRecording, g_szHeader_GSWeb_Recording },
|
||||
{ g_szServerInfo_QueryString, g_szHeader_GSWeb_QueryString },
|
||||
{ g_szServerInfo_RemoteAddress, g_szHeader_GSWeb_RemoteAddress },
|
||||
{ g_szServerInfo_RemoteHost, g_szHeader_GSWeb_RemoteHost },
|
||||
{ g_szServerInfo_RemoteIdent, g_szHeader_GSWeb_RemoteIdent },
|
||||
{ g_szServerInfo_RemoteUser, g_szHeader_GSWeb_RemoteUser },
|
||||
{ g_szServerInfo_RequestMethod, g_szHeader_GSWebRequestMethod },
|
||||
{ g_szServerInfo_ServerName, g_szHeader_GSWeb_ServerName },
|
||||
{ g_szServerInfo_ServerPort, g_szHeader_GSWeb_ServerPort },
|
||||
{ g_szServerInfo_ServerSoftware, g_szHeader_GSWeb_ServerSoftware },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
#define GSWHeaderTranslationTable_HeaderNb (sizeof(GSWHeaderTranslationTable)/sizeof(GSWHeaderTranslationTable[0]))
|
||||
*/
|
||||
#endif // _GSWHTTPHeaders_h__
|
||||
|
||||
|
317
GSWAdaptors/common/GSWHTTPRequest.c
Normal file
317
GSWAdaptors/common/GSWHTTPRequest.c
Normal file
|
@ -0,0 +1,317 @@
|
|||
/* GSWHTTPRequest.c - GSWeb: Adaptors: HTTP Request
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "GSWUtil.h"
|
||||
#include "GSWDict.h"
|
||||
#include "GSWURLUtil.h"
|
||||
#include "GSWAppRequestStruct.h"
|
||||
#include "GSWAppConnect.h"
|
||||
#include "GSWHTTPRequest.h"
|
||||
#include "GSWHTTPResponse.h"
|
||||
#include "GSWAppRequest.h"
|
||||
#include "GSWHTTPHeaders.h"
|
||||
|
||||
static ERequestMethod GetHTTPRequestMethod();
|
||||
static CONST char* GSWebHeaderForHTTPHeader(CONST char *header);
|
||||
static char* GSWHTTPRequest_PackageHeaders(GSWHTTPRequest* p_pHTTPRequest,
|
||||
char* pszBuffer,
|
||||
int p_iBufferSize);
|
||||
|
||||
|
||||
GSWHTTPRequest* GSWHTTPRequest_New(CONST char* p_pszMethod,char* p_pszURI)
|
||||
{
|
||||
GSWHTTPRequest* pHTTPRequest=calloc(1,sizeof(GSWHTTPRequest));
|
||||
pHTTPRequest->eMethod = GetHTTPRequestMethod(p_pszMethod);
|
||||
pHTTPRequest->pszRequest = p_pszURI; // It will be freed
|
||||
return pHTTPRequest;
|
||||
};
|
||||
|
||||
void GSWHTTPRequest_Free(GSWHTTPRequest* p_pHTTPRequest)
|
||||
{
|
||||
if (p_pHTTPRequest)
|
||||
{
|
||||
if (p_pHTTPRequest->pHeaders)
|
||||
{
|
||||
GSWDict_Free(p_pHTTPRequest->pHeaders);
|
||||
p_pHTTPRequest->pHeaders=NULL;
|
||||
};
|
||||
if (p_pHTTPRequest->pszRequest)
|
||||
{
|
||||
free(p_pHTTPRequest->pszRequest);
|
||||
p_pHTTPRequest->pszRequest=NULL;
|
||||
};
|
||||
if (p_pHTTPRequest->pContent)
|
||||
{
|
||||
free(p_pHTTPRequest->pContent);
|
||||
p_pHTTPRequest->pContent=NULL;
|
||||
};
|
||||
free(p_pHTTPRequest);
|
||||
p_pHTTPRequest=NULL;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
CONST char* GSWHTTPRequest_ValidateMethod(GSWHTTPRequest* p_pHTTPRequest)
|
||||
{
|
||||
switch(p_pHTTPRequest->eMethod)
|
||||
{
|
||||
case ERequestMethod_None:
|
||||
return "GSWeb Application must be launched by HTTP Server";
|
||||
break;
|
||||
case ERequestMethod_Unknown:
|
||||
case ERequestMethod_Head:
|
||||
case ERequestMethod_Put:
|
||||
return "Invalid Method";
|
||||
break;
|
||||
case ERequestMethod_Get:
|
||||
case ERequestMethod_Post:
|
||||
default:
|
||||
return NULL;
|
||||
};
|
||||
};
|
||||
|
||||
void GSWHTTPRequest_HTTPToAppRequest(GSWHTTPRequest* p_pHTTPRequest,
|
||||
GSWAppRequest* p_pAppRequest,
|
||||
GSWURLComponents* p_pURLComponents,
|
||||
CONST char* p_pszHTTPVersion)
|
||||
{
|
||||
char szInstanceBuffer[65]="";
|
||||
char* pszDefaultHTTPVersion = "HTTP/1.0";
|
||||
int iHTTPVersionLength = p_pszHTTPVersion ? strlen(p_pszHTTPVersion) : strlen(pszDefaultHTTPVersion);
|
||||
if (p_pAppRequest->iInstance > 0) /* should be -1 !!! */
|
||||
sprintf(szInstanceBuffer,"%d",p_pAppRequest->iInstance);
|
||||
p_pURLComponents->stAppName.pszStart = p_pAppRequest->pszName;
|
||||
p_pURLComponents->stAppName.iLength = strlen(p_pAppRequest->pszName);
|
||||
p_pURLComponents->stAppNumber.pszStart = szInstanceBuffer;
|
||||
p_pURLComponents->stAppNumber.iLength = strlen(szInstanceBuffer);
|
||||
p_pURLComponents->stAppHost.pszStart = p_pAppRequest->pszHost;
|
||||
p_pURLComponents->stAppHost.iLength = strlen(p_pAppRequest->pszHost);
|
||||
|
||||
if (p_pHTTPRequest->pszRequest)
|
||||
{
|
||||
free(p_pHTTPRequest->pszRequest);
|
||||
p_pHTTPRequest->pszRequest=NULL;
|
||||
};
|
||||
|
||||
p_pHTTPRequest->pszRequest = malloc(8 + (GSWComposeURLLen(p_pURLComponents)+1) + iHTTPVersionLength);
|
||||
|
||||
if (p_pHTTPRequest->uContentLength>0)
|
||||
{
|
||||
strcpy(p_pHTTPRequest->pszRequest,"POST ");
|
||||
GSWHTTPRequest_AddHeader(p_pHTTPRequest,g_szHeader_GSWeb_RequestMethod,"POST");
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(p_pHTTPRequest->pszRequest,"GET ");
|
||||
GSWHTTPRequest_AddHeader(p_pHTTPRequest,g_szHeader_GSWeb_RequestMethod,"GET");
|
||||
};
|
||||
GSWComposeURL(p_pHTTPRequest->pszRequest+strlen(p_pHTTPRequest->pszRequest),p_pURLComponents);
|
||||
strcat(p_pHTTPRequest->pszRequest," ");
|
||||
if (p_pszHTTPVersion)
|
||||
strcat(p_pHTTPRequest->pszRequest,p_pszHTTPVersion);
|
||||
else
|
||||
strcat(p_pHTTPRequest->pszRequest,pszDefaultHTTPVersion);
|
||||
strcat(p_pHTTPRequest->pszRequest,"\n");
|
||||
|
||||
GSWLog(GSW_INFO,NULL,"App Request: %s",p_pHTTPRequest->pszRequest);
|
||||
};
|
||||
|
||||
void GSWHTTPRequest_AddHeader(GSWHTTPRequest* p_pHTTPRequest,
|
||||
CONST char* p_pszKey,
|
||||
CONST char* p_pszValue)
|
||||
{
|
||||
CONST char* pszCustomKey=GSWebHeaderForHTTPHeader(p_pszKey);
|
||||
CONST char* pszHeaderKey=(pszCustomKey) ? pszCustomKey : p_pszKey;
|
||||
|
||||
if (!p_pHTTPRequest->pHeaders)
|
||||
p_pHTTPRequest->pHeaders = GSWDict_New(64);
|
||||
|
||||
// Search Content Length
|
||||
if (p_pHTTPRequest->eMethod==ERequestMethod_Post
|
||||
&& p_pHTTPRequest->uContentLength==0
|
||||
&& strcasecmp(pszHeaderKey,g_szHeader_ContentLength)==0)
|
||||
p_pHTTPRequest->uContentLength = atoi(p_pszValue);
|
||||
|
||||
GSWDict_AddString(p_pHTTPRequest->pHeaders,pszHeaderKey,p_pszValue,FALSE);
|
||||
};
|
||||
|
||||
CONST char* GSWHTTPRequest_HeaderForKey(GSWHTTPRequest* p_pHTTPRequest,CONST char* p_pszKey)
|
||||
{
|
||||
if (p_pHTTPRequest->pHeaders)
|
||||
return GSWDict_ValueForKey(p_pHTTPRequest->pHeaders,p_pszKey);
|
||||
else
|
||||
return NULL;
|
||||
};
|
||||
|
||||
static void GetHeaderLength(GSWDictElem* p_pElem,
|
||||
void* p_piAddTo)
|
||||
{
|
||||
int* piAddTo=(int*)p_piAddTo;
|
||||
// +2=": "
|
||||
// +1="\n"
|
||||
(*piAddTo)+=strlen(p_pElem->pszKey)+strlen((char*)(p_pElem->pValue))+2+1+1;
|
||||
}
|
||||
|
||||
static void FormatHeader(GSWDictElem* p_pElem,
|
||||
void* p_ppszBuffer)
|
||||
{
|
||||
char** ppszBuffer=(char**)p_ppszBuffer;
|
||||
strcpy(*ppszBuffer,p_pElem->pszKey);
|
||||
strcat(*ppszBuffer, ": ");
|
||||
strcat(*ppszBuffer,(char*)p_pElem->pValue);
|
||||
(*ppszBuffer)+= strlen(*ppszBuffer);
|
||||
**ppszBuffer = '\n';
|
||||
(*ppszBuffer)++;
|
||||
};
|
||||
|
||||
// Handle Request (send it to Application)
|
||||
|
||||
BOOL GSWHTTPRequest_SendRequest(void* p_pLogServerData,GSWHTTPRequest* p_pHTTPRequest,AppConnectHandle p_socket)
|
||||
{
|
||||
BOOL fOk = TRUE;
|
||||
char* pszBuffer=NULL;
|
||||
char* pszTmp=NULL;
|
||||
int iLength = 0;
|
||||
int iHeaderLength = 0;
|
||||
int iRequestLength = strlen(p_pHTTPRequest->pszRequest);
|
||||
int iContentLength = p_pHTTPRequest->uContentLength;
|
||||
|
||||
GSWDict_PerformForAllElem(p_pHTTPRequest->pHeaders,
|
||||
GetHeaderLength,
|
||||
&iHeaderLength);
|
||||
iHeaderLength++; // Last /n
|
||||
|
||||
iLength=iRequestLength+iHeaderLength+iContentLength;
|
||||
|
||||
pszBuffer = malloc(iLength+1);
|
||||
|
||||
strncpy(pszBuffer,
|
||||
p_pHTTPRequest->pszRequest,
|
||||
iRequestLength);
|
||||
|
||||
pszTmp = pszBuffer+iRequestLength;
|
||||
GSWDict_PerformForAllElem(p_pHTTPRequest->pHeaders,
|
||||
FormatHeader,
|
||||
(void*)&pszTmp);
|
||||
|
||||
*pszTmp++ = '\n';
|
||||
|
||||
if (iContentLength>0)
|
||||
{
|
||||
memcpy(pszTmp,p_pHTTPRequest->pContent,iContentLength);
|
||||
pszTmp+=iContentLength;
|
||||
};
|
||||
|
||||
GSWLog(GSW_INFO,p_pLogServerData,
|
||||
"Sending AppRequest Content: %s\n(iContentLength Bytes)",
|
||||
p_pHTTPRequest->pszRequest,
|
||||
iContentLength);
|
||||
// Just To be sure of the length
|
||||
iLength = pszTmp - pszBuffer;
|
||||
fOk = GSWApp_SendBlock(p_pLogServerData,p_socket,pszBuffer,iLength);
|
||||
free(pszBuffer);
|
||||
pszBuffer=NULL;
|
||||
return fOk;
|
||||
}
|
||||
|
||||
static char* GSWHTTPRequest_PackageHeaders(GSWHTTPRequest* p_pHTTPRequest,
|
||||
char* p_pszBuffer,
|
||||
int p_iBufferSize)
|
||||
{
|
||||
int iHeaderLength=0;
|
||||
char* pszBuffer=NULL;
|
||||
char* pszTmp=NULL;
|
||||
|
||||
GSWDict_PerformForAllElem(p_pHTTPRequest->pHeaders,
|
||||
GetHeaderLength,
|
||||
(void*)&iHeaderLength);
|
||||
pszBuffer = ((p_iBufferSize > (iHeaderLength+1)) ? p_pszBuffer : malloc(p_iBufferSize+2));
|
||||
pszTmp = pszBuffer;
|
||||
|
||||
GSWDict_PerformForAllElem(p_pHTTPRequest->pHeaders,FormatHeader,&pszTmp);
|
||||
*pszTmp++ = '\n';
|
||||
*pszTmp++ = '\0';
|
||||
return pszBuffer;
|
||||
};
|
||||
|
||||
|
||||
static ERequestMethod GetHTTPRequestMethod(CONST char* pszMethod)
|
||||
{
|
||||
if (pszMethod)
|
||||
{
|
||||
if (strcmp(pszMethod,g_szMethod_Get)==0)
|
||||
return ERequestMethod_Get;
|
||||
else if (strcmp(pszMethod, g_szMethod_Post)==0)
|
||||
return ERequestMethod_Post;
|
||||
else if (!strcmp(pszMethod, g_szMethod_Head)==0)
|
||||
return ERequestMethod_Head;
|
||||
else if (!strcmp(pszMethod,g_szMethod_Put)==0)
|
||||
return ERequestMethod_Put;
|
||||
else
|
||||
return ERequestMethod_Unknown;
|
||||
}
|
||||
else
|
||||
return ERequestMethod_None;
|
||||
};
|
||||
|
||||
|
||||
|
||||
static int compareHeader(CONST void* p_pKey0,CONST void* p_pKey1)
|
||||
{
|
||||
CONST char* pKey1=((GSWHeaderTranslationItem*)p_pKey1)->pszHTTP;
|
||||
/*
|
||||
if (p_pKey0)
|
||||
GSWLog(GSW_ERROR,NULL,"p_pKey0=%p (CONST char*)p_pKey0=%s",p_pKey0,(CONST char*)p_pKey0);
|
||||
if (p_pKey1)
|
||||
{
|
||||
if (((GSWHeaderTranslationItem*)p_pKey1)->pszHTTP)
|
||||
GSWLog(GSW_ERROR,NULL,"p_pKey1=%p (CONST char*)p_pKey1=%s",p_pKey1,((GSWHeaderTranslationItem*)p_pKey1)->pszHTTP);
|
||||
|
||||
};
|
||||
*/
|
||||
if (pKey1)
|
||||
return strcmp((CONST char*)p_pKey0,pKey1);
|
||||
else if (!p_pKey0)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
static CONST char* GSWebHeaderForHTTPHeader(CONST char* p_pszHTTPHeader)
|
||||
{
|
||||
GSWHeaderTranslationItem* pItem=NULL;
|
||||
if (GSWHeaderTranslationTableItemsNb==0)
|
||||
GSWHeaderTranslationTable_Init();
|
||||
pItem=bsearch(p_pszHTTPHeader,
|
||||
GSWHeaderTranslationTable,
|
||||
GSWHeaderTranslationTableItemsNb,
|
||||
sizeof(GSWHeaderTranslationItem),
|
||||
compareHeader);
|
||||
return (pItem ? pItem->pszGSWeb : NULL);
|
||||
};
|
84
GSWAdaptors/common/GSWHTTPRequest.h
Normal file
84
GSWAdaptors/common/GSWHTTPRequest.h
Normal file
|
@ -0,0 +1,84 @@
|
|||
/* GSWHTTPRequest.h - GSWeb: GSWeb Request
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWHTTPRequest_h__
|
||||
#define _GSWHTTPRequest_h__
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ERequestMethod_None = -2,
|
||||
ERequestMethod_Unknown,
|
||||
ERequestMethod_Get,
|
||||
ERequestMethod_Post,
|
||||
ERequestMethod_Head,
|
||||
ERequestMethod_Put
|
||||
} ERequestMethod;
|
||||
|
||||
typedef struct _GSWHTTPRequest
|
||||
{
|
||||
ERequestMethod eMethod; // Method
|
||||
char* pszRequest; // Request String
|
||||
GSWDict* pHeaders; // Headers
|
||||
void* pServerHandle; // Server Handle
|
||||
unsigned uContentLength; // Content Length
|
||||
void* pContent; // Content
|
||||
} GSWHTTPRequest;
|
||||
|
||||
|
||||
GSWHTTPRequest* GSWHTTPRequest_New(CONST char* pszMethod,char* p_pszURI);
|
||||
void GSWHTTPRequest_Free(GSWHTTPRequest* p_pHTTPRequest);
|
||||
|
||||
// Return error message (NULL if ok)
|
||||
CONST char*GSWHTTPRequest_ValidateMethod(GSWHTTPRequest* p_pHTTPRequest);
|
||||
|
||||
// HTTP Request -> GSWeb App Request
|
||||
void GSWHTTPRequest_HTTPToAppRequest(GSWHTTPRequest* p_pHTTPRequest,
|
||||
GSWAppRequest* p_pAppRequest,
|
||||
GSWURLComponents* p_pURLComponents,
|
||||
CONST char* p_pszHTTPVersion);
|
||||
|
||||
// Add Header
|
||||
void GSWHTTPRequest_AddHeader(GSWHTTPRequest* p_pHTTPRequest,
|
||||
CONST char* p_pszKey,
|
||||
CONST char* p_pszValue);
|
||||
|
||||
// Get Header (case insensitive)
|
||||
CONST char* GSWHTTPRequest_HeaderForKey(GSWHTTPRequest* p_pHTTPRequest,
|
||||
CONST char* p_pszKey);
|
||||
|
||||
// Handle Request (send it to Application)
|
||||
BOOL GSWHTTPRequest_SendRequest(void* p_pLogServerData,GSWHTTPRequest* p_pHTTPRequest,AppConnectHandle p_socket);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
#endif // _GSWHTTPRequest_h__
|
490
GSWAdaptors/common/GSWHTTPResponse.c
Normal file
490
GSWAdaptors/common/GSWHTTPResponse.c
Normal file
|
@ -0,0 +1,490 @@
|
|||
/* GSWHTTPResponse.c - GSWeb: Adaptors: HTTP Response
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "GSWUtil.h"
|
||||
#include "GSWDict.h"
|
||||
#include "GSWString.h"
|
||||
#include "GSWURLUtil.h"
|
||||
#include "GSWConfig.h"
|
||||
#include "GSWHTTPHeaders.h"
|
||||
#include "GSWAppRequestStruct.h"
|
||||
#include "GSWAppConnect.h"
|
||||
#include "GSWHTTPRequest.h"
|
||||
#include "GSWHTTPResponse.h"
|
||||
#include "GSWAppRequest.h"
|
||||
|
||||
|
||||
static char* g_pszLocalHostName = NULL;
|
||||
|
||||
#define STATUS "Status"
|
||||
#define HTTP_SLASH "HTTP/"
|
||||
|
||||
|
||||
GSWHTTPResponse* GSWHTTPResponse_New(void* p_pLogServerData,CONST char* p_pszStatus)
|
||||
{
|
||||
GSWHTTPResponse* pHTTPResponse=NULL;
|
||||
BOOL fOk=FALSE;
|
||||
// Accept "HTTP/1.0 200 OK GSWeb..." and "HTTP/1.0 200 OK GNUstep GSWeb..."
|
||||
if (strncmp(p_pszStatus,HTTP_SLASH,strlen(HTTP_SLASH))==0)
|
||||
{
|
||||
// Status Code
|
||||
CONST char* pszSpace=strchr(p_pszStatus,' ');
|
||||
if (pszSpace)
|
||||
{
|
||||
unsigned int uStatus=0;
|
||||
fOk=TRUE;
|
||||
pszSpace++;
|
||||
uStatus=atoi(pszSpace);
|
||||
for(;fOk && *pszSpace && !isspace(*pszSpace);pszSpace++)
|
||||
fOk=isdigit(*pszSpace);
|
||||
if (fOk)
|
||||
{
|
||||
pHTTPResponse = calloc(1,sizeof(GSWHTTPResponse));
|
||||
memset(pHTTPResponse,0,sizeof(GSWHTTPResponse));
|
||||
pHTTPResponse->uStatus=uStatus;
|
||||
pHTTPResponse->pHeaders = GSWDict_New(16);
|
||||
if (*pszSpace)
|
||||
{
|
||||
pszSpace=strchr(pszSpace,' ');
|
||||
if (pszSpace)
|
||||
pHTTPResponse->pszStatusMessage=strdup(pszSpace);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
if (!fOk)
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,"Invalid response");
|
||||
return pHTTPResponse;
|
||||
};
|
||||
|
||||
|
||||
GSWHTTPResponse* GSWHTTPResponse_BuildErrorResponse(CONST char* p_pszMessage)
|
||||
{
|
||||
GSWHTTPResponse* pHTTPResponse=calloc(1,sizeof(GSWHTTPResponse));
|
||||
char szBuffer[RESPONSE__LINE_MAX_SIZE]="";
|
||||
pHTTPResponse->uStatus = 200;
|
||||
pHTTPResponse->pszStatusMessage = strdup(g_szOKGSWeb);
|
||||
pHTTPResponse->pHeaders = GSWDict_New(2);
|
||||
GSWDict_Add(pHTTPResponse->pHeaders,
|
||||
g_szHeader_ContentType,
|
||||
g_szContentType_TextHtml,
|
||||
FALSE);
|
||||
sprintf(szBuffer,g_szErrorResponseHTMLTextTpl,p_pszMessage);
|
||||
pHTTPResponse->uContentLength = strlen(szBuffer);
|
||||
pHTTPResponse->pContent = malloc(pHTTPResponse->uContentLength);
|
||||
strcpy(pHTTPResponse->pContent,szBuffer);
|
||||
sprintf(szBuffer,"%d",pHTTPResponse->uContentLength);
|
||||
GSWDict_AddStringDup(pHTTPResponse->pHeaders,g_szHeader_ContentLength,szBuffer);
|
||||
return pHTTPResponse;
|
||||
};
|
||||
|
||||
GSWHTTPResponse* GSWHTTPResponse_BuildRedirectedResponse(CONST char* p_pszRedirectPath)
|
||||
{
|
||||
GSWHTTPResponse* pHTTPResponse=calloc(1,sizeof(GSWHTTPResponse));
|
||||
pHTTPResponse->uStatus = 302;
|
||||
pHTTPResponse->pszStatusMessage = strdup(g_szOKGSWeb);
|
||||
pHTTPResponse->pHeaders=GSWDict_New(2);
|
||||
GSWDict_Add(pHTTPResponse->pHeaders, g_szHeader_ContentType, g_szContentType_TextHtml,FALSE);
|
||||
GSWDict_AddStringDup(pHTTPResponse->pHeaders,"location",p_pszRedirectPath);
|
||||
return pHTTPResponse;
|
||||
};
|
||||
|
||||
void GSWHTTPResponse_Free(GSWHTTPResponse* p_pHTTPResponse)
|
||||
{
|
||||
if (p_pHTTPResponse)
|
||||
{
|
||||
if (p_pHTTPResponse->pHeaders)
|
||||
{
|
||||
GSWDict_Free(p_pHTTPResponse->pHeaders);
|
||||
p_pHTTPResponse->pHeaders=NULL;
|
||||
};
|
||||
if (p_pHTTPResponse->pszStatusMessage)
|
||||
{
|
||||
free(p_pHTTPResponse->pszStatusMessage);
|
||||
p_pHTTPResponse->pszStatusMessage=NULL;
|
||||
};
|
||||
if (p_pHTTPResponse->pContent)
|
||||
{
|
||||
free(p_pHTTPResponse->pContent);
|
||||
p_pHTTPResponse->pContent=NULL;
|
||||
};
|
||||
free(p_pHTTPResponse);
|
||||
p_pHTTPResponse=NULL;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
void GSWHTTPResponse_AddHeader(GSWHTTPResponse* p_pHTTPResponse,char* p_pszHeader)
|
||||
{
|
||||
char* pszKey=NULL;
|
||||
char* pszValue=NULL;
|
||||
|
||||
for (pszKey=p_pszHeader,pszValue=pszKey;*pszValue!=':';pszValue++)
|
||||
{
|
||||
if (isupper(*pszValue))
|
||||
*pszValue = tolower(*pszValue);
|
||||
};
|
||||
if (*pszValue==':')
|
||||
{
|
||||
*pszValue++='\0';
|
||||
while (*pszValue && isspace(*pszValue))
|
||||
pszValue++;
|
||||
GSWDict_AddStringDup(p_pHTTPResponse->pHeaders,pszKey,pszValue);
|
||||
|
||||
if (p_pHTTPResponse->uContentLength==0 && strcmp(g_szHeader_ContentLength,pszKey)==0)
|
||||
p_pHTTPResponse->uContentLength = atoi(pszValue);
|
||||
}
|
||||
/*
|
||||
else
|
||||
Pb
|
||||
*/
|
||||
};
|
||||
|
||||
GSWHTTPResponse* GSWHTTPResponse_GetResponse(void* p_pLogServerData,AppConnectHandle p_socket)
|
||||
{
|
||||
GSWHTTPResponse* pHTTPResponse=NULL;
|
||||
char szResponseBuffer[RESPONSE__LINE_MAX_SIZE];
|
||||
|
||||
// Get the 1st Line
|
||||
GSWApp_ReceiveLine(p_pLogServerData,p_socket,szResponseBuffer, RESPONSE__LINE_MAX_SIZE);
|
||||
pHTTPResponse = GSWHTTPResponse_New(p_pLogServerData,szResponseBuffer);
|
||||
#ifdef DEBUG
|
||||
GSWLog(GSW_INFO,p_pLogServerData,"Response receive first line:\t\t[%s]",szResponseBuffer);
|
||||
#endif
|
||||
|
||||
if (!pHTTPResponse) //Error
|
||||
pHTTPResponse=GSWHTTPResponse_BuildErrorResponse("Invalid Response");
|
||||
else
|
||||
{
|
||||
int iHeader=0;
|
||||
// Headers
|
||||
while (GSWApp_ReceiveLine(p_pLogServerData,p_socket,szResponseBuffer,RESPONSE__LINE_MAX_SIZE)>0
|
||||
&& szResponseBuffer[0]
|
||||
)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
GSWLog(GSW_INFO,p_pLogServerData,"Header %d=\t\t[%s]",iHeader,szResponseBuffer);
|
||||
#endif
|
||||
GSWHTTPResponse_AddHeader(pHTTPResponse,szResponseBuffer);
|
||||
};
|
||||
|
||||
// Content
|
||||
if (pHTTPResponse->uContentLength)
|
||||
{
|
||||
char* pszBuffer= malloc(pHTTPResponse->uContentLength);
|
||||
int iReceivedCount=GSWApp_ReceiveBlock(p_pLogServerData,p_socket,pszBuffer,pHTTPResponse->uContentLength);
|
||||
#ifdef DEBUG
|
||||
GSWLog(GSW_INFO,p_pLogServerData,"iReceivedCount=%d",iReceivedCount);
|
||||
#endif
|
||||
if (iReceivedCount!= pHTTPResponse->uContentLength)
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,
|
||||
"Content received doesn't equal to ContentLength. Too bad, same player must shoot again !");
|
||||
free(pszBuffer);
|
||||
pszBuffer=NULL;
|
||||
GSWHTTPResponse_Free(pHTTPResponse);
|
||||
pHTTPResponse=NULL;
|
||||
pHTTPResponse = GSWHTTPResponse_BuildErrorResponse("Invalid Response");
|
||||
}
|
||||
else
|
||||
pHTTPResponse->pContent = pszBuffer;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (pHTTPResponse->pContent)
|
||||
{
|
||||
char szTraceBuffer[pHTTPResponse->uContentLength+1];
|
||||
GSWLog(GSW_INFO,p_pLogServerData,"\ncontent (%d Bytes)=\n",pHTTPResponse->uContentLength);
|
||||
memcpy(szTraceBuffer,pHTTPResponse->pContent,pHTTPResponse->uContentLength);
|
||||
szTraceBuffer[pHTTPResponse->uContentLength] = 0;
|
||||
GSWLogSized(GSW_INFO,p_pLogServerData,
|
||||
pHTTPResponse->uContentLength+1,
|
||||
"%.*s",
|
||||
(int)pHTTPResponse->uContentLength,
|
||||
szTraceBuffer);
|
||||
// GSWLog(GSW_INFO,p_pLogServerData,"\nEND\n");
|
||||
};
|
||||
#endif
|
||||
};
|
||||
return pHTTPResponse;
|
||||
};
|
||||
|
||||
|
||||
static void GetHeaderLength(GSWDictElem* p_pElem,
|
||||
void* p_piAddTo)
|
||||
{
|
||||
int* piAddTo=(int*)p_piAddTo;
|
||||
// +2=": "
|
||||
// +1="\r"
|
||||
// +1="\n"
|
||||
(*piAddTo)+=strlen(p_pElem->pszKey)+strlen((char*)p_pElem->pValue)+2+1+2;
|
||||
};
|
||||
|
||||
static void FormatHeader(GSWDictElem* p_pElem,
|
||||
void* p_ppszBuffer)
|
||||
{
|
||||
char** ppszBuffer=(char**)p_ppszBuffer;
|
||||
strcpy(*ppszBuffer,p_pElem->pszKey);
|
||||
strcat(*ppszBuffer, ": ");
|
||||
strcat(*ppszBuffer,(char*)p_pElem->pValue);
|
||||
(*ppszBuffer)+= strlen(*ppszBuffer);
|
||||
**ppszBuffer = '\r';
|
||||
(*ppszBuffer)++;
|
||||
**ppszBuffer = '\n';
|
||||
(*ppszBuffer)++;
|
||||
};
|
||||
|
||||
char *GSWHTTPResponse_PackageHeaders(GSWHTTPResponse* p_pHTTPResponse,
|
||||
char* p_pszBuffer,
|
||||
int p_iBufferSize)
|
||||
{
|
||||
int iHeaderLength=0;
|
||||
char* pszBuffer=NULL;
|
||||
char* pszTmp=NULL;
|
||||
|
||||
GSWDict_PerformForAllElem(p_pHTTPResponse->pHeaders,
|
||||
GetHeaderLength,
|
||||
(void*)&iHeaderLength);
|
||||
pszBuffer = ((p_iBufferSize > (iHeaderLength)) ? p_pszBuffer : malloc(p_iBufferSize+1));
|
||||
pszTmp = pszBuffer;
|
||||
|
||||
GSWDict_PerformForAllElem(p_pHTTPResponse->pHeaders,FormatHeader,&pszTmp);
|
||||
*pszTmp = '\0';
|
||||
if (pszTmp-pszBuffer>1)
|
||||
{
|
||||
// Remove last \r\n
|
||||
*(pszTmp-1) = 0;
|
||||
*(pszTmp-2) = 0;
|
||||
};
|
||||
return pszBuffer;
|
||||
};
|
||||
|
||||
void GSWHTTPResponse_AddHeaderToString(GSWDictElem* p_pElem,void* p_pData)
|
||||
{
|
||||
GSWString* pString=(GSWString*)p_pData;
|
||||
GSWString_Append(pString,p_pElem->pszKey);
|
||||
GSWString_Append(pString,": ");
|
||||
GSWString_Append(pString,(char*)p_pElem->pValue);
|
||||
GSWString_Append(pString,"<br>");
|
||||
};
|
||||
|
||||
GSWHTTPResponse* GSWHTTPResponse_BuildTestResponse(void* p_pLogServerData,GSWHTTPRequest* p_pHTTPRequest)
|
||||
{
|
||||
GSWHTTPResponse* pHTTPResponse=GSWHTTPResponse_New(p_pLogServerData,g_szOKStatus);
|
||||
GSWDict* pRequestHeaders=NULL;
|
||||
GSWString* pContent=GSWString_New();
|
||||
|
||||
GSWDict_AddString(pHTTPResponse->pHeaders,
|
||||
g_szHeader_ContentType,
|
||||
g_szContentType_TextHtml,
|
||||
FALSE);
|
||||
|
||||
GSWString_Append(pContent, "<HTML><BODY>");
|
||||
GSWString_Append(pContent, "<br><strong>Server Adaptor:</strong><br>");
|
||||
GSWString_Append(pContent, "<p>Server = ");
|
||||
GSWString_Append(pContent, g_szGSWeb_Server);
|
||||
GSWString_Append(pContent, " <br>");
|
||||
GSWString_Append(pContent, "GNUstepWeb Web Server Adaptor version = ");
|
||||
GSWString_Append(pContent, g_szGSWeb_AdaptorVersion);
|
||||
GSWString_Append(pContent, "</p>");
|
||||
|
||||
GSWString_Append(pContent, "<br><strong>Headers:</strong><br>");
|
||||
pRequestHeaders = (GSWDict*)(p_pHTTPRequest->pHeaders);
|
||||
GSWDict_PerformForAllElem(pRequestHeaders,GSWHTTPResponse_AddHeaderToString,pContent);
|
||||
|
||||
GSWString_Append(pContent, "</BODY></HTML>");
|
||||
|
||||
pHTTPResponse->uContentLength = pContent->iLen;
|
||||
pHTTPResponse->pContent = pContent->pszData;
|
||||
GSWString_Detach(pContent);
|
||||
GSWString_Free(pContent);
|
||||
return pHTTPResponse;
|
||||
};
|
||||
|
||||
|
||||
GSWHTTPResponse* GSWDumpConfigFile(void* p_pLogServerData,GSWURLComponents* p_pURLComponents)
|
||||
{
|
||||
GSWHTTPResponse* pHTTPResponse=NULL;
|
||||
if (GSWDumpConfigFile_CanDump())
|
||||
{
|
||||
proplist_t propListConfig=NULL;
|
||||
char szBuffer[4096]="";
|
||||
GSWString* pContent=GSWString_New();
|
||||
time_t nullTime=(time_t)0;
|
||||
char pszPrefix[MAXPATHLEN]="";
|
||||
char szReqAppName[MAXPATHLEN]="Unknown";
|
||||
GSWLog(GSW_INFO,p_pLogServerData,"Creating Applications Page.");
|
||||
|
||||
if (!g_pszLocalHostName)
|
||||
{
|
||||
char szHostName[MAXHOSTNAMELEN+1];
|
||||
gethostname(szHostName, MAXHOSTNAMELEN);
|
||||
g_pszLocalHostName= strdup(szHostName);
|
||||
};
|
||||
|
||||
pHTTPResponse = GSWHTTPResponse_New(p_pLogServerData,g_szOKStatus);
|
||||
GSWDict_AddString(pHTTPResponse->pHeaders,
|
||||
g_szHeader_ContentType,
|
||||
g_szContentType_TextHtml,
|
||||
FALSE);
|
||||
|
||||
if (p_pURLComponents->stAppName.iLength>0 && p_pURLComponents->stAppName.pszStart)
|
||||
{
|
||||
strncpy(szReqAppName,p_pURLComponents->stAppName.pszStart,p_pURLComponents->stAppName.iLength);
|
||||
szReqAppName[p_pURLComponents->stAppName.iLength]=0;
|
||||
};
|
||||
sprintf(szBuffer,
|
||||
g_szDumpConfFile_Head,
|
||||
szReqAppName,
|
||||
GSWConfig_GetConfigFilePath());
|
||||
GSWString_Append(pContent,szBuffer);
|
||||
|
||||
strncpy(pszPrefix, p_pURLComponents->stPrefix.pszStart,p_pURLComponents->stPrefix.iLength);
|
||||
pszPrefix[p_pURLComponents->stPrefix.iLength] = '\0';
|
||||
|
||||
if (GSWConfig_ReadIFND(GSWConfig_GetConfigFilePath(),
|
||||
&nullTime,
|
||||
&propListConfig,
|
||||
p_pLogServerData)==EGSWConfigResult__Ok)
|
||||
{
|
||||
proplist_t propListApps=NULL;
|
||||
propListApps=GSWConfig_GetApplicationsFromConfig(propListConfig);
|
||||
if (propListApps)
|
||||
{
|
||||
int iAppIndex=0;
|
||||
int iInstanceIndex=0;
|
||||
GSWApp* pApp=NULL;
|
||||
GSWAppInstance* pAppInstance=NULL;
|
||||
proplist_t propListAppsNames=GSWConfig_ApplicationsKeysFromApplications(propListApps);
|
||||
unsigned int uAppNb=PLGetNumberOfElements(propListAppsNames);
|
||||
for(iAppIndex=0;iAppIndex<uAppNb;iAppIndex++)
|
||||
{
|
||||
proplist_t propListAppKey=GSWConfig_ApplicationKeyFromApplicationsKey(propListAppsNames,
|
||||
iAppIndex);
|
||||
if (!propListAppKey)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
char url[MAXPATHLEN+256];
|
||||
CONST char* pszAppName=PLGetString(propListAppKey);
|
||||
proplist_t propListApp;
|
||||
|
||||
sprintf(url,"%s/%s",pszPrefix,pszAppName);
|
||||
sprintf(szBuffer,"<TR>\n<TD>%s</TD>\n<TD><A HREF=\"%s\">%s</A></TD>",
|
||||
pszAppName,
|
||||
url,
|
||||
url);
|
||||
GSWString_Append(pContent,szBuffer);
|
||||
propListApp=GSWConfig_ApplicationFromApplications(propListApps,
|
||||
propListAppKey);
|
||||
if (!propListApp)
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,"no ppropListApp");
|
||||
//TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
proplist_t propListInstances=GSWConfig_InstancesFromApplication(propListApp);
|
||||
if (!propListInstances)
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,"no propListInstances");
|
||||
//TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int uInstancesNb=PLGetNumberOfElements(propListInstances);
|
||||
GSWLog(GSW_INFO,p_pLogServerData,"uInstancesNb=%u",uInstancesNb);
|
||||
if (uInstancesNb>0)
|
||||
{
|
||||
sprintf(szBuffer,"<TD colspan=3><TABLE border=1>\n");
|
||||
GSWString_Append(pContent,szBuffer);
|
||||
};
|
||||
|
||||
for(iInstanceIndex=0;iInstanceIndex<uInstancesNb;iInstanceIndex++)
|
||||
{
|
||||
proplist_t propListInstance=PLGetArrayElement(propListInstances,iInstanceIndex);
|
||||
GSWLog(GSW_INFO,p_pLogServerData,"propListInstance=%p",propListInstance);
|
||||
if (!propListInstance)
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,"no propListInstance");
|
||||
//TODO
|
||||
}
|
||||
else if (!PLIsDictionary(propListInstance))
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,"propListInstance is not a dictionary");
|
||||
}
|
||||
else
|
||||
{
|
||||
STGSWConfigEntry stEntry;
|
||||
GSWConfig_PropListInstanceToInstanceEntry(&stEntry,
|
||||
propListInstance,
|
||||
pszAppName);
|
||||
sprintf(url,
|
||||
"http://%s:%d%s/%s",
|
||||
stEntry.pszHostName,
|
||||
stEntry.iPort,
|
||||
pszPrefix,
|
||||
pszAppName);
|
||||
sprintf(szBuffer,
|
||||
"<TR>\n<TD><A HREF=\"%s\">%d</A></TD>\n<TD>%s</TD>\n<TD>%d</TD>\n</TR>\n",
|
||||
url,
|
||||
stEntry.iInstance,
|
||||
stEntry.pszHostName,
|
||||
stEntry.iPort);
|
||||
GSWString_Append(pContent,szBuffer);
|
||||
};
|
||||
};
|
||||
if (uInstancesNb>0)
|
||||
{
|
||||
sprintf(szBuffer,"</TABLE></TD>");
|
||||
GSWString_Append(pContent,szBuffer);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
sprintf(szBuffer,
|
||||
g_szDumpConfFile_Foot,
|
||||
g_szGSWeb_DefaultGSWExtensionsFrameworkWebServerResources);
|
||||
GSWString_Append(pContent,szBuffer);
|
||||
|
||||
pHTTPResponse->uContentLength = pContent->iLen;
|
||||
pHTTPResponse->pContent = pContent->pszData;
|
||||
GSWString_Detach(pContent);
|
||||
GSWString_Free(pContent);
|
||||
};
|
||||
};
|
||||
return pHTTPResponse;
|
||||
};
|
||||
|
||||
|
||||
|
70
GSWAdaptors/common/GSWHTTPResponse.h
Normal file
70
GSWAdaptors/common/GSWHTTPResponse.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
/* GSWHTTPResponse.h - GSWeb: GSWeb Request
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWHTTPResponse_h__
|
||||
#define _GSWHTTPResponse_h__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
typedef struct _GSWHTTPResponse
|
||||
{
|
||||
unsigned int uStatus;
|
||||
char* pszStatusMessage;
|
||||
GSWDict* pHeaders;
|
||||
unsigned int uContentLength;
|
||||
void* pContent;
|
||||
} GSWHTTPResponse;
|
||||
|
||||
GSWHTTPResponse* GSWHTTPResponse_New(void* p_pLogServerData,CONST char* p_pszStatus);
|
||||
void GSWHTTPResponse_Free(GSWHTTPResponse* p_pHTTPResponse);
|
||||
|
||||
// Get The response from Application
|
||||
GSWHTTPResponse* GSWHTTPResponse_GetResponse(void* p_pLogServerData,AppConnectHandle p_socket);
|
||||
|
||||
// Build an error response
|
||||
GSWHTTPResponse *GSWHTTPResponse_BuildErrorResponse(CONST char* p_pszMessage);
|
||||
|
||||
// Redirect Response
|
||||
GSWHTTPResponse* GSWHTTPResponse_BuildRedirectedResponse(CONST char* p_pszRedirectPath);
|
||||
|
||||
// Add Header
|
||||
void GSWHTTPResponse_AddHeader(GSWHTTPResponse* p_pHTTPResponse,
|
||||
char* p_pszHeader);
|
||||
|
||||
char* p_pszGSWHTTPResponse_PackageHeaders(GSWHTTPResponse* p_pHTTPResponse,
|
||||
char* p_pszBuffer,
|
||||
int iBufferSize);
|
||||
|
||||
GSWHTTPResponse* GSWHTTPResponse_BuildTestResponse(void* p_pLogServerData,GSWHTTPRequest* p_pHTTPRequest);
|
||||
|
||||
BOOL GSWDumpConfigFile_CanDump();
|
||||
GSWHTTPResponse* GSWDumpConfigFile(void* p_pLogServerData,GSWURLComponents* p_pURLComponents);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
#endif // _GSWHTTPResponse_h__
|
140
GSWAdaptors/common/GSWList.c
Normal file
140
GSWAdaptors/common/GSWList.c
Normal file
|
@ -0,0 +1,140 @@
|
|||
/* GSWDict.c - GSWeb: Dictionary
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "GSWUtil.h"
|
||||
#include "GSWList.h"
|
||||
|
||||
unsigned int GSWList_Count(GSWList* p_pList)
|
||||
{
|
||||
return p_pList->uCount;
|
||||
};
|
||||
|
||||
GSWList *GSWList_New(unsigned int p_uCapacity)
|
||||
{
|
||||
GSWList* pList=calloc(1,sizeof(GSWList));
|
||||
if (pList && p_uCapacity>0)
|
||||
GSWList_SetCapacity(pList,p_uCapacity);
|
||||
return pList;
|
||||
};
|
||||
|
||||
void GSWList_FreeElements(GSWList* p_pList)
|
||||
{
|
||||
if (p_pList)
|
||||
{
|
||||
unsigned int i=0;
|
||||
for(i=0;i<p_pList->uCount;i++)
|
||||
{
|
||||
free(p_pList->ppElements[i]);
|
||||
p_pList->ppElements[i]=NULL;
|
||||
};
|
||||
p_pList->uCount=0;
|
||||
};
|
||||
};
|
||||
|
||||
void GSWList_Free(GSWList* p_pList,BOOL p_fFreeElements)
|
||||
{
|
||||
if (p_pList)
|
||||
{
|
||||
if (p_pList->ppElements)
|
||||
{
|
||||
if (p_fFreeElements)
|
||||
GSWList_FreeElements(p_pList);
|
||||
free(p_pList->ppElements);
|
||||
p_pList->ppElements=NULL;
|
||||
};
|
||||
free(p_pList);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
void GSWList_Add(GSWList* p_pList,void* p_pElement)
|
||||
{
|
||||
if (p_pList->uCount>=p_pList->uCapacity)
|
||||
GSWList_SetCapacity(p_pList,(p_pList->uCapacity) ? p_pList->uCapacity*2 : 16);
|
||||
p_pList->ppElements[p_pList->uCount] = p_pElement;
|
||||
p_pList->uCount++;
|
||||
};
|
||||
|
||||
void GSWList_RemoveAtIndex(GSWList* p_pList,int p_iIndex)
|
||||
{
|
||||
if (p_iIndex>=0 && p_iIndex<p_pList->uCount)
|
||||
{
|
||||
p_pList->uCount--;
|
||||
for (;p_iIndex<p_pList->uCount;p_iIndex++)
|
||||
p_pList->ppElements[p_iIndex]=p_pList->ppElements[p_iIndex+1];
|
||||
};
|
||||
};
|
||||
|
||||
void GSWList_Remove(GSWList* p_pList,void* p_pElement)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<p_pList->uCount;i++)
|
||||
{
|
||||
if (p_pList->ppElements[i]==p_pElement)
|
||||
{
|
||||
GSWList_RemoveAtIndex(p_pList,i);
|
||||
i=p_pList->uCount;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
void GSWList_SetCapacity(GSWList* p_pList,unsigned int p_uCapacity)
|
||||
{
|
||||
if (p_uCapacity>p_pList->uCapacity)
|
||||
{
|
||||
if (p_pList->ppElements)
|
||||
p_pList->ppElements=realloc(p_pList->ppElements,p_uCapacity*sizeof(void*));
|
||||
else
|
||||
p_pList->ppElements=calloc(p_uCapacity, sizeof(void*));
|
||||
p_pList->uCapacity=p_uCapacity;
|
||||
};
|
||||
};
|
||||
|
||||
void GSWList_Sort(GSWList* p_pList,int (*compare)(CONST void*, CONST void*))
|
||||
{
|
||||
if (p_pList->uCount>1)
|
||||
qsort(p_pList->ppElements,p_pList->uCount,sizeof(void*), compare);
|
||||
}
|
||||
|
||||
void *GSWList_BSearch(GSWList* p_pList,CONST void* p_pKey,int (*compare)(CONST void*, CONST void*))
|
||||
{
|
||||
void** ppElement=NULL;
|
||||
if (p_pList->uCount>0)
|
||||
ppElement=bsearch(p_pKey,p_pList->ppElements,p_pList->uCount,sizeof(void*), compare);
|
||||
return (ppElement) ? *ppElement : NULL;
|
||||
};
|
||||
|
||||
void* GSWList_ElementAtIndex(GSWList* p_pList,int p_iIndex)
|
||||
{
|
||||
if (p_iIndex>=0 && p_iIndex<p_pList->uCount)
|
||||
return p_pList->ppElements[p_iIndex];
|
||||
else
|
||||
return NULL;
|
||||
};
|
||||
|
57
GSWAdaptors/common/GSWList.h
Normal file
57
GSWAdaptors/common/GSWList.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/* GSWList.h - GSWeb: List
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWList_h__
|
||||
#define _GSWList_h__
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
typedef struct _GSWList
|
||||
{
|
||||
unsigned int uCount;
|
||||
unsigned int uCapacity;
|
||||
void** ppElements;
|
||||
} GSWList;
|
||||
|
||||
unsigned int GSWList_Count(GSWList* p_pList);
|
||||
|
||||
GSWList *GSWList_New(unsigned int p_uCapacity);
|
||||
void GSWList_Free(GSWList* p_pList,BOOL p_fFreeElements);
|
||||
|
||||
void GSWList_Add(GSWList* p_pList,void* p_pElement);
|
||||
void GSWList_Remove(GSWList* p_pList,void* p_pElement);
|
||||
void GSWList_RemoveAtIndex(GSWList* p_pList,int p_iIndex);
|
||||
void GSWList_SetCapacity(GSWList* p_pList,unsigned int p_uCapacity);
|
||||
void GSWList_Sort(GSWList* p_pList,int (*compare)(CONST void *, CONST void *));
|
||||
void *GSWList_BSearch(GSWList* p_pList,CONST void* p_pKey,int (*compare)(CONST void *, CONST void *));
|
||||
|
||||
void* GSWList_ElementAtIndex(GSWList* p_pList,int p_iIndex);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // _GSWList_h__
|
425
GSWAdaptors/common/GSWLoadBalancing.c
Normal file
425
GSWAdaptors/common/GSWLoadBalancing.c
Normal file
|
@ -0,0 +1,425 @@
|
|||
/* GSWLoadBalancing.c - GSWeb: Adaptors: Load Balancing
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "GSWUtil.h"
|
||||
#include "GSWDict.h"
|
||||
#include "GSWList.h"
|
||||
#include "GSWURLUtil.h"
|
||||
#include "GSWConfig.h"
|
||||
#include "GSWAppRequestStruct.h"
|
||||
#include "GSWAppConnect.h"
|
||||
#include "GSWHTTPRequest.h"
|
||||
#include "GSWHTTPResponse.h"
|
||||
#include "GSWAppRequest.h"
|
||||
#include "GSWHTTPHeaders.h"
|
||||
#include "GSWLoadBalancing.h"
|
||||
#include "GSWLock.h"
|
||||
|
||||
static GSWLock g_lockAppList;
|
||||
static GSWList* g_pAppList = NULL;
|
||||
|
||||
|
||||
|
||||
static time_t config_mtime = (time_t)0;
|
||||
|
||||
// Callback Functions
|
||||
static int compareApps(CONST void *p1, CONST void *p2)
|
||||
{
|
||||
GSWApp* pApp1=*(GSWApp**)p1;
|
||||
GSWApp* pApp2=*(GSWApp**)p2;
|
||||
return strcmp(pApp1->pszName,pApp2->pszName);
|
||||
}
|
||||
|
||||
static int compareInstances(CONST void *p1, CONST void *p2)
|
||||
{
|
||||
GSWAppInstance* pAppInstance1=*(GSWAppInstance**)p1;
|
||||
GSWAppInstance* pAppInstance2=*(GSWAppInstance**)p2;
|
||||
return (pAppInstance1->iInstance-pAppInstance2->iInstance);
|
||||
}
|
||||
|
||||
static int compareAppNames(CONST void *p1, CONST void *p2)
|
||||
{
|
||||
GSWApp* pApp=*(GSWApp**)p2;
|
||||
return strcmp((char*)p1,pApp->pszName);
|
||||
}
|
||||
|
||||
|
||||
void GSWLoadBalancing_Init(GSWDict* p_pDict)
|
||||
{
|
||||
if (p_pDict)
|
||||
{
|
||||
CONST char* pszPath=GSWDict_ValueForKey(p_pDict,g_szGSWeb_Conf_ConfigFilePath);
|
||||
GSWConfig_SetConfigFilePath(pszPath);
|
||||
};
|
||||
|
||||
GSWLock_Init(g_lockAppList);
|
||||
};
|
||||
|
||||
static GSWLoadBalancing_ClearInstances()
|
||||
{
|
||||
int iAppIndex=0;
|
||||
int iInstanceIndex=0;
|
||||
GSWApp *pApp = NULL;
|
||||
GSWAppInstance *pAppInstance = NULL;
|
||||
for (iAppIndex=0;iAppIndex<g_pAppList->uCount;iAppIndex++)
|
||||
{
|
||||
pApp = GSWList_ElementAtIndex(g_pAppList,iAppIndex);
|
||||
for (iInstanceIndex=0;iInstanceIndex<pApp->stInstances.uCount;iInstanceIndex++)
|
||||
{
|
||||
pAppInstance = GSWList_ElementAtIndex(&pApp->stInstances,iInstanceIndex);
|
||||
pAppInstance->fValid=FALSE;
|
||||
};
|
||||
};
|
||||
};
|
||||
static EGSWConfigResult GSWLoadBalancing_NewInstance(STGSWConfigEntry* p_pConfigEntry,
|
||||
void* p_pLogServerData)
|
||||
{
|
||||
EGSWConfigResult eResult=EGSWConfigResult__Ok;
|
||||
int iAppIndex=0;
|
||||
int iInstanceIndex=0;
|
||||
GSWApp *pApp = NULL;
|
||||
GSWAppInstance *pAppInstance = NULL;
|
||||
|
||||
|
||||
if (p_pConfigEntry)
|
||||
{
|
||||
BOOL fFound=FALSE;
|
||||
for (iAppIndex=0;! fFound && iAppIndex<g_pAppList->uCount;iAppIndex++)
|
||||
{
|
||||
pApp = GSWList_ElementAtIndex(g_pAppList,iAppIndex);
|
||||
fFound=(strcmp(p_pConfigEntry->pszAppName,pApp->pszName)==0);
|
||||
};
|
||||
if (!fFound)
|
||||
{
|
||||
time_t now;
|
||||
time(&now);
|
||||
srand(now);
|
||||
pApp=(GSWApp*)calloc(1,sizeof(GSWApp));
|
||||
pApp->pszName=strdup(p_pConfigEntry->pszAppName);
|
||||
pApp->iIndex = rand();
|
||||
GSWList_Add(g_pAppList,pApp);
|
||||
};
|
||||
fFound = 0;
|
||||
for (iInstanceIndex=0;!fFound && iInstanceIndex<pApp->stInstances.uCount;iInstanceIndex++)
|
||||
{
|
||||
pAppInstance = GSWList_ElementAtIndex(&(pApp->stInstances),iInstanceIndex);
|
||||
if (pAppInstance->iInstance==p_pConfigEntry->iInstance)
|
||||
{
|
||||
fFound=TRUE;
|
||||
free(pAppInstance->pszHost);
|
||||
pAppInstance->pszHost=NULL;
|
||||
pAppInstance->pszHost=strdup(p_pConfigEntry->pszHostName);
|
||||
};
|
||||
};
|
||||
if (!fFound)
|
||||
{
|
||||
pAppInstance = (GSWAppInstance *)calloc(1,sizeof(GSWAppInstance));
|
||||
pAppInstance->iInstance = p_pConfigEntry->iInstance;
|
||||
pAppInstance->pszHost = strdup(p_pConfigEntry->pszHostName);
|
||||
GSWList_Add(&pApp->stInstances,pAppInstance);
|
||||
};
|
||||
|
||||
pAppInstance->iPort = p_pConfigEntry->iPort;
|
||||
pAppInstance->timeNextRetryTime=0;
|
||||
pAppInstance->fValid=TRUE;
|
||||
GSWLog(GSW_INFO,p_pLogServerData,
|
||||
"Config: %s instance %d host %s port %d Valid:%s timeNextRetryTime? %d",
|
||||
pApp->pszName,
|
||||
pAppInstance->iInstance,
|
||||
pAppInstance->pszHost,
|
||||
pAppInstance->iPort,
|
||||
(pAppInstance->fValid ? "YES" : "NO"),
|
||||
pAppInstance->timeNextRetryTime);
|
||||
};
|
||||
return eResult;
|
||||
};
|
||||
|
||||
|
||||
static void GSWLoadBalancing_VerifyConfiguration(void* p_pLogServerData)
|
||||
{
|
||||
proplist_t propListConfig=NULL;
|
||||
if (!g_pAppList)
|
||||
g_pAppList = GSWList_New(16);
|
||||
|
||||
if (GSWConfig_ReadIFND(GSWConfig_GetConfigFilePath(),
|
||||
&config_mtime,
|
||||
&propListConfig,
|
||||
p_pLogServerData)==EGSWConfigResult__Ok)
|
||||
{
|
||||
proplist_t propListApps=NULL;
|
||||
GSWLoadBalancing_ClearInstances();
|
||||
propListApps=GSWConfig_GetApplicationsFromConfig(propListConfig);
|
||||
if (propListApps)
|
||||
{
|
||||
int iAppIndex=0;
|
||||
int iInstanceIndex=0;
|
||||
GSWApp* pApp=NULL;
|
||||
GSWAppInstance* pAppInstance=NULL;
|
||||
proplist_t propListAppsNames=GSWConfig_ApplicationsKeysFromApplications(propListApps);
|
||||
unsigned int uAppNb=PLGetNumberOfElements(propListAppsNames);
|
||||
for(iAppIndex=0;iAppIndex<uAppNb;iAppIndex++)
|
||||
{
|
||||
proplist_t propListAppKey=GSWConfig_ApplicationKeyFromApplicationsKey(propListAppsNames,iAppIndex);
|
||||
if (!propListAppKey)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
CONST char* pszAppName=PLGetString(propListAppKey);
|
||||
proplist_t propListApp=GSWConfig_ApplicationFromApplications(propListApps,
|
||||
propListAppKey);
|
||||
if (!propListApp)
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,"no ppropListApp");
|
||||
//TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
proplist_t propListInstances=GSWConfig_InstancesFromApplication(propListApp);
|
||||
if (!propListInstances)
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,"no propListInstances");
|
||||
//TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int uInstancesNb=PLGetNumberOfElements(propListInstances);
|
||||
|
||||
for(iInstanceIndex=0;iInstanceIndex<uInstancesNb;iInstanceIndex++)
|
||||
{
|
||||
proplist_t propListInstance=PLGetArrayElement(propListInstances,iInstanceIndex);
|
||||
if (!propListInstance)
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,"no propListInstance");
|
||||
//TODO
|
||||
}
|
||||
else if (!PLIsDictionary(propListInstance))
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,"propListInstance is not a dictionary");
|
||||
}
|
||||
else
|
||||
{
|
||||
STGSWConfigEntry stEntry;
|
||||
GSWConfig_PropListInstanceToInstanceEntry(&stEntry,
|
||||
propListInstance,
|
||||
pszAppName);
|
||||
GSWLoadBalancing_NewInstance(&stEntry,p_pLogServerData);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
// Changed !
|
||||
for (iAppIndex=g_pAppList->uCount-1;iAppIndex>=0;iAppIndex--)
|
||||
{
|
||||
pApp=GSWList_ElementAtIndex(g_pAppList,iAppIndex);
|
||||
for (iInstanceIndex=pApp->stInstances.uCount-1;iInstanceIndex>=0;iInstanceIndex--)
|
||||
{
|
||||
pAppInstance = GSWList_ElementAtIndex(&pApp->stInstances,iInstanceIndex);
|
||||
if (!pAppInstance->fValid)
|
||||
{
|
||||
GSWLog(GSW_INFO,p_pLogServerData,"Removing %s instance %d %s",
|
||||
pApp->pszName,
|
||||
pAppInstance->iInstance,
|
||||
pAppInstance->pszHost);
|
||||
GSWList_RemoveAtIndex(&pApp->stInstances,iInstanceIndex);
|
||||
if (pAppInstance->uOpenedRequestsNb==0)
|
||||
{
|
||||
free(pAppInstance->pszHost);
|
||||
pAppInstance->pszHost=NULL;
|
||||
free(pAppInstance);
|
||||
pAppInstance=NULL;
|
||||
};
|
||||
};
|
||||
};
|
||||
if (pApp->stInstances.uCount==0)
|
||||
{
|
||||
GSWList_RemoveAtIndex(g_pAppList,iAppIndex);
|
||||
GSWLog(GSW_INFO,p_pLogServerData,"Removing application %s as there is no instance left.",
|
||||
pApp->pszName);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSWList_Sort(&pApp->stInstances,compareInstances);
|
||||
for (iInstanceIndex=0;iInstanceIndex<pApp->stInstances.uCount-1;iInstanceIndex++)
|
||||
{
|
||||
GSWAppInstance* pAppInstance0=GSWList_ElementAtIndex(&pApp->stInstances,iInstanceIndex);
|
||||
GSWAppInstance* pAppInstance1=GSWList_ElementAtIndex(&pApp->stInstances,iInstanceIndex+1);
|
||||
if (pAppInstance0->iInstance == pAppInstance1->iInstance)
|
||||
{
|
||||
GSWLog(GSW_ERROR,
|
||||
p_pLogServerData,
|
||||
"Configuration error: instance numbers must be unique:\n\t(%s:%d@%s) == (%s:%d@%s)",
|
||||
pApp->pszName,pAppInstance0->iInstance,
|
||||
pAppInstance0->pszHost,
|
||||
pApp->pszName,pAppInstance1->iInstance,
|
||||
pAppInstance1->pszHost);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
GSWList_Sort(g_pAppList,compareApps);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
BOOL GSWLoadBalancing_FindApp(void* p_pLogServerData,GSWAppRequest *p_pAppRequest)
|
||||
{
|
||||
BOOL fFound=FALSE;
|
||||
GSWApp* pApp=NULL;
|
||||
|
||||
GSWLock_Lock(g_lockAppList);
|
||||
GSWLoadBalancing_VerifyConfiguration(p_pLogServerData);
|
||||
pApp = GSWList_BSearch(g_pAppList,
|
||||
p_pAppRequest->pszName,
|
||||
compareAppNames);
|
||||
if (pApp)
|
||||
{
|
||||
int iTries=pApp->stInstances.uCount;
|
||||
GSWAppInstance* pAppInstance=NULL;
|
||||
time_t curTime = (time_t)0;
|
||||
|
||||
while (!fFound && iTries-->0)
|
||||
{
|
||||
pApp->iIndex = (pApp->iIndex+1) % pApp->stInstances.uCount;
|
||||
pAppInstance=GSWList_ElementAtIndex((&pApp->stInstances),pApp->iIndex);
|
||||
if (pAppInstance->timeNextRetryTime!=0)
|
||||
{
|
||||
if (!curTime)
|
||||
time(&curTime);
|
||||
if (pAppInstance->timeNextRetryTime<curTime)
|
||||
{
|
||||
GSWLog(GSW_INFO,
|
||||
p_pLogServerData,
|
||||
"LoadBalance: Instance %s:%d was marked dead for %d secs. Now resurecting !",
|
||||
p_pAppRequest->pszName,
|
||||
pAppInstance->iInstance,
|
||||
APP_CONNECT_RETRY_DELAY);
|
||||
pAppInstance->timeNextRetryTime=0;
|
||||
};
|
||||
};
|
||||
if (pAppInstance->timeNextRetryTime==0 && pAppInstance->fValid)
|
||||
{
|
||||
fFound = TRUE;
|
||||
strcpy(p_pAppRequest->pszName,pApp->pszName);
|
||||
p_pAppRequest->iInstance = pAppInstance->iInstance;
|
||||
p_pAppRequest->pszHost = pAppInstance->pszHost;
|
||||
p_pAppRequest->iPort = pAppInstance->iPort;
|
||||
p_pAppRequest->eType = EAppType_LoadBalanced;
|
||||
p_pAppRequest->pLoadBalancingData = pAppInstance;
|
||||
pAppInstance->uOpenedRequestsNb++;
|
||||
};
|
||||
};
|
||||
};
|
||||
GSWLock_Unlock(g_lockAppList);
|
||||
|
||||
if (fFound)
|
||||
GSWLog(GSW_INFO,p_pLogServerData,"LoadBalance: looking for %s, fFound instance %d on %s:%d",
|
||||
p_pAppRequest->pszName,
|
||||
p_pAppRequest->iInstance,
|
||||
p_pAppRequest->pszHost,
|
||||
p_pAppRequest->iPort);
|
||||
else
|
||||
GSWLog(GSW_INFO,p_pLogServerData,"LoadBalance: looking for %s, Not Found",
|
||||
p_pAppRequest->pszName);
|
||||
return fFound;
|
||||
};
|
||||
|
||||
BOOL GSWLoadBalancing_FindInstance(void* p_pLogServerData,GSWAppRequest *p_pAppRequest)
|
||||
{
|
||||
BOOL fFound=FALSE;
|
||||
GSWApp* pApp=NULL;
|
||||
int i=0;
|
||||
GSWLock_Lock(g_lockAppList);
|
||||
GSWLoadBalancing_VerifyConfiguration(p_pLogServerData);
|
||||
|
||||
pApp=GSWList_BSearch(g_pAppList,p_pAppRequest->pszName,compareAppNames);
|
||||
if (pApp)
|
||||
{
|
||||
GSWAppInstance* pAppInstance=NULL;
|
||||
for (i=0;i<pApp->stInstances.uCount && !fFound;i++)
|
||||
{
|
||||
pAppInstance = GSWList_ElementAtIndex((&pApp->stInstances),i);
|
||||
if (pAppInstance->iInstance
|
||||
&& pAppInstance->iInstance==p_pAppRequest->iInstance
|
||||
&& pAppInstance->fValid)
|
||||
{
|
||||
fFound=TRUE;
|
||||
p_pAppRequest->iInstance = pAppInstance->iInstance;
|
||||
p_pAppRequest->pszHost = pAppInstance->pszHost;
|
||||
p_pAppRequest->iPort = pAppInstance->iPort;
|
||||
p_pAppRequest->eType = EAppType_LoadBalanced;
|
||||
p_pAppRequest->pLoadBalancingData = pAppInstance;
|
||||
pAppInstance->uOpenedRequestsNb++;
|
||||
};
|
||||
};
|
||||
};
|
||||
GSWLock_Unlock(g_lockAppList);
|
||||
return fFound;
|
||||
};
|
||||
|
||||
void GSWLoadBalancing_MarkNotRespondingApp(void* p_pLogServerData,GSWAppRequest *p_pAppRequest)
|
||||
{
|
||||
GSWAppInstance* pAppInstance;
|
||||
time_t now;
|
||||
time(&now);
|
||||
pAppInstance = (GSWAppInstance *)p_pAppRequest->pLoadBalancingData;
|
||||
pAppInstance->uOpenedRequestsNb--;
|
||||
pAppInstance->timeNextRetryTime=now+APP_CONNECT_RETRY_DELAY;
|
||||
GSWLog(GSW_WARNING,p_pLogServerData,"Marking %s unresponsive",p_pAppRequest->pszName);
|
||||
}
|
||||
|
||||
void GSWLoadBalancing_StartAppRequest(void* p_pLogServerData,GSWAppRequest *p_pAppRequest)
|
||||
{
|
||||
GSWAppInstance* pAppInstance=(GSWAppInstance*)p_pAppRequest->pLoadBalancingData;
|
||||
if (pAppInstance->timeNextRetryTime!=0)
|
||||
{
|
||||
pAppInstance->timeNextRetryTime=0;
|
||||
GSWLog(GSW_WARNING,p_pLogServerData,"Marking %s as alive",p_pAppRequest->pszName);
|
||||
};
|
||||
}
|
||||
|
||||
void GSWLoadBalancing_StopAppRequest(void* p_pLogServerData,GSWAppRequest *p_pAppRequest)
|
||||
{
|
||||
GSWAppInstance* pAppInstance=(GSWAppInstance*)p_pAppRequest->pLoadBalancingData;
|
||||
GSWLock_Lock(g_lockAppList);
|
||||
pAppInstance->uOpenedRequestsNb--;
|
||||
if (!pAppInstance->fValid && pAppInstance->uOpenedRequestsNb==0)
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,"Not deleted (not implemented) %s (%d)",
|
||||
p_pAppRequest->pszName,
|
||||
p_pAppRequest->iInstance);
|
||||
};
|
||||
GSWLock_Unlock(g_lockAppList);
|
||||
p_pAppRequest->pLoadBalancingData = NULL;
|
||||
};
|
||||
|
35
GSWAdaptors/common/GSWLoadBalancing.h
Normal file
35
GSWAdaptors/common/GSWLoadBalancing.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* GSWLoadBalancing.h - GSWeb: GSWeb Load Balancing
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWLoadBalancing_h__
|
||||
#define _GSWLoadBalancing_h__
|
||||
|
||||
void GSWLoadBalancing_Init(GSWDict *dict);
|
||||
BOOL GSWLoadBalancing_FindApp(void* p_pLogServerData,GSWAppRequest *app);
|
||||
BOOL GSWLoadBalancing_FindInstance(void* p_pLogServerData,GSWAppRequest *app);
|
||||
void GSWLoadBalancing_MarkNotRespondingApp(void* p_pLogServerData,GSWAppRequest *app);
|
||||
void GSWLoadBalancing_StartAppRequest(void* p_pLogServerData,GSWAppRequest *app);
|
||||
void GSWLoadBalancing_StopAppRequest(void* p_pLogServerData,GSWAppRequest *app);
|
||||
|
||||
#endif // GSWLoadBalancing
|
||||
|
59
GSWAdaptors/common/GSWLock.h
Normal file
59
GSWAdaptors/common/GSWLock.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/* GSWLock.h - GSWeb: Lock
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWLock_h__
|
||||
#define _GSWLock_h__
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
// Apache has no theading for old versions
|
||||
#if !defined(REENTRANT) || defined(Apache)
|
||||
#define GSWLock void*
|
||||
#define GSWLock_Init(TheLock)
|
||||
#define GSWLock_Lock(TheLock)
|
||||
#define GSWLock_Unlock(TheLock)
|
||||
#define GSWLock_Free(TheLock)
|
||||
#define GSWLock_Sleep(SecNb) sleep(SecNb)
|
||||
#elif defined(Netscape)
|
||||
#include <base/systems.h>
|
||||
#include <base/crit.h>
|
||||
#include <base/systhr.h>
|
||||
#define GSWLock CRITICAL
|
||||
#define GSWLock_Init(TheLock) (TheLock = crit_init())
|
||||
#define GSWLock_Lock(TheLock) crit_enter(TheLock)
|
||||
#define GSWLock_Unlock(TheLock) crit_exit(TheLock)
|
||||
#define GSWLock_Free(TheLock) crit_terminate(TheLock)
|
||||
#define GSWLock_Sleep(SecNb) systhread_sleep(SecNb*1000)
|
||||
#else
|
||||
#error "GSWLock.h Unknwon server"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // _GSWLock_h__
|
80
GSWAdaptors/common/GSWString.c
Normal file
80
GSWAdaptors/common/GSWString.c
Normal file
|
@ -0,0 +1,80 @@
|
|||
/* GSWString.c - GSWeb: Adaptors: String
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "GSWUtil.h"
|
||||
#include "GSWString.h"
|
||||
|
||||
|
||||
GSWString* GSWString_New()
|
||||
{
|
||||
GSWString* pString = malloc(sizeof(GSWString));
|
||||
memset(pString,0,sizeof(GSWString));
|
||||
return pString;
|
||||
};
|
||||
|
||||
void GSWString_Free(GSWString* p_pString)
|
||||
{
|
||||
if (p_pString)
|
||||
{
|
||||
if (p_pString->pszData)
|
||||
{
|
||||
free(p_pString->pszData);
|
||||
p_pString->pszData=NULL;
|
||||
};
|
||||
free(p_pString);
|
||||
};
|
||||
};
|
||||
|
||||
void GSWString_Detach(GSWString* p_pString)
|
||||
{
|
||||
memset(p_pString,0,sizeof(GSWString));
|
||||
};
|
||||
|
||||
void GSWString_Append(GSWString* p_pString,
|
||||
CONST char* p_pszString)
|
||||
{
|
||||
int iLen = strlen(p_pszString);
|
||||
if ((p_pString->iLen+iLen+1)>p_pString->iSize)
|
||||
{
|
||||
if (!p_pString->pszData)
|
||||
{
|
||||
p_pString->iSize=max(iLen+1,4096);
|
||||
p_pString->pszData=malloc(p_pString->iSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
p_pString->iSize+=max(iLen+1,4096);
|
||||
p_pString->pszData=realloc(p_pString->pszData,p_pString->iSize);
|
||||
};
|
||||
};
|
||||
memcpy(p_pString->pszData+p_pString->iLen,p_pszString,iLen+1);
|
||||
p_pString->iLen+=iLen;
|
||||
};
|
||||
|
49
GSWAdaptors/common/GSWString.h
Normal file
49
GSWAdaptors/common/GSWString.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* GSWString.h - GSWeb: String
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWString_h__
|
||||
#define _GSWString_h__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
typedef struct _GSWString
|
||||
{
|
||||
int iSize;
|
||||
int iLen;
|
||||
char* pszData;
|
||||
} GSWString;
|
||||
|
||||
GSWString* GSWString_New();
|
||||
void GSWString_Free(GSWString* p_pString);
|
||||
void GSWString_Detach(GSWString* p_pString);
|
||||
void GSWString_Append(GSWString* p_pString,
|
||||
CONST char* p_pszString);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of C header
|
||||
#endif //_cplusplus
|
||||
|
||||
#endif // _GSWString_h__
|
||||
|
310
GSWAdaptors/common/GSWURLUtil.c
Normal file
310
GSWAdaptors/common/GSWURLUtil.c
Normal file
|
@ -0,0 +1,310 @@
|
|||
/* GSWURLUtil.c - GSWeb: Adaptors: URL Utils
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
//<PREFIX>/<APPLICATION-NAME>[ApplicationSuffix[/<APPLICATION-NUMBER>][/<REQUEST-HANDLER-KEY>[/<REQUEST-HANDLER-PATH>]]][?<QUERY-STRING>]
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "GSWUtil.h"
|
||||
#include "GSWDict.h"
|
||||
#include "GSWConfig.h"
|
||||
#include "GSWURLUtil.h"
|
||||
|
||||
GSWURLError GSWParseURL(GSWURLComponents* p_pURLComponents,CONST char* p_pszURL)
|
||||
{
|
||||
GSWURLError eError=GSWURLError_OK;
|
||||
GSWURLComponent* pURLCPrefix=&p_pURLComponents->stPrefix;
|
||||
GSWURLComponent* pURLCVersion=&p_pURLComponents->stVersion;
|
||||
GSWURLComponent* pURLCAppName=&p_pURLComponents->stAppName;
|
||||
GSWURLComponent* pURLCAppNum=&p_pURLComponents->stAppNumber;
|
||||
GSWURLComponent* pURLCReqHandlerKey=&p_pURLComponents->stRequestHandlerKey;
|
||||
GSWURLComponent* pURLCReqHandlerPath=&p_pURLComponents->stRequestHandlerPath;
|
||||
GSWURLComponent* pURLCQueryString=&p_pURLComponents->stQueryString;
|
||||
int iURLLen=p_pszURL ? strlen(p_pszURL) : 0;
|
||||
CONST char* pszStart=pszStart = (p_pszURL ? p_pszURL : "");
|
||||
CONST char *pszStop=NULL;
|
||||
CONST char *pszNext=NULL;
|
||||
CONST char* pszPrefix=NULL;
|
||||
CONST char *pszS=NULL;
|
||||
CONST char* pszURLEnd=p_pszURL+iURLLen;
|
||||
CONST char* pszQueryStringMark=strchr(pszStart,'?');
|
||||
CONST char* pszTmpStop=(pszQueryStringMark && pszQueryStringMark<pszURLEnd) ? pszQueryStringMark : pszURLEnd;
|
||||
int i, j;
|
||||
memset(p_pURLComponents,0,sizeof(GSWURLComponents));
|
||||
|
||||
// First, get URL prefix
|
||||
pszPrefix=strcasestr(pszStart,g_szGSWeb_Prefix);
|
||||
if (pszPrefix && pszQueryStringMark && pszQueryStringMark<=pszPrefix)
|
||||
pszPrefix=NULL;
|
||||
|
||||
if (pszPrefix)
|
||||
{
|
||||
CONST char* pszAppExtension=NULL;
|
||||
pszStop=pszPrefix+strlen(g_szGSWeb_Prefix);
|
||||
pszNext=*pszStop ? pszStop+1 : pszStop; // Drop the trailing /
|
||||
pURLCPrefix->pszStart = pszPrefix;
|
||||
pURLCPrefix->iLength = pszStop-pszStart;
|
||||
pURLCPrefix->iLength = max(pURLCPrefix->iLength,0);
|
||||
pURLCVersion->pszStart = g_szGSWeb_AdaptorVersion;
|
||||
pURLCVersion->iLength = strlen(g_szGSWeb_AdaptorVersion);
|
||||
|
||||
// Get Application Name
|
||||
pszStart=pszNext;
|
||||
pszAppExtension=strcasestr(pszStart,g_szGSWeb_AppExtention);
|
||||
if (pszAppExtension)
|
||||
{
|
||||
if (pszQueryStringMark && pszQueryStringMark<=pszAppExtension)
|
||||
{
|
||||
pszAppExtension=NULL;
|
||||
pszStop=pszURLEnd;
|
||||
pszNext=pszStop;
|
||||
}
|
||||
else
|
||||
{
|
||||
pszStop=pszAppExtension;
|
||||
pszNext=pszStop+strlen(g_szGSWeb_AppExtention);
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
pszStop=strchr(pszStart,'/');
|
||||
if (pszStop && pszQueryStringMark && pszQueryStringMark<=pszStop)
|
||||
pszStop=pszQueryStringMark-1;
|
||||
if (pszStop)
|
||||
pszNext=pszStop+1;
|
||||
else
|
||||
{
|
||||
pszStop=pszTmpStop;
|
||||
pszNext=NULL;
|
||||
};
|
||||
};
|
||||
pURLCAppName->pszStart = pszStart;
|
||||
pURLCAppName->iLength = pszStop-pszStart;
|
||||
pURLCAppName->iLength = max(pURLCAppName->iLength,0);
|
||||
// Drop trailing slashes
|
||||
while(pURLCAppName->iLength && pURLCAppName->pszStart[pURLCAppName->iLength-1]== '/')
|
||||
pURLCAppName->iLength--;
|
||||
pURLCAppName->iLength = max(pURLCAppName->iLength,0);
|
||||
|
||||
// Get Instance Number
|
||||
pszStart = pszNext;
|
||||
if (!pszStart)
|
||||
{
|
||||
pURLCAppNum->pszStart="";
|
||||
pURLCAppNum->iLength=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Skip slashes
|
||||
while(*pszStart=='/')
|
||||
pszStart++;
|
||||
|
||||
// Find
|
||||
for (pszS=pszStart;pszS<pszTmpStop && *pszS!='/';pszS++);
|
||||
pszStop= pszS;
|
||||
pszNext=(pszStop<pszTmpStop) ? pszStop+1 : pszStop;
|
||||
pURLCAppNum->pszStart = pszStart;
|
||||
pURLCAppNum->iLength = pszStop-pszStart;
|
||||
pURLCAppNum->iLength = max(pURLCAppNum->iLength,0);
|
||||
|
||||
// -1 case ?
|
||||
if (!(pURLCAppNum->iLength==2
|
||||
&& pURLCAppNum->pszStart[0]=='-'
|
||||
&& pURLCAppNum->pszStart[1]=='1'))
|
||||
{
|
||||
// Test if alldigits
|
||||
for (pszS=pszStart;pszS<pszStop && isdigit(*pszS);pszS++);
|
||||
|
||||
if (pszS!=pszStop)
|
||||
{
|
||||
// not all digits, so it's the request handler key !
|
||||
pURLCReqHandlerKey->pszStart = pURLCAppNum->pszStart;
|
||||
pURLCReqHandlerKey->iLength = pURLCAppNum->iLength;
|
||||
pURLCReqHandlerKey->iLength = max(pURLCReqHandlerKey->iLength,0);
|
||||
pURLCAppNum->pszStart="";
|
||||
pURLCAppNum->iLength=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pszStart=pszNext;
|
||||
// Skip slashes
|
||||
while(*pszStart=='/')
|
||||
pszStart++;
|
||||
|
||||
for (pszS=pszStart;pszS<pszTmpStop && *pszS!='/';pszS++);
|
||||
pszStop = pszS;
|
||||
pURLCReqHandlerKey->pszStart = pszStart;
|
||||
pURLCReqHandlerKey->iLength = pszStop-pszStart;
|
||||
pURLCReqHandlerKey->iLength = max(pURLCReqHandlerKey->iLength,0);
|
||||
pszNext=(pszStop<pszTmpStop) ? pszStop+1 : pszStop;
|
||||
};
|
||||
};
|
||||
// Get Request Handler Path
|
||||
pszStart = pszNext;
|
||||
for (pszS=pszStart;pszS<pszTmpStop;pszS++);
|
||||
pszStop = pszS;
|
||||
pURLCReqHandlerPath->pszStart = pszStart;
|
||||
pURLCReqHandlerPath->iLength = pszStop-pszStart;
|
||||
pURLCReqHandlerPath->iLength = max(pURLCReqHandlerPath->iLength,0);
|
||||
pszNext=(pszStop<pszTmpStop) ? pszStop+1 : pszStop;
|
||||
pszStart=pszNext;
|
||||
};
|
||||
// Query String
|
||||
if (!pszStart)
|
||||
pszStart=pszTmpStop;
|
||||
pURLCQueryString->pszStart = pszStart;
|
||||
pURLCQueryString->iLength = pszURLEnd - pszStart;
|
||||
pURLCQueryString->iLength = max(pURLCQueryString->iLength,0);
|
||||
};
|
||||
if (!pURLCPrefix->pszStart || pURLCPrefix->iLength<=0)
|
||||
{
|
||||
eError=GSWURLError_InvalidPrefix;
|
||||
GSWLog(GSW_ERROR,NULL,"ParseURL GSWURLError_InvalidPrefix");
|
||||
}
|
||||
else if (!pURLCAppName->pszStart || pURLCAppName->iLength<=0)
|
||||
{
|
||||
eError=GSWURLError_InvalidAppName;
|
||||
GSWLog(GSW_ERROR,NULL,"ParseURL GSWURLError_InvalidAppName");
|
||||
}
|
||||
else if (!pURLCAppNum->pszStart)
|
||||
{
|
||||
eError=GSWURLError_InvalidAppNumber;
|
||||
GSWLog(GSW_ERROR,NULL,"ParseURL GSWURLError_InvalidAppNumber");
|
||||
}
|
||||
else if ((!pURLCReqHandlerKey->pszStart || pURLCReqHandlerKey->iLength<=0)
|
||||
&& pURLCReqHandlerPath->iLength>0)
|
||||
{
|
||||
eError=GSWURLError_InvalidRequestHandlerKey;
|
||||
GSWLog(GSW_ERROR,NULL,"ParseURL GSWURLError_InvalidRequestHandlerKey");
|
||||
}
|
||||
/*
|
||||
else if (!pURLCReqHandlerPath->pszStart || pURLCReqHandlerPath->iLength<=0)
|
||||
eError=GSWURLError_InvalidRequestHandlerPath;
|
||||
else if (!pURLCQueryString->pszStart || pURLCQueryString->iLength<=0)
|
||||
eError=GSWURLError_InvalidQueryString;
|
||||
*/
|
||||
GSWLog(GSW_INFO,NULL,"End ParseURL eError=%d",eError);
|
||||
return eError;
|
||||
};
|
||||
|
||||
void GSWComposeURL(char* p_pszURL,GSWURLComponents* p_pURLComponents)
|
||||
{
|
||||
GSWURLComponent* pURLCPrefix=&p_pURLComponents->stPrefix;
|
||||
GSWURLComponent* pURLCAppName=&p_pURLComponents->stAppName;
|
||||
GSWURLComponent* pURLCAppNum=&p_pURLComponents->stAppNumber;
|
||||
GSWURLComponent* pURLCReqHandlerKey=&p_pURLComponents->stRequestHandlerKey;
|
||||
GSWURLComponent* pURLCReqHandlerPath=&p_pURLComponents->stRequestHandlerPath;
|
||||
GSWURLComponent* pURLCQueryString=&p_pURLComponents->stQueryString;
|
||||
|
||||
strncpy(p_pszURL,pURLCPrefix->pszStart, pURLCPrefix->iLength);
|
||||
p_pszURL+=pURLCPrefix->iLength;
|
||||
|
||||
*p_pszURL++='/';
|
||||
strncpy(p_pszURL, pURLCAppName->pszStart, pURLCAppName->iLength);
|
||||
p_pszURL+= pURLCAppName->iLength;
|
||||
strcpy(p_pszURL,g_szGSWeb_AppExtention);
|
||||
p_pszURL+=strlen(g_szGSWeb_AppExtention);
|
||||
|
||||
if (pURLCAppNum->iLength>0)
|
||||
{
|
||||
*p_pszURL++='/';
|
||||
strncpy(p_pszURL,pURLCAppNum->pszStart,pURLCAppNum->iLength);
|
||||
p_pszURL+= pURLCAppNum->iLength;
|
||||
};
|
||||
|
||||
if (pURLCReqHandlerKey->iLength>0)
|
||||
{
|
||||
*p_pszURL++='/';
|
||||
strncpy(p_pszURL, pURLCReqHandlerKey->pszStart,pURLCReqHandlerKey->iLength);
|
||||
p_pszURL+= pURLCReqHandlerKey->iLength;
|
||||
};
|
||||
|
||||
if (pURLCReqHandlerPath->iLength>0)
|
||||
{
|
||||
*p_pszURL++='/';
|
||||
strncpy(p_pszURL, pURLCReqHandlerPath->pszStart,pURLCReqHandlerPath->iLength);
|
||||
p_pszURL+= pURLCReqHandlerPath->iLength;
|
||||
};
|
||||
|
||||
if (pURLCQueryString->iLength>0)
|
||||
{
|
||||
*p_pszURL++='?';
|
||||
strncpy(p_pszURL,pURLCQueryString->pszStart,pURLCQueryString->iLength);
|
||||
p_pszURL+= pURLCQueryString->iLength;
|
||||
};
|
||||
*p_pszURL=0;
|
||||
};
|
||||
|
||||
int GSWComposeURLLen(GSWURLComponents* p_pURLComponents)
|
||||
{
|
||||
int iLength=0;
|
||||
GSWURLComponent* pURLCPrefix=&p_pURLComponents->stPrefix;
|
||||
GSWURLComponent* pURLCAppName=&p_pURLComponents->stAppName;
|
||||
GSWURLComponent* pURLCAppNum=&p_pURLComponents->stAppNumber;
|
||||
GSWURLComponent* pURLCReqHandlerKey=&p_pURLComponents->stRequestHandlerKey;
|
||||
GSWURLComponent* pURLCReqHandlerPath=&p_pURLComponents->stRequestHandlerPath;
|
||||
GSWURLComponent* pURLCQueryString=&p_pURLComponents->stQueryString;
|
||||
|
||||
iLength+=pURLCPrefix->iLength;
|
||||
iLength+=1+pURLCAppName->iLength;
|
||||
iLength+=strlen(g_szGSWeb_AppExtention);
|
||||
if (pURLCAppNum->iLength>0)
|
||||
iLength+= 1+pURLCAppNum->iLength;
|
||||
if (pURLCReqHandlerKey->iLength>0)
|
||||
iLength+=1+pURLCReqHandlerKey->iLength;
|
||||
if (pURLCReqHandlerPath->iLength>0)
|
||||
iLength+= 1+pURLCReqHandlerPath->iLength;
|
||||
if (pURLCQueryString->iLength>0)
|
||||
iLength+=1+pURLCQueryString->iLength;
|
||||
return iLength;
|
||||
};
|
||||
|
||||
CONST char* szGSWURLErrorMessage[]=
|
||||
{
|
||||
"", // GSWURLError_OK
|
||||
"Invalid prefix in URL", // GSWURLError_InvalidPrefix
|
||||
"Invalid version in URL", // GSWURLError_InvalidVersion
|
||||
"Invalid application name", // GSWURLError_InvalidAppName
|
||||
"Invalid application number in URL", // GSWURLError_InvalidAppNumber,
|
||||
"Invalid request handler key in URL", // GSWURLError_InvalidRequestHandlerKey,
|
||||
"Invalid request handler path in URL", // GSWURLError_InvalidRequestHandlerPath,
|
||||
"Invalid application host name in URL", // GSWURLError_InvalidAppHost,
|
||||
"Invalid page name in URL", // GSWURLError_InvalidPageName,
|
||||
"Invalid session ID in URL", // GSWURLError_InvalidSessionID,
|
||||
"Invalid context ID in URL", // GSWURLError_InvalidContextID,
|
||||
"Invalid sender ID in URL", // GSWURLError_InvalidSenderID,
|
||||
"Invalid query string in URL", // GSWURLError_InvalidQueryString,
|
||||
"Invalid suffix in URL" // GSWURLError_InvalidSuffix
|
||||
};
|
||||
|
||||
CONST char* GSWURLErrorMessage(GSWURLError p_eError)
|
||||
{
|
||||
if (p_eError>=0 && p_eError<sizeof(szGSWURLErrorMessage)/sizeof(szGSWURLErrorMessage[0]))
|
||||
return szGSWURLErrorMessage[p_eError];
|
||||
else
|
||||
return "";
|
||||
};
|
81
GSWAdaptors/common/GSWURLUtil.h
Normal file
81
GSWAdaptors/common/GSWURLUtil.h
Normal file
|
@ -0,0 +1,81 @@
|
|||
/* GSWURLUtil.h - GSWeb: Adaptors: URL Utils
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWURLUtil_h__
|
||||
#define _GSWURLUtil_h__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _GSWURLComponent
|
||||
{
|
||||
CONST char* pszStart;
|
||||
int iLength;
|
||||
} GSWURLComponent;
|
||||
|
||||
typedef struct _GSWURLComponents
|
||||
{
|
||||
GSWURLComponent stPrefix;
|
||||
GSWURLComponent stVersion;
|
||||
GSWURLComponent stAppName;
|
||||
GSWURLComponent stAppNumber;
|
||||
GSWURLComponent stAppHost;
|
||||
GSWURLComponent stSessionID;
|
||||
GSWURLComponent stPageName;
|
||||
GSWURLComponent stContextID;
|
||||
GSWURLComponent stSenderID;
|
||||
GSWURLComponent stQueryString;
|
||||
GSWURLComponent stSuffix;
|
||||
GSWURLComponent stRequestHandlerKey;
|
||||
GSWURLComponent stRequestHandlerPath;
|
||||
} GSWURLComponents;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GSWURLError_OK = 0,
|
||||
GSWURLError_InvalidPrefix,
|
||||
GSWURLError_InvalidVersion,
|
||||
GSWURLError_InvalidAppName,
|
||||
GSWURLError_InvalidAppNumber,
|
||||
GSWURLError_InvalidRequestHandlerKey,
|
||||
GSWURLError_InvalidRequestHandlerPath,
|
||||
GSWURLError_InvalidAppHost,
|
||||
GSWURLError_InvalidPageName,
|
||||
GSWURLError_InvalidSessionID,
|
||||
GSWURLError_InvalidContextID,
|
||||
GSWURLError_InvalidSenderID,
|
||||
GSWURLError_InvalidQueryString,
|
||||
GSWURLError_InvalidSuffix
|
||||
} GSWURLError;
|
||||
|
||||
GSWURLError GSWParseURL(GSWURLComponents* p_pURLComponents,CONST char* p_pszURL);
|
||||
void GSWComposeURL(char* p_pszURL,GSWURLComponents* p_pURLComponents);
|
||||
int GSWComposeURLLen(GSWURLComponents* p_pURLComponents);
|
||||
CONST char* GSWURLErrorMessage(GSWURLError p_eError);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif //_cplusplus
|
||||
|
||||
|
||||
#endif //_GSWURLUtil_h__
|
525
GSWAdaptors/common/GSWUtil.c
Normal file
525
GSWAdaptors/common/GSWUtil.c
Normal file
|
@ -0,0 +1,525 @@
|
|||
/* GSWUtil.c - GSWeb: Util
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#include <stdarg.h>
|
||||
#include <netdb.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include "GSWLock.h"
|
||||
|
||||
#if defined(Netscape)
|
||||
#include <frame/log.h>
|
||||
#elif (Apache)
|
||||
#include <httpd.h>
|
||||
#include <http_log.h>
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include "GSWUtil.h"
|
||||
#include "GSWDict.h"
|
||||
#include "GSWConfig.h"
|
||||
|
||||
|
||||
static BOOL fLogInitialized = FALSE;
|
||||
static const char* pszLogPath = NULL;
|
||||
static const char* pszLogFlagPath = NULL;
|
||||
static const char* pszDumpFlagPath = NULL;
|
||||
|
||||
static GSWLock g_lockLog=NULL;
|
||||
|
||||
const char* const pszLogLevels[] = {"Info", "Warn", "Error", "" };
|
||||
|
||||
#define MINLEVEL GSW_INFO
|
||||
#define MAXLEVEL GSW_ERROR
|
||||
|
||||
static int iLogMinLevel = MINLEVEL;
|
||||
|
||||
// Hosts Cache
|
||||
static GSWDict* g_pHostCache = NULL;
|
||||
|
||||
|
||||
void GSWLog_Init(GSWDict* p_pDict,int p_iLevel)
|
||||
{
|
||||
char szPath[MAXPATHLEN];
|
||||
GSWLock_Init(g_lockLog);
|
||||
|
||||
if (p_pDict)
|
||||
{
|
||||
pszLogFlagPath=GSWDict_ValueForKey(p_pDict,GSWEB_CONF__LOG_FLAG_FILE_PATH);
|
||||
pszLogPath=GSWDict_ValueForKey(p_pDict,GSWEB_CONF__LOG_FILE_PATH);
|
||||
pszDumpFlagPath=GSWDict_ValueForKey(p_pDict,GSWEB_CONF__DUMP_FLAG_FILE_PATH);
|
||||
};
|
||||
if (pszLogFlagPath)
|
||||
pszLogFlagPath = strdup(pszLogFlagPath);
|
||||
else
|
||||
pszLogFlagPath = strdup(g_szGSWeb_DefaultLogFlagPath);
|
||||
|
||||
if (pszLogPath)
|
||||
pszLogPath = strdup(pszLogPath);
|
||||
else
|
||||
pszLogPath = strdup(g_szGSWeb_DefaultLogFilePath);
|
||||
|
||||
if (pszDumpFlagPath)
|
||||
pszDumpFlagPath = strdup(pszDumpFlagPath);
|
||||
else
|
||||
pszDumpFlagPath = strdup(g_szGSWeb_DefaultDumpFlagPath);
|
||||
|
||||
{
|
||||
int fd;
|
||||
fd = open(pszLogPath, O_WRONLY, 0666);
|
||||
close(fd);
|
||||
chmod(pszLogPath, 0666);
|
||||
};
|
||||
iLogMinLevel = p_iLevel;
|
||||
fLogInitialized = 1;
|
||||
GSWLog(GSW_INFO,NULL,"GSWebLog init");
|
||||
GSWLog(GSW_INFO,NULL,"pszLogFlagPath=%s",pszLogFlagPath);
|
||||
GSWLog(GSW_INFO,NULL,"pszDumpFlagPath=%s",pszDumpFlagPath);
|
||||
GSWLog(GSW_INFO,NULL,"pszLogPath=%s",pszLogPath);
|
||||
};
|
||||
|
||||
static BOOL isLoggingEnabled()
|
||||
{
|
||||
static BOOL fLog=FALSE;
|
||||
static int iStatCounter=0;
|
||||
if (iStatCounter==0)
|
||||
{
|
||||
struct stat stStat;
|
||||
iStatCounter = LOG_FILE_STAT_COUNTER; // reset counter
|
||||
fLog = ( (stat(pszLogFlagPath,&stStat) == 0) && (stStat.st_uid == 0));
|
||||
}
|
||||
else
|
||||
iStatCounter--;
|
||||
return fLog;
|
||||
};
|
||||
|
||||
BOOL GSWDumpConfigFile_CanDump()
|
||||
{
|
||||
static BOOL fDump=FALSE;
|
||||
static int iDumpStatCounter=0;
|
||||
if (iDumpStatCounter==0)
|
||||
{
|
||||
struct stat stStat;
|
||||
iDumpStatCounter = DUMP_FILE_STAT_COUNTER; // reset counter
|
||||
fDump = ( (stat(pszDumpFlagPath,&stStat) == 0) && (stStat.st_uid == 0));
|
||||
}
|
||||
else
|
||||
iDumpStatCounter--;
|
||||
return fDump;
|
||||
};
|
||||
|
||||
void VGSWLogSized(int p_iLevel,
|
||||
#if defined(Apache)
|
||||
server_rec* p_pLogServerData,
|
||||
#else
|
||||
void* p_pLogServerData,
|
||||
#endif
|
||||
int p_iBufferSize,
|
||||
CONST char* p_pszFormat,
|
||||
va_list ap)
|
||||
{
|
||||
FILE* pLog = NULL;
|
||||
char szBuffer[p_iBufferSize+128];
|
||||
|
||||
if (p_iLevel>=iLogMinLevel)
|
||||
{
|
||||
BOOL fIsLoggingEnabled=FALSE;
|
||||
if (!fLogInitialized)
|
||||
GSWLog_Init(NULL,iLogMinLevel);
|
||||
|
||||
GSWLock_Lock(g_lockLog);
|
||||
fIsLoggingEnabled=isLoggingEnabled();
|
||||
if (fIsLoggingEnabled
|
||||
#if defined(Netscape) || defined(Apache)
|
||||
|| p_iLevel == GSW_ERROR
|
||||
#endif
|
||||
)
|
||||
{
|
||||
vsprintf(szBuffer,p_pszFormat,ap);
|
||||
pLog=fopen(pszLogPath,"a+");
|
||||
if (pLog)
|
||||
{
|
||||
fprintf(pLog,"%s: %s\n",pszLogLevels[p_iLevel],szBuffer);
|
||||
fclose(pLog);
|
||||
};
|
||||
};
|
||||
GSWLock_Unlock(g_lockLog);
|
||||
|
||||
#if defined(Netscape) || defined(Apache)
|
||||
if (p_iLevel == GSW_ERROR)
|
||||
{
|
||||
#if defined(Netscape)
|
||||
log_error(0,"GSWeb",NULL,NULL,szBuffer);
|
||||
#endif
|
||||
#if defined(Apache)
|
||||
ap_log_error(APLOG_MARK,APLOG_EMERG,
|
||||
NULL/*(server_rec*)p_pLogServerData*/,"%s",szBuffer);
|
||||
//log_error(szBuffer,(server_rec*)p_pLogServerData);
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
void GSWLog(int p_iLevel,
|
||||
#if defined(Apache)
|
||||
server_rec* p_pLogServerData,
|
||||
#else
|
||||
void* p_pLogServerData,
|
||||
#endif
|
||||
CONST char* p_pszFormat,...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap,p_pszFormat);
|
||||
VGSWLogSized(p_iLevel,
|
||||
p_pLogServerData,
|
||||
4096,
|
||||
p_pszFormat,
|
||||
ap);
|
||||
va_end(ap);
|
||||
};
|
||||
|
||||
void GSWLogSized(int p_iLevel,
|
||||
#if defined(Apache)
|
||||
server_rec* p_pLogServerData,
|
||||
#else
|
||||
void* p_pLogServerData,
|
||||
#endif
|
||||
int p_iBufferSize,
|
||||
CONST char* p_pszFormat,...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap,p_pszFormat);
|
||||
VGSWLogSized(p_iLevel,
|
||||
p_pLogServerData,
|
||||
p_iBufferSize,
|
||||
p_pszFormat,
|
||||
ap);
|
||||
va_end(ap);
|
||||
};
|
||||
|
||||
|
||||
// return new len
|
||||
int DeleteTrailingCRNL(char* p_pszString)
|
||||
{
|
||||
int i=0;
|
||||
if (p_pszString)
|
||||
{
|
||||
i=strlen(p_pszString)-1;
|
||||
while (i>=0 && p_pszString[i] && (p_pszString[i]=='\r' || p_pszString[i]=='\n'))
|
||||
p_pszString[i--]=0;
|
||||
i++;
|
||||
};
|
||||
return i;
|
||||
}
|
||||
|
||||
int DeleteTrailingSlash(char* p_pszString)
|
||||
{
|
||||
int i=0;
|
||||
if (p_pszString)
|
||||
{
|
||||
i=strlen(p_pszString)-1;
|
||||
while (i>=0 && p_pszString[i] && p_pszString[i]=='/')
|
||||
p_pszString[i--]=0;
|
||||
i++;
|
||||
};
|
||||
return i;
|
||||
}
|
||||
|
||||
int DeleteTrailingSpaces(char* p_pszString)
|
||||
{
|
||||
int i=0;
|
||||
if (p_pszString)
|
||||
{
|
||||
i=strlen(p_pszString)-1;
|
||||
while (i>=0 && p_pszString[i] && p_pszString[i]==' ')
|
||||
p_pszString[i--]=0;
|
||||
i++;
|
||||
};
|
||||
return i;
|
||||
}
|
||||
|
||||
CONST char* strcasestr(CONST char* p_pszString,CONST char* p_pszSearchedString)
|
||||
{
|
||||
if (p_pszString && p_pszSearchedString)
|
||||
{
|
||||
int i=0;
|
||||
int iStringLen=strlen(p_pszString);
|
||||
int iSearchedStringLen=strlen(p_pszSearchedString);
|
||||
if (iStringLen>0 && iSearchedStringLen>0)
|
||||
{
|
||||
char ch1stUpper=toupper(p_pszSearchedString[0]);
|
||||
for(i=0;i<iStringLen-iSearchedStringLen+1;i++)
|
||||
{
|
||||
if (toupper(p_pszString[i])==ch1stUpper)
|
||||
{
|
||||
BOOL fSame=TRUE;
|
||||
int j=0;
|
||||
for(j=1;j<iSearchedStringLen && fSame;j++)
|
||||
fSame=toupper(p_pszString[i+j])==toupper(p_pszSearchedString[j]);
|
||||
if (fSame)
|
||||
return p_pszString+i;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
return NULL;
|
||||
};
|
||||
|
||||
#if defined(HAS_REENTRANT_GETHOSTENT) && !defined(_REENTRANT)
|
||||
#define _REENTRANT /* needs to be defined so proper structs get included */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void GSWUtil_ClearHostCache()
|
||||
{
|
||||
if (g_pHostCache)
|
||||
{
|
||||
GSWDict_Free(g_pHostCache);
|
||||
g_pHostCache=NULL;
|
||||
};
|
||||
};
|
||||
|
||||
PSTHostent GSWUtil_FindHost(void* p_pLogServerData,CONST char* p_pszHost)
|
||||
{
|
||||
PSTHostent pHost=NULL;
|
||||
if (!p_pszHost)
|
||||
p_pszHost="localhost";
|
||||
|
||||
pHost = (g_pHostCache) ? (PSTHostent)GSWDict_ValueForKey(g_pHostCache,p_pszHost) : NULL;
|
||||
if (!pHost)
|
||||
{
|
||||
pHost = GSWUtil_HostLookup(p_pLogServerData,p_pszHost);
|
||||
if (pHost)
|
||||
{
|
||||
if (!g_pHostCache)
|
||||
g_pHostCache = GSWDict_New(32);
|
||||
GSWDict_Add(g_pHostCache,p_pszHost,pHost,TRUE);
|
||||
GSWLog(GSW_INFO,p_pLogServerData,"Caching hostent for %s",p_pszHost);
|
||||
};
|
||||
};
|
||||
return pHost;
|
||||
};
|
||||
|
||||
|
||||
#define ROUND_UP(n, m) (((unsigned)(n)+(m)-1)&~((m)-1))
|
||||
#define BUFLEN 4096
|
||||
|
||||
|
||||
#if defined(NEEDS_HSTRERR)
|
||||
#ifndef NETDB_SUCCESS
|
||||
#define NETDB_SUCCESS 0
|
||||
#endif
|
||||
|
||||
CONST char *hstrerror(int herr)
|
||||
{
|
||||
if (herr == -1) /* see errno */
|
||||
return strerror(errno);
|
||||
else if (herr == HOST_NOT_FOUND)
|
||||
return "Host not found";
|
||||
else if (herr == TRY_AGAIN)
|
||||
return "Try again"; /* ? */
|
||||
else if (herr == NO_RECOVERY)
|
||||
return "Non recoverable error";
|
||||
else if (herr == NO_DATA)
|
||||
return "No data";
|
||||
else if (herr == NO_ADDRESS)
|
||||
return "No address"; /* same as no data */
|
||||
else if (herr == NETDB_SUCCESS)
|
||||
return "No error"; /* strange */
|
||||
else
|
||||
return "unknown error";
|
||||
}
|
||||
#endif
|
||||
|
||||
static PSTHostent GSWUtil_CopyHostent(PSTHostent p_pHost)
|
||||
{
|
||||
PSTHostent pNewHost=NULL;
|
||||
int iSize=(ROUND_UP(sizeof(struct hostent), sizeof(void *)))+strlen(p_pHost->h_name)+1;
|
||||
int iAliasNb=0;
|
||||
int iAddressesNb = 0;
|
||||
char** ppszAliasOrAddress=NULL;
|
||||
char** ppszNewHostAliasOrAddress=NULL;
|
||||
void* pTmp=NULL;
|
||||
|
||||
// Aliases
|
||||
for (ppszAliasOrAddress=p_pHost->h_aliases;
|
||||
ppszAliasOrAddress && *ppszAliasOrAddress;
|
||||
ppszAliasOrAddress++)
|
||||
{
|
||||
iSize+=strlen(*ppszAliasOrAddress)+1;
|
||||
iAliasNb++;
|
||||
};
|
||||
|
||||
// Aliases Pointers Null Terminated List
|
||||
iSize=ROUND_UP(iSize,sizeof(char *));
|
||||
iSize+=(iAliasNb+1)*sizeof(char*);
|
||||
|
||||
for (ppszAliasOrAddress=p_pHost->h_addr_list;
|
||||
ppszAliasOrAddress && *ppszAliasOrAddress;
|
||||
ppszAliasOrAddress++)
|
||||
iAddressesNb++;
|
||||
|
||||
iSize+=iAddressesNb*(sizeof(char*)+p_pHost->h_length+1);
|
||||
|
||||
pNewHost=malloc(ROUND_UP(iSize,sizeof(char*)));
|
||||
pTmp=pNewHost;
|
||||
pNewHost->h_addrtype = p_pHost->h_addrtype;
|
||||
pNewHost->h_length = p_pHost->h_length;
|
||||
|
||||
pTmp+=ROUND_UP(sizeof(struct hostent),sizeof(void*));
|
||||
pNewHost->h_aliases = (char **)pTmp;
|
||||
pTmp+=(iAliasNb+1)*sizeof(char*);
|
||||
pNewHost->h_addr_list = (char**)pTmp;
|
||||
pTmp+=(iAddressesNb+1)*sizeof(char*);
|
||||
|
||||
pNewHost->h_name = pTmp;
|
||||
strcpy(pNewHost->h_name,p_pHost->h_name);
|
||||
pTmp+=strlen(pNewHost->h_name)+1;
|
||||
|
||||
// Copy Aliases
|
||||
for (ppszAliasOrAddress=p_pHost->h_aliases,ppszNewHostAliasOrAddress=pNewHost->h_aliases;
|
||||
ppszAliasOrAddress && *ppszAliasOrAddress;
|
||||
ppszAliasOrAddress++,ppszNewHostAliasOrAddress++)
|
||||
{
|
||||
*ppszNewHostAliasOrAddress = (char*)pTmp;
|
||||
strcpy((char*)pTmp,*ppszAliasOrAddress);
|
||||
pTmp+=strlen(*ppszAliasOrAddress) + 1;
|
||||
};
|
||||
*ppszNewHostAliasOrAddress=NULL;
|
||||
|
||||
pTmp=(void *)ROUND_UP(pTmp,pNewHost->h_length);
|
||||
for (ppszAliasOrAddress=p_pHost->h_addr_list,ppszNewHostAliasOrAddress=pNewHost->h_addr_list;
|
||||
ppszAliasOrAddress && *ppszAliasOrAddress;
|
||||
ppszAliasOrAddress++,ppszNewHostAliasOrAddress++)
|
||||
{
|
||||
*ppszNewHostAliasOrAddress=(char*)pTmp;
|
||||
memcpy(*ppszNewHostAliasOrAddress,*ppszAliasOrAddress,pNewHost->h_length);
|
||||
pTmp+=pNewHost->h_length;
|
||||
};
|
||||
*ppszNewHostAliasOrAddress=NULL;
|
||||
return pNewHost;
|
||||
};
|
||||
|
||||
PSTHostent GSWUtil_HostLookup(void* p_pLogServerData,CONST char *p_pszHost)
|
||||
{
|
||||
PSTHostent pHost=NULL;
|
||||
struct in_addr hostaddr;
|
||||
int error=0;
|
||||
|
||||
#if defined(HAS_REENTRANT_GETHOSTENT)
|
||||
struct hostent stTmpHost;
|
||||
char szBuffer[BUFLEN];
|
||||
|
||||
pHost = &stTmpHost; /* point to struct on the stack */
|
||||
memset(pHost,0,sizeof(struct hostent));
|
||||
memset(szBuffer,0,sizeof(szBuffer));
|
||||
#endif
|
||||
|
||||
if (!p_pszHost)
|
||||
p_pszHost="localhost";
|
||||
|
||||
if (isdigit(*p_pszHost))
|
||||
hostaddr.s_addr=inet_addr(p_pszHost);
|
||||
|
||||
#if defined(HAS_REENTRANT_GETHOSTENT)
|
||||
if (isdigit(*p_pszHost))
|
||||
{
|
||||
#if defined(SOLARIS)
|
||||
pHost = gethostbyaddr_r((char *)&hostaddr.s_addr,
|
||||
sizeof(hostaddr.s_addr),
|
||||
AF_INET,
|
||||
pHost,
|
||||
szBuffer,
|
||||
BUFLEN, &error);
|
||||
#else // !SOLARIS
|
||||
if (gethostbyaddr_r((char *)&hostaddr.s_addr,
|
||||
sizeof(hostaddr.s_addr),
|
||||
AF_INET,
|
||||
&stTmpHost,
|
||||
szBuffer) == 0)
|
||||
{
|
||||
pHost = &stTmpHost;
|
||||
error = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pHost=NULL;
|
||||
error = h_errno;
|
||||
};
|
||||
#endif // SOLARIS
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(SOLARIS)
|
||||
pHost = gethostbyname_r(p_pszHost,
|
||||
&stTmpHost,
|
||||
szBuffer,
|
||||
BUFLEN,
|
||||
&error);
|
||||
#else // !SOLARIS
|
||||
pHost = (gethostbyname_r(p_pszHost,&stTmpHost,szBuffer)==0) ? &stTmpHost : NULL;
|
||||
error = (pHost) ? 0 : h_errno;
|
||||
#endif // SOLARIS
|
||||
};
|
||||
#else // !HAS_REENTRANT_GETHOSTENT
|
||||
if (isdigit(*p_pszHost))
|
||||
{
|
||||
pHost = gethostbyaddr((char *)&hostaddr.s_addr, sizeof(hostaddr.s_addr), AF_INET);
|
||||
error = (pHost) ? 0 : h_errno;
|
||||
}
|
||||
else
|
||||
{
|
||||
pHost = gethostbyname(p_pszHost);
|
||||
error = (pHost) ? 0 : h_errno;
|
||||
}
|
||||
#endif // HAS_REENTRANT_GETHOSTENT
|
||||
|
||||
if (!pHost)
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,"gethostbyname(%s) returns no host: %s",
|
||||
p_pszHost,
|
||||
hstrerror(error));
|
||||
}
|
||||
else if (pHost->h_addrtype != AF_INET)
|
||||
{
|
||||
GSWLog(GSW_ERROR,p_pLogServerData,"Wrong address type in hostptr for host %s",p_pszHost);
|
||||
};
|
||||
if (pHost)
|
||||
pHost=GSWUtil_CopyHostent(pHost);
|
||||
return pHost;
|
||||
};
|
||||
|
91
GSWAdaptors/common/GSWUtil.h
Normal file
91
GSWAdaptors/common/GSWUtil.h
Normal file
|
@ -0,0 +1,91 @@
|
|||
/* GSWUtil.h - GSWeb: Adaptors: Util
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWUtil_h__
|
||||
#define _GSWUtil_h__
|
||||
|
||||
#ifndef BOOL
|
||||
typedef int BOOL;
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#define TRUE (!FALSE)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(Apache)
|
||||
#include "httpd.h"
|
||||
#endif
|
||||
|
||||
#define GSW_INFO 0
|
||||
#define GSW_WARNING 1
|
||||
#define GSW_ERROR 2
|
||||
#define max(x, y) ((x) > (y) ? (x) : (y))
|
||||
#define min(x, y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
void GSWLog(int p_iLevel,
|
||||
#if defined(Apache)
|
||||
server_rec* p_pLogServerData,
|
||||
#else
|
||||
void* p_pLogServerData,
|
||||
#endif
|
||||
CONST char *p_pszFormat, ...);
|
||||
|
||||
void GSWLogSized(int p_iLevel,
|
||||
#if defined(Apache)
|
||||
server_rec* p_pLogServerData,
|
||||
#else
|
||||
void* p_pLogServerData,
|
||||
#endif
|
||||
int p_iBufferSize,
|
||||
CONST char *p_pszFormat, ...);
|
||||
|
||||
// return new len
|
||||
int DeleteTrailingCRNL(char* p_pszString);
|
||||
int DeleteTrailingSlash(char* p_pszString);
|
||||
int DeleteTrailingSpaces(char* p_pszString);
|
||||
CONST char* strcasestr(CONST char* p_pszString,CONST char* p_pszSearchedString);
|
||||
|
||||
|
||||
//#include <netdb.h>
|
||||
typedef struct hostent* PSTHostent;
|
||||
|
||||
PSTHostent GSWUtil_HostLookup(void* p_pLogServerData,CONST char* p_pszHost);
|
||||
void GSWUtil_ClearHostCache();
|
||||
PSTHostent GSWUtil_FindHost(void* p_pLogServerData,CONST char* p_pszHost);
|
||||
|
||||
#include "GSWDict.h"
|
||||
|
||||
void GSWLog_Init(GSWDict* p_pDict,int p_iLevel);
|
||||
BOOL GSWDumpConfigFile_CanDump();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // _GSWUtil_h__
|
81
GSWAdaptors/common/common.make
Normal file
81
GSWAdaptors/common/common.make
Normal file
|
@ -0,0 +1,81 @@
|
|||
#
|
||||
# common.make
|
||||
#
|
||||
# Set all of the common environment variables.
|
||||
#
|
||||
# Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
#
|
||||
# Author: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
#
|
||||
# This file is part of the GNUstepWeb Adaptors Makefile Package.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this library; see the file COPYING.LIB.
|
||||
# If not, write to the Free Software Foundation,
|
||||
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
COMMONFILES = $(COMMON)/GSWHTTPHeaders.c \
|
||||
$(COMMON)/config.c $(COMMON)/GSWURLUtil.c $(COMMON)/GSWDict.c \
|
||||
$(COMMON)/GSWHTTPRequest.c $(COMMON)/GSWHTTPResponse.c \
|
||||
$(COMMON)/GSWAppConnectSocket.c $(COMMON)/GSWUtil.c $(COMMON)/GSWAppRequest.c \
|
||||
$(COMMON)/GSWLoadBalancing.c $(COMMON)/GSWList.c $(COMMON)/GSWConfig.c \
|
||||
$(COMMON)/GSWString.c
|
||||
|
||||
|
||||
COMMONOBJS = $(OBJROOT)/GSWHTTPHeaders.o \
|
||||
$(OBJROOT)/config.o $(OBJROOT)/GSWURLUtil.o $(OBJROOT)/GSWDict.o \
|
||||
$(OBJROOT)/GSWHTTPRequest.o $(OBJROOT)/GSWHTTPResponse.o \
|
||||
$(OBJROOT)/GSWAppConnectSocket.o $(OBJROOT)/GSWUtil.o $(OBJROOT)/GSWAppRequest.o \
|
||||
$(OBJROOT)/GSWLoadBalancing.o $(OBJROOT)/GSWList.o $(OBJROOT)/GSWConfig.o \
|
||||
$(OBJROOT)/GSWString.o
|
||||
|
||||
$(ADAPTORLIB):: $(COMMONOBJS)
|
||||
# libtool -static $(ARCH) -o $(ADAPTORLIB) $(COMMONOBJS)
|
||||
ar -rc $(ADAPTORLIB) $(COMMONOBJS)
|
||||
ranlib $(ADAPTORLIB)
|
||||
|
||||
|
||||
$(OBJROOT)/GSWHTTPHeaders.o: $(COMMON)/GSWHTTPHeaders.c
|
||||
$(CC) $(CFLAGS) -c -o $*.o $<
|
||||
|
||||
$(OBJROOT)/GSWConfig.o: $(COMMON)/GSWConfig.c
|
||||
$(CC) $(CFLAGS) -c -o $*.o $<
|
||||
|
||||
$(OBJROOT)/GSWList.o: $(COMMON)/GSWList.c
|
||||
$(CC) $(CFLAGS) -c -o $*.o $<
|
||||
|
||||
$(OBJROOT)/GSWString.o: $(COMMON)/GSWString.c
|
||||
$(CC) $(CFLAGS) -c -o $*.o $<
|
||||
|
||||
$(OBJROOT)/GSWLoadBalancing.o: $(COMMON)/GSWLoadBalancing.c
|
||||
$(CC) $(CFLAGS) -c -o $*.o $<
|
||||
|
||||
$(OBJROOT)/GSWAppRequest.o: $(COMMON)/GSWAppRequest.c
|
||||
$(CC) $(CFLAGS) -c -o $*.o $<
|
||||
|
||||
$(OBJROOT)/GSWURLUtil.o: $(COMMON)/GSWURLUtil.c
|
||||
$(CC) $(CFLAGS) -c -o $*.o $<
|
||||
|
||||
$(OBJROOT)/GSWDict.o: $(COMMON)/GSWDict.c
|
||||
$(CC) $(CFLAGS) -c -o $*.o $<
|
||||
|
||||
$(OBJROOT)/GSWUtil.o: $(COMMON)/GSWUtil.c
|
||||
$(CC) $(CFLAGS) -c -o $*.o $<
|
||||
|
||||
$(OBJROOT)/config.o: $(COMMON)/config.c
|
||||
$(CC) $(CFLAGS) -c -o $*.o $<
|
||||
|
||||
$(OBJROOT)/GSWHTTPRequest.o: $(COMMON)/GSWHTTPRequest.c
|
||||
$(CC) $(CFLAGS) -c -o $*.o $<
|
||||
|
||||
$(OBJROOT)/GSWHTTPResponse.o: $(COMMON)/GSWHTTPResponse.c
|
||||
$(CC) $(CFLAGS) -c -o $*.o $<
|
||||
|
||||
$(OBJROOT)/GSWAppConnectSocket.o: $(COMMON)/GSWAppConnectSocket.c
|
||||
$(CC) $(CFLAGS) -c -o $*.o $<
|
||||
|
24
GSWAdaptors/common/config.c
Normal file
24
GSWAdaptors/common/config.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/* config.h - GSWeb: Adaptors: Config
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
135
GSWAdaptors/common/config.h
Normal file
135
GSWAdaptors/common/config.h
Normal file
|
@ -0,0 +1,135 @@
|
|||
/* config.h - GSWeb: Adaptors: Config
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWebConfig_h__
|
||||
#define _GSWebConfig_h__
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif //_cplusplus
|
||||
|
||||
#define CONST const
|
||||
#define DEBUG 1
|
||||
|
||||
#define GSWEB_SERVER_ADAPTOR_VERSION_MAJOR 1
|
||||
#define GSWEB_SERVER_ADAPTOR_VERSION_MAJOR_STRING "1"
|
||||
#define GSWEB_SERVER_ADAPTOR_VERSION_MINOR 0
|
||||
#define GSWEB_SERVER_ADAPTOR_VERSION_MINOR_STRING "0"
|
||||
|
||||
#define GSWEB_VERSION_MAJOR 1
|
||||
#define GSWEB_VERSION_MINOR 0
|
||||
|
||||
#define GSWEB_PREFIX "/GSWeb"
|
||||
#define GSWEB_HANDLER "GSWeb"
|
||||
|
||||
#define GSWAPP_EXTENSION ".gswa"
|
||||
|
||||
// Time Outs ...
|
||||
#define APP_CONNECT_TIMEOUT 300
|
||||
#define RESPONSE__LINE_MAX_SIZE 8192
|
||||
#define APP_CONNECT_RETRY_DELAY 3
|
||||
#define APP_CONNECT_RETRIES_NB 10
|
||||
|
||||
|
||||
#define HITS_PER_SECOND 80
|
||||
#define LOG_FILE_STAT_COUNTER (HITS_PER_SECOND*20)
|
||||
#define DUMP_FILE_STAT_COUNTER (1)
|
||||
#define CONFIG_FILE_STAT_INTERVAL 10
|
||||
|
||||
|
||||
// Configuration Strings
|
||||
#define GSWEB__MIME_TYPE "application/x-httpd-gsweb"
|
||||
|
||||
|
||||
// Config File Keywords
|
||||
|
||||
// All
|
||||
#define GSWEB_CONF__DOC_ROOT "GSWeb_DocumentRoot"
|
||||
#define GSWEB_CONF__CONFIG_FILE_PATH "GSWeb_ConfigFilePath"
|
||||
#define GSWEB_CONF__LOG_FILE_PATH "GSWeb_LogFilePath"
|
||||
#define GSWEB_CONF__LOG_FLAG_FILE_PATH "GSWeb_LogFlagFilePath"
|
||||
#define GSWEB_CONF__DUMP_FLAG_FILE_PATH "GSWeb_DumpFlagFilePath"
|
||||
|
||||
|
||||
// Aapche
|
||||
#define GSWEB_CONF__ALIAS "GSWeb_Alias"
|
||||
|
||||
// Netscape
|
||||
#define GSWEB_CONF__PATH_TRANS "from" // NameTrans
|
||||
#define GSWEB_CONF__APP_ROOT "dir" // NameTrans
|
||||
#define GSWEB_CONF__NAME "name" // NameTrans, Object
|
||||
|
||||
|
||||
#define DEFAULT_CONFIG_FILE_PATH "/etc/httpd/conf/gsweb.conf"
|
||||
#define DEFAULT_LOG_FILE_PATH "/var/log/httpd/gsweb.log"
|
||||
#define DEFAULT_LOG_FLAG_PATH "/etc/httpd/conf/gsweb-log"
|
||||
#define DEFAULT_DUMP_FLAG_PATH "/etc/httpd/conf/gsweb-dump"
|
||||
|
||||
#define DEFAULT_GSWEXTENSIONS_FRAMEWORK_WEB_SERVER_RESOURCES "/GSWeb/Frameworks/WOExtensions.framework/WebServerResources"
|
||||
|
||||
|
||||
#define GSWEB_INSTANCE_COOKIE "gswinst="
|
||||
|
||||
|
||||
/*
|
||||
* operating specific things regarding gethostbyname()
|
||||
*/
|
||||
#if defined(SOLARIS)
|
||||
#define HAS_REENTRANT_GETHOSTENT
|
||||
#if defined(NSAPI) || defined(Apache)
|
||||
#define NEEDS_HSTRERR
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(Apache)
|
||||
#pragma message(Apache)
|
||||
#define SERVER "Apache"
|
||||
#elif defined(Netscape)
|
||||
#if defined(WAI)
|
||||
#pragma message(WAI)
|
||||
#define SERVER "WAI"
|
||||
#else
|
||||
#pragma message(NSAPI)
|
||||
#define SERVER "NSAPI"
|
||||
#endif
|
||||
#elif defined(CGI)
|
||||
#pragma message(CGI)
|
||||
#define SERVER "CGI"
|
||||
#else
|
||||
#pragma message(Unknwon)
|
||||
#define SERVER "Unknown"
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MAXHOSTNAMELEN
|
||||
#define MAXHOSTNAMELEN 256 /* reasonable default */
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of C header
|
||||
#endif //_cplusplus
|
||||
|
||||
#endif
|
91
GSWAdaptors/netscape/GNUmakefile
Normal file
91
GSWAdaptors/netscape/GNUmakefile
Normal file
|
@ -0,0 +1,91 @@
|
|||
# Makefile for Netscape (NSAPI) GNUstepWeb module
|
||||
# Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
#
|
||||
# Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
# Date: Jully 1999
|
||||
#
|
||||
# This file is part of the GNUstep Web Library.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
# The result of this is a libgsweb.so
|
||||
|
||||
PLATFORM_OS=solaris
|
||||
SRCROOT = ..
|
||||
DSTROOT = .
|
||||
SERVERAPI = netscape
|
||||
OBJROOT = ../$(SERVERAPI)
|
||||
|
||||
|
||||
#include $(MAKEFILEPATH)/pb_makefiles/platform.make
|
||||
|
||||
ADAPTOR = $(DSTROOT)/libgsweb.so
|
||||
|
||||
#Not Used yet
|
||||
LOADBALANCING = roundrobin
|
||||
ADAPTORLIB = $(OBJROOT)/libAdaptor.a
|
||||
COMMON = $(SRCROOT)/common
|
||||
|
||||
|
||||
#NS Root directory
|
||||
#NS_ROOT = /netscape/suitespot
|
||||
NS_ROOT=/netscape/enterprise/ns-home/nsapi
|
||||
NETSCAPELIB = $(NS_ROOT)/lib
|
||||
NETSCAPE_VERSION = Netscape_3
|
||||
|
||||
#
|
||||
# any additional macros for this Server API
|
||||
#
|
||||
INCLUDE = -I$(COMMON) -I$(NS_ROOT)/include -I/usr/local/include/
|
||||
|
||||
#-DDEBUG_NETSCAPE_GUTS
|
||||
APIDEFINES = -DNetscape -D$(NETSCAPE_VERSION) -DREENTRANT -DNET_SSL -DSW_THREADS -DXP_UNIX
|
||||
|
||||
ifeq "solaris" "$(PLATFORM_OS)"
|
||||
CFLAGS = -O2 $(RC_CFLAGS) $(INCLUDE) -D$(SERVERAPI) $(APIDEFINES) -DSOLARIS
|
||||
else
|
||||
CFLAGS = -O2 $(RC_CFLAGS) $(INCLUDE) -D$(SERVERAPI) $(APIDEFINES)
|
||||
endif
|
||||
|
||||
TRANSPORT = nssocket
|
||||
|
||||
all:: $(ADAPTOR)
|
||||
|
||||
include $(COMMON)/common.make
|
||||
|
||||
OFILES = $(OBJROOT)/gsweb.o
|
||||
|
||||
|
||||
ifeq "solaris" "$(PLATFORM_OS)"
|
||||
$(ADAPTOR):: $(OFILES) $(ADAPTORLIB)
|
||||
ld -G $(OFILES) $(ADAPTORLIB) $(OTHER_LDFLAGS) -lnsl -lsocket -L/usr/local/lib -lPropList -o $(ADAPTOR)
|
||||
else
|
||||
$(ADAPTOR):: $(OFILES) $(ADAPTORLIB)
|
||||
$(CC) -dll $(LDFLAGS) $(OTHER_LDFLAGS) -L$(NETSCAPELIB) -lns-httpd35 -L/usr/local/lib -lPropList -o $(ADAPTOR) \
|
||||
$(OFILES) $(ADAPTORLIB) -Xlinker /DEF:$(DEFFILE)
|
||||
endif
|
||||
|
||||
install: $(ADAPTOR)
|
||||
mv $(ADAPTOR) $(DSTROOT)
|
||||
|
||||
|
||||
clean:
|
||||
rm -f $(COMMONOBJS) $(ADAPTORLIB) $(OFILES) $(ADAPTOR) \
|
||||
libgsweb.lib core
|
||||
|
||||
|
||||
$(OBJROOT)/gsweb.o: $(SRCROOT)/$(SERVERAPI)/gsweb.c
|
||||
$(CC) $(CFLAGS) -c -o $*.o $<
|
||||
|
554
GSWAdaptors/netscape/gsweb.c
Normal file
554
GSWAdaptors/netscape/gsweb.c
Normal file
|
@ -0,0 +1,554 @@
|
|||
/* GNUstepNetscape.c - GSWeb: Netscape NSAPI Interface
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jully 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <base/systems.h>
|
||||
#include <base/pblock.h>
|
||||
#include <base/session.h>
|
||||
#include <base/daemon.h>
|
||||
#include <base/net.h>
|
||||
#include <base/util.h>
|
||||
#include <frame/log.h>
|
||||
#include <frame/req.h>
|
||||
#include <frame/http.h>
|
||||
#include <frame/conf.h>
|
||||
#include <netsite.h>
|
||||
|
||||
#include "GSWUtil.h"
|
||||
#include "GSWDict.h"
|
||||
#include "GSWConfig.h"
|
||||
#include "GSWURLUtil.h"
|
||||
#include "GSWHTTPHeaders.h"
|
||||
#include "GSWAppRequestStruct.h"
|
||||
#include "GSWAppConnect.h"
|
||||
#include "GSWHTTPRequest.h"
|
||||
#include "GSWHTTPResponse.h"
|
||||
#include "GSWAppRequest.h"
|
||||
|
||||
#define server_portnum port
|
||||
|
||||
//TODO
|
||||
//#define DEBUG_NETSCAPE
|
||||
|
||||
// Keywords of obj.conf
|
||||
|
||||
|
||||
// Global Doc Root
|
||||
static char* glb_pDocRoot = NULL;
|
||||
|
||||
#ifdef DEBUG_NETSCAPE
|
||||
static void NSDebugLog(pblock* p_pBlock,
|
||||
const char* p_pszText)
|
||||
{
|
||||
int i;
|
||||
struct pb_entry* entry = NULL;
|
||||
pb_param* nv=NULL;
|
||||
for (i=0;p_pBlock && i<p_pBlock->hsize;i++)
|
||||
{
|
||||
entry = p_pBlock->ht[i];
|
||||
while (entry)
|
||||
{
|
||||
nv = entry->param;
|
||||
if (nv)
|
||||
GSWLog(GSW_ERROR,"%s: \t%s = %s",p_pszText,nv->name,nv->value);
|
||||
entry = entry->next;
|
||||
};
|
||||
};
|
||||
};
|
||||
#else
|
||||
#define NSDebugLog(Block,Text)
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Init
|
||||
|
||||
NSAPI_PUBLIC
|
||||
int GSWeb_Init(pblock* p_pBlock,
|
||||
Session* p_pSession,
|
||||
Request *p_pRequest)
|
||||
{
|
||||
GSWDict* pDict=NULL;
|
||||
const char* pDocRoot=NULL;
|
||||
int i=0;
|
||||
GSWConfig_Init();
|
||||
|
||||
pDict=GSWDict_New(16);
|
||||
|
||||
// Get Config Params
|
||||
for (i=0;i<p_pBlock->hsize;i++)
|
||||
{
|
||||
struct pb_entry* pEntry=p_pBlock->ht[i];
|
||||
while (pEntry)
|
||||
{
|
||||
pb_param* pParam = pEntry->param;
|
||||
if (pParam)
|
||||
GSWDict_AddStringDup(pDict,pParam->name,pParam->value);
|
||||
pEntry = pEntry->next;
|
||||
};
|
||||
};
|
||||
GSWLog_Init(pDict,GSW_INFO);
|
||||
GSWLoadBalancing_Init(pDict);
|
||||
|
||||
// Get The Document Root
|
||||
pDocRoot = GSWDict_ValueForKey(pDict,g_szGSWeb_Conf_DocRoot);
|
||||
if (pDocRoot)
|
||||
{
|
||||
glb_pDocRoot = strdup(pDocRoot);
|
||||
GSWLog(GSW_INFO,NULL,"RootDocument=%s",glb_pDocRoot);
|
||||
}
|
||||
else
|
||||
GSWLog(GSW_INFO,NULL,"no RootDocument");
|
||||
|
||||
GSWDict_Free(pDict);
|
||||
GSWLog(GSW_INFO,NULL,"GNUstepWeb initialized");
|
||||
return REQ_PROCEED;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// NameTrans
|
||||
|
||||
NSAPI_PUBLIC
|
||||
int GSWeb_NameTrans(pblock *p_pBlock, Session *sn, Request *p_pRequest)
|
||||
{
|
||||
int iRetVal=REQ_PROCEED;
|
||||
GSWURLComponents stURIComponents;
|
||||
const char *pszFrom=NULL;
|
||||
const char *pszURIPath=NULL;
|
||||
const char *pszObjName=NULL;
|
||||
|
||||
memset(&stURIComponents,0,sizeof(stURIComponents));
|
||||
|
||||
pszFrom = pblock_findval(g_szGSWeb_Conf_PathTrans,p_pBlock);
|
||||
pszURIPath = pblock_findval("ppath",p_pRequest->vars);
|
||||
pszObjName = pblock_findval(g_szGSWeb_Conf_Name,p_pBlock);
|
||||
|
||||
if (!pszFrom || !pszURIPath || !pszObjName)
|
||||
iRetVal=REQ_NOACTION;
|
||||
else if (strncmp(pszFrom,pszURIPath,strlen(pszFrom)) == 0)
|
||||
{
|
||||
// Parse the URL
|
||||
GSWURLError eError=GSWParseURL(&stURIComponents,pszURIPath);
|
||||
if (eError!=GSWURLError_OK)
|
||||
iRetVal=REQ_NOACTION;
|
||||
else
|
||||
{
|
||||
const char *pszAppRoot=NULL;
|
||||
pblock_nvinsert(g_szGSWeb_Conf_Name,(char *)pszObjName,p_pRequest->vars);
|
||||
pszAppRoot = pblock_findval(g_szGSWeb_Conf_AppRoot,p_pBlock);
|
||||
if (pszAppRoot)
|
||||
pblock_nvinsert(g_szGSWeb_Conf_AppRoot,(char *)pszAppRoot,p_pRequest->vars);
|
||||
iRetVal=REQ_PROCEED;
|
||||
};
|
||||
}
|
||||
else
|
||||
iRetVal=REQ_NOACTION;
|
||||
return iRetVal;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// GNUstepWeb Request Handler
|
||||
|
||||
NSAPI_PUBLIC int GSWeb_RequestHandler(pblock* p_pBlock,
|
||||
Session* p_pSession,
|
||||
Request* p_pRequest)
|
||||
{
|
||||
int iRetVal=REQ_PROCEED;
|
||||
GSWHTTPResponse* pResponse = NULL;
|
||||
GSWURLError eError=GSWURLError_OK;
|
||||
const char* pszURLError=NULL;
|
||||
char* pszURI=NULL;
|
||||
GSWURLComponents stURLComponents;
|
||||
memset(&stURLComponents,0,sizeof(stURLComponents));
|
||||
|
||||
NSDebugLog(p_pSession->client,"Session Client");
|
||||
NSDebugLog(p_pSession->client,"Session Client");
|
||||
NSDebugLog(p_pBlock,"pBlock");
|
||||
NSDebugLog(p_pRequest->vars,"p_pRequest->vars");
|
||||
NSDebugLog(p_pRequest->reqpb,"p_pRequest->reqpb");
|
||||
NSDebugLog(p_pRequest->headers,"p_pRequest->headers");
|
||||
NSDebugLog(p_pRequest->srvhdrs,"p_pRequest->srvhdrs");
|
||||
|
||||
// Get the URI
|
||||
pszURI = pblock_findval("uri", p_pRequest->reqpb);
|
||||
|
||||
// Log it
|
||||
GSWLog(GSW_INFO,NULL,"GNUstepWeb New Request: %s", pszURI);
|
||||
|
||||
// Parse it
|
||||
// Parse the uri
|
||||
eError=GSWParseURL(&stURLComponents,pszURI);
|
||||
if (eError!=GSWURLError_OK)
|
||||
{
|
||||
pszURLError=GSWURLErrorMessage(eError);
|
||||
// Log the error
|
||||
GSWLog(GSW_INFO,NULL,"URL Parsing Error: %s", pszURLError);
|
||||
if (eError==GSWURLError_InvalidAppName && GSWDumpConfigFile_CanDump())
|
||||
{
|
||||
pResponse = GSWDumpConfigFile(NULL,&stURLComponents);
|
||||
iRetVal=dieSendResponse(p_pSession,p_pRequest,&pResponse);
|
||||
}
|
||||
else
|
||||
iRetVal=dieWithMessage(p_pSession,p_pRequest,pszURLError);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Build the GSWHTTPRequest with the method
|
||||
GSWHTTPRequest* pRequest= GSWHTTPRequest_New(pblock_findval("method", p_pRequest->reqpb), NULL);
|
||||
|
||||
// validate the method
|
||||
const char* pszRequestError= GSWHTTPRequest_ValidateMethod(pRequest);
|
||||
|
||||
if (pszRequestError)
|
||||
{
|
||||
GSWHTTPRequest_Free(pRequest);
|
||||
iRetVal=dieWithMessage(p_pSession,p_pRequest,pszRequestError);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Copy Headers
|
||||
copyHeaders(p_pBlock, p_pSession, p_pRequest, pRequest);
|
||||
|
||||
// Get Form data
|
||||
|
||||
// POST Method
|
||||
if ((pRequest->eMethod==ERequestMethod_Post) && (pRequest->uContentLength>0))
|
||||
{
|
||||
char* pszBuffer = malloc(pRequest->uContentLength);
|
||||
char* pszData = pszBuffer;
|
||||
int c;
|
||||
int i=0;
|
||||
for(i=0;i<pRequest->uContentLength;i++)//TODOV
|
||||
{
|
||||
// Get a character
|
||||
c = netbuf_getc(p_pSession->inbuf);
|
||||
if (c == IO_ERROR)
|
||||
{
|
||||
log_error(0,"GNUstepWeb",
|
||||
p_pSession,
|
||||
p_pRequest,
|
||||
"Error reading form data (Post Method)");
|
||||
free(pszBuffer);
|
||||
pResponse = GSWHTTPResponse_BuildErrorResponse("Bad mojo"); // TODO
|
||||
};
|
||||
// Add Data
|
||||
*pszData++ = c;
|
||||
}
|
||||
pRequest->pContent = pszBuffer;
|
||||
}
|
||||
// GET Method
|
||||
else if (pRequest->eMethod==ERequestMethod_Get)
|
||||
{
|
||||
// Get the QueryString
|
||||
const char* pQueryString = pblock_findval("query", p_pRequest->reqpb);
|
||||
stURLComponents.stQueryString.pszStart = pQueryString;
|
||||
stURLComponents.stQueryString.iLength = pQueryString ? strlen(pQueryString) : 0;
|
||||
};
|
||||
|
||||
|
||||
// So far, so good...
|
||||
if (!pResponse)
|
||||
{
|
||||
// Now we call the Application !
|
||||
|
||||
// get the document root
|
||||
const char* pszDocRoot=getDocumentRoot(p_pRequest);
|
||||
pRequest->pServerHandle = p_pRequest;
|
||||
|
||||
// Build the response (Beware: tr_handleRequest free pRequest)
|
||||
pResponse=GSWAppRequest_HandleRequest(&pRequest,
|
||||
&stURLComponents,
|
||||
pblock_findval("protocol",p_pRequest->reqpb),
|
||||
pszDocRoot,
|
||||
"SB", // TODO AppTest name
|
||||
NULL);
|
||||
};
|
||||
|
||||
// Send the response (if any)
|
||||
if (pResponse)
|
||||
{
|
||||
iRetVal = sendResponse(p_pSession, p_pRequest, pResponse);
|
||||
GSWHTTPResponse_Free(pResponse);
|
||||
}
|
||||
else
|
||||
// No Application Response !
|
||||
iRetVal = REQ_EXIT;
|
||||
};
|
||||
};
|
||||
return iRetVal;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Get the DocumentRoot
|
||||
|
||||
static const char *getDocumentRoot(Request* p_pRequest)
|
||||
{
|
||||
const char* pszAppRoot=NULL;
|
||||
|
||||
// Try to get AppRoot
|
||||
pszAppRoot = pblock_findval(g_szGSWeb_Conf_AppRoot,p_pRequest->vars);
|
||||
if (!pszAppRoot)
|
||||
{
|
||||
// If global AppRoot, take it !
|
||||
if (glb_pDocRoot)
|
||||
pszAppRoot=glb_pDocRoot;
|
||||
else
|
||||
{
|
||||
httpd_object *dflt=NULL;
|
||||
int iDTable=0;
|
||||
|
||||
// Get the "default" object
|
||||
dflt = objset_findbyname("default",NULL,p_pRequest->os);
|
||||
|
||||
// Find the root option
|
||||
for (iDTable=0, pszAppRoot=NULL;dflt && iDTable<dflt->nd && !pszAppRoot;iDTable++)
|
||||
{
|
||||
int j=0;
|
||||
dtable dt=dflt->dt[iDTable];
|
||||
for (j=0;j<dt.ni && !pszAppRoot;j++)
|
||||
{
|
||||
const char* pszFN=NULL;
|
||||
pblock* pBlock = dt.inst[j].param;
|
||||
pszFN = pblock_findval("fn", pBlock);
|
||||
if (strcmp(pszFN, "document-root")==0)
|
||||
pszAppRoot=pblock_findval("root",pBlock);
|
||||
};
|
||||
};
|
||||
glb_pDocRoot = (char*)pszAppRoot;
|
||||
};
|
||||
};
|
||||
return pszAppRoot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Copy A Header headers into p_pGSWHTTPRequest
|
||||
|
||||
static void copyAHeader(const char* p_pszHeaderKey,
|
||||
pblock* p_pBlock,
|
||||
GSWHTTPRequest* p_pGSWHTTPRequest,
|
||||
const char* p_pszGSWebKey)
|
||||
{
|
||||
const char* p_pszValue = pblock_findval(p_pszHeaderKey,p_pBlock);
|
||||
if (p_pszValue)
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
(p_pszGSWebKey ? p_pszGSWebKey : p_pszHeaderKey),
|
||||
p_pszValue);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Copy headers into p_pGSWHTTPRequest
|
||||
|
||||
static void copyHeaders(pblock* p_pBlock,
|
||||
Session* p_pSession,
|
||||
Request* p_pRequest,
|
||||
GSWHTTPRequest* p_pGSWHTTPRequest)
|
||||
{
|
||||
int i=0;
|
||||
const char* pszHeaderValue=NULL;
|
||||
char szPort[64]="";
|
||||
request_loadheaders(p_pSession,p_pRequest);
|
||||
|
||||
// copy p_pRequest headers
|
||||
for (i=0;i<p_pRequest->headers->hsize;i++)
|
||||
{
|
||||
struct pb_entry *pEntry=p_pRequest->headers->ht[i];
|
||||
while (pEntry)
|
||||
{
|
||||
pb_param *header = pEntry->param;
|
||||
if (header)
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,header->name,header->value);
|
||||
pEntry = pEntry->next;
|
||||
};
|
||||
};
|
||||
|
||||
// Add Method
|
||||
if (p_pGSWHTTPRequest->eMethod==ERequestMethod_Post)
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_RequestMethod,
|
||||
g_szMethod_Post);
|
||||
else
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_RequestMethod,
|
||||
g_szMethod_Get);
|
||||
|
||||
// Add server headers
|
||||
copyAHeader("query",
|
||||
p_pRequest->reqpb,
|
||||
p_pGSWHTTPRequest,
|
||||
g_szServerInfo_QueryString);
|
||||
copyAHeader("protocol",
|
||||
p_pRequest->reqpb,
|
||||
p_pGSWHTTPRequest,
|
||||
g_szServerInfo_ServerProtocol);
|
||||
copyAHeader("ip",
|
||||
p_pSession->client,
|
||||
p_pGSWHTTPRequest,
|
||||
g_szServerInfo_RemoteAddress);
|
||||
copyAHeader("auth-user",
|
||||
p_pRequest->vars,
|
||||
p_pGSWHTTPRequest,
|
||||
g_szServerInfo_AuthUser);
|
||||
copyAHeader("auth-type",
|
||||
p_pRequest->vars,
|
||||
p_pGSWHTTPRequest,
|
||||
g_szServerInfo_AuthType);
|
||||
/*
|
||||
AUTH_TYPE pblock_findval("auth-type", p_pRequest->vars);
|
||||
AUTH_USER pblock_findval("auth-user", p_pRequest->vars);
|
||||
uContentLength pblock_findval("content-length", p_pRequest->srvhdrs);
|
||||
CONTENT_TYPE pblock_findval( content-type", p_pRequest->srvhdrs);
|
||||
GATEWAY_INTERFACE "CGI/1.1"
|
||||
HTTP_* pblock_findval( "*", p_pRequest->headers); (* is lower-case, dash replaces underscore)
|
||||
PATH_INFO pblock_findval("path-info", p_pRequest->vars);
|
||||
PATH_TRANSLATED pblock_findval( path-translated", p_pRequest->vars);
|
||||
QUERY_STRING pblock_findval( query", p_pRequest->reqpb); // Only for GET
|
||||
REMOTE_ADDR pblock_findval("ip", p_pSession->client);
|
||||
REMOTE_HOST session_dns(p_pSession) ? session_dns(p_pSession) : pblock_findval("ip", p_pSession->client);
|
||||
REMOTE_IDENT pblock_findval( "from", p_pRequest->headers);
|
||||
REMOTE_USER pblock_findval("auth-user", p_pRequest->vars);
|
||||
REQUEST_METHOD pblock_findval("method", req->reqpb);
|
||||
SCRIPT_NAME pblock_findval("uri", p_pRequest->reqpb);
|
||||
SERVER_NAME char *util_hostname();
|
||||
SERVER_PORT conf_getglobals()->Vport; (as a string)
|
||||
SERVER_PROTOCOL pblock_findval("protocol", p_pRequest->reqpb);
|
||||
SERVER_SOFTWARE MAGNUS_VERSION_STRING
|
||||
Netscape specific:
|
||||
CLIENT_CERT pblock_findval("auth-cert", p_pRequest->vars);
|
||||
HOST char *session_maxdns(p_pSession); (may be null)
|
||||
HTTPS security_active ? "ON" : "OFF";
|
||||
HTTPS_KEYSIZE pblock_findval("keysize", p_pSession->client);
|
||||
HTTPS_SECRETKEYSIZE pblock_findval("secret-keysize", p_pSession->client);
|
||||
QUERY pblock_findval( query", p_pRequest->reqpb); // Only for GET
|
||||
SERVER_URL http_uri2url_dynamic("","", p_pSession, p_pRequest);
|
||||
*/
|
||||
|
||||
// Try to get Host
|
||||
pszHeaderValue = session_maxdns(p_pSession);
|
||||
if (!pszHeaderValue)
|
||||
pszHeaderValue = session_dns(p_pSession);
|
||||
if (pszHeaderValue)
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_RemoteHost,
|
||||
pszHeaderValue);
|
||||
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_ServerSoftware,
|
||||
system_version());
|
||||
|
||||
util_itoa(server_portnum, szPort);
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_ServerPort,
|
||||
szPort);
|
||||
|
||||
//TODO
|
||||
/*
|
||||
conf_global_vars_s* pServerConf = conf_getglobals();
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest, "SERVER_NAME",pServerConf->Vserver_hostname);
|
||||
*/
|
||||
|
||||
pszHeaderValue = getDocumentRoot(p_pRequest);
|
||||
if (pszHeaderValue)
|
||||
GSWHTTPRequest_AddHeader(p_pGSWHTTPRequest,
|
||||
g_szServerInfo_DocumentRoot,
|
||||
pszHeaderValue);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// callback finction to copy an header into p_pRequest
|
||||
static void getHeader(GSWDictElem* p_pElem,Request* p_pRequest)
|
||||
{
|
||||
pblock_nvinsert(p_pElem->pszKey,
|
||||
p_pElem->pValue,
|
||||
((Request*)p_pRequest)->srvhdrs);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// send response
|
||||
|
||||
static int sendResponse(Session* p_pSession,
|
||||
Request* p_pRequest,
|
||||
GSWHTTPResponse* p_pResponse)
|
||||
{
|
||||
int iRetVal=REQ_PROCEED;
|
||||
// Process Headers
|
||||
pblock_remove(g_szHeader_ContentType,p_pRequest->srvhdrs);
|
||||
GSWDict_PerformForAllElem(p_pResponse->pHeaders,getHeader,p_pRequest);
|
||||
|
||||
// Verify content-length
|
||||
if (!pblock_findval(g_szHeader_ContentLength,p_pRequest->srvhdrs)) // !content-length ?
|
||||
{
|
||||
char szLen[64];
|
||||
util_itoa(p_pResponse->uContentLength,szLen);
|
||||
pblock_nvinsert(g_szHeader_ContentLength,szLen,p_pRequest->srvhdrs);
|
||||
};
|
||||
|
||||
// Status
|
||||
protocol_status(p_pSession,p_pRequest,p_pResponse->uStatus,p_pResponse->pszStatusMessage);
|
||||
|
||||
// HEAD request unattended
|
||||
if (protocol_start_response(p_pSession, p_pRequest) == REQ_NOACTION)
|
||||
{
|
||||
GSWLog(GSW_ERROR,NULL,"protocol_start_response() returned REQ_NOACTION");
|
||||
iRetVal=REQ_PROCEED;
|
||||
}
|
||||
else if (p_pResponse->uContentLength)
|
||||
{
|
||||
// Send response
|
||||
if (net_write(p_pSession->csd, p_pResponse->pContent, p_pResponse->uContentLength) == IO_ERROR)
|
||||
{
|
||||
GSWLog(GSW_ERROR,NULL,"Failed to send response");
|
||||
iRetVal=REQ_EXIT;
|
||||
};
|
||||
};
|
||||
return iRetVal;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// die/send response
|
||||
static int dieSendResponse(Session* p_pSession,
|
||||
Request* p_pRequest,
|
||||
GSWHTTPResponse** p_ppResponse)
|
||||
{
|
||||
sendResponse(p_pSession,
|
||||
p_pRequest,
|
||||
*p_ppResponse);
|
||||
GSWHTTPResponse_Free(*p_ppResponse);
|
||||
*p_ppResponse=NULL;
|
||||
return REQ_PROCEED;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// die with a message
|
||||
static int dieWithMessage(Session* p_pSession,
|
||||
Request* p_pRequest,
|
||||
const char* p_pszMessage)
|
||||
{
|
||||
GSWHTTPResponse* pResponse=NULL;
|
||||
log_error(0,"GNUstepWeb",NULL,NULL,"Aborting request - %s",p_pszMessage);
|
||||
pResponse = GSWHTTPResponse_BuildErrorResponse(p_pszMessage);
|
||||
return dieSendResponse(p_pSession,
|
||||
p_pRequest,
|
||||
&pResponse);
|
||||
};
|
||||
|
||||
|
||||
|
42
GSWAdaptors/netscape/obj.conf
Normal file
42
GSWAdaptors/netscape/obj.conf
Normal file
|
@ -0,0 +1,42 @@
|
|||
# Netscape Communications Corporation - obj.conf
|
||||
# You can edit this file, but comments and formatting changes
|
||||
# might be lost when the admin server makes changes.
|
||||
|
||||
Init format.access="%Ses->client.ip% - %Req->vars.auth-user% [%SYSDATE%] \"%Req->reqpb.clf-request%\" %Req->srvhdrs.clf-status% %Req->srvhdrs.content-length%" fn="flex-init" access="/opt/ns-home/https-mulberry/logs/access"
|
||||
Init fn="load-types" mime-types="mime.types"
|
||||
Init fn="load-modules" shlib="/usr/GNUstep/Libraries/ix86/linux-gnu/gnu-gnu-gnu-xgps/libgswebNSAPIAdaptor_d.so" \
|
||||
funcs="GSWeb_Init,GSWeb_NameTrans,GSWeb_RequestHandler"
|
||||
Init fn="GSWeb_Init" GSWeb_DocumentRoot="/opt/ns-home/docs" GSWeb_DocumentRoot="/NextLibrary/GSWAdaptors/Configuration/GNUstepWeb.conf"
|
||||
#
|
||||
# test stuff
|
||||
Init fn="load-modules" shlib="/export/home/squirk/Developer/nsapi/pbdump.so" \
|
||||
funcs="test_nametrans,test_object,test_init"
|
||||
Init fn="test_init" foo="Foo" bar="Bar" blech="Blech"
|
||||
|
||||
|
||||
<Object name="default">
|
||||
NameTrans from="/ns-icons" fn="pfx2dir" dir="/opt/ns-home/ns-icons"
|
||||
NameTrans from="/mc-icons" fn="pfx2dir" dir="/opt/ns-home/ns-icons"
|
||||
NameTrans from="/GSWeb" fn="GSWeb_NameTrans" name="gsweb"
|
||||
NameTrans from="/cgi-bin" fn="pfx2dir" dir="/opt/ns-home/cgi-bin" name="cgi"
|
||||
NameTrans root="/opt/ns-home/docs" fn="document-root"
|
||||
PathCheck fn="unix-uri-clean"
|
||||
PathCheck fn="find-pathinfo"
|
||||
PathCheck index-names="index.html,home.html" fn="find-index"
|
||||
ObjectType fn="type-by-extension"
|
||||
ObjectType fn="force-type" type="text/plain"
|
||||
Service fn="imagemap" method="(GET|HEAD)" type="magnus-internal/imagemap"
|
||||
Service fn="index-common" method="(GET|HEAD)" type="magnus-internal/directory"
|
||||
Service fn="send-file" method="(GET|HEAD)" type="*~magnus-internal/*"
|
||||
AddLog fn="flex-log" name="access"
|
||||
</Object>
|
||||
|
||||
<Object name="gsweb">
|
||||
Service fn="GSWeb_RequestHandler"
|
||||
</Object>
|
||||
|
||||
<Object name="cgi">
|
||||
ObjectType fn="force-type" type="magnus-internal/cgi"
|
||||
Service fn="send-cgi"
|
||||
</Object>
|
||||
|
|
@ -0,0 +1 @@
|
|||
#include "GSWExceptionPage"
|
|
@ -0,0 +1,80 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>GNUstepWeb Erreurr</TITLE>
|
||||
</HEAD>
|
||||
<BODY bgcolor=white>
|
||||
|
||||
<TABLE BORDER=0>
|
||||
<TR>
|
||||
<TD ALIGN=center VALIGN=TOP>
|
||||
<GSWEB NAME=ExclamationImage></GSWEB><br>
|
||||
Ré-entrer<br>
|
||||
<GSWEB NAME=ReenterHyperlink>
|
||||
<B><GSWEB NAME=ApplicationNameString></GSWEB></B>
|
||||
</GSWEB>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=TOP>
|
||||
<GSWEB NAME=VisibleConditional>
|
||||
<HR>
|
||||
<TABLE BORDER=0>
|
||||
<TR>
|
||||
<TD ALIGN=RIGHT VALIGN=TOP>
|
||||
<B>Application:</B>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=TOP>
|
||||
<GSWEB NAME=ApplicationNameString></GSWEB>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD ALIGN=RIGHT VALIGN=TOP>
|
||||
<B>Erreurr:</B>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=TOP>
|
||||
<GSWEB NAME=ExceptionNameString></GSWEB>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD ALIGN=RIGHT VALIGN=TOP>
|
||||
<B>Raison:</B>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=TOP>
|
||||
<GSWEB NAME=ReasonRepetition>
|
||||
<GSWEB NAME=ReasonString></GSWEB><BR>
|
||||
</GSWEB>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD colspan=2 ALIGN=LEFT VALIGN=bottom>
|
||||
<HR>
|
||||
<B>Dictionaire des informations utilisateur:</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<GSWEB NAME=HasUserInfoConditional>
|
||||
<GSWEB NAME=UserInfoRowRepetition>
|
||||
<TR>
|
||||
<TD ALIGN=RIGHT VALIGN=TOP>
|
||||
<B><GSWEB NAME=UserInfoKeyString></GSWEB>:</B>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=TOP>
|
||||
<GSWEB NAME=UserInfoValueString></GSWEB>
|
||||
</TD>
|
||||
</TR>
|
||||
</GSWEB>
|
||||
</GSWEB>
|
||||
<GSWEB NAME=NoUserInfoConditional>
|
||||
<TR>
|
||||
<TD ALIGN=RIGHT VALIGN=TOP>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=TOP>
|
||||
<B>L'Exception n'a pas de dictionaire des informations utilisateur</B>
|
||||
</TD>
|
||||
</TR>
|
||||
</GSWEB>
|
||||
</GSWEB>
|
||||
</TABLE>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -0,0 +1 @@
|
|||
#include "GSWPageRestorationErrorPage"
|
|
@ -0,0 +1,26 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Erreur: Page Manquante</TITLE>
|
||||
</HEAD>
|
||||
<BODY bgcolor=white>
|
||||
|
||||
<TABLE BORDER=0>
|
||||
<TR>
|
||||
<TD ALIGN=CENTER VALIGN=TOP>
|
||||
<GSWEB NAME=ExclamationImage></GSWEB><BR>
|
||||
Ré-entrer<BR>
|
||||
<GSWEB NAME=ReenterHyperlink>
|
||||
<B><GSWEB NAME=ApplicationNameString></GSWEB></B>
|
||||
</GSWEB>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=MIDDLE>
|
||||
<B> Vous etes retourné trop loin.<BR></B>
|
||||
La limite de
|
||||
<GSWEB NAME=BacktrackingLimitString></GSWEB>
|
||||
a été dépassée.<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -0,0 +1 @@
|
|||
#include "GSWSessionCreationErrorPage.gswc"
|
|
@ -0,0 +1,23 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Erreur de création de session</TITLE>
|
||||
</HEAD>
|
||||
<BODY BGCOLOR="white">
|
||||
|
||||
<TABLE BORDER=0 WIDTH="100%">
|
||||
<TR>
|
||||
<TD ALIGN=CENTER VALIGN=TOP>
|
||||
<GSWEB NAME=ExclamationImage></GSWEB><BR>
|
||||
Ré-entrer<BR>
|
||||
<GSWEB NAME=ReenterHyperlink>
|
||||
<B><GSWEB NAME=ApplicationNameString></GSWEB></B>
|
||||
</GSWEB>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=MIDDLE>
|
||||
<B>Votre session n'a pu etre crée.<B>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -0,0 +1 @@
|
|||
#include "GSWSessionRestorationErrorPage"
|
|
@ -0,0 +1,24 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Erreur: Session Manquante</TITLE>
|
||||
</HEAD>
|
||||
<BODY bgcolor="white">
|
||||
|
||||
<TABLE BORDER=0 WIDTH="100%">
|
||||
<TR>
|
||||
<TD ALIGN=CENTER VALIGN=TOP>
|
||||
<GSWEB NAME=ExclamationImage></GSWEB><BR>
|
||||
Ré-entrer<BR>
|
||||
<GSWEB NAME=ReenterHyperlink>
|
||||
<B><GSWEB NAME=ApplicationNameString></GSWEB></B>
|
||||
</GSWEB>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=MIDDLE>
|
||||
<B>Votre session a expiré.<B>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
162
GSWExtensions.framework/GNUmakefile
Normal file
162
GSWExtensions.framework/GNUmakefile
Normal file
|
@ -0,0 +1,162 @@
|
|||
# GNUmakefile - GSWeb: GNUmakefile
|
||||
# Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
#
|
||||
# Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
# Date: Jan 1999
|
||||
#
|
||||
# This file is part of the GNUstep Web Library.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
# Install into the system root by default
|
||||
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT)
|
||||
|
||||
GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Makefiles
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
include ../Version
|
||||
include ../config.mak
|
||||
|
||||
srcdir = .
|
||||
|
||||
# The library to be compiled
|
||||
GSWBUNDLE_NAME=GSWExtensions
|
||||
GSWExtensions_HAS_GSWCOMPONENTS=YES
|
||||
|
||||
# The bundle resource files and directories
|
||||
GSWExtensions_RESOURCE_FILES = \
|
||||
Resources/Info-gnustep.plist
|
||||
|
||||
GSWExtensions_COMPONENTS= \
|
||||
GSWSessionCreationErrorPage.gswc \
|
||||
GSWSessionRestorationErrorPage.gswc \
|
||||
GSWCollapsibleComponentContent.gswc \
|
||||
GSWStatsPage.gswc \
|
||||
GSWDictionaryRepetition.gswc \
|
||||
GSWTable.gswc \
|
||||
GSWExceptionPage.gswc \
|
||||
GSWTableString.gswc \
|
||||
GSWIFrame.gswc \
|
||||
GSWMetaRefresh.gswc \
|
||||
GSWRedirect.gswc
|
||||
|
||||
#GSWCompletionBar.gswc
|
||||
#GSWAnyField.gswc
|
||||
#GSWSimpleArrayDisplay.gswc
|
||||
#GSWAppleScript.gswc
|
||||
#GSWSimpleArrayDisplay2.gswc
|
||||
#GSWBatchNavigationBar.gswc
|
||||
#GSWSortOrder.gswc
|
||||
#GSWSortOrderManyKey.gswc
|
||||
#GSWThresholdColoredNumber.gswc
|
||||
#GSWToManyRelationship.gswc
|
||||
#GSWPageRestorationErrorPage.gswc
|
||||
#GSWToOneRelationship.gswc
|
||||
|
||||
GSWExtensions_LANGUAGES= \
|
||||
French
|
||||
|
||||
GSWExtensions_RESOURCE_DIRS =
|
||||
|
||||
GSWExtensions_WEBSERVER_RESOURCE_FILES = \
|
||||
Ascending.gif \
|
||||
Descending.gif \
|
||||
DownTriangle.gif \
|
||||
PoweredByGNUstep.gif \
|
||||
RightTriangle.gif \
|
||||
Unsorted.gif \
|
||||
appOff.gif \
|
||||
appOn.gif \
|
||||
back.gif \
|
||||
dir.gif \
|
||||
exclamation.gif \
|
||||
eye.gif \
|
||||
lft-OSarw.gif \
|
||||
rt-OSarw.gif \
|
||||
text.gif \
|
||||
gswapp.gif \
|
||||
gswappsrv.gif
|
||||
|
||||
|
||||
# The bundles libraries to link against
|
||||
#GSWExtensions_BUNDLE_LIBS =
|
||||
|
||||
# The bundles to be installed
|
||||
GSWBUNDLE_INSTALL = $(BUNDLE_NAME)
|
||||
GSWBUNDLE_INSTALL_DIR = $(GNUSTEP_LIBRARIES_ROOT)/gsweb
|
||||
|
||||
# Use .gdladaptor as the bundle extension
|
||||
GSWBUNDLE_EXTENSION = .framework
|
||||
|
||||
# The Objective-C source files to be compiled
|
||||
GSWExtensions_OBJC_FILES = \
|
||||
GSWStatsPage.m \
|
||||
GSWCollapsibleComponentContent.m \
|
||||
GSWSessionCreationErrorPage.m \
|
||||
GSWSessionRestorationErrorPage.m \
|
||||
GSWExceptionPage.m \
|
||||
GSWDictionaryRepetition.m \
|
||||
GSWRedirect.m \
|
||||
GSWIFrame.m \
|
||||
GSWMetaRefresh.m
|
||||
|
||||
#GSWCompletionBar.m
|
||||
|
||||
# The library to be compiled
|
||||
LIBRARY_NAME=libGSWExtensions
|
||||
|
||||
# The bundle Objective-C source files to be compiled
|
||||
libGSWExtensions_OBJC_FILES = $(GSWExtensions_OBJC_FILES)
|
||||
|
||||
libGSWExtensions_HEADER_FILES_DIR = .
|
||||
libGSWExtensions_HEADER_FILES_INSTALL_DIR = /gsweb/GSWExtensions.framework
|
||||
|
||||
libGSWExtensions_HEADER_FILES = \
|
||||
GSWCollapsibleComponentContent.h \
|
||||
GSWDictionaryRepetition.h \
|
||||
GSWExceptionPage.h \
|
||||
GSWIFrame.h \
|
||||
GSWMetaRefresh.h \
|
||||
GSWPageRestorationErrorPage.h \
|
||||
GSWRedirect.h \
|
||||
GSWSessionCreationErrorPage.h \
|
||||
GSWSessionRestorationErrorPage.h \
|
||||
GSWStatsPage.h
|
||||
|
||||
#GSWCompletionBar.h
|
||||
#GSWThresholdColoredNumber.h
|
||||
#GSWSortOrder.h
|
||||
#GSWSortOrderManyKey.h
|
||||
#GSWSimpleArrayDisplay.h
|
||||
#GSWSimpleArrayDisplay2.h
|
||||
#GSWBatchNavigationBar.h
|
||||
|
||||
SRCS = $(LIBRARY_NAME:=.m)
|
||||
|
||||
HDRS = $(LIBRARY_NAME:=.h)
|
||||
|
||||
#DIST_FILES = $(SRCS) $(HDRS) GNUmakefile Makefile.postamble Makefile.preamble
|
||||
|
||||
|
||||
-include Makefile.preamble
|
||||
|
||||
-include GNUmakefile.local
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/gswbundle.make
|
||||
include $(GNUSTEP_MAKEFILES)/library.make
|
||||
|
||||
-include Makefile.postamble
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
Required = (condition, openedLabel, closedLabel);
|
||||
Optional = (closedImageFileName, openedImageFileName, visibility, );
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
Link: GSWHyperlink
|
||||
{
|
||||
action = toggleVisibilityAction;
|
||||
disabled = ^disabled;
|
||||
};
|
||||
|
||||
Image: GSWImage
|
||||
{
|
||||
filename = imageFileName;
|
||||
alt = helpString;
|
||||
name = helpString;
|
||||
border = "0";
|
||||
align = "ABSTOP";
|
||||
}
|
||||
|
||||
Label: GSWString
|
||||
{
|
||||
value = label;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
Condition: GSWConditional
|
||||
{
|
||||
condition = isVisible;
|
||||
}
|
||||
|
||||
Content: GSWComponentContent
|
||||
{
|
||||
};
|
|
@ -0,0 +1 @@
|
|||
<GSWEB NAME=Link><GSWEB NAME=Image></GSWEB></GSWEB> <GSWEB NAME=Label></GSWEB><GSWEB NAME=Condition><GSWEB NAME=Content></GSWEB></GSWEB>
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"WebObjects Release" = "WebObjects 3.5";
|
||||
encoding = NSWindowsCP1252StringEncoding;
|
||||
}
|
51
GSWExtensions.framework/GSWCollapsibleComponentContent.h
Normal file
51
GSWExtensions.framework/GSWCollapsibleComponentContent.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/* GSWCollapsibleComponentContent.h - GSWeb: Class GSWCollapsibleComponentContent
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWCollapsibleComponentContent_h__
|
||||
#define _GSWCollapsibleComponentContent_h__
|
||||
|
||||
|
||||
//==============================================================================
|
||||
@interface GSWCollapsibleComponentContent: GSWComponent
|
||||
{
|
||||
BOOL isVisibleConditionPassed;
|
||||
BOOL isVisible;
|
||||
NSString* openedImageFileName;
|
||||
NSString* closedImageFileName;
|
||||
NSString* openedHelpString;
|
||||
NSString* closedHelpString;
|
||||
};
|
||||
|
||||
-(void)awake;
|
||||
-(void)sleep;
|
||||
-(void)dealloc;
|
||||
-(BOOL)synchronizesVariablesWithBindings;
|
||||
-(BOOL)isVisible;
|
||||
-(GSWComponent*)toggleVisibilityAction;
|
||||
-(NSString*)imageFileName;
|
||||
-(id)label;
|
||||
-(NSString*)helpString;
|
||||
|
||||
@end
|
||||
|
||||
#endif //_GSWCollapsibleComponentContent_h__
|
180
GSWExtensions.framework/GSWCollapsibleComponentContent.m
Normal file
180
GSWExtensions.framework/GSWCollapsibleComponentContent.m
Normal file
|
@ -0,0 +1,180 @@
|
|||
/* GSWCollapsibleComponentContent.m - GSWeb: Class GSWCollapsibleComponentContent
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <gsweb/GSWeb.framework/GSWeb.h>
|
||||
#include "GSWCollapsibleComponentContent.h"
|
||||
|
||||
//===================================================================================
|
||||
@implementation GSWCollapsibleComponentContent
|
||||
|
||||
-(void)awake
|
||||
{
|
||||
[super awake];
|
||||
};
|
||||
|
||||
-(void)sleep
|
||||
{
|
||||
[super sleep];
|
||||
};
|
||||
|
||||
-(void)dealloc
|
||||
{
|
||||
GSWLogC("Dealloc GSWCollopsibleComponent");
|
||||
GSWLogC("Dealloc GSWCollopsibleComponent Super");
|
||||
DESTROY(openedImageFileName);
|
||||
DESTROY(closedImageFileName);
|
||||
DESTROY(openedHelpString);
|
||||
DESTROY(closedHelpString);
|
||||
[super dealloc];
|
||||
GSWLogC("End Dealloc GSWCollopsibleComponent");
|
||||
};
|
||||
|
||||
-(BOOL)synchronizesVariablesWithBindings
|
||||
{
|
||||
return NO;
|
||||
};
|
||||
|
||||
-(BOOL)isVisible
|
||||
{
|
||||
LOGObjectFnStart();
|
||||
NSDebugMLog(@"isVisibleConditionPassed=%s",(isVisibleConditionPassed ? "YES" : "NO"));
|
||||
if (!isVisibleConditionPassed)
|
||||
{
|
||||
isVisible=boolValueFor([self valueForBinding:@"condition"]);
|
||||
isVisibleConditionPassed=YES;
|
||||
};
|
||||
NSDebugMLog(@"isVisible=%s",(isVisible ? "YES" : "NO"));
|
||||
LOGObjectFnStop();
|
||||
return isVisible;
|
||||
};
|
||||
|
||||
-(GSWComponent*)toggleVisibilityAction
|
||||
{
|
||||
LOGObjectFnStart();
|
||||
NSDebugMLog(@"isVisible=%s",(isVisible ? "YES" : "NO"));
|
||||
isVisible = ![self isVisible];
|
||||
NSDebugMLog(@"isVisible=%s",(isVisible ? "YES" : "NO"));
|
||||
if ([self hasBinding:@"visibility"])
|
||||
{
|
||||
[self setValue:[NSNumber numberWithBool:isVisible]
|
||||
forBinding:@"visibility"];
|
||||
};
|
||||
LOGObjectFnStop();
|
||||
return nil;
|
||||
};
|
||||
|
||||
-(NSString*)imageFileName
|
||||
{
|
||||
NSString* _image=nil;
|
||||
LOGObjectFnStart();
|
||||
if ([self isVisible])
|
||||
{
|
||||
if (!openedImageFileName)
|
||||
{
|
||||
if ([self hasBinding:@"openedImageFileName"])
|
||||
ASSIGN(openedImageFileName,[self valueForBinding:@"openedImageFileName"]);
|
||||
else if ([self hasBinding:@"helpString"])
|
||||
ASSIGN(openedImageFileName,[self valueForBinding:@"helpString"]);
|
||||
else
|
||||
ASSIGN(openedImageFileName,@"DownTriangle.gif");
|
||||
};
|
||||
_image=openedImageFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDebugMLog(@"closedImageFileName=%@",closedImageFileName);
|
||||
if (!closedImageFileName)
|
||||
{
|
||||
if ([self hasBinding:@"closedImageFileName"])
|
||||
ASSIGN(closedImageFileName,[self valueForBinding:@"closedImageFileName"]);
|
||||
else if ([self hasBinding:@"helpString"])
|
||||
ASSIGN(closedImageFileName,[self valueForBinding:@"helpString"]);
|
||||
else
|
||||
ASSIGN(closedImageFileName,@"RightTriangle.gif");
|
||||
};
|
||||
_image=closedImageFileName;
|
||||
};
|
||||
NSDebugMLog(@"_image=%@",_image);
|
||||
LOGObjectFnStop();
|
||||
return _image;
|
||||
};
|
||||
|
||||
-(NSString*)label
|
||||
{
|
||||
NSString* _label=nil;
|
||||
LOGObjectFnStart();
|
||||
if ([self isVisible])
|
||||
{
|
||||
if ([self hasBinding:@"openedLabel"])
|
||||
_label=[self valueForBinding:@"openedLabel"];
|
||||
else if ([self hasBinding:@"label"])
|
||||
_label=[self valueForBinding:@"label"];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([self hasBinding:@"closedLabel"])
|
||||
_label=[self valueForBinding:@"closedLabel"];
|
||||
else if ([self hasBinding:@"label"])
|
||||
_label=[self valueForBinding:@"label"];
|
||||
};
|
||||
NSDebugMLog(@"_label=%@",_label);
|
||||
LOGObjectFnStop();
|
||||
return _label;
|
||||
};
|
||||
|
||||
-(NSString*)helpString
|
||||
{
|
||||
NSString* _helpString=nil;
|
||||
LOGObjectFnStart();
|
||||
if ([self isVisible])
|
||||
{
|
||||
if (!openedHelpString)
|
||||
{
|
||||
if ([self hasBinding:@"openedHelpString"])
|
||||
ASSIGN(openedHelpString,[self valueForBinding:@"openedHelpString"]);
|
||||
else if ([self hasBinding:@"helpString"])
|
||||
ASSIGN(openedHelpString,[self valueForBinding:@"helpString"]);
|
||||
else
|
||||
ASSIGN(openedHelpString,@"Click to collapse");
|
||||
};
|
||||
_helpString=openedHelpString;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!closedHelpString)
|
||||
{
|
||||
if ([self hasBinding:@"closedHelpString"])
|
||||
ASSIGN(closedHelpString,[self valueForBinding:@"closedHelpString"]);
|
||||
else if ([self hasBinding:@"helpString"])
|
||||
ASSIGN(closedHelpString,[self valueForBinding:@"helpString"]);
|
||||
else
|
||||
ASSIGN(closedHelpString,@"Click to expand");
|
||||
};
|
||||
_helpString=closedHelpString;
|
||||
};
|
||||
NSDebugMLog(@"_helpString=%@",_helpString);
|
||||
LOGObjectFnStop();
|
||||
return _helpString;
|
||||
};
|
||||
|
||||
|
||||
@end
|
4
GSWExtensions.framework/GSWDictionaryRepetition.api
Normal file
4
GSWExtensions.framework/GSWDictionaryRepetition.api
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
Required = (dictionary, key, item);
|
||||
Optional = ();
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
Repetition: GSWRepetition
|
||||
{
|
||||
list = keyList;
|
||||
item = currentKey;
|
||||
}
|
||||
|
||||
Content: GSWComponentContent
|
||||
{
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
<GSWEB NAME=Repetition><GSWEB NAME=Content></GSWEB></GSWEB>
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"WebObjects Release" = "WebObjects 3.5";
|
||||
encoding = NSWindowsCP1252StringEncoding;
|
||||
}
|
47
GSWExtensions.framework/GSWDictionaryRepetition.h
Normal file
47
GSWExtensions.framework/GSWDictionaryRepetition.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* GSWDictionaryRepetition.h - GSWeb: Class GSWDictionaryRepetition
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWDictionaryRepetition_h__
|
||||
#define _GSWDictionaryRepetition_h__
|
||||
|
||||
|
||||
//====================================================================
|
||||
@interface GSWDictionaryRepetition: GSWComponent
|
||||
{
|
||||
NSArray* keyList;
|
||||
NSDictionary* dictionary;
|
||||
};
|
||||
|
||||
-(id)init;
|
||||
-(void)dealloc;
|
||||
-(void)awake;
|
||||
-(void)sleep;
|
||||
-(BOOL)synchronizesVariablesWithBindings;
|
||||
-(NSDictionary*)dictionary;
|
||||
-(NSArray*)keyList;
|
||||
-(id)currentKey;
|
||||
-(void)setCurrentKey:(NSString*)aKey;
|
||||
|
||||
@end
|
||||
|
||||
#endif // _GSWDictionaryRepetition_h__
|
89
GSWExtensions.framework/GSWDictionaryRepetition.m
Normal file
89
GSWExtensions.framework/GSWDictionaryRepetition.m
Normal file
|
@ -0,0 +1,89 @@
|
|||
/* GSWDictionaryRepetition.m - GSWeb: Class GSWDictionaryRepetition
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <gsweb/GSWeb.framework/GSWeb.h>
|
||||
#include "GSWDictionaryRepetition.h"
|
||||
|
||||
//====================================================================
|
||||
@implementation GSWDictionaryRepetition
|
||||
|
||||
-(void)awake
|
||||
{
|
||||
[super awake];
|
||||
};
|
||||
|
||||
-(void)sleep
|
||||
{
|
||||
[super sleep];
|
||||
};
|
||||
|
||||
-(id)init
|
||||
{
|
||||
return [super init];
|
||||
};
|
||||
|
||||
-(void)dealloc
|
||||
{
|
||||
DESTROY(keyList);
|
||||
DESTROY(dictionary);
|
||||
[super dealloc];
|
||||
};
|
||||
|
||||
-(BOOL)synchronizesVariablesWithBindings
|
||||
{
|
||||
return NO;
|
||||
};
|
||||
|
||||
-(NSDictionary*)dictionary
|
||||
{
|
||||
if (!dictionary)
|
||||
{
|
||||
ASSIGN(dictionary,[self valueForBinding:@"dictionary"]);
|
||||
};
|
||||
return dictionary;
|
||||
};
|
||||
|
||||
-(NSArray*)keyList
|
||||
{
|
||||
if (!keyList)
|
||||
{
|
||||
ASSIGN(keyList,[[self dictionary] allKeys]);
|
||||
};
|
||||
return keyList;
|
||||
};
|
||||
|
||||
-(id)currentKey
|
||||
{
|
||||
return nil;
|
||||
};
|
||||
|
||||
-(void)setCurrentKey:(id)key_
|
||||
{
|
||||
id _value = [[self dictionary] objectForKey:key_];
|
||||
[self setValue:key_
|
||||
forBinding:@"key"];
|
||||
[self setValue:_value
|
||||
forBinding:@"item"];
|
||||
};
|
||||
|
||||
@end
|
||||
|
4
GSWExtensions.framework/GSWExceptionPage.api
Normal file
4
GSWExtensions.framework/GSWExceptionPage.api
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
Required = ();
|
||||
Optional = ();
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
ExclamationImage: GSWImage
|
||||
{
|
||||
filename = "exclamation.gif";
|
||||
framework = "GSWExtensions";
|
||||
border = 0;
|
||||
}
|
||||
|
||||
VisibleConditional: GSWCollapsibleComponentContent
|
||||
{
|
||||
condition = application.class.isDebuggingEnabled;
|
||||
closedLabel = "An Exception has Occurred";
|
||||
openedLabel = "Exception Description";
|
||||
}
|
||||
|
||||
ApplicationNameString: GSWString
|
||||
{
|
||||
value = application.name;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
ExceptionNameString: GSWString
|
||||
{
|
||||
value = exception.name;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
ReasonRepetition: GSWRepetition
|
||||
{
|
||||
list = reasons;
|
||||
item = tmpReason;
|
||||
}
|
||||
|
||||
ReasonString: GSWString
|
||||
{
|
||||
value = tmpReason;
|
||||
escapeHTML = YES;
|
||||
}
|
||||
|
||||
ReenterHyperlink: GSWHyperlink
|
||||
{
|
||||
directActionName = "default";
|
||||
target = "_top";
|
||||
}
|
||||
|
||||
HasUserInfoConditional: GSWConditional
|
||||
{
|
||||
condition = exception.userInfo;
|
||||
}
|
||||
|
||||
NoUserInfoConditional: GSWConditional
|
||||
{
|
||||
condition = exception.userInfo;
|
||||
negate = YES;
|
||||
}
|
||||
|
||||
UserInfoRowRepetition: GSWDictionaryRepetition
|
||||
{
|
||||
dictionary = exception.userInfo;
|
||||
key = tmpUserInfoKey;
|
||||
item = tmpUserInfoValue;
|
||||
}
|
||||
|
||||
UserInfoKeyString: GSWString
|
||||
{
|
||||
value = tmpUserInfoKey;
|
||||
escapeHTML = NO;
|
||||
}
|
||||
|
||||
UserInfoValueString: GSWString
|
||||
{
|
||||
value = tmpUserInfoValue;
|
||||
escapeHTML = YES;
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>GNUstepWeb Error</TITLE>
|
||||
</HEAD>
|
||||
<BODY bgcolor="white">
|
||||
|
||||
<TABLE BORDER=0>
|
||||
<TR>
|
||||
<TD ALIGN=center VALIGN=TOP>
|
||||
<GSWEB NAME=ExclamationImage></GSWEB><br>
|
||||
Re-enter<br>
|
||||
<GSWEB NAME=ReenterHyperlink>
|
||||
<B><GSWEB NAME=ApplicationNameString></GSWEB></B>
|
||||
</GSWEB>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=TOP>
|
||||
<GSWEB NAME=VisibleConditional>
|
||||
<HR>
|
||||
<TABLE BORDER=0>
|
||||
<TR>
|
||||
<TD ALIGN=RIGHT VALIGN=TOP>
|
||||
<B>Application:</B>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=TOP>
|
||||
<GSWEB NAME=ApplicationNameString></GSWEB>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD ALIGN=RIGHT VALIGN=TOP>
|
||||
<B>Error:</B>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=TOP>
|
||||
<GSWEB NAME=ExceptionNameString></GSWEB>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD ALIGN=RIGHT VALIGN=TOP>
|
||||
<B>Reason:</B>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=TOP>
|
||||
<GSWEB NAME=ReasonRepetition>
|
||||
<GSWEB NAME=ReasonString></GSWEB><BR>
|
||||
</GSWEB>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD colspan=2 ALIGN=LEFT VALIGN=bottom>
|
||||
<HR>
|
||||
<B>User Info Dictionary:</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<GSWEB NAME=HasUserInfoConditional>
|
||||
<GSWEB NAME=UserInfoRowRepetition>
|
||||
<TR>
|
||||
<TD ALIGN=RIGHT VALIGN=TOP>
|
||||
<B><GSWEB NAME=UserInfoKeyString></GSWEB>:</B>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=TOP>
|
||||
<GSWEB NAME=UserInfoValueString></GSWEB>
|
||||
</TD>
|
||||
</TR>
|
||||
</GSWEB>
|
||||
</GSWEB>
|
||||
<GSWEB NAME=NoUserInfoConditional>
|
||||
<TR>
|
||||
<TD ALIGN=RIGHT VALIGN=TOP>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=TOP>
|
||||
<B>Exception has no userInfo dictionary</B>
|
||||
</TD>
|
||||
</TR>
|
||||
</GSWEB>
|
||||
</GSWEB>
|
||||
</TABLE>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
48
GSWExtensions.framework/GSWExceptionPage.h
Normal file
48
GSWExtensions.framework/GSWExceptionPage.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* GSWExceptionPage.h - GSWeb: Class GSWExceptionPage
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWExceptionPage_h__
|
||||
#define _GSWExceptionPage_h__
|
||||
|
||||
|
||||
//==============================================================================
|
||||
@interface GSWExceptionPage: GSWComponent
|
||||
{
|
||||
NSString* tmpReason;
|
||||
|
||||
NSString* tmpUserInfoKey;
|
||||
NSString* tmpUserInfoValue;
|
||||
|
||||
NSException* exception;
|
||||
NSArray* reasons;
|
||||
};
|
||||
|
||||
-(void)dealloc;
|
||||
-(NSArray*)getReasons;
|
||||
-(void)appendToResponse:(GSWResponse*)response_
|
||||
inContext:(GSWContext*)context_;
|
||||
-(void)setException:(NSException*)exception_;
|
||||
@end
|
||||
|
||||
#endif // _GSWExceptionPage_h__
|
||||
|
76
GSWExtensions.framework/GSWExceptionPage.m
Normal file
76
GSWExtensions.framework/GSWExceptionPage.m
Normal file
|
@ -0,0 +1,76 @@
|
|||
/* GSWExceptionPage.m - GSWeb: Class GSWExceptionPage
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <gsweb/GSWeb.framework/GSWeb.h>
|
||||
#include "GSWExceptionPage.h"
|
||||
|
||||
//===================================================================================
|
||||
@implementation GSWExceptionPage
|
||||
|
||||
-(void)dealloc
|
||||
{
|
||||
GSWLogCStdOut("Dealloc GSWExceptionPage\n");
|
||||
GSWLogC("Dealloc GSWExceptionPage\n");
|
||||
DESTROY(exception);
|
||||
GSWLogCStdOut("Dealloc GSWExceptionPage reasons\n");
|
||||
GSWLogC("Dealloc GSWExceptionPage reasons\n");
|
||||
DESTROY(reasons);
|
||||
GSWLogCStdOut("Dealloc GSWExceptionPage super\n");
|
||||
GSWLogC("Dealloc GSWExceptionPage super\n");
|
||||
[super dealloc];
|
||||
GSWLogCStdOut("Dealloc GSWExceptionPage end\n");
|
||||
GSWLogC("Dealloc GSWExceptionPage end\n");
|
||||
};
|
||||
|
||||
-(void)awake
|
||||
{
|
||||
[super awake];
|
||||
};
|
||||
|
||||
-(void)sleep
|
||||
{
|
||||
[super sleep];
|
||||
};
|
||||
|
||||
-(NSArray*)getReasons
|
||||
{
|
||||
if (!reasons)
|
||||
{
|
||||
ASSIGN(reasons,[[exception description] componentsSeparatedByString:@"\n"]);
|
||||
};
|
||||
return reasons;
|
||||
};
|
||||
|
||||
-(void)appendToResponse:(GSWResponse*)response_
|
||||
inContext:(GSWContext*)context_
|
||||
{
|
||||
[super appendToResponse:response_
|
||||
inContext:context_];
|
||||
[response_ disableClientCaching];
|
||||
};
|
||||
|
||||
-(void)setException:(NSException*)exception_
|
||||
{
|
||||
ASSIGN(exception,exception_);
|
||||
};
|
||||
|
||||
@end
|
4
GSWExtensions.framework/GSWIFrame.api
Normal file
4
GSWExtensions.framework/GSWIFrame.api
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
Required = (src, pageName, value);
|
||||
Optional = (frameborder, align, height, width, marginheight, marginwidth, name, scrolling, longdesc);
|
||||
}
|
20
GSWExtensions.framework/GSWIFrame.gswc/GSWIFrame.gswd
Normal file
20
GSWExtensions.framework/GSWIFrame.gswc/GSWIFrame.gswd
Normal file
|
@ -0,0 +1,20 @@
|
|||
IFrameContainer: GSWGenericContainer
|
||||
{
|
||||
elementName = "iframe";
|
||||
src = srcUrl;
|
||||
frameborder = ^frameborder;
|
||||
align = ^align;
|
||||
height = ^height;
|
||||
width = ^width;
|
||||
marginheight = ^marginheight;
|
||||
marginwidth = ^marginwidth;
|
||||
name = ^name;
|
||||
scrolling = ^scrolling;
|
||||
longdesc = ^longdesc;
|
||||
invokeAction = getFrameContent;
|
||||
}
|
||||
|
||||
AltContent: GSWComponentContent
|
||||
{
|
||||
}
|
||||
|
1
GSWExtensions.framework/GSWIFrame.gswc/GSWIFrame.html
Normal file
1
GSWExtensions.framework/GSWIFrame.gswc/GSWIFrame.html
Normal file
|
@ -0,0 +1 @@
|
|||
<GSWEB NAME=IFrameContainer><GSWEB NAME=AltContent></GSWEB></GSWEB>
|
37
GSWExtensions.framework/GSWIFrame.h
Normal file
37
GSWExtensions.framework/GSWIFrame.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/* GSWIFrame.h - GSWeb: Class GSWIFrame
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWIFrame_h__
|
||||
#define _GSWIFrame_h__
|
||||
|
||||
|
||||
//==============================================================================
|
||||
@interface GSWIFrame: GSWComponent
|
||||
-(BOOL)synchronizesVariablesWithBindings;
|
||||
-(NSString*)srcUrl;
|
||||
-(GSWElement*)getFrameContent;
|
||||
@end
|
||||
|
||||
#endif // _GSWIFrame_h__
|
||||
|
||||
|
57
GSWExtensions.framework/GSWIFrame.m
Normal file
57
GSWExtensions.framework/GSWIFrame.m
Normal file
|
@ -0,0 +1,57 @@
|
|||
/* GSWIFrame.m - GSWeb: Class GSWIFrame
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <gsweb/GSWeb.framework/GSWeb.h>
|
||||
#include "GSWIFrame.h"
|
||||
|
||||
//===================================================================================
|
||||
@implementation GSWIFrame
|
||||
|
||||
-(BOOL)synchronizesVariablesWithBindings
|
||||
{
|
||||
return NO;
|
||||
};
|
||||
|
||||
-(NSString*)srcUrl
|
||||
{
|
||||
NSString* _src=nil;
|
||||
if ([self hasBinding:@"src"])
|
||||
_src=[self valueForBinding:@"src"];
|
||||
else if ([self hasBinding:@"pageName"] || [self hasBinding:@"value"])
|
||||
_src=[[self context]componentActionURL];
|
||||
return _src;
|
||||
};
|
||||
|
||||
-(GSWElement*)getFrameContent
|
||||
{
|
||||
GSWElement* _element=nil;
|
||||
if ([self hasBinding:@"pageName"])
|
||||
{
|
||||
NSString* _pageName = [self valueForBinding:@"pageName"];
|
||||
_element=[self pageWithName:_pageName];
|
||||
}
|
||||
else
|
||||
_element = [self valueForBinding:@"value"];
|
||||
return _element;
|
||||
};
|
||||
|
||||
@end
|
4
GSWExtensions.framework/GSWMetaRefresh.api
Normal file
4
GSWExtensions.framework/GSWMetaRefresh.api
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
Required = (seconds, pageName, action);
|
||||
Optional = ();
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
MetaRefresh: GSWGenericElement
|
||||
{
|
||||
elementName = "meta";
|
||||
"http-equiv" = "refresh";
|
||||
content = contentString;
|
||||
invokeAction = invokeAction;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
<GSWEB NAME=MetaRefresh></GSWEB>
|
36
GSWExtensions.framework/GSWMetaRefresh.h
Normal file
36
GSWExtensions.framework/GSWMetaRefresh.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* GSWMetaRefresh.h - GSWeb: Class GSWMetaRefresh
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWMetaRefresh_h__
|
||||
#define _GSWMetaRefresh_h__
|
||||
|
||||
|
||||
//==============================================================================
|
||||
@interface GSWMetaRefresh: GSWComponent
|
||||
-(BOOL)synchronizesVariablesWithBindings;
|
||||
-(NSString*)contentString;
|
||||
-(GSWComponent*)invokeAction;
|
||||
@end
|
||||
|
||||
#endif // _GSWMetaRefresh_h__
|
||||
|
56
GSWExtensions.framework/GSWMetaRefresh.m
Normal file
56
GSWExtensions.framework/GSWMetaRefresh.m
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* GSWMetaRefresh.m - GSWeb: Class GSWMetaRefresh
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <gsweb/GSWeb.framework/GSWeb.h>
|
||||
#include "GSWMetaRefresh.h"
|
||||
|
||||
//===================================================================================
|
||||
@implementation GSWMetaRefresh
|
||||
-(BOOL)synchronizesVariablesWithBindings
|
||||
{
|
||||
return NO;
|
||||
};
|
||||
|
||||
-(NSString*)contentString
|
||||
{
|
||||
NSNumber* _seconds = [self valueForBinding:@"seconds"];
|
||||
NSString* _contentString = [NSString stringWithFormat:@"%@;url=%@",
|
||||
[_seconds description],
|
||||
[[self context]componentActionURL]];
|
||||
return _contentString;
|
||||
};
|
||||
|
||||
-(GSWComponent*)invokeAction
|
||||
{
|
||||
GSWComponent* _component = nil;
|
||||
if ([self hasBinding:@"pageName"])
|
||||
{
|
||||
NSString* _pageName = [self valueForBinding:@"pageName"];
|
||||
_component = [self pageWithName:_pageName];
|
||||
}
|
||||
else
|
||||
_component = [self valueForBinding:@"action"];
|
||||
return _component;
|
||||
};
|
||||
|
||||
|
||||
@end
|
4
GSWExtensions.framework/GSWPageRestorationErrorPage.api
Normal file
4
GSWExtensions.framework/GSWPageRestorationErrorPage.api
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
Required = ();
|
||||
Optional = ();
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
ExclamationImage: GSWImage
|
||||
{
|
||||
filename = "exclamation.gif";
|
||||
framework = "GSWExtensions";
|
||||
border = 0;
|
||||
}
|
||||
|
||||
ApplicationNameString: GSWString
|
||||
{
|
||||
value = application.name;
|
||||
}
|
||||
|
||||
ReenterHyperlink: GSWHyperlink
|
||||
{
|
||||
pageName = "Main";
|
||||
target = "_top";
|
||||
};
|
||||
|
||||
BacktrackingLimitString: GSWString
|
||||
{
|
||||
value = application.pageCacheSize;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Missing Page Error</TITLE>
|
||||
</HEAD>
|
||||
<BODY bgcolor="white">
|
||||
|
||||
<TABLE BORDER=0>
|
||||
<TR>
|
||||
<TD ALIGN=CENTER VALIGN=TOP>
|
||||
<GSWEB NAME=ExclamationImage></GSWEB><BR>
|
||||
Re-enter<BR>
|
||||
<GSWEB NAME=ReenterHyperlink>
|
||||
<B><GSWEB NAME=ApplicationNameString></GSWEB></B>
|
||||
</GSWEB>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=MIDDLE>
|
||||
<B> You backtracked too far.<BR></B>
|
||||
The application backtracking limit of
|
||||
<GSWEB NAME=BacktrackingLimitString></GSWEB>
|
||||
has been exceeded.<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
34
GSWExtensions.framework/GSWPageRestorationErrorPage.h
Normal file
34
GSWExtensions.framework/GSWPageRestorationErrorPage.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* GSWPageRestorationErrorPage.h - GSWeb: Class GSWPageRestorationErrorPage
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWPageRestorationErrorPage_h__
|
||||
#define _GSWPageRestorationErrorPage_h__
|
||||
|
||||
|
||||
//==============================================================================
|
||||
@interface GSWPageRestorationErrorPage: GSWComponent
|
||||
-(void)appendToResponse:(GSWResponse*)response_
|
||||
inContext:(GSWContext*)context_;
|
||||
@end
|
||||
|
||||
#endif // _GSWPageRestorationErrorPage_h__
|
48
GSWExtensions.framework/GSWPageRestorationErrorPage.m
Normal file
48
GSWExtensions.framework/GSWPageRestorationErrorPage.m
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* GSWPageRestorationErrorPage.m - GSWeb: Class GSWPageRestorationErrorPage
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <gsweb/GSWeb.framework/GSWeb.h>
|
||||
#include "GSWPageRestorationErrorPage.h"
|
||||
|
||||
//===================================================================================
|
||||
@implementation GSWPageRestorationErrorPage
|
||||
|
||||
-(void)awake
|
||||
{
|
||||
[super awake];
|
||||
};
|
||||
|
||||
-(void)sleep
|
||||
{
|
||||
[super sleep];
|
||||
};
|
||||
|
||||
-(void)appendToResponse:(GSWResponse*)response_
|
||||
inContext:(GSWContext*)context_
|
||||
{
|
||||
[super appendToResponse:response_
|
||||
inContext:context_];
|
||||
[response_ disableClientCaching];
|
||||
};
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
47
GSWExtensions.framework/GSWRedirect.h
Normal file
47
GSWExtensions.framework/GSWRedirect.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* GSWRedirect.h - GSWeb: Class GSWRedirect
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWRedirect_h__
|
||||
#define _GSWRedirect_h__
|
||||
|
||||
|
||||
//==============================================================================
|
||||
@interface GSWRedirect : GSWComponent
|
||||
{
|
||||
NSString* url;
|
||||
BOOL permanent;
|
||||
};
|
||||
|
||||
-(void)awake;
|
||||
-(void)sleep;
|
||||
-(void)dealloc;
|
||||
-(void)appendToResponse:(GSWResponse*)response_
|
||||
inContext:(GSWContext*)context_;
|
||||
-(void)setURL:(NSString*)url_;
|
||||
-(NSString*)url;
|
||||
-(void)setPermanent:(BOOL)permanent_;
|
||||
-(BOOL)permanent;
|
||||
|
||||
@end
|
||||
|
||||
#endif // _GSWRedirect_h__
|
78
GSWExtensions.framework/GSWRedirect.m
Normal file
78
GSWExtensions.framework/GSWRedirect.m
Normal file
|
@ -0,0 +1,78 @@
|
|||
/* GSWRedirect.m - GSWeb: Class GSWRedirect
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <gsweb/GSWeb.framework/GSWeb.h>
|
||||
#include "GSWRedirect.h"
|
||||
|
||||
//===================================================================================
|
||||
@implementation GSWRedirect
|
||||
|
||||
-(void)awake
|
||||
{
|
||||
[super awake];
|
||||
};
|
||||
|
||||
-(void)sleep
|
||||
{
|
||||
[super sleep];
|
||||
};
|
||||
|
||||
-(void)dealloc
|
||||
{
|
||||
DESTROY(url);
|
||||
[super dealloc];
|
||||
};
|
||||
|
||||
-(void)appendToResponse:(GSWResponse*)response_
|
||||
inContext:(GSWContext*)context_
|
||||
{
|
||||
// [response_ appendContentHTMLAttributeValue:url];
|
||||
[response_ setHeader:url
|
||||
forKey:@"location"];
|
||||
if (permanent)
|
||||
[response_ setStatus:301];
|
||||
else
|
||||
[response_ setStatus:302];
|
||||
};
|
||||
|
||||
-(void)setURL:(NSString*)url_
|
||||
{
|
||||
ASSIGN(url,url_);
|
||||
};
|
||||
|
||||
-(NSString*)url
|
||||
{
|
||||
return url;
|
||||
};
|
||||
|
||||
-(void)setPermanent:(BOOL)permanent_
|
||||
{
|
||||
permanent = permanent_;
|
||||
};
|
||||
|
||||
-(BOOL)permanent
|
||||
{
|
||||
return permanent;
|
||||
};
|
||||
|
||||
@end
|
4
GSWExtensions.framework/GSWSessionCreationErrorPage.api
Normal file
4
GSWExtensions.framework/GSWSessionCreationErrorPage.api
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
Required = ();
|
||||
Optional = ();
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
ExclamationImage: GSWImage
|
||||
{
|
||||
filename = "exclamation.gif";
|
||||
framework = "GSWExtensions";
|
||||
border = 0;
|
||||
}
|
||||
|
||||
ApplicationNameString: GSWString
|
||||
{
|
||||
value = application.name;
|
||||
}
|
||||
|
||||
ReenterHyperlink: GSWHyperlink
|
||||
{
|
||||
directActionName = "default";
|
||||
target = "_top";
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Session Creation Error</TITLE>
|
||||
</HEAD>
|
||||
<BODY BGCOLOR="white">
|
||||
|
||||
<TABLE BORDER=0 WIDTH="100%">
|
||||
<TR>
|
||||
<TD ALIGN=CENTER VALIGN=TOP>
|
||||
<GSWEB NAME=ExclamationImage></GSWEB><BR>
|
||||
Re-enter<BR>
|
||||
<GSWEB NAME=ReenterHyperlink>
|
||||
<B><GSWEB NAME=ApplicationNameString></GSWEB></B>
|
||||
</GSWEB>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=MIDDLE>
|
||||
<B>Your session could not be created.<B>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
34
GSWExtensions.framework/GSWSessionCreationErrorPage.h
Normal file
34
GSWExtensions.framework/GSWSessionCreationErrorPage.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* GSWSessionCreationErrorPage.h - GSWeb: Class GSWSessionCreationErrorPage
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWSessionCreationErrorPage_h__
|
||||
#define _GSWSessionCreationErrorPage_h__
|
||||
|
||||
|
||||
//==============================================================================
|
||||
@interface GSWSessionCreationErrorPage: GSWComponent
|
||||
-(void)appendToResponse:(GSWResponse*)response_
|
||||
inContext:(GSWContext*)context_;
|
||||
@end
|
||||
|
||||
#endif // _GSWSessionCreationErrorPage_h__
|
48
GSWExtensions.framework/GSWSessionCreationErrorPage.m
Normal file
48
GSWExtensions.framework/GSWSessionCreationErrorPage.m
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* GSWSessionCreationErrorPage.m - GSWeb: Class GSWSessionCreationErrorPage
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <gsweb/GSWeb.framework/GSWeb.h>
|
||||
#include "GSWSessionCreationErrorPage.h"
|
||||
|
||||
//===================================================================================
|
||||
@implementation GSWSessionCreationErrorPage
|
||||
|
||||
-(void)awake
|
||||
{
|
||||
[super awake];
|
||||
};
|
||||
|
||||
-(void)sleep
|
||||
{
|
||||
[super sleep];
|
||||
};
|
||||
|
||||
-(void)appendToResponse:(GSWResponse*)response_
|
||||
inContext:(GSWContext*)context_
|
||||
{
|
||||
[super appendToResponse:response_
|
||||
inContext:context_];
|
||||
[response_ disableClientCaching];
|
||||
};
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
Required = ();
|
||||
Optional = ();
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
ExclamationImage: GSWImage
|
||||
{
|
||||
filename = "exclamation.gif";
|
||||
framework = "GSWExtensions";
|
||||
border = 0;
|
||||
}
|
||||
|
||||
ApplicationNameString: GSWString
|
||||
{
|
||||
value = application.name;
|
||||
}
|
||||
|
||||
ReenterHyperlink: GSWHyperlink
|
||||
{
|
||||
pageName = "Main";
|
||||
target = "_top";
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Missing Session Error</TITLE>
|
||||
</HEAD>
|
||||
<BODY bgcolor="white">
|
||||
|
||||
<TABLE BORDER=0 WIDTH="100%">
|
||||
<TR>
|
||||
<TD ALIGN=CENTER VALIGN=TOP>
|
||||
<GSWEB NAME=ExclamationImage></GSWEB><BR>
|
||||
Re-enter<BR>
|
||||
<GSWEB NAME=ReenterHyperlink>
|
||||
<B><GSWEB NAME=ApplicationNameString></GSWEB></B>
|
||||
</GSWEB>
|
||||
</TD>
|
||||
<TD ALIGN=LEFT VALIGN=MIDDLE>
|
||||
<B>Your session has timed out.<B>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
35
GSWExtensions.framework/GSWSessionRestorationErrorPage.h
Normal file
35
GSWExtensions.framework/GSWSessionRestorationErrorPage.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* GSWSessionRestorationErrorPage.h - GSWeb: Class GSWSessionRestorationErrorPage
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWSessionRestorationErrorPage_h__
|
||||
#define _GSWSessionRestorationErrorPage_h__
|
||||
|
||||
|
||||
//====================================================================
|
||||
@interface GSWSessionRestorationErrorPage : GSWComponent
|
||||
-(void)appendToResponse:(GSWResponse*)aResponse
|
||||
inContext:(GSWContext*)aContext;
|
||||
@end
|
||||
|
||||
|
||||
#endif //_GSWSessionRestorationErrorPage_h__
|
38
GSWExtensions.framework/GSWSessionRestorationErrorPage.m
Normal file
38
GSWExtensions.framework/GSWSessionRestorationErrorPage.m
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* GSWSessionRestorationErrorPage.m - GSWeb: Class GSWSessionRestorationErrorPage
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Jan 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <gsweb/GSWeb.framework/GSWeb.h>
|
||||
#include "GSWSessionRestorationErrorPage.h"
|
||||
|
||||
//====================================================================
|
||||
@implementation GSWSessionRestorationErrorPage
|
||||
|
||||
-(void)appendToResponse:(GSWResponse*)aResponse
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
[super appendToResponse:aResponse
|
||||
inContext:aContext];
|
||||
[aResponse disableClientCaching];
|
||||
};
|
||||
|
||||
@end
|
||||
|
7
GSWExtensions.framework/GSWStatsPage.api
Normal file
7
GSWExtensions.framework/GSWStatsPage.api
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
/*
|
||||
GSWStats.gswc - GSWExtensions framework
|
||||
*/
|
||||
Required = ();
|
||||
Optional = (username, password);
|
||||
}
|
329
GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.gswd
Normal file
329
GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.gswd
Normal file
|
@ -0,0 +1,329 @@
|
|||
ALLOWED: GSWConditional
|
||||
{
|
||||
condition = session._allowedToViewStatistics;
|
||||
}
|
||||
|
||||
ActionAvg: GSWString
|
||||
{
|
||||
numberformat = "0.000";
|
||||
value = tmpItem."Avg Resp. Time";
|
||||
}
|
||||
|
||||
ActionBar: GSWCompletionBar
|
||||
{
|
||||
align = "RIGHT";
|
||||
numberformat = "0";
|
||||
value = tmpItem.Served;
|
||||
valueMax = maxActionCount;
|
||||
}
|
||||
|
||||
ActionMax: GSWString
|
||||
{
|
||||
numberformat = "0.000";
|
||||
value = tmpItem."Max Resp. Time";
|
||||
}
|
||||
|
||||
ActionMin: GSWString
|
||||
{
|
||||
numberformat = "0.000";
|
||||
value = tmpItem."Min Resp. Time";
|
||||
}
|
||||
|
||||
ActionName: GSWString
|
||||
{
|
||||
value = tmpKey;
|
||||
}
|
||||
|
||||
ActionsRepetition: GSWDictionaryRepetition
|
||||
{
|
||||
dictionary = directActionsDict;
|
||||
key = tmpKey;
|
||||
item = tmpItem;
|
||||
}
|
||||
|
||||
AvgComponentActionTransactions: GSWString
|
||||
{
|
||||
numberformat = "0.000";
|
||||
value = transactions."Component Action Avg. Transaction Time";
|
||||
}
|
||||
|
||||
AvgDirectActionTransactions: GSWString
|
||||
{
|
||||
numberformat = "0.000";
|
||||
value = transactions."Direct Action Avg. Transaction Time";
|
||||
}
|
||||
|
||||
AvgIdleTime: GSWString
|
||||
{
|
||||
numberformat = "0.000";
|
||||
value = transactions."Avg. Idle Time";
|
||||
}
|
||||
|
||||
AvgTransactionTime: GSWString
|
||||
{
|
||||
numberformat = "0.000";
|
||||
value = transactions."Avg. Transaction Time";
|
||||
}
|
||||
|
||||
PageCountBar: GSWCompletionBar
|
||||
{
|
||||
align = "RIGHT";
|
||||
numberformat = "0";
|
||||
value = tmpItem.Served;
|
||||
valueMax = maxPageCount;
|
||||
}
|
||||
|
||||
BAR_DETAILS: GSWCompletionBar
|
||||
{
|
||||
align = "RIGHT";
|
||||
numberformat = "0%";
|
||||
value = detailPercent;
|
||||
}
|
||||
|
||||
Conditional2: GSWConditional
|
||||
{
|
||||
condition = instance;
|
||||
}
|
||||
|
||||
ComponentActionTransactions: GSWString
|
||||
{
|
||||
value = transactions."Component Action Transactions";
|
||||
}
|
||||
|
||||
DetailCount: GSWString
|
||||
{
|
||||
value = detailCount;
|
||||
}
|
||||
|
||||
DetailName: GSWString
|
||||
{
|
||||
value = tmpKey;
|
||||
}
|
||||
|
||||
DetailsRepetition: GSWDictionaryRepetition
|
||||
{
|
||||
dictionary = detailsDict;
|
||||
key = tmpKey;
|
||||
item = tmpItem;
|
||||
}
|
||||
|
||||
DirectActionTransactions: GSWString
|
||||
{
|
||||
value = transactions."Direct Action Transactions";
|
||||
}
|
||||
|
||||
Form1: GSWForm
|
||||
{
|
||||
}
|
||||
|
||||
Form4: GSWForm
|
||||
{
|
||||
directActionName = "GSWStats";
|
||||
}
|
||||
|
||||
ISLASTUSER: GSWConditional
|
||||
{
|
||||
condition = sessionStats.count;
|
||||
}
|
||||
|
||||
ISLOGPATH: GSWConditional
|
||||
{
|
||||
condition = statsDict.LogFile.length
|
||||
}
|
||||
|
||||
ISMAXSESSIONS: GSWConditional
|
||||
{
|
||||
condition = maxSessionsDate;
|
||||
}
|
||||
|
||||
LOGPATH: GSWString
|
||||
{
|
||||
value = statsDict.LogFile
|
||||
}
|
||||
|
||||
MaxSessions: GSWString
|
||||
{
|
||||
dateformat = "%H:%M:%S (%z %Z) on %a, %b %d %Y";
|
||||
value = maxSessionsDate;
|
||||
}
|
||||
|
||||
MemoryKeyCell: GSWString
|
||||
{
|
||||
value = tmpKey;
|
||||
}
|
||||
|
||||
MemoryRepetition: GSWDictionaryRepetition
|
||||
{
|
||||
dictionary = memoryDict;
|
||||
key = tmpKey;
|
||||
item = tmpItem;
|
||||
}
|
||||
|
||||
MemoryValueCell: GSWString
|
||||
{
|
||||
numberformat = "0,000,000";
|
||||
value = tmpItem;
|
||||
}
|
||||
|
||||
MovingAvgIdleTime: GSWString
|
||||
{
|
||||
numberformat = "0.000";
|
||||
value = transactions."Moving Avg. Idle Time";
|
||||
}
|
||||
|
||||
MovingAvgSampleSize: GSWString
|
||||
{
|
||||
value = transactions."Sample Size For Moving Avg.";
|
||||
}
|
||||
|
||||
MovingAvgTransactionTime: GSWString
|
||||
{
|
||||
numberformat = "0.000";
|
||||
value = transactions."Moving Avg. Transaction Time";
|
||||
}
|
||||
|
||||
PASSGSWRD: GSWPasswordField
|
||||
{
|
||||
WIDTH = 12;
|
||||
value = password;
|
||||
}
|
||||
|
||||
PageAvg: GSWString
|
||||
{
|
||||
numberformat = "0.000";
|
||||
value = tmpItem."Avg Resp. Time";
|
||||
}
|
||||
|
||||
PageMax: GSWString
|
||||
{
|
||||
numberformat = "0.000";
|
||||
value = tmpItem."Max Resp. Time";
|
||||
}
|
||||
|
||||
PageMin: GSWString
|
||||
{
|
||||
numberformat = "0.000";
|
||||
value = tmpItem."Min Resp. Time";
|
||||
}
|
||||
|
||||
PageName: GSWString
|
||||
{
|
||||
value = tmpKey;
|
||||
}
|
||||
|
||||
PagesRepetition: GSWDictionaryRepetition
|
||||
{
|
||||
dictionary = pagesDict;
|
||||
key = tmpKey;
|
||||
item = tmpItem;
|
||||
}
|
||||
|
||||
PoweredByImage: GSWImage
|
||||
{
|
||||
ALT = "Powered By GNUstepWeb";
|
||||
BORDER = 0;
|
||||
HEIGHT = 49;
|
||||
WIDTH = 221;
|
||||
filename = "PoweredByGNUstepWeb.gif";
|
||||
}
|
||||
|
||||
REFRESH: GSWSubmitButton
|
||||
{
|
||||
directActionName = "GSWStats";
|
||||
value = "Refresh Page";
|
||||
}
|
||||
|
||||
REFUSED: GSWConditional
|
||||
{
|
||||
condition = session._allowedToViewStatistics;
|
||||
negate = "1";
|
||||
}
|
||||
|
||||
RunningTime: GSWString
|
||||
{
|
||||
value = runningTime;
|
||||
}
|
||||
|
||||
SUBMIT: GSWSubmitButton
|
||||
{
|
||||
action = submit;
|
||||
}
|
||||
|
||||
SessionMemoryKeyCell: GSWString
|
||||
{
|
||||
value = tmpKey;
|
||||
}
|
||||
|
||||
SessionMemoryRepetition: GSWDictionaryRepetition
|
||||
{
|
||||
dictionary = sessionMemoryDict;
|
||||
key = tmpKey;
|
||||
item = tmpItem;
|
||||
}
|
||||
|
||||
SessionMemoryValueCell: GSWString
|
||||
{
|
||||
numberformat = "000,000";
|
||||
value = tmpItem;
|
||||
}
|
||||
|
||||
SessionStatsField: GSWString
|
||||
{
|
||||
value = tmpItem;
|
||||
}
|
||||
|
||||
SessionStatsRepetition: GSWRepetition
|
||||
{
|
||||
list = sessionStats;
|
||||
item = tmpItem;
|
||||
}
|
||||
|
||||
SessionsKeyCell: GSWString
|
||||
{
|
||||
value = tmpKey;
|
||||
}
|
||||
|
||||
SessionsRepetition: GSWDictionaryRepetition
|
||||
{
|
||||
dictionary = sessionsDict;
|
||||
key = tmpKey;
|
||||
item = tmpItem;
|
||||
}
|
||||
|
||||
SessionsValueCell: GSWString
|
||||
{
|
||||
numberformat = "0.00";
|
||||
value = tmpItem;
|
||||
}
|
||||
|
||||
String11: GSWString
|
||||
{
|
||||
value = host;
|
||||
}
|
||||
|
||||
String21: GSWString
|
||||
{
|
||||
dateformat = "%H:%M:%S (%z %Z) on %a, %b %d %Y";
|
||||
value = statsDict.StartedAt;
|
||||
}
|
||||
|
||||
String2: GSWString
|
||||
{
|
||||
value = application.name;
|
||||
}
|
||||
|
||||
String6: GSWString
|
||||
{
|
||||
value = instance;
|
||||
}
|
||||
|
||||
Transactions: GSWString
|
||||
{
|
||||
value = transactions.Transactions;
|
||||
}
|
||||
|
||||
USERNAME: GSWTextField
|
||||
{
|
||||
WIDTH = 12;
|
||||
value = userName;
|
||||
}
|
306
GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.html
Normal file
306
GSWExtensions.framework/GSWStatsPage.gswc/GSWStatsPage.html
Normal file
|
@ -0,0 +1,306 @@
|
|||
<HTML>
|
||||
<HEAD><TITLE></TITLE>
|
||||
</HEAD>
|
||||
<BODY BGCOLOR=#FFFFFF>
|
||||
|
||||
<GSWEB NAME=REFUSED>
|
||||
<CENTER>
|
||||
<h2><FONT color=#FF0000>This Request Requires A User Login</FONT></h2>
|
||||
<BR>
|
||||
<!-- ****
|
||||
<GSWEB name=Form1>
|
||||
<TABLE border=1 cellPadding=2 cellSpacing=0 bgcolor="#f6ffff">
|
||||
<TABLE BORDER=0 WIDTH=80%>
|
||||
<TR align=CENTER>
|
||||
<TD>
|
||||
User
|
||||
</TD>
|
||||
<TD>
|
||||
<GSWEB NAME="USERNAME"></GSWEB>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR align=CENTER>
|
||||
<TD>
|
||||
Password
|
||||
</TD>
|
||||
<TD>
|
||||
<GSWEB NAME="PASSWORD"></GSWEB>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<GSWEB NAME="SUBMIT"></GSWEB>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</TABLE>
|
||||
<BR>
|
||||
</GSWEB>
|
||||
********** -->
|
||||
</CENTER>
|
||||
</GSWEB><GSWEB NAME=ALLOWED>
|
||||
|
||||
<GSWEB NAME=Form4><TABLE BORDER=0 WIDTH=100%>
|
||||
<TR>
|
||||
<TD ALIGN=CENTER COLSPAN=2>
|
||||
<H2>Statistics For <FONT color=#FF0000>
|
||||
<GSWEB name=String2></GSWEB>
|
||||
<GSWEB name=Conditional2>
|
||||
#<FONT color=#FF0000>
|
||||
<GSWEB name=String6></GSWEB>
|
||||
</FONT>
|
||||
</GSWEB>
|
||||
</FONT>On Host <FONT color=#FF0000>
|
||||
<GSWEB name=String11></GSWEB>
|
||||
</FONT>
|
||||
</H2>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD ALIGN=CENTER>
|
||||
<GSWEB NAME="REFRESH"></GSWEB>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE></GSWEB><HR>
|
||||
|
||||
<BR>
|
||||
|
||||
<CENTER>
|
||||
<TABLE BORDER=2 CELLPADDING=4 CELLSPACING=2 bgcolor="#d0d0d0">
|
||||
<TR align = CENTER bgcolor="#b0b0b0">
|
||||
<TD COLSPAN=6><FONT SIZE=+1><B>Application Statistics</B></FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>   </TD>
|
||||
<TD ALIGN=CENTER><FONT SIZE=-1>Transactions</FONT></TD>
|
||||
<TD ALIGN=CENTER><FONT SIZE=-1>Average Transaction<BR>Time</FONT></TD>
|
||||
<TD ALIGN=CENTER><FONT SIZE=-1>Average Idle<BR>Time</FONT></TD>
|
||||
<TD ALIGN=CENTER><FONT SIZE=-1>Moving Average*<BR>Transaction Time</FONT></TD>
|
||||
<TD ALIGN=CENTER><FONT SIZE=-1>Moving Average*<BR>Idle Time</FONT></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Overall</TD>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><GSWEB name=Transactions></GSWEB></FONT></TD>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><GSWEB name=AvgTransactionTime></GSWEB></FONT></TD>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><GSWEB name=AvgIdleTime></GSWEB></FONT></TD>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><GSWEB name=MovingAvgTransactionTime></GSWEB></FONT></TD>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><GSWEB name=MovingAvgIdleTime></GSWEB></FONT></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Component Actions</TD>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><GSWEB name=ComponentActionTransactions></GSWEB></FONT></TD>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><GSWEB name=AvgComponentActionTransactions></GSWEB></FONT></TD>
|
||||
<TD ALIGN=CENTER><FONT size=-1>NA</FONT></TD>
|
||||
<TD ALIGN=CENTER>   </TD>
|
||||
<TD ALIGN=CENTER><FONT size=-1>NA</FONT></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Direct Actions</TD>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><GSWEB name=DirectActionTransactions></GSWEB></FONT></TD>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><GSWEB name=AvgDirectActionTransactions></GSWEB></FONT></TD>
|
||||
<TD ALIGN=CENTER><FONT size=-1>NA</FONT></TD>
|
||||
<TD ALIGN=CENTER>   </TD>
|
||||
<TD ALIGN=CENTER><FONT size=-1>NA</FONT></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Started at</TD>
|
||||
<TD COLSPAN=5>
|
||||
<FONT color=#0000FF><GSWEB name=String21></GSWEB></FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Running time</TD>
|
||||
<TD COLSPAN=5>
|
||||
<FONT color=#0000FF><GSWEB name=RunningTime></GSWEB></FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
<FONT SIZE=-1>
|
||||
* The sample size for Moving Averages is <FONT color=#0000FF><GSWEB name=MovingAvgSampleSize></GSWEB></FONT> transactions.
|
||||
</FONT>
|
||||
</CENTER>
|
||||
|
||||
<HR>
|
||||
<CENTER>
|
||||
<TABLE BORDER=2 CELLPADDING=4 CELLSPACING=2 bgcolor="#d0d0d0">
|
||||
<TR align=CENTER bgcolor="#b0b0b0">
|
||||
<TD COLSPAN=2><FONT SIZE=+1><B>Sessions Statistics</B></FONT></TD>
|
||||
</TR>
|
||||
<GSWEB name=SessionsRepetition>
|
||||
<TR>
|
||||
<TD>
|
||||
<GSWEB name=SessionsKeyCell>
|
||||
</GSWEB>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT color=#0000FF><GSWEB name=SessionsValueCell>
|
||||
</GSWEB></FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
</GSWEB>
|
||||
<GSWEB NAME="ISMAXSESSIONS">
|
||||
<TR>
|
||||
<TD COLSPAN=2>Peak Concurrent Sessions at<BR><FONT color=#0000FF><GSWEB NAME="MaxSessions"></GSWEB></FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
</GSWEB>
|
||||
</TABLE>
|
||||
</CENTER>
|
||||
<BR>
|
||||
<CENTER>
|
||||
<TABLE BORDER=0 WIDTH="100%"> <!-- spacer table - invisible -->
|
||||
<TR><TD ALIGN=CENTER>
|
||||
<TABLE BORDER=2 CELLPADDING=4 CELLSPACING=2 bgcolor="#d0d0d0">
|
||||
<TR align=CENTER bgcolor="#b0b0b0">
|
||||
<TD COLSPAN=2><B>Memory Usage (bytes)</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<GSWEB name=MemoryRepetition>
|
||||
<TR>
|
||||
<TD>
|
||||
<GSWEB name=MemoryKeyCell></GSWEB>
|
||||
</TD>
|
||||
<TD ALIGN="RIGHT">
|
||||
<FONT color=#0000FF><GSWEB name=MemoryValueCell></GSWEB></FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
</GSWEB>
|
||||
</TABLE>
|
||||
</TD><TD ALIGN=CENTER>
|
||||
<TABLE BORDER=2 CELLPADDING=4 CELLSPACING=2 bgcolor="#d0d0d0">
|
||||
<TR align = CENTER bgcolor="#b0b0b0">
|
||||
<TD COLSPAN=2><B>Avg. Memory Usage Per Session (bytes)</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<GSWEB name=SessionMemoryRepetition>
|
||||
<TR>
|
||||
<TD>
|
||||
<GSWEB name=SessionMemoryKeyCell>
|
||||
</GSWEB>
|
||||
</TD>
|
||||
<TD ALIGN="RIGHT">
|
||||
<FONT color=#0000FF><GSWEB name=SessionMemoryValueCell>
|
||||
</GSWEB></FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
</GSWEB>
|
||||
</TABLE>
|
||||
</TD></TR></TABLE>
|
||||
</CENTER>
|
||||
|
||||
<BR>
|
||||
|
||||
<GSWEB NAME=ISLASTUSER>
|
||||
Response Descriptions For Last User :
|
||||
<BR>
|
||||
<CENTER>
|
||||
<table border=2 cellpadding=4 cellspacing=2 bgcolor="#d0d0d0" WIDTH="80%">
|
||||
<GSWEB name=SessionStatsRepetition>
|
||||
<TR>
|
||||
<TD>
|
||||
<FONT color=#0000FF><GSWEB name=SessionStatsField>
|
||||
</GSWEB></FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
</GSWEB>
|
||||
</table>
|
||||
</CENTER>
|
||||
</GSWEB><HR>
|
||||
|
||||
<CENTER>
|
||||
<TABLE border=2 cellpadding=4 cellspacing=2 width="80%" bgcolor="#d0d0d0">
|
||||
<TR><TD COLSPAN=5 ALIGN=CENTER BGCOLOR="#b0b0b0">
|
||||
<FONT SIZE=+1><B> Component Action Statistics </B></FONT>
|
||||
</TD></TR>
|
||||
<TR align=CENTER bgcolor="#d6d8df">
|
||||
<TD WIDTH = "20%">
|
||||
Name
|
||||
</TD>
|
||||
<TD WIDTH = "50%">Served
|
||||
</TD>
|
||||
<TD WIDTH = "10%">
|
||||
Min
|
||||
</TD>
|
||||
<TD WIDTH = "10%">
|
||||
Avg
|
||||
</TD>
|
||||
<TD WIDTH = "10%">
|
||||
Max
|
||||
</TD>
|
||||
</TR>
|
||||
<GSWEB NAME=PagesRepetition>
|
||||
<TR>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><GSWEB NAME=PageName></GSWEB></FONT></TD>
|
||||
<TD align=left><GSWEB NAME="PageCountBar"></GSWEB></TD>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><GSWEB NAME=PageMin></GSWEB></FONT></TD>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><B><GSWEB NAME=PageAvg></GSWEB></B></FONT></TD>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><GSWEB NAME=PageMax></GSWEB></FONT></TD>
|
||||
</TR>
|
||||
</GSWEB>
|
||||
</TABLE>
|
||||
</CENTER>
|
||||
|
||||
<HR>
|
||||
|
||||
<CENTER>
|
||||
<TABLE border=2 cellpadding=4 cellspacing=2 width="80%" bgcolor="#d0d0d0">
|
||||
<TR><TD COLSPAN=5 ALIGN=CENTER BGCOLOR="#b0b0b0">
|
||||
<FONT SIZE=+1><B> Direct Action Statistics </B></FONT>
|
||||
</TD></TR>
|
||||
<TR align=CENTER bgcolor="#d6d8df">
|
||||
<TD WIDTH="20%">Name</TD>
|
||||
<TD WIDTH="50%">Served</TD>
|
||||
<TD WIDTH="10%">Min</TD>
|
||||
<TD WIDTH="10%">Avg</TD>
|
||||
<TD WIDTH="10%">Max</TD>
|
||||
</TR>
|
||||
<GSWEB NAME=ActionsRepetition>
|
||||
<TR>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><GSWEB NAME=ActionName></GSWEB></FONT></TD>
|
||||
<TD align=left><GSWEB NAME="ActionBar"></GSWEB></TD>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><GSWEB NAME=ActionMin></GSWEB></FONT></TD>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><B><GSWEB NAME=ActionAvg></GSWEB></B></FONT></TD>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><GSWEB NAME=ActionMax></GSWEB></FONT></TD>
|
||||
</TR>
|
||||
</GSWEB>
|
||||
</TABLE>
|
||||
</CENTER>
|
||||
|
||||
<HR>
|
||||
|
||||
<CENTER>
|
||||
<TABLE border=2 cellPadding=4 cellspacing=2 width="80%" bgcolor="#d0d0d0">
|
||||
<TR><TD COLSPAN=3 ALIGN=CENTER BGCOLOR="#b0b0b0">
|
||||
<FONT SIZE=+1><B>Detailed Statistics</B></FONT>
|
||||
</TD></TR>
|
||||
<TR align=CENTER bgcolor="#d6d8df">
|
||||
<TD WIDTH="40%">
|
||||
Response Description
|
||||
</TD>
|
||||
<TD WIDTH="50%">Percent Of Total
|
||||
</TD>
|
||||
<TD WIDTH="10%">
|
||||
Served
|
||||
</TD>
|
||||
</TR>
|
||||
<GSWEB NAME=DetailsRepetition>
|
||||
<TR>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><GSWEB NAME=DetailName></GSWEB></FONT></TD>
|
||||
<TD align=left><GSWEB NAME="BAR_DETAILS"></GSWEB></TD>
|
||||
<TD ALIGN=CENTER><FONT color=#0000FF><GSWEB NAME=DetailCount></GSWEB></FONT></TD>
|
||||
</TR>
|
||||
</GSWEB>
|
||||
</TABLE>
|
||||
<BR>
|
||||
<GSWEB NAME=ISLOGPATH>
|
||||
<HR>
|
||||
<BR>
|
||||
Statistics Details Saved In Common Log Format In File <FONT color=#0000FF><GSWEB NAME=LOGPATH></GSWEB></FONT></GSWEB>
|
||||
|
||||
<HR>
|
||||
<BR>
|
||||
<A HREF="http://www.sbuilders.com"><GSWEB name=PoweredByImage></GSWEB></A>
|
||||
</CENTER>
|
||||
</GSWEB>
|
||||
</BODY>
|
||||
</HTML>
|
64
GSWExtensions.framework/GSWStatsPage.h
Normal file
64
GSWExtensions.framework/GSWStatsPage.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* GSWStatsPage.h - GSWeb: Class GSWStatsPage
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GSWStatsPage_h__
|
||||
#define _GSWStatsPage_h__
|
||||
|
||||
|
||||
//==============================================================================
|
||||
@interface GSWStatsPage: GSWComponent
|
||||
{
|
||||
NSString* tmpKey;
|
||||
NSString* tmpItem;
|
||||
|
||||
NSDictionary* detailsDict;
|
||||
NSDictionary* pagesDict;
|
||||
NSDictionary* directActionsDict;
|
||||
NSDictionary* sessionMemoryDict;
|
||||
NSDictionary* transactions;
|
||||
NSDictionary* statsDict;
|
||||
NSDictionary* memoryDict;
|
||||
NSArray* sessionStats;
|
||||
NSMutableDictionary* sessionsDict;
|
||||
NSNumber* maxPageCount;
|
||||
NSNumber* maxActionCount;
|
||||
NSDate* maxSessionsDate;
|
||||
NSString* userName;
|
||||
NSString* password;
|
||||
};
|
||||
|
||||
-(id)submit;
|
||||
-(id)host;
|
||||
-(id)instance;
|
||||
-(NSNumber*)_maxServedForDictionary:(NSDictionary*)aDictionary;
|
||||
-(id)_initIvars;
|
||||
-(void)appendToResponse:(GSWResponse*)aResponse
|
||||
inContext:(GSWContext*)aContext;
|
||||
-(void)setDetailPercent:(NSNumber*)aValue;
|
||||
-(NSNumber*)detailPercent;
|
||||
-(id)runningTime;
|
||||
-(id)detailCount;
|
||||
|
||||
@end
|
||||
|
||||
#endif //_GSWStatsPage_h__
|
133
GSWExtensions.framework/GSWStatsPage.m
Normal file
133
GSWExtensions.framework/GSWStatsPage.m
Normal file
|
@ -0,0 +1,133 @@
|
|||
/* GSWStatsPage.m - GSWeb: Class GSWStatsPage
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
|
||||
Date: Apr 1999
|
||||
|
||||
This file is part of the GNUstep Web Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include <gsweb/GSWeb.framework/GSWeb.h>
|
||||
#include "GSWStatsPage.h"
|
||||
|
||||
//===================================================================================
|
||||
@implementation GSWStatsPage
|
||||
-(id)submit
|
||||
{
|
||||
GSWStatisticsStore* _statisticsStore = [[self application] statisticsStore];
|
||||
if (_statisticsStore)
|
||||
{
|
||||
[_statisticsStore validateLogin:password];
|
||||
};
|
||||
return self;
|
||||
};
|
||||
|
||||
-(id)host
|
||||
{
|
||||
return [[NSHost currentHost] name];
|
||||
}
|
||||
|
||||
-(id)instance
|
||||
{
|
||||
id _instance=nil;
|
||||
NSArray* _commandLineArguments = [[NSProcessInfo processInfo] arguments];
|
||||
unsigned int i=0;
|
||||
i = [_commandLineArguments indexOfObject:@"-n"];
|
||||
if (i!=NSNotFound && ([_commandLineArguments count] > i + 1))
|
||||
_instance=[_commandLineArguments objectAtIndex:i+1];
|
||||
return _instance;
|
||||
};
|
||||
|
||||
-(NSNumber*)_maxServedForDictionary:(NSDictionary*)aDictionary
|
||||
{
|
||||
int _maxServedCount = 0;
|
||||
int _tmpCount=0;
|
||||
NSDictionary* _page = nil;
|
||||
NSEnumerator* _enum = [aDictionary objectEnumerator];
|
||||
while (_page = [_enum nextObject])
|
||||
{
|
||||
_tmpCount = [[_page objectForKey:@"Served"] intValue];
|
||||
_maxServedCount = max(_maxServedCount,_tmpCount);
|
||||
};
|
||||
return [NSNumber numberWithInt:_maxServedCount];
|
||||
};
|
||||
|
||||
-(id)_initIvars
|
||||
{
|
||||
id currentCount, i;
|
||||
statsDict = [[self application] statistics];
|
||||
pagesDict = [statsDict objectForKey:@"Pages"];
|
||||
directActionsDict = [statsDict objectForKey:@"DirectActions"];
|
||||
detailsDict = [statsDict objectForKey:@"Details"];
|
||||
transactions = [statsDict objectForKey:@"Transactions"];
|
||||
memoryDict = [statsDict objectForKey:@"Memory"];
|
||||
sessionsDict = [[[NSMutableDictionary alloc] initWithDictionary:
|
||||
[statsDict objectForKey:@"Sessions"]]
|
||||
autorelease];
|
||||
sessionMemoryDict = [sessionsDict objectForKey:@"Avg. Memory Per Session"];
|
||||
[sessionsDict removeObjectForKey:@"Avg. Memory Per Session"];
|
||||
|
||||
sessionStats = [sessionsDict objectForKey:@"Last Session's Statistics"];
|
||||
[sessionsDict removeObjectForKey:@"Last Session's Statistics"];
|
||||
|
||||
maxSessionsDate = [sessionsDict objectForKey:@"Peak Active Sessions Date"];
|
||||
[sessionsDict removeObjectForKey:@"Peak Active Sessions Date"];
|
||||
|
||||
maxPageCount = 0;
|
||||
maxActionCount = 0;
|
||||
|
||||
maxPageCount = [self _maxServedForDictionary:pagesDict];
|
||||
maxActionCount = [self _maxServedForDictionary:directActionsDict];
|
||||
};
|
||||
|
||||
-(void)appendToResponse:(GSWResponse*)aResponse
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
// ** This should probably be somewhere else.
|
||||
[self _initIvars];
|
||||
[super appendToResponse:aResponse
|
||||
inContext:aContext];
|
||||
};
|
||||
|
||||
|
||||
-(void)setDetailPercent:(NSNumber*)aValue
|
||||
{
|
||||
}
|
||||
|
||||
-(NSNumber*)detailPercent
|
||||
{
|
||||
int _detailPercent=0;
|
||||
id aTransactionsCount = [transactions objectForKey:@"Transactions"];
|
||||
int aDetailCount = [[self detailCount] intValue];
|
||||
if (aTransactionsCount > 0)
|
||||
_detailPercent=(aDetailCount / [aTransactionsCount intValue]) * 100;
|
||||
return [NSNumber numberWithInt:_detailPercent];
|
||||
};
|
||||
|
||||
-(id)runningTime
|
||||
{
|
||||
NSTimeInterval aRunningTime = (-1.0 * [[statsDict objectForKey:@"StartedAt"] timeIntervalSinceNow]);
|
||||
NSString* aRunningTimeString = [GSWStatisticsStore timeIntervalDescription:aRunningTime];
|
||||
return aRunningTimeString;
|
||||
}
|
||||
|
||||
-(id)detailCount
|
||||
{
|
||||
return [detailsDict objectForKey:tmpKey];
|
||||
}
|
||||
|
||||
|
||||
@end
|
4
GSWExtensions.framework/GSWTable.api
Normal file
4
GSWExtensions.framework/GSWTable.api
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
Required = (list, maxColumns, row, col, index);
|
||||
Optional = ();
|
||||
}
|
37
GSWExtensions.framework/GSWTable.gswc/GSWTable.gswd
Normal file
37
GSWExtensions.framework/GSWTable.gswc/GSWTable.gswd
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
TableContainer: GSWGenericContainer {
|
||||
elementName = "table";
|
||||
bgcolor = ^tableBackgroundColor;
|
||||
border = ^border;
|
||||
cellpadding = ^cellpadding;
|
||||
cellspacing = ^cellspacing;
|
||||
}
|
||||
|
||||
RowRepetition: GSWRepetition {
|
||||
count = rowCount;
|
||||
index = currentRow;
|
||||
}
|
||||
|
||||
TableRow: GSWGenericContainer {
|
||||
elementName = "tr";
|
||||
bgcolor = ^rowBackgroundColor;
|
||||
}
|
||||
|
||||
ColRepetition: GSWRepetition {
|
||||
count = colCount;
|
||||
index = currentCol;
|
||||
}
|
||||
|
||||
PushItem: GSWMethodInvocation {
|
||||
invoke = pushItem;
|
||||
}
|
||||
|
||||
CellContainer: GSWGenericContainer {
|
||||
elementName = "td";
|
||||
bgcolor = ^cellBackgroundColor;
|
||||
align = ^cellAlign;
|
||||
valign = ^cellVAlign;
|
||||
}
|
||||
|
||||
Content: GSWComponentContent {
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue