Skip to content

Commit

Permalink
Removed Win32 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgdavidson committed Nov 5, 2001
1 parent 50b3378 commit 477565d
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 136 deletions.
35 changes: 13 additions & 22 deletions nscgi/nscgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/


static const char *RCSID = "@(#) $Header: /Users/dossy/Desktop/cvs/aolserver/nscgi/nscgi.c,v 1.13 2001/04/26 18:43:10 jgdavidson Exp $, compiled: " __DATE__ " " __TIME__;
static const char *RCSID = "@(#) $Header: /Users/dossy/Desktop/cvs/aolserver/nscgi/nscgi.c,v 1.14 2001/11/05 20:30:38 jgdavidson Exp $, compiled: " __DATE__ " " __TIME__;

#include "ns.h"
#include <sys/stat.h>
Expand All @@ -44,14 +44,6 @@ static const char *RCSID = "@(#) $Header: /Users/dossy/Desktop/cvs/aolserver/nsc
#define CGI_ECONTENT 4
#define CGI_SYSENV 8

#ifdef WIN32
#define S_ISREG(m) ((m)&_S_IFREG)
#define S_ISDIR(m) ((m)&_S_IFDIR)
#define DEVNULL "nul:"
#else
#define DEVNULL "/dev/null"
#endif

/*
* The following structure is allocated for each instance the module is
* loaded (normally just once).
Expand Down Expand Up @@ -137,7 +129,7 @@ static char *NextWord(char *s);
static void SetAppend(Ns_Set *set, int index, char *sep, char *value);
static void SetUpdate(Ns_Set *set, char *key, char *value);

NS_EXPORT int Ns_ModuleVersion = 1;
int Ns_ModuleVersion = 1;


/*
Expand All @@ -157,7 +149,7 @@ NS_EXPORT int Ns_ModuleVersion = 1;
*----------------------------------------------------------------------
*/

