/*
- * $Id: zoomsh.c,v 1.2 2001-10-24 12:24:43 adam Exp $
+ * $Id: zoomsh.c,v 1.6 2001-11-16 10:18:20 adam Exp $
*
* ZOOM-C Shell
*/
const char *h;
if (!c[i])
continue;
- if ((h = Z3950_connection_host(c[i])) && !strcmp (h, host))
+ if ((h = Z3950_connection_option_get(c[i], "host"))
+ && !strcmp (h, host))
{
Z3950_connection_destroy (c[i]);
c[i] = 0;
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');
}
}
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))
;
continue;
if ((error = Z3950_connection_error(c[i], &errmsg, &addinfo)))
fprintf (stderr, "%s error: %s (%d) %s\n",
- Z3950_connection_host(c[i]), errmsg,
+ Z3950_connection_option_get(c[i], "host"), errmsg,
error, addinfo);
else if (r[i])
{
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;
continue;
if ((error = Z3950_connection_error(c[i], &errmsg, &addinfo)))
fprintf (stderr, "%s error: %s (%d) %s\n",
- Z3950_connection_host(c[i]), errmsg,
+ Z3950_connection_option_get(c[i], "host"), errmsg,
error, addinfo);
else if (r[i])
{
int start = Z3950_options_get_int (options, "start", 0);
int count = Z3950_options_get_int (options, "count", 0);
- printf ("%s: %d hits\n", Z3950_connection_host(c[i]),
+ printf ("%s: %d hits\n", Z3950_connection_option_get(c[i], "host"),
Z3950_resultset_size(r[i]));
/* and display */
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,
for (j = -1, i = 0; i<MAX_CON; i++)
{
const char *h;
- if (c[i] && (h = Z3950_connection_host(c[i])) &&
+ if (c[i] && (h = Z3950_connection_option_get(c[i], "host")) &&
!strcmp (h, host))
{
Z3950_connection_destroy (c[i]);
Z3950_connection_connect (c[i], host, 0);
if ((error = Z3950_connection_error(c[i], &errmsg, &addinfo)))
- printf ("%s error: %s (%d) %s\n", Z3950_connection_host(c[i]),
+ printf ("%s error: %s (%d) %s\n",
+ Z3950_connection_option_get(c[i], "host"),
errmsg, error, addinfo);
}
while (1)
{
char buf[1000];
+ char *cp;
const char *bp = buf;
#if HAVE_READLINE_READLINE_H
char* line_in;
if (!fgets (buf, 999, stdin))
break;
#endif
+ if ((cp = strchr(buf, '\n')))
+ *cp = '\0';
if (!cmd_parse (c, r, options, &bp))
break;
}