* Europagate, 1995
*
* $Log: urp.c,v $
- * Revision 1.25 1995/04/17 09:34:33 adam
+ * Revision 1.27 1995/04/19 10:46:19 adam
+ * Persistency works much better now. New command: status - history-like
+ *
+ * Revision 1.26 1995/04/19 07:31:12 adam
+ * First work on Z39.50 persistence.
+ *
+ * Revision 1.25 1995/04/17 09:34:33 adam
* Timeout (idletime) adjustable. Minor changes in kernel.
*
* Revision 1.24 1995/03/28 11:42:35 adam
return 1;
}
-static int reopen_target (void)
+int reopen_target (void)
{
const char *v;
if (info.zass)
gw_log (GW_LOG_WARN, KERNEL_LOG, "Zass free...");
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "reopen_target");
info.zass = zass_open (info.hostname, info.port);
if (!info.zass)
{
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Cannot connect to target %s:%d",
+ info.hostname, info.port);
fprintf (reply_fd, "%s %s:%d\n",
gw_res_get (info.kernel_res, "gw.err.connect",
"Cannot connect to target"),
gw_res_get (info.kernel_res, "gw.msg.database",
"Selected databases"),
info.database);
+ if (info.setno >= 0)
+ fprintf (reply_fd, "set=%d\n", info.setno);
+ else
+ fprintf (reply_fd, "set=Default\n");
return 0;
}
gw_res_get (info.kernel_res, str, ""), addinfo);
}
-static int exec_find (struct ccl_token *list)
+static int exec_find (struct ccl_token *list, const char *search_str)
{
const struct zass_searchent *p;
struct gw_user_set *us;
+ char setname[32];
struct ccl_rpn_node *rpn;
int error;
const char *pos;
- us = user_set_add ("Default", -1);
+ if (info.setno == -1)
+ strcpy (setname, "Default");
+ else
+ sprintf (setname, "%d", info.setno);
rpn = ccl_find (info.bibset, list, &error, &pos);
if (!rpn)
{
gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Searching in database %s",
info.database );
assert (info.zass);
- p = zass_search (info.zass, rpn, "Default", info.database );
+ fprintf (reply_fd, "Searching in database %s\n", info.database);
+ p = zass_p_search (info.zass, rpn, setname, info.database, info.sets);
if (!p)
+ {
+ fprintf (reply_fd, "Search fail\n");
return -1;
+ }
if (p->errcode != -1)
{
display_diag_error (p->errcode, p->errstring);
}
fprintf (reply_fd, "%d %s\n", p->num,
gw_res_get (info.kernel_res, "gw.msg.hits", "hit(s)"));
- us->hits = p->num;
+ us = user_set_add (setname, p->num, info.database, rpn, 1, search_str);
+ fprintf (reply_fd, "Result-set %s created\n", setname);
+ if (info.setno >= 0)
+ info.setno++;
return 0;
}
return reopen_target ();
}
+static void exec_status_r (struct gw_user_set *sp)
+{
+ if (!sp)
+ return;
+ exec_status_r (sp->prev);
+ fprintf (reply_fd, "%6s %7d %12.12s %.50s\n", sp->name, sp->hits,
+ sp->database, sp->search_str);
+}
+
+static int exec_status (struct ccl_token *list)
+{
+ fprintf (reply_fd, " Name Hits Database Find\n");
+ exec_status_r (info.sets);
+ return 0;
+}
+
static int exec_base (struct ccl_token *list)
{
struct ccl_token *li = list;
gw_log (GW_LOG_DEBUG, KERNEL_LOG, "present in set %s", set);
gw_log (GW_LOG_DEBUG, KERNEL_LOG, "present of %d records from offset %d",
number, offset);
- zp = zass_present(info.zass, (char *) set, offset, number);
+ zp = zass_p_present(info.zass, (char *) set, offset, number);
if (zp)
{
int i;
}
fprintf (reply_fd, gw_res_get (info.kernel_res,
"gw.msg.records",
- "Got %d records"),
- zp->num);
+ "Got %d records from set %s"),
+ zp->num, set);
fprintf (reply_fd, "\n");
for (i = 0, pp = zp->records; pp; pp = pp->next, i++)
{
"command ignored"));
return 0;
}
+#if 0
+ ccl_token_and = gw_res_get (info.kernel_res, "ccl.token.and", "and");
+ ccl_token_or = gw_res_get (info.kernel_res, "ccl.token.or", "or");
+ ccl_token_not = gw_res_get (info.kernel_res, "ccl.token.not", "not");
+ ccl_token_set = gw_res_get (info.kernel_res, "ccl.token.set", "set");
+#endif
switch (no)
{
case 1:
- return exec_find (cmd->next);
+ return exec_find (cmd->next, str);
case 2:
return exec_show (cmd->next);
case 3:
return exec_base (cmd->next);
case 4:
return exec_help (cmd->next);
+ case 7:
+ return exec_status (cmd->next);
case 9:
return exec_target (cmd->next);
default:
fprintf (reply_fd, "%s\n", gw_res_get (info.kernel_res,
"gw.msg.cont",
"Continued..."));
- ccl_token_and = gw_res_get (info.kernel_res, "ccl.token.and", "and");
- ccl_token_or = gw_res_get (info.kernel_res, "ccl.token.or", "or");
- ccl_token_not = gw_res_get (info.kernel_res, "ccl.token.not", "not");
- ccl_token_set = gw_res_get (info.kernel_res, "ccl.token.set", "set");
return 0;
}