Added include sys/time.h
[yaz-moved-to-github.git] / client / client.c
index b925810..9f13e82 100644 (file)
@@ -1,20 +1,30 @@
 /* 
- * Copyright (c) 1995-2004, Index Data
+ * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: client.c,v 1.265 2005-01-08 01:20:18 adam Exp $
+ * $Id: client.c,v 1.270 2005-01-17 13:08:53 adam Exp $
  */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
+#include <time.h>
+#include <ctype.h>
 #if HAVE_LOCALE_H
 #include <locale.h>
 #endif
-
 #if HAVE_LANGINFO_H
 #include <langinfo.h>
 #endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
 
 #if HAVE_OPENSSL_SSL_H
 #include <openssl/bio.h>
 #include <openssl/err.h>
 #endif
 
-#include <time.h>
-#include <ctype.h>
-
 #ifdef WIN32
 #include <io.h>
+#include <windows.h>
 #define S_ISREG(x) (x & _S_IFREG)
 #define S_ISDIR(x) (x & _S_IFDIR)
-#else
-#include <unistd.h>
 #endif
 
 #include <yaz/yaz-util.h>
@@ -62,7 +68,6 @@
 #include <readline/history.h>
 #endif
 
-#include <sys/stat.h>
 
 #include "admin.h"
 #include "tabcomplete.h"
@@ -1253,11 +1258,11 @@ static int send_srw(Z_SRW_PDU *sr)
 #endif
 
 #if HAVE_XML2
-static int send_SRW_scanRequest(const char *arg, int num, int pos)
+static int send_SRW_scanRequest(const char *arg, int pos, int num)
 {
     Z_SRW_PDU *sr = 0;
     
-    /* regular request .. */
+    /* regular requestse .. */
     sr = yaz_srw_get(out, Z_SRW_scan_request);
 
     switch(queryType)
@@ -2856,8 +2861,16 @@ int cmd_scan(const char *arg)
             cmd_open(0);
        if (!conn)
            return 0;
-        if (send_SRW_scanRequest(arg, 20, 0) < 0)
-            return 0;
+       if (*arg)
+       {
+           if (send_SRW_scanRequest(arg, scan_position, 20) < 0)
+               return 0;
+       }
+       else
+       {
+           if (send_SRW_scanRequest(last_scan_line, 1, 20) < 0)
+               return 0;
+       }
        return 2;
 #else
         return 0;
@@ -3520,11 +3533,19 @@ static void handle_srw_response(Z_SRW_searchRetrieveResponse *res)
 static void handle_srw_scan_term(Z_SRW_scanTerm *term)
 {
     if (term->displayTerm)
-       printf ("%s: ", term->displayTerm);
-    if (term->value)
-       printf ("%s: ", term->value);
+       printf("%s:", term->displayTerm);
+    else if (term->value)
+       printf("%s:", term->value);
+    else
+       printf("No value:");
     if (term->numberOfRecords)
-       printf ("%d", *term->numberOfRecords);
+       printf(" %d", *term->numberOfRecords);
+    if (term->whereInList)
+       printf(" %s", term->whereInList);
+    if (term->value && term->displayTerm)
+       printf(" %s", term->value);
+
+    strcpy(last_scan_line, term->value);
     printf("\n");
 }