NS_EXPORT int
int
Ns_ModuleInit(char *server, char *module)
{
char *path, *key, *value, *section;
Expand All @@ -169,15 +161,14 @@ Ns_ModuleInit(char *server, char *module)

/*
* On the first (and likely only) load, register
* the temp file cleanup routine and open devNull
* the temp file cleanup routine and open /dev/null
* for requests without content data.
*/

if (!initialized) {
devNull = open(DEVNULL, O_RDONLY);
devNull = open("/dev/null", O_RDONLY);
if (devNull < 0) {
Ns_Log(Error, "nscgi: open(%s) failed: %s",
DEVNULL, strerror(errno));
Ns_Log(Error, "nscgi: open(/dev/null) failed: %s", strerror(errno));
return NS_ERROR;
}
Ns_DupHigh(&devNull);
Expand All @@ -189,7 +180,7 @@ Ns_ModuleInit(char *server, char *module)
* Config basic options.
*/

path = Ns_ConfigPath(server, module, NULL);
path = Ns_ConfigGetPath(server, module, NULL);
modPtr = ns_calloc(1, sizeof(Mod));
modPtr->module = module;
modPtr->server = server;
Expand All @@ -214,20 +205,20 @@ Ns_ModuleInit(char *server, char *module)
*/

Ns_DStringInit(&ds);
section = Ns_ConfigGet(path, "interps");
section = Ns_ConfigGetValue(path, "interps");
if (section != NULL) {
Ns_DStringVarAppend(&ds, "ns/interps/", section, NULL);
modPtr->interps = Ns_ConfigSection(ds.string);
modPtr->interps = Ns_ConfigGetSection(ds.string);
if (modPtr->interps == NULL) {
Ns_Log(Warning, "nscgi: no such interps section: %s",
ds.string);
}
Ns_DStringTrunc(&ds, 0);
}
section = Ns_ConfigGet(path, "environment");
section = Ns_ConfigGetValue(path, "environment");
if (section != NULL) {
Ns_DStringVarAppend(&ds, "ns/environment/", section, NULL);
modPtr->mergeEnv = Ns_ConfigSection(ds.string);
modPtr->mergeEnv = Ns_ConfigGetSection(ds.string);
if (modPtr->mergeEnv == NULL) {
Ns_Log(Warning, "nscgi: no such environment section: %s",
ds.string);
Expand All @@ -245,7 +236,7 @@ Ns_ModuleInit(char *server, char *module)
* Register all requested mappings.
*/

set = Ns_ConfigSection(path);
set = Ns_ConfigGetSection(path);
for (i = 0; set != NULL && i < Ns_SetSize(set); ++i) {
key = Ns_SetKey(set, i);
value = Ns_SetValue(set, i);
Expand Down Expand Up @@ -543,7 +534,7 @@ CgiInit(Cgi *cgiPtr, Map *mapPtr, Ns_Conn *conn)
if (e != NULL) {
*e = '\0';
}
cgiPtr->interpEnv = Ns_ConfigSection(s);
cgiPtr->interpEnv = Ns_ConfigGetSection(s);
}
}
if (cgiPtr->interp != NULL) {
Expand Down
28 changes: 14 additions & 14 deletions nscp/nscp.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* Tcl commands.
*/

static const char *RCSID = "@(#) $Header: /Users/dossy/Desktop/cvs/aolserver/nscp/nscp.c,v 1.15 2001/03/16 22:22:02 jgdavidson Exp $, compiled: " __DATE__ " " __TIME__;
static const char *RCSID = "@(#) $Header: /Users/dossy/Desktop/cvs/aolserver/nscp/nscp.c,v 1.16 2001/11/05 20:30:38 jgdavidson Exp $, compiled: " __DATE__ " " __TIME__;

#include "ns.h"

Expand All @@ -61,14 +61,14 @@ static Ns_ThreadProc EvalThread;
typedef struct Sess {
Mod *modPtr;
int id;
SOCKET sock;
int sock;
struct sockaddr_in sa;
} Sess;

static Ns_SockProc AcceptProc;
static Tcl_CmdProc ExitCmd;
static int Login(Sess *sessPtr);
static int GetLine(SOCKET sock, char *prompt, Tcl_DString *dsPtr, int echo);
static int GetLine(int sock, char *prompt, Tcl_DString *dsPtr, int echo);
static Ns_ArgProc ArgProc;

/*
Expand All @@ -90,7 +90,7 @@ static unsigned char dont_echo[] = {TN_IAC, TN_DONT, TN_ECHO};
static unsigned char will_echo[] = {TN_IAC, TN_WILL, TN_ECHO};
static unsigned char wont_echo[] = {TN_IAC, TN_WONT, TN_ECHO};

NS_EXPORT int Ns_ModuleVersion = 1;
int Ns_ModuleVersion = 1;


/*
Expand All @@ -111,13 +111,13 @@ NS_EXPORT int Ns_ModuleVersion = 1;
*----------------------------------------------------------------------
*/

NS_EXPORT int
int
Ns_ModuleInit(char *server, char *module)
{
Mod *modPtr;
char *path, *addr, *pass, *user, *key, *end;
int i, new, port;
SOCKET lsock;
int lsock;
Ns_Set *set;
Tcl_HashEntry *hPtr;

Expand All @@ -126,13 +126,13 @@ Ns_ModuleInit(char *server, char *module)
*/

path = Ns_ConfigGetPath(server, module, NULL);
if (((addr = Ns_ConfigGet(path, "address")) == NULL)
if (((addr = Ns_ConfigGetValue(path, "address")) == NULL)
|| (!Ns_ConfigGetInt(path, "port", &port)) ) {
Ns_Log(Error, "nscp: address and port must be specified in config");
return NS_ERROR;
}
lsock = Ns_SockListen(addr, port);
if (lsock == INVALID_SOCKET) {
if (lsock == -1) {
Ns_Log(Error, "nscp: could not listen on %s:%d", addr, port);
return NS_ERROR;
}
Expand Down Expand Up @@ -244,7 +244,7 @@ ArgProc(Tcl_DString *dsPtr, void *arg)
*/

static int
AcceptProc(SOCKET lsock, void *arg, int why)
AcceptProc(int lsock, void *arg, int why)
{
Mod *modPtr = arg;
Sess *sessPtr;
Expand All @@ -253,16 +253,16 @@ AcceptProc(SOCKET lsock, void *arg, int why)

if (why == NS_SOCK_EXIT) {
Ns_Log(Notice, "nscp: shutdown");
ns_sockclose(lsock);
close(lsock);
return NS_FALSE;
}
sessPtr = ns_malloc(sizeof(Sess));
sessPtr->modPtr = modPtr;
len = sizeof(struct sockaddr_in);
sessPtr->sock = Ns_SockAccept(lsock, (struct sockaddr *) &sessPtr->sa, &len);
if (sessPtr->sock == INVALID_SOCKET) {
if (sessPtr->sock == -1) {
Ns_Log(Error, "nscp: accept() failed: %s",
ns_sockstrerror(ns_sockerrno));
strerror(errno));
ns_free(sessPtr);
} else {
sessPtr->id = ++next;
Expand Down Expand Up @@ -364,7 +364,7 @@ EvalThread(void *arg)
Ns_TclDeAllocateInterp(interp);
}
Ns_Log(Notice, "nscp: disconnect: %s", ns_inet_ntoa(sessPtr->sa.sin_addr));
ns_sockclose(sessPtr->sock);
close(sessPtr->sock);
ns_free(sessPtr);
}

Expand All @@ -387,7 +387,7 @@ EvalThread(void *arg)
*/

static int
GetLine(SOCKET sock, char *prompt, Tcl_DString *dsPtr, int echo)
GetLine(int sock, char *prompt, Tcl_DString *dsPtr, int echo)
{
unsigned char buf[2048];
int n;
Expand Down
20 changes: 10 additions & 10 deletions nsd/listen.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* connections.
*/

static const char *RCSID = "@(#) $Header: /Users/dossy/Desktop/cvs/aolserver/nsd/listen.c,v 1.3 2000/08/02 23:38:25 kriston Exp $, compiled: " __DATE__ " " __TIME__;
static const char *RCSID = "@(#) $Header: /Users/dossy/Desktop/cvs/aolserver/nsd/listen.c,v 1.4 2001/11/05 20:26:23 jgdavidson Exp $, compiled: " __DATE__ " " __TIME__;

#include "nsd.h"

Expand Down Expand Up @@ -84,7 +84,7 @@ Ns_SockListenCallback(char *addr, int port, Ns_SockProc *proc, void *arg)
{
Tcl_HashEntry *hPtr;
Tcl_HashTable *tablePtr;
SOCKET new, sock;
int new, sock;
ListenData *ldPtr;
int status;
struct sockaddr_in sa;
Expand All @@ -100,10 +100,10 @@ Ns_SockListenCallback(char *addr, int port, Ns_SockProc *proc, void *arg)

sa.sin_port = 0;
sock = Ns_SockBind(&sa);
if (sock == INVALID_SOCKET) {
if (sock == -1) {
return NS_ERROR;
}
ns_sockclose(sock);
close(sock);
}
status = NS_OK;
Ns_MutexLock(&lock);
Expand All @@ -123,7 +123,7 @@ Ns_SockListenCallback(char *addr, int port, Ns_SockProc *proc, void *arg)
tablePtr = Tcl_GetHashValue(hPtr);
} else {
sock = Ns_SockListen(NULL, port);
if (sock == INVALID_SOCKET) {
if (sock == -1) {
Tcl_DeleteHashEntry(hPtr);
status = NS_ERROR;
} else {
Expand Down Expand Up @@ -199,22 +199,22 @@ Ns_SockPortBound(int port)
*/

static int
ListenCallback(SOCKET sock, void *arg, int why)
ListenCallback(int sock, void *arg, int why)
{
struct sockaddr_in sa;
int len;
Tcl_HashTable *tablePtr;
Tcl_HashEntry *hPtr;
SOCKET new;
int new;
ListenData *ldPtr;

tablePtr = arg;
if (why == NS_SOCK_EXIT) {
ns_sockclose(sock);
close(sock);
return NS_FALSE;
}
new = Ns_SockAccept(sock, NULL, NULL);
if (new != INVALID_SOCKET) {
if (new != -1) {
Ns_SockSetBlocking(new);
len = sizeof(sa);
getsockname(new, (struct sockaddr *) &sa, &len);
Expand All @@ -229,7 +229,7 @@ ListenCallback(SOCKET sock, void *arg, int why)
}
Ns_MutexUnlock(&lock);
if (ldPtr == NULL) {
ns_sockclose(new);
close(new);
} else {
(*ldPtr->proc) (new, ldPtr->arg, why);
}
Expand Down
Loading

0 comments on commit 477565d

Please sign in to comment.