Author: chrisz
Date: Sun Apr 8 14:00:36 2007
New Revision: 6433
Added:
Webware/trunk/WebKit/Adapters/wkcgi/make.bat
Removed:
Webware/trunk/WebKit/Adapters/wkcgi/wkcgi.dsp
Webware/trunk/WebKit/Adapters/wkcgi/wkcgi.dsw
Modified:
Webware/trunk/WebKit/Adapters/common/environ.c
Webware/trunk/WebKit/Adapters/common/environ.h
Webware/trunk/WebKit/Adapters/common/marshal.c
Webware/trunk/WebKit/Adapters/common/marshal.h
Webware/trunk/WebKit/Adapters/common/parsecfg.c
Webware/trunk/WebKit/Adapters/common/wkcommon.c
Webware/trunk/WebKit/Adapters/common/wkcommon.h
Webware/trunk/WebKit/Adapters/wkcgi/README
Webware/trunk/WebKit/Adapters/wkcgi/webkit.cfg
Webware/trunk/WebKit/Adapters/wkcgi/wkcgi.c
Webware/trunk/WebKit/Adapters/wkcgi/wkcgi.exe
Webware/trunk/WebKit/Adapters/wkcgi/wkcgi.h
Log:
Get wkcgi running with Microsoft Visual C++ 2005 Express Edition.
Modified: Webware/trunk/WebKit/Adapters/common/environ.c
==============================================================================
--- Webware/trunk/WebKit/Adapters/common/environ.c (original)
+++ Webware/trunk/WebKit/Adapters/common/environ.c Sun Apr 8 14:00:36 2007
@@ -7,7 +7,6 @@
extern char** environ;
-
/*********************************************
* Extract environ item from a string into an EnvItem, used for cgi
**********************************************/
@@ -25,7 +24,6 @@
else index ++;
}
-
item->key = calloc(sizeof(char), index+1);
item->val = calloc(sizeof(char), fullLen-index);
@@ -33,7 +31,6 @@
memcpy(item->val, envstr+index+1, fullLen - index);
return item;
-
}
int environLength() {
@@ -45,11 +42,10 @@
}
EnvItem** extractEnviron() {
-
int envItems;
int item = 0;
EnvItem **itemList;
-
+
envItems = environLength();
itemList = (EnvItem**) calloc(sizeof(EnvItem*), envItems+1);
@@ -60,25 +56,23 @@
}
return itemList;
-}
-
-
+}
int freeEnviron( EnvItem** env) {
int i;
- char msg[400];
+ // char msg[400];
- //sprintf(msg, "Starting to free environment\r\n");
- //log_message(msg);
+ // sprintf(msg, "Starting to free environment\r\n");
+ // log_message(msg);
for(i=0; env[i] != NULL; i++) {
- //sprintf(msg, "Freeing item %i", i);
- //log_message(msg);
- //sprintf(msg, "Freeing key %.100s", env[i]->key);
- //log_message(msg);
+ // sprintf(msg, "Freeing item %i", i);
+ // log_message(msg);
+ // sprintf(msg, "Freeing key %.100s", env[i]->key);
+ // log_message(msg);
if (env[i]->key !=NULL) free(env[i]->key);
- //sprintf(msg, "Freeing val %.100s", env[i]->val);
- //log_message(msg);
+ // sprintf(msg, "Freeing val %.100s", env[i]->val);
+ // log_message(msg);
if (env[i]->val !=NULL) free(env[i]->val);
free(env[i]);
}
@@ -87,7 +81,6 @@
return 1;
}
-
#if 0
int main(char argc, char* argv[]) {
Modified: Webware/trunk/WebKit/Adapters/common/environ.h
==============================================================================
--- Webware/trunk/WebKit/Adapters/common/environ.h (original)
+++ Webware/trunk/WebKit/Adapters/common/environ.h Sun Apr 8 14:00:36 2007
@@ -1,4 +1,3 @@
-
/* Environ.h */
#ifndef ENVIRON_H
@@ -9,10 +8,10 @@
char* val;
} EnvItem;
+int log_message(char* msg);
EnvItem* splitEnviron(char* envstr);
EnvItem** extractEnviron();
int freeEnviron(EnvItem** env);
-
#endif
Modified: Webware/trunk/WebKit/Adapters/common/marshal.c
==============================================================================
--- Webware/trunk/WebKit/Adapters/common/marshal.c (original)
+++ Webware/trunk/WebKit/Adapters/common/marshal.c Sun Apr 8 14:00:36 2007
@@ -1,25 +1,18 @@
-
/* marshal.c */
-/* author: Jay Love (jsliv@...) */
+/* Author: Jay Love (jsliv@...) */
/* Adapted from marshal.c in the python distribution */
/* This file handles the creation of python marshal structures. */
-
-
#include <string.h>
#include <stdlib.h>
#include "marshal.h"
/*
#define w_byte(c, p) if ((p)->ptr != (p)->end) *(p)->ptr++ = (c); \
- else w_more(c, p)
+ else w_more(c, p)
*/
-
-
-
-char* expand_memory(WFILE* p, long add)
-{
+char* expand_memory(WFILE* p, long add) {
char* newptr;
long currsize;
long newsize = 0;
@@ -28,9 +21,9 @@
if (add == 0) add = 4096;
newsize = currsize + add;
-
+
newptr = calloc(newsize, 1);
- //if !newptr //need a check here
+ // if !newptr //need a check here
memcpy( newptr, p->str, currsize);
p->end = newptr + newsize;
@@ -40,54 +33,38 @@
return newptr;
}
-
-
-
void insert_data(WFILE* dest, WFILE* src) {
-
long src_len, dest_avail, len_need;
-
-
src_len = src->ptr - src->str;
dest_avail = dest->end - dest->ptr;
len_need = src_len - dest_avail;
- if (len_need > 0) { // potential off by one here
+ if (len_need > 0) { // potential off by one here
expand_memory(dest, len_need+1);
}
memcpy(dest->ptr, src->str, src_len);
- dest->ptr = dest->ptr + src_len;
-
+ dest->ptr += src_len;
}
-
-
-void
-w_more(char c, WFILE* p) {
-
+void w_more(char c, WFILE* p) {
if (p->str == NULL)
return; /* An error already occurred, we're screwed */
-
expand_memory(p, 0);
*p->ptr++ = c;
}
-
void w_byte(char c, WFILE* p) {
- if ((p)->ptr != (p)->end)
+ if ((p)->ptr != (p)->end)
*(p)->ptr++ = (c);
else w_more(c, p);
}
-
-
-void
-w_string(char* s, int n, WFILE* p) {
-// log_message("In w_string", p->r);
+void w_string(char* s, int n, WFILE* p) {
+ // log_message("In w_string", p->r);
while (--n >= 0) {
w_byte(*s, p);
s++;
- }
+ }
}
void w_short(int x, WFILE* p) {
@@ -103,41 +80,33 @@
}
#if SIZEOF_LONG > 4
-void
-w_long64(x, p)
- long x;
- WFILE *p;
+void w_long64(long x, WFILE *p)
{
w_long(x, p);
w_long(x>>32, p);
}
#endif
-
void write_string( char* s, long len, WFILE* p) {
-
- w_byte(TYPE_STRING, p);
- w_long(len, p);
- if (len > 0)
- w_string( s, len, p);
+ w_byte(TYPE_STRING, p);
+ w_long(len, p);
+ if (len > 0)
+ w_string( s, len, p);
}
void write_integer(int number, WFILE* wf) {
- long x,y;
- x = (long)number;
+ long x;
+ x = (long)number;
#if SIZEOF_LONG > 4
- long y = x>>31;
- if (y && y != -1) {
- w_byte(TYPE_INT64, wf);
- w_long64(x, wf);
- }
- else
+ long y = x>>31;
+ if (y && y != -1) {
+ w_byte(TYPE_INT64, wf);
+ w_long64(x, wf);
+ }
+ else
#endif
- {
- w_byte(TYPE_INT, wf);
- w_long(x, wf);
- }
+ {
+ w_byte(TYPE_INT, wf);
+ w_long(x, wf);
+ }
}
-
-
-
Modified: Webware/trunk/WebKit/Adapters/common/marshal.h
==============================================================================
--- Webware/trunk/WebKit/Adapters/common/marshal.h (original)
+++ Webware/trunk/WebKit/Adapters/common/marshal.h Sun Apr 8 14:00:36 2007
@@ -1,20 +1,15 @@
-
-
-
#ifndef MARSHAL_H
#define MARSHAL_H
typedef struct WFILE{
- char *str;
+ char *str;
char *ptr;
char *end;
} WFILE;
-
-
-#define HUGE_STRING_LENGTH 4096
+#define HUGE_STRING_LENGTH 4096
#define TYPE_NULL '0'
#define TYPE_NONE 'N'
#define TYPE_ELLIPSIS '.'
@@ -31,9 +26,6 @@
#define TYPE_UNICODE 'u'
#define TYPE_UNKNOWN '?'
-
-
-
void insert_data(WFILE* dest, WFILE* src);
void w_byte(char c, WFILE* p);
@@ -43,6 +35,4 @@
void write_string( char* s, long len, WFILE* p);
void write_integer(int number, WFILE* wf);
-
#endif
-
Modified: Webware/trunk/WebKit/Adapters/common/parsecfg.c
==============================================================================
--- Webware/trunk/WebKit/Adapters/common/parsecfg.c (original)
+++ Webware/trunk/WebKit/Adapters/common/parsecfg.c Sun Apr 8 14:00:36 2007
@@ -427,7 +427,7 @@
(dynamic allocating)
word_type ... what word type parse as
+ CFG_PARAMETER ... parameter
- + CFG_VALUE ....... value
+ + CFG_VALUE ....... value
+ CFG_SECTION ..... section
OUTPUT new current pointer (on error, return NULL)
-------------------------------------------------- */
@@ -524,7 +524,7 @@
long tmp;
unsigned long utmp;
float ftmp;
- float dtmp;
+ double dtmp;
char *endptr;
char *strptr;
cfgList *listptr;
@@ -656,7 +656,7 @@
return (CFG_NO_ERROR);
case CFG_FLOAT:
- ftmp = strtod(value, &endptr);
+ ftmp = (float)strtod(value, &endptr);
if (*endptr) {
return (CFG_INVALID_NUMBER);
}
@@ -704,7 +704,7 @@
line ....... pointer to current working line
type ....... file type
section .... section number
- parameter_buf ... for error handling
+ parameter_buf ... for error handling
parameter_line .. for error handling
OUTPUT CFG_NO_ERROR on success, CFG_JUST_RETURN_WITHOUT_MSG otherwise
-------------------------------------------------- */
@@ -1000,8 +1000,8 @@
/* --------------------------------------------------
NAME dump_simple
- FUNCTION
- INPUT
+ FUNCTION
+ INPUT
OUTPUT 0 on success, -1 on error
-------------------------------------------------- */
static int dump_simple(FILE *fp, cfgStruct cfg[], cfgFileType type)
@@ -1057,8 +1057,8 @@
/* --------------------------------------------------
NAME dump_ini
- FUNCTION
- INPUT
+ FUNCTION
+ INPUT
OUTPUT 0 on success, -1 on error
-------------------------------------------------- */
static int dump_ini(FILE *fp, cfgStruct cfg[], cfgFileType type, int max)
@@ -1120,8 +1120,8 @@
/* --------------------------------------------------
NAME single_or_double_quote
- FUNCTION
- INPUT
+ FUNCTION
+ INPUT
OUTPUT none
-------------------------------------------------- */
static void single_or_double_quote(const char *str, char *ret)
@@ -1140,8 +1140,8 @@
/* --------------------------------------------------
NAME fetch_simple
- FUNCTION
- INPUT
+ FUNCTION
+ INPUT
OUTPUT 0 on success, -1 on error
-------------------------------------------------- */
static int fetch_simple(const char *file, FILE *fp, char *parameter_name, void *result_value, cfgValueType value_type)
@@ -1229,8 +1229,8 @@
/* --------------------------------------------------
NAME fetch_ini
- FUNCTION
- INPUT
+ FUNCTION
+ INPUT
OUTPUT 0 on success, -1 on error
-------------------------------------------------- */
static int fetch_ini(const char *file, FILE *fp, char *parameter_name, void *result_value, cfgValueType value_type, int section_num, const char *section_name)
Modified: Webware/trunk/WebKit/Adapters/common/wkcommon.c
==============================================================================
--- Webware/trunk/WebKit/Adapters/common/wkcommon.c (original)
+++ Webware/trunk/WebKit/Adapters/common/wkcommon.c Sun Apr 8 14:00:36 2007
@@ -1,4 +1,3 @@
-
/* Common Functions */
#include "wkcommon.h"
@@ -9,8 +8,6 @@
#include "parsecfg.h"
DictHolder* createDicts(EnvItem ** envItems) {
-
-
char *key, *val;
int i=0;
int length=0;
@@ -18,193 +15,176 @@
WFILE* env_dict= NULL;
WFILE* whole_dict=NULL;
DictHolder* dictholder;
- char msg[500];
+ // char msg[500];
- dictholder = calloc(sizeof(DictHolder),1);
+ dictholder = calloc(sizeof(DictHolder),1);
dictholder->int_dict = NULL;
dictholder->whole_dict = NULL;
env_dict = setup_WFILE();
- whole_dict = setup_WFILE();
+ whole_dict = setup_WFILE();
int_dict = setup_WFILE();
-
if (env_dict == NULL || whole_dict == NULL || int_dict == NULL) {
- log_message("Couldn't allocate python data structures");
+ log_message("Couldn't allocate Python data structures");
return dictholder;
}
+ // log_message("extracted environ");
-
-
-// log_message("extracted environ");
-
- //start dictionary
+ // start dictionary
w_byte(TYPE_DICT, env_dict);
-
for (i = 0; envItems[i] != NULL; i++) {
key = envItems[i]->key;
val = envItems[i]->val;
- //sprintf(msg, "Adding dict key=%.100s, val=%.100s", key, val);
- //log_message(msg);
+ // sprintf(msg, "Adding dict key=%.100s, val=%.100s", key, val);
+ // log_message(msg);
write_string(key, (int) strlen(key), env_dict);
if (val != NULL) write_string(val, strlen(val), env_dict);
else w_byte(TYPE_NONE, env_dict);
}
w_byte(TYPE_NULL, env_dict);
- //end dictionary
+ // end dictionary
log_message("Built env dictionary");
-
- //We can start building the full dictionary now
+ // We can start building the full dictionary now
w_byte(TYPE_DICT, whole_dict);
write_string("format", 6, whole_dict); //key
write_string("CGI", 3, whole_dict); //value
write_string("time", 4, whole_dict); //key
w_byte(TYPE_INT, whole_dict); //value
-//This won't work. Marshal converts this from a float to a string, I have neither. Floats are ugly.
+ // This won't work. Marshal converts this from a float to a string,
+ // I have neither. Floats are ugly.
w_long((long)time(0), whole_dict);//value
write_string("environ", 7, whole_dict); //key
- //copy env_dict into whole_dict
- insert_data(whole_dict, env_dict);
+ // copy env_dict into whole_dict
+ insert_data(whole_dict, env_dict);
freeWFILE(env_dict); //free this dict as we don't need it any longer
-
- //that should be it
- //end dictionary
+ // that should be it
+ // end dictionary
w_byte(TYPE_NULL, whole_dict);
- //Setup the integer dict
+ // Setup the integer dict
length = whole_dict->ptr - whole_dict->str;
write_integer((int)length, int_dict);
dictholder->int_dict = int_dict;
dictholder->whole_dict = whole_dict;
- //now we send it
-
- return dictholder;
+ //now we send it
+ return dictholder;
}
-
-
-
-
/* ========================================================================= */
/* Open a socket to appserver host */
-/* Taken from apache jserv.
+/* Taken from apache jserv.
/*
/* ======================================================================== */
int wksock_open(unsigned long address, int port) {
- struct sockaddr_in addr;
- int sock;
- int ret;
-
- /* Check if we have a valid host address */
- if (address==0) {
-// log_message("cannot connect to unspecified host");
- return -1;
- }
+ struct sockaddr_in addr;
+ int sock;
+ int ret;
+
+ /* Check if we have a valid host address */
+ if (address==0) {
+ // log_message("cannot connect to unspecified host");
+ return -1;
+ }
- /* Check if we have a valid port number. */
- if (port < 1024) {
-// log_message("invalid port, must be geater than 1024");
- //port = 8007;
- }
- addr.sin_addr.s_addr = address;
- addr.sin_port = htons((unsigned short)port);
- addr.sin_family = AF_INET;
-
- /* Open the socket */
- sock = socket( AF_INET, SOCK_STREAM, 0);
- if (sock==-1) {
+ /* Check if we have a valid port number. */
+ if (port < 1024) {
+ // log_message("invalid port, must be geater than 1024");
+ //port = 8007;
+ }
+ addr.sin_addr.s_addr = address;
+ addr.sin_port = htons((unsigned short)port);
+ addr.sin_family = AF_INET;
+
+ /* Open the socket */
+ sock = socket( AF_INET, SOCK_STREAM, 0);
+ if (sock==-1) {
#ifndef WIN32
- return -1;
-#else
+ return -1;
+#else
int err = WSAGetLastError();
return -1;
#endif
}
- /* Tries to connect to appserver (continues trying while error is EINTR) */
- do {
- ret=connect(sock,(struct sockaddr *)&addr,sizeof(struct sockaddr_in));
-#ifdef WIN32
- if (ret==SOCKET_ERROR) errno=WSAGetLastError()-WSABASEERR;
-#endif /* WIN32 */
- } while (ret==-1 && (errno==EINTR || errno == EAGAIN));
-
- /* Check if we connected */
- if (ret==-1) {
-// log_message("Can not connect to WebKit AppServer");
- return -1;
- }
-#ifdef TCP_NODELAY
- {
- int set = 1;
- setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&set,
- sizeof(set));
- }
-#endif
+ /* Tries to connect to appserver (continues trying while error is EINTR) */
+ do {
+ ret=connect(sock,(struct sockaddr *)&addr,sizeof(struct sockaddr_in));
+ #ifdef WIN32
+ if (ret==SOCKET_ERROR) errno=WSAGetLastError()-WSABASEERR;
+ #endif /* WIN32 */
+ } while (ret==-1 && (errno==EINTR || errno == EAGAIN));
+
+ /* Check if we connected */
+ if (ret==-1) {
+ // log_message("Can not connect to WebKit AppServer");
+ return -1;
+ }
+ #ifdef TCP_NODELAY
+ {
+ int set = 1;
+ setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&set,
+ sizeof(set));
+ }
+ #endif
- /* Return the socket number */
- return sock;
+ /* Return the socket number */
+ return sock;
}
-
-
/* ========================================================================= */
/* Returns a unsigned long representing the ip address of a string */
/* ========================================================================= */
unsigned long resolve_host(char *value) {
- int x;
+ int x;
- /* Check if we only have digits in the string */
- for (x=0; value[x]!='\0'; x++)
- if (!isdigit(value[x]) && value[x] != '.') break;
-
- if (value[x] != '\0') {
- /* If we found also characters we use gethostbyname()*/
- struct hostent *host;
-
- host=gethostbyname(value);
- if (host==NULL) return 0;
- return ((struct in_addr *)host->h_addr_list[0])->s_addr;
- } else {
- /* If we found only digits we use inet_addr() */
- return inet_addr(value);
- }
- return 0;
+ /* Check if we only have digits in the string */
+ for (x=0; value[x]!='\0'; x++)
+ if (!isdigit(value[x]) && value[x] != '.') break;
+
+ if (value[x] != '\0') {
+ /* If we found also characters we use gethostbyname()*/
+ struct hostent *host;
+
+ host=gethostbyname(value);
+ if (host==NULL) return 0;
+ return ((struct in_addr *)host->h_addr_list[0])->s_addr;
+ } else {
+ /* If we found only digits we use inet_addr() */
+ return inet_addr(value);
+ }
+ return 0;
}
-
-
-
/* ====================================================== */
/* Initialize the WFILE structure
* This is used by the marshalling functions.
/* ======================================================= */
-struct WFILE* setup_WFILE()
-{
+struct WFILE* setup_WFILE() {
struct WFILE* wf = NULL;
wf = calloc(sizeof(WFILE),1);
if (wf == NULL) {
-// log_message("Failed to get WFILE structure\n");
- return wf;
+ // log_message("Failed to get WFILE structure\n");
+ return wf;
}
wf->str = NULL; wf->ptr = NULL; wf->end = NULL;
wf->str = calloc(4096,1);
if (wf->str == NULL) {
-// log_message("Couldn't allocate memory");
- return NULL;
+ // log_message("Couldn't allocate memory");
+ return NULL;
}
wf->end = wf->str + 4096;
wf->ptr = wf->str;
@@ -218,37 +198,29 @@
return 1;
}
-
-
-
Configuration* GetConfiguration(Configuration* config, char* configFile) {
-
- FILE* cfgfile;
- struct stat statbuf;
- int result;
- int size;
- char* host;
- char* portstr;
+ // FILE* cfgfile;
+ // struct stat statbuf;
+ // int result;
+ // int size;
+ // char* host;
+ // char* portstr;
int mark=0;
- int port;
- char c;
- // Configuration* config;
+ // int port;
+ // char c;
+ // Configuration* config;
int rv;
- // config = malloc(sizeof(Configuration));
+ // config = malloc(sizeof(Configuration));
-
cfgStruct cfg[]={ /* this must be initialized */
- /* parameter type address of variable */
- {"Host", CFG_STRING, &config->host },
- {"Port", CFG_INT, (int*)&(config->port) },
- {"MaxConnectAttempts", CFG_INT, (int*)&(config->retry_attempts) },
- {"ConnectRetryDelay", CFG_INT, (int*)&(config->retry_delay) },
+ /* parameter type address of variable */
+ {"Host", CFG_STRING, &config->host },
+ {"Port", CFG_INT, (int*)&(config->port) },
+ {"MaxConnectAttempts", CFG_INT, (int*)&(config->retry_attempts)},
+ {"ConnectRetryDelay", CFG_INT, (int*)&(config->retry_delay) },
};
-
-
-
config->host = "localhost";
config->port = 8086;
config->retry_attempts = 10;
@@ -256,21 +228,19 @@
log_message("Trying to parse config file");
- rv = cfgParse(configFile, cfg, CFG_SIMPLE);
+ rv = cfgParse(configFile, cfg, CFG_SIMPLE);
log_message("Got config");
if(rv == -1) {
- log_message("Whoops, Couldn't get config info");
+ log_message("Whoops, Couldn't get config info");
}
-// fprintf(stderr, "Host: %s\n",config->host);
-// fprintf(stderr, "Port: %i\n", config->port);
-
-// fprintf(stderr, "Attempts: %i\n",config->retry_attempts);
-// fprintf(stderr, "Delay: %i\n", config->retry_delay);
-
+ // fprintf(stderr, "Host: %s\n",config->host);
+ // fprintf(stderr, "Port: %i\n", config->port);
+ // fprintf(stderr, "Attempts: %i\n",config->retry_attempts);
+ // fprintf(stderr, "Delay: %i\n", config->retry_delay);
return config;
@@ -282,7 +252,7 @@
host = malloc(size+1);
portstr = malloc(size+1);
cfgfile = open(configFile, "r");
-
+
c = fgetc(cfgfile);
while (c != ":") {
*(host+mark) = c;
Modified: Webware/trunk/WebKit/Adapters/common/wkcommon.h
==============================================================================
--- Webware/trunk/WebKit/Adapters/common/wkcommon.h (original)
+++ Webware/trunk/WebKit/Adapters/common/wkcommon.h Sun Apr 8 14:00:36 2007
@@ -1,4 +1,3 @@
-
/* wkcommon.h */
#include <stdlib.h>
@@ -33,8 +32,7 @@
typedef struct {
WFILE* int_dict;
WFILE* whole_dict;
-} DictHolder;
-
+} DictHolder;
typedef struct {
char* host;
@@ -43,10 +41,10 @@
int retry_delay;
} Configuration;
+int log_message(char* msg);
DictHolder* createDicts(EnvItem ** envItems);
int wksock_open(unsigned long address, int port);
unsigned long resolve_host(char *value);
struct WFILE* setup_WFILE();
-int freeWFILE(struct WFILE* wf);
+int freeWFILE(struct WFILE* wf);
Configuration* GetConfiguration(Configuration*, char*);
-
Modified: Webware/trunk/WebKit/Adapters/wkcgi/README
==============================================================================
--- Webware/trunk/WebKit/Adapters/wkcgi/README (original)
+++ Webware/trunk/WebKit/Adapters/wkcgi/README Sun Apr 8 14:00:36 2007
@@ -6,7 +6,7 @@
It'll retry the connection 10 times with a delay of 1 second between retries.
To change any of these parameters, put a file name webkit.cfg in the same
-directory as the cgi executable. A sample file is included here.
+directory as the CGI executable. A sample file is included here.
Build Instructions:
@@ -15,7 +15,8 @@
adapt the LIBS setting in the Makefile before.
On Windows:
-A VC6 project file is included.
+If you have the free Microsoft Visual C++ 2005 Express Edition and the
+Microsoft Platform SDK installed, use the 'make.bat' batch file.
You will be able to get prebuilt binaries from webware.sourceforge.net.
If you don't see any there, ask on the webware-discuss mailing list.
Added: Webware/trunk/WebKit/Adapters/wkcgi/make.bat
==============================================================================
--- (empty file)
+++ Webware/trunk/WebKit/Adapters/wkcgi/make.bat Sun Apr 8 14:00:36 2007
@@ -0,0 +1,27 @@
+@echo off
+
+rem Batch file for generating the wkcgi.exe CGI executable.
+
+rem You need to have the following freely available tools installed:
+rem (see http://msdn.microsoft.com/vstudio/express/downloads/):
+rem - Microsoft Visual C++ 2005 Express Edition
+rem - Microsoft Platform SDK for Microsoft Visual C++ 2005 Express
+rem (Microsoft Windows Server 2003 R2 Platform SDK)
+
+rem Set environment variables
+
+set VC=%ProgramFiles%\Microsoft Visual Studio 8\VC
+set SDK=%ProgramFiles%\Microsoft Platform SDK for Windows Server 2003 R2
+set APACHE=%ProgramFiles%\Apache Software Foundation\Apache2.2
+
+call "%VC%\vcvarsall" x86
+call "%SDK%\setenv" /XP32
+
+rem Compile and link wkcgi
+
+cl /W3 /O2 /EHsc /wd4996 ^
+ /D "WIN32" /D "_CONSOLE" /D "_MBCS" ^
+ wkcgi.c ^
+ ..\common\wkcommon.c ..\common\marshal.c ^
+ ..\common\environ.c ..\common\parsecfg.c ^
+ /link wsock32.lib /subsystem:console
Modified: Webware/trunk/WebKit/Adapters/wkcgi/webkit.cfg
==============================================================================
--- Webware/trunk/WebKit/Adapters/wkcgi/webkit.cfg (original)
+++ Webware/trunk/WebKit/Adapters/wkcgi/webkit.cfg Sun Apr 8 14:00:36 2007
@@ -2,4 +2,3 @@
Port = 8086
MaxConnectAttempts = 10
ConnectRetryDelay = 1
-
Modified: Webware/trunk/WebKit/Adapters/wkcgi/wkcgi.c
==============================================================================
--- Webware/trunk/WebKit/Adapters/wkcgi/wkcgi.c (original)
+++ Webware/trunk/WebKit/Adapters/wkcgi/wkcgi.c Sun Apr 8 14:00:36 2007
@@ -1,26 +1,15 @@
-//wkcgi.c
+// wkcgi.c
#include <stdlib.h>
#include <stdio.h>
#include "wkcgi.h"
-
-
-
-
-
-
-
int log_message(char * msg) {
-// fprintf (stderr, msg);
- return 0;
+ // fprintf (stderr, msg);
+ return 0;
}
-
-
-
int sendCgiRequest(int sock, DictHolder* alldicts) {
-
int bs = 0;
int length=0;
int totalsent=0;
@@ -28,13 +17,12 @@
char *buffer;
int buflen=8092;
char *len_str;
-
-
+
bs = send( sock, alldicts->int_dict->str, alldicts->int_dict->ptr - alldicts->int_dict->str, 0);
bs = 0;
length = alldicts->whole_dict->ptr - alldicts->whole_dict->str;
- while (totalsent < length) {
+ while (totalsent < length) {
bs = send( sock, alldicts->whole_dict->str + totalsent, buflen>(length-totalsent)?length-totalsent:buflen, 0);
if( bs < 0 ) {
log_message("send() returned error code");
@@ -55,7 +43,7 @@
int amount_to_send=0;
content_length = atoi(getenv("CONTENT_LENGTH"));
log_message("There is post data");
- buffer = (char*) calloc(8092,1);
+ buffer = (char*) calloc(8092, 1);
while (read < content_length) {
amount_to_read = content_length-read;
if( amount_to_read > 8092 ) {
@@ -71,7 +59,7 @@
return -1;
}
}
- read = read + read_this_time;
+ read += read_this_time;
amount_to_send = read_this_time;
while( amount_to_send > 0 ) {
sent_this_time = send(sock, buffer+(read_this_time-amount_to_send), amount_to_send, 0);
@@ -89,23 +77,23 @@
//Let the AppServer know we're done
shutdown(sock, 1);
-
+
return 0;
}
int processCgiResponse(sock) {
- char* buff;
- int buflen = 8092;
- int br;
-
- buff = calloc(buflen,1);
- do {
- br = recv(sock, buff, buflen, 0);
- fwrite(buff, br, 1, stdout);
- } while (br > 0);
+ char* buff;
+ int buflen = 8092;
+ int br;
+
+ buff = calloc(buflen,1);
+ do {
+ br = recv(sock, buff, buflen, 0);
+ fwrite(buff, br, 1, stdout);
+ } while (br > 0);
- return 1;
+ return 1;
}
@@ -114,32 +102,32 @@
WORD wVersionRequested;
WSADATA wsaData;
int err;
-
+
_setmode(_fileno(stdin), _O_BINARY);
_setmode(_fileno(stdout), _O_BINARY);
wVersionRequested = MAKEWORD( 1, 0 );
-
+
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
- /* Tell the user that we could not find a usable */
- /* WinSock DLL. */
+ /* Tell the user that we could not find a usable */
+ /* WinSock DLL. */
return 0;
}
return 1;
}
-#endif
+#endif
int main(char* argc, char* argv[]) {
int sock = 0;
DictHolder* dicts;
char msgbuf[500];
- // char* addrstr = /*"localhost";//*/ "127.0.0.1";
- // int port = 8086;
+ // char* addrstr = /*"localhost";//*/ "127.0.0.1";
+ // int port = 8086;
unsigned long addr;
EnvItem **envItems;
- // int retryattempts = 10;
- // int retrydelay = 1;
+ // int retryattempts = 10;
+ // int retrydelay = 1;
int retrycount = 0;
Configuration* config;
#ifdef WIN32
@@ -171,32 +159,31 @@
#else
GetConfiguration(config, ConfigFilename);
#endif
-
- // retryattempts = config->retry_attempts;
- // retrydelay = config->retry_delay;
- // addrstr = config->host;
- // port = config->port;
+
+ // retryattempts = config->retry_attempts;
+ // retrydelay = config->retry_delay;
+ // addrstr = config->host;
+ // port = config->port;
addr = resolve_host(config->host); //(addrstr);
log_message("Got addr translation");
-
/* while (sock < 0) {
sock = wksock_open(addr, config->port);
}
*/
while (sock <= 0 ) {
- sock = wksock_open(addr, config->port);
- if (sock > 0 || (retrycount > config->retry_attempts)) break;
- // if (errno != EAGAIN) break;
- sprintf(msgbuf, "Couldn't connect to AppServer,attempt %i of %i", retrycount, config->retry_attempts);
- log_message(msgbuf);
- retrycount++;
+ sock = wksock_open(addr, config->port);
+ if (sock > 0 || (retrycount > config->retry_attempts)) break;
+ // if (errno != EAGAIN) break;
+ sprintf(msgbuf, "Couldn't connect to AppServer,attempt %i of %i", retrycount, config->retry_attempts);
+ log_message(msgbuf);
+ retrycount++;
#ifdef WIN32
- Sleep(config->retry_delay*1000);
+ Sleep(config->retry_delay*1000);
#else
- sleep(config->retry_delay);
+ sleep(config->retry_delay);
#endif
}
@@ -223,7 +210,3 @@
return 0;
}
-
-
-
-
Modified: Webware/trunk/WebKit/Adapters/wkcgi/wkcgi.exe
==============================================================================
Binary files. No diff available.
Modified: Webware/trunk/WebKit/Adapters/wkcgi/wkcgi.h
==============================================================================
--- Webware/trunk/WebKit/Adapters/wkcgi/wkcgi.h (original)
+++ Webware/trunk/WebKit/Adapters/wkcgi/wkcgi.h Sun Apr 8 14:00:36 2007
@@ -1,14 +1,9 @@
-
-
-
-
+// wkcgi.h
#include "../common/wkcommon.h"
#include "../common/marshal.h"
-
-
int log_message(char* msg);
unsigned long resolve_host(char *value);
int wksock_open(unsigned long address, int port);
-//DictHolder createDicts(EnvItem ** envItems);
+// DictHolder createDicts(EnvItem ** envItems);
|