]> Nishi Git Mirror - dataworks.git/commitdiff
working
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Thu, 13 Jun 2024 05:39:17 +0000 (05:39 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Thu, 13 Jun 2024 05:39:17 +0000 (05:39 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@291 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

HEADER [new file with mode: 0644]
RemoteClient/hayes.c
RemoteClient/rcli.c

diff --git a/HEADER b/HEADER
new file mode 100644 (file)
index 0000000..6a61b9f
--- /dev/null
+++ b/HEADER
@@ -0,0 +1 @@
+DataWorks - Simple DBMS
index b5f4a491ba4b3f3cc81861860c47c025320ea3e7..897fc5b75be097ddff062a9f022f8961237677a3 100644 (file)
@@ -43,7 +43,7 @@ extern int argc;
 extern char** argv;
 
 int port = -1;
-bool connected;
+bool connected = false;
 
 bool option(const char* str, const char* shortopt, const char* longopt);
 
@@ -171,13 +171,13 @@ int rcli_init(void) {
                        }
                        if(__dw_strcaseequ(resp, "CONNECT")) {
                                printf("Connected\n");
+                               connected = true;
                                break;
                        }
                }
                return 0;
        }
-       disconnect(0);
-       return 1;
+       return 0;
 }
 
 void disconnect(int sock) {
@@ -187,3 +187,18 @@ void disconnect(int sock) {
        while(inp(get_ioport() + 6) & (1 << 7)) outp(get_ioport() + 4, 0);
        connected = false;
 }
+
+char* readline_sock(void) {
+       char* resp = modem_response();
+       if(__dw_strcaseequ(resp, "NO CARRIER")) {
+               connected = false;
+               free(resp);
+       }
+       return connected ? resp : NULL;
+}
+
+void writeline(const char* str) {
+       char* w = __dw_strcat(str, "\r\n");
+       write_serial(w);
+       free(w);
+}
index 7efbe4db1225f450a0108c9ee6854add4f394a2f..39e906782e8a4d57c0234c5ce2d8fa9beb921d42 100644 (file)
@@ -39,6 +39,8 @@ int argc;
 char** argv;
 
 int rcli_init(void);
+char* readline_sock(void);
+void writeline(const char*);
 
 bool option(const char* str, const char* shortopt, const char* longopt) {
        char* dos_shortopt = __dw_strcat("/", shortopt);
@@ -55,4 +57,13 @@ int main(int _argc, char** _argv) {
        argv = _argv;
        int st = rcli_init();
        if(st != 0) return st;
+       while(1) {
+               char* resp = readline_sock();
+               if(resp == NULL) {
+                       break;
+               }
+               printf("!%s!\n", resp);
+               free(resp);
+       }
+       return 0;
 }