give the possibility to pass an error message to the user
[iauth.git] / iauth_query.c
index 7c7c7145bc0e54c131e283dc16c77cf81b0b23a3..d0026ff44be38efd9d85b958040d171f6a23fff4 100644 (file)
@@ -113,6 +113,18 @@ const struct iauth_result *iauth_query(struct iauth_client *cli) {
         return NULL;
     }
     *arg++ = 0;
+    if(strcmp(tread, "error") == 0) {
+        strcpy(res.cclass, "error");
+       tread = arg;
+    if(!(arg = strchr(tread, '%'))) {
+        close(fds[0]);
+        return NULL;
+    }
+    *arg++ = 0;
+       
+        strcpy(res.str, tread);
+        return &res;
+       }
     if(strcmp(tread, "$") == 0 || strlen(tread) > IAUTH_DATALEN) res.cclass[0] = 0;
     else strcpy(res.cclass, tread);
 
@@ -148,10 +160,11 @@ const struct iauth_result *iauth_query(struct iauth_client *cli) {
 
     /* Read modes string. */
     tread = arg;
-    if(!*tread) {
+    if(!(arg = strchr(tread, '%'))) {
         close(fds[0]);
         return NULL;
     }
+    *arg++ = 0;
     if(strcmp(tread, "$") == 0 || strlen(tread) > IAUTH_DATALEN) res.modes[0] = 0;
     else strcpy(res.modes, tread);