From: nishi Date: Thu, 13 Jun 2024 06:03:39 +0000 (+0000) Subject: auto disconnect X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=4968e23c4f3bff7384c3bb14680be5b0e7c820fe;p=dataworks.git auto disconnect git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@294 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- diff --git a/RemoteClient/hayes.c b/RemoteClient/hayes.c index 897fc5b..540839f 100644 --- a/RemoteClient/hayes.c +++ b/RemoteClient/hayes.c @@ -47,7 +47,7 @@ bool connected = false; bool option(const char* str, const char* shortopt, const char* longopt); -void disconnect(int sock); +void disconnect(void); int get_ioport() { #ifdef PC98 @@ -180,7 +180,7 @@ int rcli_init(void) { return 0; } -void disconnect(int sock) { +void disconnect(void) { while((inp(get_ioport() + 5) & 0x20) == 0) ; delay(100); diff --git a/RemoteClient/rcli.c b/RemoteClient/rcli.c index 6ed5adb..e254399 100644 --- a/RemoteClient/rcli.c +++ b/RemoteClient/rcli.c @@ -42,6 +42,7 @@ char** argv; int rcli_init(void); char* readline_sock(void); void writeline(const char*); +void disconnect(void); bool option(const char* str, const char* shortopt, const char* longopt) { char* dos_shortopt = __dw_strcat("/", shortopt); @@ -57,6 +58,7 @@ int main(int _argc, char** _argv) { argc = _argc; argv = _argv; int st = rcli_init(); + bool ready = false; if(st != 0) return st; while(1) { char* resp = readline_sock(); @@ -75,6 +77,8 @@ int main(int _argc, char** _argv) { char* arg = has_arg ? resp + i + 1 : NULL; if(__dw_strcaseequ(resp, "READY")) { printf("Connection is ready\n"); + ready = true; + break; } else if(__dw_strcaseequ(resp, "ATTR") && has_arg) { int start = 0; for(i = 0;; i++) { @@ -105,5 +109,13 @@ int main(int _argc, char** _argv) { } free(resp); } + if(ready){ + writeline("QUIT"); + while(true){ + char* resp = readline_sock(); + if(resp == NULL) break; + free(resp); + } + } return 0; } diff --git a/RemoteClient/tcpip.c b/RemoteClient/tcpip.c index 0841439..2326f9b 100644 --- a/RemoteClient/tcpip.c +++ b/RemoteClient/tcpip.c @@ -63,7 +63,7 @@ int rcli_init(void) { return 0; } -void disconnect(int sock) {} +void disconnect(void) {} char* readline_sock(void) { return NULL; }