diff -r -N -c socketmud/src/Makefile socketmud-cygwin/src/Makefile *** socketmud/src/Makefile 2004-07-14 18:45:14.000000000 +0200 --- socketmud-cygwin/src/Makefile 2004-12-12 14:26:42.000000000 +0100 *************** *** 1,5 **** CC = gcc ! C_FLAGS = -Wall -pedantic L_FLAGS = -lz -lpthread -lcrypt O_FILES = socket.o io.o strings.o update.o utils.o interpret.o help.o \ --- 1,5 ---- CC = gcc ! C_FLAGS = -Wall -pedantic -O -DCYGWIN32 -DNOMCCP -DNOCRYPT L_FLAGS = -lz -lpthread -lcrypt O_FILES = socket.o io.o strings.o update.o utils.o interpret.o help.o \ diff -r -N -c socketmud/src/action_safe.c socketmud-cygwin/src/action_safe.c *** socketmud/src/action_safe.c 2003-05-01 23:38:05.000000000 +0200 --- socketmud-cygwin/src/action_safe.c 2004-12-12 14:26:42.000000000 +0100 *************** *** 103,108 **** --- 103,109 ---- } } + #ifndef NOMCCP void cmd_compress(D_MOBILE *dMob, char *arg) { /* no socket, no compression */ *************** *** 126,131 **** --- 127,133 ---- text_to_mobile(dMob, "Compression disabled.\n\r"); } } + #endif void cmd_save(D_MOBILE *dMob, char *arg) { *************** *** 152,158 **** --- 154,162 ---- { dsock_next = dsock->next; + #ifndef NOMCCP compressEnd(dsock, dsock->compressing, FALSE); + #endif if (dsock->state != STATE_PLAYING) { diff -r -N -c socketmud/src/interpret.c socketmud-cygwin/src/interpret.c *** socketmud/src/interpret.c 2002-03-09 19:49:45.000000000 +0100 --- socketmud-cygwin/src/interpret.c 2004-12-12 14:26:42.000000000 +0100 *************** *** 44,50 **** --- 44,52 ---- /* --------------------------------------------- */ { "commands", cmd_commands, LEVEL_GUEST }, + #ifndef NOMCCP { "compress", cmd_compress, LEVEL_GUEST }, + #endif { "copyover", cmd_copyover, LEVEL_GOD }, { "help", cmd_help, LEVEL_GUEST }, { "linkdead", cmd_linkdead, LEVEL_ADMIN }, diff -r -N -c socketmud/src/io.c socketmud-cygwin/src/io.c *** socketmud/src/io.c 2004-07-14 18:37:53.000000000 +0200 --- socketmud-cygwin/src/io.c 2004-12-12 14:26:42.000000000 +0100 *************** *** 13,19 **** --- 13,21 ---- /* include main header file */ #include "mud.h" + #ifndef CYGWIN32 extern FILE *stderr; + #endif time_t current_time; /* diff -r -N -c socketmud/src/mccp.c socketmud-cygwin/src/mccp.c *** socketmud/src/mccp.c 2003-04-02 10:08:25.000000000 +0200 --- socketmud-cygwin/src/mccp.c 2004-12-12 14:26:42.000000000 +0100 *************** *** 17,22 **** --- 17,24 ---- #include "mud.h" + #ifndef NOMCCP + /* local functions */ bool processCompressed ( D_SOCKET *dsock ); *************** *** 161,163 **** --- 163,167 ---- /* success */ return TRUE; } + + #endif diff -r -N -c socketmud/src/mud.h socketmud-cygwin/src/mud.h *** socketmud/src/mud.h 2004-12-12 14:05:53.000000000 +0100 --- socketmud-cygwin/src/mud.h 2004-12-12 14:26:42.000000000 +0100 *************** *** 121,129 **** --- 121,131 ---- sh_int state; sh_int control; sh_int top_output; + #ifndef NOMCCP unsigned char compressing; /* MCCP support */ z_stream * out_compress; /* MCCP support */ unsigned char * out_compress_buf; /* MCCP support */ + #endif }; struct dMobile *************** *** 183,188 **** --- 185,194 ---- extern int control; /* boot control socket thingy */ extern time_t current_time; /* let's cut down on calls to time() */ + #ifdef CYGWIN32 + extern pthread_mutex_t lookup_mutex; /* to lock gethostbyaddr() calls */ + #endif + /*************************** * End of Global Variables * ***************************/ *************** *** 191,196 **** --- 197,204 ---- * MCCP support * ***********************/ + #ifndef NOMCCP + extern const unsigned char compress_will[]; extern const unsigned char compress_will2[]; *************** *** 198,203 **** --- 206,213 ---- #define TELOPT_COMPRESS2 86 #define COMPRESS_BUF_SIZE 8192 + #endif + /*********************** * End of MCCP support * ***********************/ *************** *** 213,219 **** --- 223,233 ---- #define buffer_new(size) __buffer_new ( size) #define buffer_strcat(buffer,text) __buffer_strcat ( buffer, text ) + #ifdef NOCRYPT + #define crypt(s1, s2) (s1) + #else char *crypt ( const char *key, const char *salt ); + #endif /* * socket.c *************** *** 296,302 **** --- 310,318 ---- void cmd_commands ( D_M *dMob, char *arg ); void cmd_who ( D_M *dMob, char *arg ); void cmd_help ( D_M *dMob, char *arg ); + #ifndef NOMCCP void cmd_compress ( D_M *dMob, char *arg ); + #endif void cmd_save ( D_M *dMob, char *arg ); void cmd_copyover ( D_M *dMob, char *arg ); void cmd_linkdead ( D_M *dMob, char *arg ); *************** *** 304,311 **** --- 320,329 ---- /* * mccp.c */ + #ifndef NOMCCP bool compressStart ( D_S *dsock, unsigned char teleopt ); bool compressEnd ( D_S *dsock, unsigned char teleopt, bool forced ); + #endif /* * save.c diff -r -N -c socketmud/src/socket.c socketmud-cygwin/src/socket.c *** socketmud/src/socket.c 2004-12-12 14:06:38.000000000 +0100 --- socketmud-cygwin/src/socket.c 2004-12-12 14:26:42.000000000 +0100 *************** *** 29,36 **** --- 29,38 ---- D_MOBILE * dmobile_list = NULL; /* the mobile list of active mobiles */ /* mccp support */ + #ifndef NOMCCP const unsigned char compress_will [] = { IAC, WILL, TELOPT_COMPRESS, '\0' }; const unsigned char compress_will2 [] = { IAC, WILL, TELOPT_COMPRESS2, '\0' }; + #endif const unsigned char do_echo [] = { IAC, WONT, TELOPT_ECHO, '\0' }; const unsigned char dont_echo [] = { IAC, WILL, TELOPT_ECHO, '\0' }; *************** *** 41,46 **** --- 43,52 ---- bool shut_down = FALSE; int control; + #ifdef CYGWIN32 + pthread_mutex_t lookup_mutex = PTHREAD_MUTEX_INITIALIZER; + #endif + /* * This is where it all starts, nothing special. */ *************** *** 120,126 **** --- 126,136 ---- if (FD_ISSET(control, &rFd)) { struct sockaddr_in sock; + #ifdef CYGWIN32 + int socksize; + #else unsigned int socksize; + #endif int newConnection; socksize = sizeof(sock); *************** *** 342,349 **** --- 352,361 ---- } /* negotiate compression */ + #ifndef NOMCCP text_to_buffer(sock_new, (char *) compress_will2); text_to_buffer(sock_new, (char *) compress_will); + #endif /* send the greeting */ text_to_buffer(sock_new, greeting); *************** *** 450,455 **** --- 462,468 ---- length = strlen(txt); /* write compressed */ + #ifndef NOMCCP if (dsock && dsock->out_compress) { dsock->out_compress->next_in = (unsigned char *) txt; *************** *** 491,496 **** --- 504,510 ---- } return TRUE; } + #endif /* write uncompressed */ for (iPtr = 0; iPtr < length; iPtr += iWrt) *************** *** 744,750 **** void next_cmd_from_buffer(D_SOCKET *dsock) { ! int size = 0, i = 0, j = 0, telopt = 0; /* if theres already a command ready, we return */ if (dsock->next_command[0] != '\0') --- 758,767 ---- void next_cmd_from_buffer(D_SOCKET *dsock) { ! int size = 0, i = 0, j = 0; ! #ifndef NOMCCP ! int telopt = 0; ! #endif /* if theres already a command ready, we return */ if (dsock->next_command[0] != '\0') *************** *** 765,770 **** --- 782,788 ---- /* copy the next command into next_command */ for ( ; i < size; i++) { + #ifndef NOMCCP if (dsock->inbuf[i] == (signed char) IAC) { telopt = 1; *************** *** 792,798 **** compressEnd(dsock, TELOPT_COMPRESS2, FALSE); } } ! else if (isprint(dsock->inbuf[i]) && isascii(dsock->inbuf[i])) { dsock->next_command[j++] = dsock->inbuf[i]; } --- 810,818 ---- compressEnd(dsock, TELOPT_COMPRESS2, FALSE); } } ! else ! #endif ! if (isprint(dsock->inbuf[i]) && isascii(dsock->inbuf[i])) { dsock->next_command[j++] = dsock->inbuf[i]; } *************** *** 1017,1025 **** --- 1037,1060 ---- { LOOKUP_DATA *lData = (LOOKUP_DATA *) arg; struct hostent *from = 0; + #ifndef CYGWIN32 struct hostent ent; char buf[16384]; int err; + #endif + + #ifdef CYGWIN32 + + pthread_mutex_lock(&lookup_mutex); + from = gethostbyaddr(lData->buf, sizeof(lData->buf), AF_INET); + if (from && from->h_name) + { + free(lData->dsock->hostname); + lData->dsock->hostname = strdup(from->h_name); + } + pthread_mutex_unlock(&lookup_mutex); + + #else /* do the lookup and store the result at &from */ gethostbyaddr_r(lData->buf, sizeof(lData->buf), AF_INET, &ent, buf, 16384, &from, &err); *************** *** 1031,1036 **** --- 1066,1073 ---- lData->dsock->hostname = strdup(from->h_name); } + #endif + /* set it ready to be closed or used */ lData->dsock->lookup_status++; *************** *** 1040,1050 **** --- 1077,1094 ---- /* and kill the thread */ pthread_exit(0); + + #ifdef CYGWIN32 + return NULL; + #endif } void recycle_sockets() { D_SOCKET *dsock, *dsock_next; + #ifdef CYGWIN32 + int argp = 0; + #endif for (dsock = dsock_list; dsock; dsock = dsock_next) { *************** *** 1066,1071 **** --- 1110,1119 ---- bug("Recycle_sockets: Closed socket not in list"); } + #ifdef CYGWIN32 + ioctl(dsock->control, FIONBIO, &argp); + #endif + /* close the socket */ close(dsock->control); *************** *** 1073,1079 **** --- 1121,1129 ---- free(dsock->hostname); /* stop compression */ + #ifndef NOMCCP compressEnd(dsock, dsock->compressing, TRUE); + #endif /* put the socket in the free_list */ dsock->next = dsock_free; diff -r -N -c socketmud/src/utils.c socketmud-cygwin/src/utils.c *** socketmud/src/utils.c 2004-07-14 18:49:11.000000000 +0200 --- socketmud-cygwin/src/utils.c 2004-12-12 14:26:42.000000000 +0100 *************** *** 201,208 **** --- 201,210 ---- dsock->state = STATE_PLAYING; /* negotiate compression */ + #ifndef NOMCCP text_to_buffer(dsock, (char *) compress_will2); text_to_buffer(dsock, (char *) compress_will); + #endif } fclose(fp); }