From a81f7b5902d7038071ee327d54451ecb06e444f5 Mon Sep 17 00:00:00 2001 From: nishi Date: Thu, 13 Jun 2024 02:09:13 +0000 Subject: [PATCH] add rcli stuff git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@285 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- Makefiles/Platforms/win9x.mk | 1 + Makefiles/common-decl.mk | 1 + Makefiles/common.mk | 12 +++++++++--- README.md | 3 +++ RemoteClient/Makefile | 2 +- RemoteClient/hayes.c | 27 +++++++++++++++++++++++++++ RemoteClient/rcli.c | 5 +++++ RemoteClient/tcpip.c | 27 +++++++++++++++++++++++++++ Server/tcpip.c | 24 ++++++++++++++---------- 9 files changed, 88 insertions(+), 14 deletions(-) create mode 100644 RemoteClient/hayes.c create mode 100644 RemoteClient/rcli.c create mode 100644 RemoteClient/tcpip.c diff --git a/Makefiles/Platforms/win9x.mk b/Makefiles/Platforms/win9x.mk index e4c1dcd..e28993e 100644 --- a/Makefiles/Platforms/win9x.mk +++ b/Makefiles/Platforms/win9x.mk @@ -4,3 +4,4 @@ WATCOM_PLATFORM=win95 include Makefiles/Platforms/watcom.mk EXEC_SUFFIX=.exe SERVER = +RCLI = diff --git a/Makefiles/common-decl.mk b/Makefiles/common-decl.mk index fbde8f3..933fc48 100644 --- a/Makefiles/common-decl.mk +++ b/Makefiles/common-decl.mk @@ -22,6 +22,7 @@ PLATFORM_M = `uname -m` PLATFORM_P = `uname -p | sed -E "s/[ \\(\\)]/-/g"` LINK_LIB = ../Library/$(STATICLIB_PREFIX)dataworks$(STATICLIB_SUFFIX) SERVER = ./Server +RCLI = ./RemoteClient SERVER_MODULE = tcpip.o RCLI_MODULE = tcpip.o VERSION = `cat Library/dataworks.c | grep " dataworks_version " | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?'` diff --git a/Makefiles/common.mk b/Makefiles/common.mk index 58e59fc..7afe2b4 100644 --- a/Makefiles/common.mk +++ b/Makefiles/common.mk @@ -1,10 +1,10 @@ # $Id$ -.PHONY: all no-doc replace format clean ./Library ./Client ./Document ./Grammar ./Package/PKGBUILD archive archive-prepare archive-cleanup archive-targz archive-zip dosbox prepare-dosbox dosbox-x cleanup-dosbox get-version +.PHONY: all no-doc replace format clean ./Library ./Client ./Document ./Grammar ./RemoteClient ./Package/PKGBUILD archive archive-prepare archive-cleanup archive-targz archive-zip dosbox prepare-dosbox dosbox-x cleanup-dosbox get-version -all: ./Grammar ./Library ./Client $(SERVER) ./Document +all: ./Grammar ./Library ./Client $(SERVER) $(RCLI) ./Document -no-doc: ./Grammar ./Library ./Client $(SERVER) +no-doc: ./Grammar ./Library ./Client $(SERVER) $(RCLI) ./Grammar:: $(MAKE) -C $@ $(COMPILE_FLAGS) @@ -18,6 +18,9 @@ no-doc: ./Grammar ./Library ./Client $(SERVER) ./Server:: ./Library $(MAKE) -C $@ $(COMPILE_FLAGS) +./RemoteClient:: ./Library + $(MAKE) -C $@ $(COMPILE_FLAGS) + ./Document:: $(MAKE) -C ./Document $(COMPILE_FLAGS) @@ -45,6 +48,7 @@ archive-prepare: all rm -f dataworks.zip dataworks.tar.gz rm -rf dataworks-dist mkdir -p dataworks-dist + mkdir -p dataworks-dist/RemoteClient mkdir -p dataworks-dist/Server mkdir -p dataworks-dist/Client mkdir -p dataworks-dist/Library @@ -54,6 +58,8 @@ archive-prepare: all -cp Library/*.lib dataworks-dist/Library/ -cp Server/dataworks_server$(EXEC_SUFFIX) dataworks-dist/Server/ -rmdir dataworks-dist/Server + -cp RemoteClient/dataworks_remote_client$(EXEC_SUFFIX) dataworks-dist/RemoteClient/ + -rmdir dataworks-dist/RemoteClient cp Library/*.h dataworks-dist/Library/ cp Client/dataworks$(EXEC_SUFFIX) dataworks-dist/Client/ cp -rf Document/doc/html dataworks-dist/Document/html diff --git a/README.md b/README.md index 15e3ae0..a0e1478 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,9 @@ Original: http://sw.nishi.boats/svn/nishi-dataworks - `Package` Contains files related to package manager + - `RemoteClient` + + Contains remote client source code - `Server` Contains server source code diff --git a/RemoteClient/Makefile b/RemoteClient/Makefile index 1bdaf00..c864c42 100644 --- a/RemoteClient/Makefile +++ b/RemoteClient/Makefile @@ -5,7 +5,7 @@ OBJS = rcli.o $(RCLI_MODULE) -all: dataworks_server$(EXEC_SUFFIX) +all: dataworks_remote_client$(EXEC_SUFFIX) dataworks_remote_client$(EXEC_SUFFIX): $(OBJS) $(LINK_LIB) $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) $(LINK_LIB) $(RCLILINK_LIB) diff --git a/RemoteClient/hayes.c b/RemoteClient/hayes.c new file mode 100644 index 0000000..a2b35fc --- /dev/null +++ b/RemoteClient/hayes.c @@ -0,0 +1,27 @@ +/* $Id$ */ +/* --- START LICENSE --- */ +/* -------------------------------------------------------------------------- */ +/* Copyright (c) 2024 Crabware. */ +/* Redistribution and use in source and binary forms, with or without modific */ +/* ation, are permitted provided that the following conditions are met: */ +/* 1. Redistributions of source code must retain the above copyright noti */ +/* ce, this list of conditions and the following disclaimer. */ +/* 2. Redistributions in binary form must reproduce the above copyright n */ +/* otice, this list of conditions and the following disclaimer in the documen */ +/* tation and/or other materials provided with the distribution. */ +/* 3. Neither the name of the copyright holder nor the names of its contr */ +/* ibutors may be used to endorse or promote products derived from this softw */ +/* are without specific prior written permission. */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS */ +/* " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, TH */ +/* E IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPO */ +/* SE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS */ +/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CON */ +/* SEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITU */ +/* TE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPT */ +/* ION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, S */ +/* TRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN AN */ +/* Y WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY */ +/* OF SUCH DAMAGE. */ +/* -------------------------------------------------------------------------- */ +/* --- END LICENSE --- */ diff --git a/RemoteClient/rcli.c b/RemoteClient/rcli.c new file mode 100644 index 0000000..ab24a2f --- /dev/null +++ b/RemoteClient/rcli.c @@ -0,0 +1,5 @@ +/* $Id$ */ +/* --- START LICNESE --- */ +/* --- END LICNESE --- */ + +int main() {} diff --git a/RemoteClient/tcpip.c b/RemoteClient/tcpip.c new file mode 100644 index 0000000..a2b35fc --- /dev/null +++ b/RemoteClient/tcpip.c @@ -0,0 +1,27 @@ +/* $Id$ */ +/* --- START LICENSE --- */ +/* -------------------------------------------------------------------------- */ +/* Copyright (c) 2024 Crabware. */ +/* Redistribution and use in source and binary forms, with or without modific */ +/* ation, are permitted provided that the following conditions are met: */ +/* 1. Redistributions of source code must retain the above copyright noti */ +/* ce, this list of conditions and the following disclaimer. */ +/* 2. Redistributions in binary form must reproduce the above copyright n */ +/* otice, this list of conditions and the following disclaimer in the documen */ +/* tation and/or other materials provided with the distribution. */ +/* 3. Neither the name of the copyright holder nor the names of its contr */ +/* ibutors may be used to endorse or promote products derived from this softw */ +/* are without specific prior written permission. */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS */ +/* " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, TH */ +/* E IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPO */ +/* SE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS */ +/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CON */ +/* SEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITU */ +/* TE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPT */ +/* ION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, S */ +/* TRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN AN */ +/* Y WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY */ +/* OF SUCH DAMAGE. */ +/* -------------------------------------------------------------------------- */ +/* --- END LICENSE --- */ diff --git a/Server/tcpip.c b/Server/tcpip.c index 736e631..db4bcb9 100644 --- a/Server/tcpip.c +++ b/Server/tcpip.c @@ -41,7 +41,11 @@ extern char** argv; extern bool auth; extern char* authfile; -#ifdef __MINGW32__ +#if defined(__MINGW32__) +#define USE_WINSOCK +#endif + +#ifdef USE_WINSOCK #include #include #include @@ -61,7 +65,7 @@ bool option(const char* str, const char* shortopt, const char* longopt); int port = 4096; int server_socket; -#ifdef __MINGW32__ +#ifdef USE_WINSOCK struct sockaddr_in server_address; #else struct sockaddr_in6 server_address; @@ -97,11 +101,11 @@ int server_init(void) { db = dataworks_database_open(argv[i]); } } -#ifdef __MINGW32__ +#ifdef USE_WINSOCK WSADATA wsa; WSAStartup(MAKEWORD(2, 0), &wsa); #endif -#ifdef __MINGW32__ +#ifdef USE_WINSOCK if((server_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) { #else if((server_socket = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP)) < 0) { @@ -120,7 +124,7 @@ int server_init(void) { close(server_socket); return 1; } -#ifdef __MINGW32__ +#ifdef USE_WINSOCK #else int no = 0; if(setsockopt(server_socket, IPPROTO_IPV6, IPV6_V6ONLY, &no, sizeof(no)) < 0) { @@ -130,7 +134,7 @@ int server_init(void) { } #endif memset(&server_address, 0, sizeof(server_address)); -#ifdef __MINGW32__ +#ifdef USE_WINSOCK server_address.sin_family = AF_INET; server_address.sin_addr.S_un.S_addr = INADDR_ANY; server_address.sin_port = htons(port); @@ -149,7 +153,7 @@ int server_init(void) { close(server_socket); return 1; } -#ifdef __MINGW32__ +#ifdef USE_WINSOCK #else signal(SIGCHLD, SIG_IGN); #endif @@ -157,7 +161,7 @@ int server_init(void) { return 0; } -#ifdef __MINGW32__ +#ifdef USE_WINSOCK unsigned int WINAPI pass_sock(LPVOID sockptr) { int sock = *(int*)sockptr; #else @@ -165,7 +169,7 @@ void pass_sock(int sock) { #endif protocol_init(sock); protocol_loop(sock); -#ifdef __MINGW32__ +#ifdef USE_WINSOCK closesocket(sock); #else close(sock); @@ -177,7 +181,7 @@ void server_loop(void) { struct sockaddr_in claddr; int clen = sizeof(claddr); int sock = accept(server_socket, (struct sockaddr*)&claddr, &clen); -#ifdef __MINGW32__ +#ifdef USE_WINSOCK HANDLE thread; thread = (HANDLE)_beginthreadex(NULL, 0, pass_sock, &sock, 0, NULL); #else -- 2.43.0