]> Nishi Git Mirror - dataworks.git/commitdiff
can get ATTR now
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Thu, 13 Jun 2024 05:54:45 +0000 (05:54 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Thu, 13 Jun 2024 05:54:45 +0000 (05:54 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@293 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

RemoteClient/rcli.c
RemoteClient/tcpip.c

index ad5bd372f606c7425e1051d0b3519699c758fd61..6ed5adb289f227062e3fad6a3571fa8a48903329 100644 (file)
@@ -30,8 +30,8 @@
 
 #include <stdbool.h>
 #include <stdio.h>
-#include <string.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <dataworks.h>
 #include <dw_util.h>
@@ -63,7 +63,46 @@ int main(int _argc, char** _argv) {
                if(resp == NULL) {
                        break;
                }
-               printf("!%s!\n", resp);
+               int i;
+               bool has_arg = false;
+               for(i = 0; resp[i] != 0; i++) {
+                       if(resp[i] == ':') {
+                               resp[i] = 0;
+                               has_arg = true;
+                               break;
+                       }
+               }
+               char* arg = has_arg ? resp + i + 1 : NULL;
+               if(__dw_strcaseequ(resp, "READY")) {
+                       printf("Connection is ready\n");
+               } else if(__dw_strcaseequ(resp, "ATTR") && has_arg) {
+                       int start = 0;
+                       for(i = 0;; i++) {
+                               if(arg[i] == ':' || arg[i] == 0) {
+                                       bool brk = arg[i] == 0;
+                                       arg[i] = 0;
+                                       int j;
+                                       char* curarg = arg + start;
+                                       for(j = 0; curarg[j] != 0; j++) {
+                                               if(curarg[j] == '=') {
+                                                       curarg[j] = 0;
+                                                       if(__dw_strcaseequ(curarg, "VER")) {
+                                                               printf("Server version : ");
+                                                       } else if(__dw_strcaseequ(curarg, "PLATFORM")) {
+                                                               printf("Server Platform: ");
+                                                       } else {
+                                                               printf("%s: ", curarg);
+                                                       }
+                                                       fflush(stdout);
+                                                       printf("%s\n", curarg + j + 1);
+                                                       break;
+                                               }
+                                       }
+                                       start = i + 1;
+                                       if(brk) break;
+                               }
+                       }
+               }
                free(resp);
        }
        return 0;
index b905f0d75bc865bd705d205e5c0dbf92f3ae9d19..08414391ef198548b9142d6b177c075d0ad6910f 100644 (file)
@@ -63,12 +63,8 @@ int rcli_init(void) {
        return 0;
 }
 
-void disconnect(int sock) {
-}
+void disconnect(int sock) {}
 
-char* readline_sock(void) {
-       return NULL;
-}
+char* readline_sock(void) { return NULL; }
 
-void writeline(const char* str) {
-}
+void writeline(const char* str) {}