Client doesn't set VAL_PROXY otherinfo unless -p is specified.
[yaz-moved-to-github.git] / client / client.c
index be3a8d3..00819c2 100644 (file)
@@ -3,7 +3,13 @@
  * See the file LICENSE for details.
  *
  * $Log: client.c,v $
- * Revision 1.124  2001-07-04 20:13:51  ja7
+ * Revision 1.126  2001-08-06 20:22:23  adam
+ * Client doesn't set VAL_PROXY otherinfo unless -p is specified.
+ *
+ * Revision 1.125  2001/07/19 19:51:41  adam
+ * Added typecasts to make C++ happy.
+ *
+ * Revision 1.124  2001/07/04 20:13:51  ja7
  * Added new commend "proxy" for ysing a yaz-proxy to connect to the target
  * Added new command line option -p for setting the proxy host
  *
 #include <yaz/proto.h>
 #include <yaz/marcdisp.h>
 #include <yaz/diagbib1.h>
+#include <yaz/otherinfo.h>
 
 #include <yaz/pquery.h>
 
@@ -472,7 +479,7 @@ static char ccl_fields[512] = "default.bib";
 static char* esPackageName = 0;
 static char* yazProxy = 0;
 
-static char last_cmd[100] = "?";
+static char last_cmd[32] = "?";
 static FILE *marcdump = 0;
 static char *refid = NULL;
 
@@ -565,9 +572,9 @@ static void send_initRequest(const char* type_and_host)
 
     req->referenceId = set_refid (out);
 
-
-    yaz_oi_set_string_oidval(&req->otherInfo, out, VAL_PROXY, 1, type_and_host);
-
+    if (yazProxy) 
+        yaz_oi_set_string_oidval(&req->otherInfo, out, VAL_PROXY,
+        1, type_and_host);
     
     send_apdu(apdu);
     printf("Sent initrequest.\n");
@@ -692,12 +699,12 @@ int cmd_open(char *arg)
 
     if(yazProxy) 
     {
-      conn = cs_create_host(yazProxy, 1, &add);
+       conn = cs_create_host(yazProxy, 1, &add);
     } 
     else 
     { 
-      conn = cs_create_host(type_and_host, 1, &add);
-    };
+       conn = cs_create_host(type_and_host, 1, &add);
+    }
        
     if (!conn)
     {
@@ -2505,7 +2512,7 @@ static int client(int wait)
 #ifdef USE_SELECT
         fd_set input;
 #endif
-        char line[1024], word[1024], arg[1024];
+        char line[1024], word[32], arg[1024];
         
 #ifdef USE_SELECT
         FD_ZERO(&input);
@@ -2548,7 +2555,7 @@ static int client(int wait)
             gettimeofday (&tv_start, 0);
 #endif
 
-            if ((res = sscanf(line, "%s %[^;]", word, arg)) <= 0)
+            if ((res = sscanf(line, "%31s %1023[^;]", word, arg)) <= 0)
             {
                 strcpy(word, last_cmd);
                 *arg = '\0';
@@ -2722,8 +2729,8 @@ int main(int argc, char **argv)
                 apdu_file=fopen(arg, "a");
             break;
        case 'p':
-         yazProxy=strdup(arg);
-         break;
+           yazProxy=strdup(arg);
+           break;
         case 'v':
             yaz_log_init (yaz_log_mask_str(arg), "", NULL);
             break;