]> Nishi Git Mirror - dataworks.git/commitdiff
can .quit now
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Thu, 13 Jun 2024 06:12:43 +0000 (06:12 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Thu, 13 Jun 2024 06:12:43 +0000 (06:12 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@295 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

RemoteClient/rcli.c

index e2543995927cd34901b755d74959d3c37d4b64ef..bfc990a31f97cba62cc9a0b7b51d6b414d544d0f 100644 (file)
@@ -109,9 +109,34 @@ int main(int _argc, char** _argv) {
                }
                free(resp);
        }
-       if(ready){
+       if(ready) {
+               char cbuf[2];
+               cbuf[1] = 0;
+               char* str = malloc(1);
+               str[0] = 0;
+               printf(". ");
+               fflush(stdout);
+               while(true) {
+                       int len = fread(cbuf, 1, 1, stdin);
+                       if(len <= 0) break;
+                       if(cbuf[0] == '\n') {
+                               if(__dw_strcaseequ(str, ".quit")) {
+                                       break;
+                               }
+                               free(str);
+                               str = malloc(1);
+                               str[0] = 0;
+                               printf(". ");
+                               fflush(stdout);
+                       } else if(cbuf[0] != '\r') {
+                               char* tmp = str;
+                               str = __dw_strcat(tmp, cbuf);
+                               free(tmp);
+                       }
+               }
+               free(str);
                writeline("QUIT");
-               while(true){
+               while(true) {
                        char* resp = readline_sock();
                        if(resp == NULL) break;
                        free(resp);