]> Nishi Git Mirror - dataworks.git/commitdiff
fix
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Wed, 5 Jun 2024 10:54:36 +0000 (10:54 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Wed, 5 Jun 2024 10:54:36 +0000 (10:54 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@157 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

Platforms/dos.mk
Platforms/dos32a.mk
Platforms/dos4g.mk
Platforms/dos4gnz.mk
Platforms/win9x.mk
Server/Makefile
Server/server.c
common-decl.mk
common.mk

index 502742b41f900c27ac58792c1e5ba6e554630ff0..31eed61fef6fd365c7929a2cc81ca02972ce5256 100644 (file)
@@ -5,3 +5,4 @@ include Platforms/watcom.mk
 EXEC_SUFFIX=.exe
 CFLAGS += -march=i86
 LDFLAGS += -march=i86
+SERVER_MODULE = hayes.o
index 96640daef85996db38f98fee372f10c4e8ae2d1a..c97f12fe37923ba95e8ab78cc8ad514f27132351 100644 (file)
@@ -3,3 +3,4 @@
 WATCOM_PLATFORM=dos32a
 include Platforms/watcom.mk
 EXEC_SUFFIX=.exe
+SERVER_MODULE = hayes.o
index a9d05e5b3160e573103a5f6462c10660054b4c4e..e7c894de2464f98536873863cc7f4d4a23a400c4 100644 (file)
@@ -3,3 +3,4 @@
 WATCOM_PLATFORM=dos4g
 include Platforms/watcom.mk
 EXEC_SUFFIX=.exe
+SERVER_MODULE = hayes.o
index 7472be9b14986e9347177bd0608feb6531c5582b..051d00aee7b0e6464cc2413cb8dcf8f34b01e109 100644 (file)
@@ -3,3 +3,4 @@
 WATCOM_PLATFORM=dos4gnz
 include Platforms/watcom.mk
 EXEC_SUFFIX=.exe
+SERVER_MODULE = hayes.o
index 8e885adfc7b81e07e915b5a1469d5562168de098..0f6283924374f99db07dc0dd0135d43ce1df2d3e 100644 (file)
@@ -3,3 +3,4 @@
 WATCOM_PLATFORM=win95
 include Platforms/watcom.mk
 EXEC_SUFFIX=.exe
+SERVER =
index 10573c3b777f4bfd223ea124711c94e2e77e6cc2..e017f9238e2e27affbc2284ce071fea9b0f7fbf5 100644 (file)
@@ -3,7 +3,7 @@
 .PHONY: all clean
 .SUFFIXES: .c .o
 
-OBJS = server.o
+OBJS = server.o $(SERVER_MODULE)
 
 all: dataworks_server$(EXEC_SUFFIX)
 
index 915daa13313d5fc2601e59e80fd580581f3299fd..8299d6dad3b5d72112d46205bf20a2b95ba0932f 100644 (file)
@@ -56,192 +56,18 @@ char** argv;
 
 void protocol_init(int sock);
 
-#ifdef HAYES
-int port = -1;
-
-void write_serial(const char* str) {
-       const char* ptr = str;
-       while(1) {
-               if(_bios_serialcom(_COM_STATUS, port, 0) & 0x10) {
-                       _bios_serialcom(_COM_SEND, port, *ptr);
-                       ptr++;
-                       if(*ptr == 0) break;
-               }
-       }
-}
-
-char* modem_response(void) {
-       char* buf = malloc(513);
-       buf[0] = 0;
-       int count = 0;
-       while(1) {
-               if(_bios_serialcom(_COM_STATUS, port, 0) & 0x0100) {
-                       unsigned short b = _bios_serialcom(_COM_RECEIVE, port, 0);
-                       char ch = b & 0xff;
-                       if(ch != '\r' && ch != '\n' && ch != 0) {
-                               buf[count] = ch;
-                               buf[count + 1] = 0;
-                               count++;
-                       } else if(ch == '\r') {
-                               if(strlen(buf) != 0) break;
-                       }
-               }
-       }
-       return buf;
-}
-
-int server_init(void) {
-       printf("Using Hayes Modem\n");
-       int i;
-       for(i = 1; i < argc; i++) {
-               if(__dw_strcaseequ(argv[i], "COM1")) {
-                       port = 0;
-               } else if(__dw_strcaseequ(argv[i], "COM2")) {
-                       port = 1;
-               } else if(__dw_strcaseequ(argv[i], "COM3")) {
-                       port = 2;
-               } else if(__dw_strcaseequ(argv[i], "COM4")) {
-                       port = 3;
-               } else {
-                       fprintf(stderr, "Invalid port: %s\n", argv[i]);
-                       return 1;
-               }
-       }
-       if(port == -1) {
-               fprintf(stderr, "Specify serial port\n");
-               return 1;
-       }
-       _bios_serialcom(_COM_INIT, port, _COM_9600 | _COM_NOPARITY | _COM_CHR8 | _COM_STOP1);
-       write_serial("AT&FE0F1\r");
-       free(modem_response()); /* Kill echo */
-       char* resp = modem_response();
-       if(__dw_strcaseequ(resp, "OK")) {
-               fprintf(stderr, "Modem initialization successful\n");
-       } else {
-               fprintf(stderr, "Modem initialization fail\n");
-               free(resp);
-               return 1;
-       }
-       free(resp);
-       return 0;
+bool option(const char* str, const char* shortopt, const char* longopt) {
+       char* dos_shortopt = __dw_strcat("/", shortopt);
+       char* dos_longopt = __dw_strcat("/", longopt);
+       char* nix_shortopt = __dw_strcat("-", shortopt);
+       char* nix_longopt = __dw_strcat("--", longopt);
+       if(__dw_strcaseequ(str, dos_longopt) || __dw_strcaseequ(str, nix_longopt) || strcmp(str, dos_shortopt) == 0 || strcmp(str, nix_shortopt) == 0) return true;
+       return false;
 }
 
-void server_loop(void) {
-       bool connected = false;
-       while(1) {
-               char* resp = modem_response();
-               if(__dw_strcaseequ(resp, "NO CARRIER")) {
-                       free(resp);
-                       printf("Disconnected\n");
-                       connected = false;
-                       continue;
-               }
-               int i;
-               bool has_arg = false;
-               for(i = 0; resp[i] != 0; i++) {
-                       if(resp[i] == ' ') {
-                               resp[i] = 0;
-                               has_arg = true;
-                               break;
-                       }
-               }
-               if(connected) {
-               } else {
-                       if(__dw_strcaseequ(resp, "RING")) {
-                               printf("Got a call, answering\n");
-                               write_serial("ATA\r");
-                       } else if(__dw_strcaseequ(resp, "CONNECT")) {
-                               printf("Connection successful");
-                               if(has_arg) printf(", %s BPS", resp + i + 1);
-                               printf("\n");
-                               printf("Entering connected state\n");
-                               connected = true;
-                               protocol_init(0);
-                       }
-               }
-               free(resp);
-       }
-}
-
-void writeline(int sock, const char* str) {
-       char* snd = __dw_strcat(str, "\r\n");
-       write_serial(snd);
-       free(snd);
-}
-#endif
-
-#ifdef TCPIP
-int port = 4096;
-int server_socket;
-struct sockaddr_in6 server_address;
-
-int server_init(void) {
-       printf("Using BSD TCP/IP\n");
-       int i;
-       for(i = 1; i < argc; i++) {
-               port = atoi(argv[i]);
-       }
-       if((server_socket = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP)) < 0) {
-               fprintf(stderr, "BSD TCP/IP initialization fail\n");
-               return 1;
-       }
-       int yes = 1;
-       if(setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) {
-               fprintf(stderr, "BSD TCP/IP initialization fail\n");
-               close(server_socket);
-               return 1;
-       }
-       if(setsockopt(server_socket, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes)) < 0) {
-               fprintf(stderr, "BSD TCP/IP initialization fail\n");
-               close(server_socket);
-               return 1;
-       }
-       int no = 0;
-       if(setsockopt(server_socket, IPPROTO_IPV6, IPV6_V6ONLY, &no, sizeof(no)) < 0) {
-               fprintf(stderr, "BSD TCP/IP initialization fail\n");
-               close(server_socket);
-               return 1;
-       }
-       memset(&server_address, 0, sizeof(server_address));
-       server_address.sin6_family = AF_INET6;
-       server_address.sin6_addr = in6addr_any;
-       server_address.sin6_port = htons(port);
-       if(bind(server_socket, (struct sockaddr*)&server_address, sizeof(server_address)) < 0) {
-               fprintf(stderr, "BSD TCP/IP initialization fail\n");
-               close(server_socket);
-               return 1;
-       }
-       if(listen(server_socket, 128) < 0) {
-               fprintf(stderr, "BSD TCP/IP initialization fail\n");
-               close(server_socket);
-               return 1;
-       }
-       signal(SIGCHLD, SIG_IGN);
-       fprintf(stderr, "BSD TCP/IP initialization successful\n");
-       return 0;
-}
-
-void server_loop(void) {
-       while(1) {
-               struct sockaddr_in claddr;
-               int clen = sizeof(claddr);
-               int sock = accept(server_socket, (struct sockaddr*)&claddr, &clen);
-               pid_t p = fork();
-               if(p == 0) {
-                       protocol_init(sock);
-                       _exit(0);
-               } else {
-                       close(sock);
-               }
-       }
-}
-
-void writeline(int sock, const char* str) {
-       char* snd = __dw_strcat(str, "\r\n");
-       send(sock, snd, strlen(snd), 0);
-       free(snd);
-}
-#endif
+int server_init(void);
+void server_loop(void);
+void writeline(int sock, const char* str);
 
 void protocol_init(int sock) {
        /* sock is ignored on hayes */
index fe1db40cd3aa45e4171f451126e29868aec6a3c5..3b5139f805185c71e160b8bcde5719b402cd1f2e 100644 (file)
@@ -22,5 +22,6 @@ PLATFORM_M = `uname -m`
 PLATFORM_P = `uname -p | sed -E "s/[ \\(\\)]/-/g"`
 LINK_LIB = ../Library/$(STATICLIB_PREFIX)dataworks$(STATICLIB_SUFFIX)
 SERVER = ./Server
+SERVER_MODULE = tcpip.o
 
-COMPILE_FLAGS = CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" LIB_PREFIX="$(LIB_PREFIX)" LIB_SUFFIX="$(LIB_SUFFIX)" EXEC_SUFFIX="$(EXEC_SUFFIX)" PLATFORM_M="$(PLATFORM_M)" PLATFORM_P="$(PLATFORM_P)" STATICLIB_PREFIX="$(STATICLIB_PREFIX)" STATICLIB_SUFFIX="$(STATICLIB_SUFFIX)" AR="$(AR)" RANLIB="$(RANLIB)" SHCC="$(SHCC)" LINK_LIB="$(LINK_LIB)" AR_ARGS="$(AR_ARGS)" WINDRES="$(WINDRES)" YACC="$(YACC)" LEX="$(LEX)" LFLAGS="$(LFLAGS)" YFLAGS="$(YFLAGS)"
+COMPILE_FLAGS = CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" LIB_PREFIX="$(LIB_PREFIX)" LIB_SUFFIX="$(LIB_SUFFIX)" EXEC_SUFFIX="$(EXEC_SUFFIX)" PLATFORM_M="$(PLATFORM_M)" PLATFORM_P="$(PLATFORM_P)" STATICLIB_PREFIX="$(STATICLIB_PREFIX)" STATICLIB_SUFFIX="$(STATICLIB_SUFFIX)" AR="$(AR)" RANLIB="$(RANLIB)" SHCC="$(SHCC)" LINK_LIB="$(LINK_LIB)" AR_ARGS="$(AR_ARGS)" WINDRES="$(WINDRES)" YACC="$(YACC)" LEX="$(LEX)" LFLAGS="$(LFLAGS)" YFLAGS="$(YFLAGS)" SERVER_MODULE="$(SERVER_MODULE)"
index 37752dc6ff3726950161af0f36c25de0b4a53874..4442009bc2de9b8b0b964075514f67f1071cfbd5 100644 (file)
--- a/common.mk
+++ b/common.mk
@@ -83,8 +83,8 @@ prepare-dosbox: no-doc
        echo "[sdl]" >> dosbox.conf
        echo "windowresolution=640x400" >> dosbox.conf
        echo "[render]" >> dosbox.conf
-       echo "aspect=true surface" >> dosbox.conf
-       echo "aspect_ratio=16:9" >> dosbox.conf
+       echo "aspect=true" >> dosbox.conf
+       echo "aspect_ratio=16:10" >> dosbox.conf
        echo "[cpu]" >> dosbox.conf
        echo "cycles=12000" >> dosbox.conf
        echo "[autoexec]" >> dosbox.conf
@@ -92,7 +92,7 @@ prepare-dosbox: no-doc
        echo "c:" >> dosbox.conf
        echo "copy Server\*$(EXEC_SUFFIX) dwserv$(EXEC_SUFFIX)" >> dosbox.conf
        echo "copy Client\*$(EXEC_SUFFIX) dw$(EXEC_SUFFIX)" >> dosbox.conf
-       echo "dwserv COM1" >> dosbox.conf
+       echo "dwserv -p COM1" >> dosbox.conf
        echo "dw /NC /f op.txt /create db.dwf" >> dosbox.conf
        echo "dw /NC /f op.txt db.dwf" >> dosbox.conf
        echo "pause" >> dosbox.conf