ZOOM: record objects "owned" by result sets.
[yaz-moved-to-github.git] / zoom / zoomsh.c
index 2f3897f..69e3195 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: zoomsh.c,v 1.1 2001-10-23 21:00:20 adam Exp $
+ * $Id: zoomsh.c,v 1.4 2001-11-15 08:58:29 adam Exp $
  *
  * ZOOM-C Shell
  */
@@ -9,9 +9,6 @@
 #include <string.h>
 #include <ctype.h>
 
-#define HAVE_READLINE_READLINE_H 1
-#define HAVE_READLINE_HISTORY_H 1
-
 #if HAVE_READLINE_READLINE_H
 #include <readline/readline.h> 
 #endif
@@ -32,7 +29,7 @@ static int next_token (const char **cpp, const char **t_start)
     while (*cp == ' ')
        cp++;
     *t_start = cp;
-    while (*cp && *cp != ' ')
+    while (*cp && *cp != ' ' && *cp != '\r' && *cp != '\n')
     {
        cp++;
        len++;
@@ -120,16 +117,17 @@ static void display_records (Z3950_connection c,
     for (i = 0; i<count; i++)
     {
        int pos = i + start;
-       const char *db = Z3950_resultset_get (r, pos, "database", 0);
+        Z3950_record rec = Z3950_resultset_record (r, pos);
+       const char *db = Z3950_record_get (rec, "database", 0);
        int len;
-       const char *rec = Z3950_resultset_get (r, pos, "render", &len);
-       const char *syntax = Z3950_resultset_get (r, pos, "syntax", 0);
+       const char *render = Z3950_record_get (rec, "render", &len);
+       const char *syntax = Z3950_record_get (rec, "syntax", 0);
        /* if rec is non-null, we got a record for display */
        if (rec)
        {
            printf ("%d %s %s\n", pos+1, (db ? db : "unknown"), syntax);
-           if (rec)
-               fwrite (rec, 1, len, stdout);
+           if (render)
+               fwrite (render, 1, len, stdout);
            putchar ('\n');
        }
     }
@@ -149,7 +147,7 @@ static void cmd_show (Z3950_connection *c, Z3950_resultset *r,
        Z3950_options_set (options, "count", count_str);
 
     for (i = 0; i<MAX_CON; i++)
-       Z3950_resultset_records (r[i], 0, 0);
+       Z3950_resultset_records (r[i], 0, atoi(start_str), atoi(count_str));
     while (Z3950_event (MAX_CON, c))
        ;
 
@@ -178,11 +176,11 @@ static void cmd_search (Z3950_connection *c, Z3950_resultset *r,
                        Z3950_options options,
                        const char **args)
 {
-    Z3950_search s;
+    Z3950_query s;
     int i;
     
-    s = Z3950_search_create ();
-    if (Z3950_search_prefix (s, *args))
+    s = Z3950_query_create ();
+    if (Z3950_query_prefix (s, *args))
     {
        fprintf (stderr, "Bad PQF: %s\n", *args);
        return;
@@ -224,7 +222,7 @@ static void cmd_search (Z3950_connection *c, Z3950_resultset *r,
            display_records (c[i], r[i], start, count);
        }
     }
-    Z3950_search_destroy (s);
+    Z3950_query_destroy (s);
 }
 
 static void cmd_help (Z3950_connection *c, Z3950_resultset *r,