6 |
#include "errno.h" |
#include "errno.h" |
7 |
#include "signal.h" |
#include "signal.h" |
8 |
#include "stdlib.h" |
#include "stdlib.h" |
9 |
|
extern void sigint ( int ); |
10 |
|
|
11 |
#ifdef DODEBUG |
#ifdef DODEBUG |
12 |
#define dprintf(s,arg) \ |
#define dprintf(s,arg) \ |
86 |
static int SocketsEnabled(); |
static int SocketsEnabled(); |
87 |
static void close_winsock(); |
static void close_winsock(); |
88 |
extern void doReverse ( char *s, int n ); |
extern void doReverse ( char *s, int n ); |
89 |
|
extern void init_shared_memory (void); |
90 |
|
|
91 |
|
unsigned int shared_memory_initialised = FALSE; |
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
/* |
/* |
861 |
} |
} |
862 |
|
|
863 |
void init_shared_memory (void) |
void init_shared_memory (void) |
864 |
{ |
{ |
865 |
sprintf(sharedMemory.name,"gcl-%d",getpid()); |
if ( ! shared_memory_initialised ) { |
866 |
sharedMemory.handle = |
sprintf(sharedMemory.name,"gcl-%d",getpid()); |
867 |
CreateFileMapping((HANDLE)-1, NULL, PAGE_READWRITE, 0, sharedMemory.length , TEXT (sharedMemory.name)); |
sharedMemory.handle = |
868 |
if (sharedMemory.handle == NULL) |
CreateFileMapping((HANDLE)-1, NULL, PAGE_READWRITE, 0, sharedMemory.length , TEXT (sharedMemory.name)); |
869 |
error("CreateFileMapping failed"); |
if (sharedMemory.handle == NULL) |
870 |
sharedMemory.address = |
error("CreateFileMapping failed"); |
871 |
MapViewOfFile(sharedMemory.handle, /* Handle to mapping object. */ |
sharedMemory.address = |
872 |
FILE_MAP_WRITE, /* Read/write permission */ |
MapViewOfFile(sharedMemory.handle, /* Handle to mapping object. */ |
873 |
0, /* Max. object size. */ |
FILE_MAP_WRITE, /* Read/write permission */ |
874 |
0, /* Size of hFile. */ |
0, /* Max. object size. */ |
875 |
0); /* Map entire file. */ |
0, /* Size of hFile. */ |
876 |
if (sharedMemory.address == NULL) |
0); /* Map entire file. */ |
877 |
{ error("MapViewOfFile failed");} |
if (sharedMemory.address == NULL) |
878 |
init_signals_pendingPtr(); |
{ error("MapViewOfFile failed");} |
879 |
atexit(close_shared_memory); |
init_signals_pendingPtr(); |
880 |
|
atexit(close_shared_memory); |
881 |
|
} |
882 |
} |
} |
883 |
|
|
884 |
/* The only signal REALLY handled somewhat under mingw is the |
/* The only signal REALLY handled somewhat under mingw is the |
947 |
|
|
948 |
char *GCLExeName ( void ) |
char *GCLExeName ( void ) |
949 |
{ |
{ |
950 |
static char module_name_buf[PATH_MAX]; |
static char module_name_buf[128]; |
951 |
char *rv = NULL; |
char *rv = NULL; |
952 |
module_name_buf[0] = 0; |
module_name_buf[0] = 0; |
953 |
DWORD result = GetModuleFileName ( (HMODULE) NULL, (LPTSTR) &module_name_buf, PATH_MAX ); |
DWORD result = GetModuleFileName ( (HMODULE) NULL, (LPTSTR) &module_name_buf, 128 ); |
954 |
if ( result > PATH_MAX ) { |
if ( result != 0 ) { |
955 |
fprintf ( stderr, |
rv = module_name_buf; |
|
"GCLExeName: ERROR: GetModuleFileName returned a path larger than %d characters.\n", |
|
|
PATH_MAX ); |
|
|
} else { |
|
|
if ( result != 0 ) { |
|
|
rv = module_name_buf; |
|
|
} |
|
956 |
} |
} |
957 |
return ( (char *) rv ); |
return ( (char *) rv ); |
958 |
} |
} |
959 |
|
|
960 |
|
void WindowsHandlers ( void ) |
961 |
|
{ |
962 |
|
/* SetConsoleCtrlHandler ( (PHANDLER_ROUTINE) sigint, TRUE ); */ |
963 |
|
} |