Slight updates.
[doldaconnect.git] / clients / test.c
index 25deedb..04f471c 100644 (file)
@@ -12,14 +12,12 @@ void authcallback(int err, wchar_t *reason, void *data)
 
 int main(int argc, char **argv)
 {
-    int i;
     struct pollfd pfd;
     int fd, done;
     struct dc_response *resp;
-    struct dc_intresp *ires;
     
     dc_init();
-    fd = dc_connect("localhost", -1);
+    fd = dc_connect(NULL);
     done = 0;
     while(!done)
     {
@@ -38,10 +36,11 @@ int main(int argc, char **argv)
            done = 1;
        while((resp = dc_getresp()) != NULL)
        {
-           if(resp->cmdname == NULL)
+           if(!wcscmp(resp->cmdname, L".connect"))
            {
-               printf("Connected\n");
-               dc_loginasync(NULL, 0, NULL, authcallback, NULL);
+               printf("Connected: %i\n", resp->code);
+               if(resp->code == 201)
+                   dc_loginasync(NULL, 1, NULL, authcallback, NULL);
            }
            dc_freeresp(resp);
        }