diff -r -N -c socketmud/src/Makefile socketmud-cygwin/src/Makefile *** socketmud/src/Makefile Wed Jan 7 18:43:00 2004 --- socketmud-cygwin/src/Makefile Fri Jan 9 23:31:13 2004 *************** *** 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 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 Thu May 1 23:38:05 2003 --- socketmud-cygwin/src/action_safe.c Fri Jan 9 23:29:38 2004 *************** *** 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 Sat Mar 9 19:49:45 2002 --- socketmud-cygwin/src/interpret.c Fri Jan 9 23:29:51 2004 *************** *** 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 Sat Sep 6 17:51:18 2003 --- socketmud-cygwin/src/io.c Fri Jan 9 23:01:47 2004 *************** *** 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 Wed Apr 2 10:08:25 2003 --- socketmud-cygwin/src/mccp.c Fri Jan 9 23:30:02 2004 *************** *** 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 Wed Jan 7 18:31:51 2004 --- socketmud-cygwin/src/mud.h Fri Jan 9 23:29:07 2004 *************** *** 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 * ***********************/ *************** *** 296,302 **** --- 306,314 ---- 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 **** --- 316,325 ---- /* * 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 Wed Jan 7 18:44:00 2004 --- socketmud-cygwin/src/socket.c Fri Jan 9 23:30:53 2004 *************** *** 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. */ *************** *** 125,131 **** --- 131,141 ---- if (FD_ISSET(control, &rFd)) { struct sockaddr_in sock; + #ifdef CYGWIN32 + int socksize; + #else unsigned int socksize; + #endif int newConnection; socksize = sizeof(sock); *************** *** 347,354 **** --- 357,366 ---- } /* 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); *************** *** 455,460 **** --- 467,473 ---- length = strlen(txt); /* write compressed */ + #ifndef NOMCCP if (dsock && dsock->out_compress) { dsock->out_compress->next_in = (unsigned char *) txt; *************** *** 496,501 **** --- 509,515 ---- } return TRUE; } + #endif /* write uncompressed */ for (iPtr = 0; iPtr < length; iPtr += iWrt) *************** *** 749,755 **** 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') --- 763,772 ---- 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') *************** *** 770,775 **** --- 787,793 ---- /* copy the next command into next_command */ for ( ; i < size; i++) { + #ifndef NOMCCP if (dsock->inbuf[i] == (signed char) IAC) { telopt = 1; *************** *** 797,803 **** compressEnd(dsock, TELOPT_COMPRESS2, FALSE); } } ! else if (isprint(dsock->inbuf[i]) && isascii(dsock->inbuf[i])) { dsock->next_command[j++] = dsock->inbuf[i]; } --- 815,823 ---- compressEnd(dsock, TELOPT_COMPRESS2, FALSE); } } ! else ! #endif ! if (isprint(dsock->inbuf[i]) && isascii(dsock->inbuf[i])) { dsock->next_command[j++] = dsock->inbuf[i]; } *************** *** 1024,1032 **** --- 1044,1067 ---- { 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); *************** *** 1038,1043 **** --- 1073,1080 ---- lData->dsock->hostname = strdup(from->h_name); } + #endif + /* set it ready to be closed or used */ lData->dsock->lookup_status++; *************** *** 1047,1052 **** --- 1084,1093 ---- /* and kill the thread */ pthread_exit(0); + + #ifdef CYGWIN32 + return NULL; + #endif } void recycle_sockets() *************** *** 1080,1086 **** --- 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 Sat Sep 6 17:50:04 2003 --- socketmud-cygwin/src/utils.c Fri Jan 9 23:30:12 2004 *************** *** 202,209 **** --- 202,211 ---- 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); }