# Europagate, 1995
#
# $Log: Makefile,v $
-# Revision 1.16 1995/04/19 07:30:56 adam
+# Revision 1.17 1995/04/19 10:46:17 adam
+# Persistency works much better now. New command: status - history-like
+#
+# Revision 1.16 1995/04/19 07:30:56 adam
# First work on Z39.50 persistence.
#
# Revision 1.15 1995/04/17 11:27:29 quinn
#
SHELL=/bin/sh
-ZPRE=/home/proj/zdist/zdist102b1-1/libz3950
-ZINC=-I$(ZPRE)
-ZLIB=$(ZPRE)/libz3950.a
+#ZPRE=/home/proj/zdist/zdist102b1-1/libz3950
+#ZINC=-I$(ZPRE)
+#ZLIB=$(ZPRE)/libz3950.a
-#ZLIB=../../yaz/lib/libyaz.a
+ZLIB=../../yaz/lib/libyaz.a
INCLUDE=-I../include
#CFLAGS=-g -Wall
* Europagate, 1995
*
* $Log: kernel.h,v $
- * Revision 1.13 1995/04/19 07:31:04 adam
+ * Revision 1.14 1995/04/19 10:46:18 adam
+ * Persistency works much better now. New command: status - history-like
+ *
+ * Revision 1.13 1995/04/19 07:31:04 adam
* First work on Z39.50 persistence.
*
* Revision 1.12 1995/04/17 09:34:29 adam
char *database; /* database(s) in which we search */
struct ccl_rpn_node *rpn; /* rpn request */
int present_flag; /* present in target (presistency) */
+ char *search_str; /* find request string */
struct gw_user_set *prev;
};
struct gw_user_set *user_set_add (const char *name, int hits,
const char *database,
struct ccl_rpn_node *rpn,
- int present_flag);
+ int present_flag,
+ const char *search_str);
struct gw_user_set *user_set_search (const char *name);
void user_set_init (void);
# Email gateway - resources for danish conversation
-# $Id: lang.dk.res,v 1.6 1995/03/01 14:32:25 adam Exp $
+# $Id: lang.dk.res,v 1.7 1995/04/19 10:46:18 adam Exp $
#
# Beskeder
gw.msg.subject: Din forespørgsel
gw.msg.connect: Forbindelse oprettet til server
gw.msg.databases: Databaser til stede
gw.msg.database: Valgte databaser
-gw.msg.records: %d poster modtaget
+gw.msg.records: %d poster modtaget fra sæt %s
# Fejlmeddelelser
gw.err.no.database: Database skal vælges inden find-forespørgsel
# Email gateway - resources for english conversation
-# $Id: lang.uk.res,v 1.5 1995/03/01 14:32:25 adam Exp $
+# $Id: lang.uk.res,v 1.6 1995/04/19 10:46:18 adam Exp $
#
# Messages
gw.msg.subject: Your Z39.50 Query
gw.msg.connect: Connection established to target
gw.msg.databases: Known databases
gw.msg.database: Selected databases
-gw.msg.msg.records: %d records found
+gw.msg.records: %d records found in set %s
# Error messages
gw.err.no.database: You must choose database before issuing a find-query
* Europagate, 1995
*
* $Log: main.c,v $
- * Revision 1.16 1995/04/19 07:31:07 adam
+ * Revision 1.17 1995/04/19 10:46:18 adam
+ * Persistency works much better now. New command: status - history-like
+ *
+ * Revision 1.16 1995/04/19 07:31:07 adam
* First work on Z39.50 persistence.
*
* Revision 1.15 1995/04/17 09:34:30 adam
fprintf (stderr, " -i id Set IPC userid\n");
exit (1);
case 'd':
+ gw_log_level (GW_LOG_ALL & ~RES_DEBUG);
+ break;
+ case 'D':
gw_log_level (GW_LOG_ALL);
break;
case 't':
struct gw_user_set *user_set_add (const char *name, int hits,
const char *database,
struct ccl_rpn_node *rpn,
- int present_flag)
+ int present_flag,
+ const char *search_str)
{
struct gw_user_set *s;
s->database = gw_strdup (database);
s->rpn = rpn;
s->present_flag = present_flag;
+ s->search_str = gw_strdup (search_str);
s->prev = info.sets;
info.sets = s;
return s;
* Europagate, 1995
*
* $Log: persist.c,v $
- * Revision 1.1 1995/04/19 07:31:10 adam
+ * Revision 1.2 1995/04/19 10:46:19 adam
+ * Persistency works much better now. New command: status - history-like
+ *
+ * Revision 1.1 1995/04/19 07:31:10 adam
* First work on Z39.50 persistence.
*
*/
#include "kernel.h"
+static int fgetsx (char *buf, int size, FILE *inf)
+{
+ char *cp;
+
+ if (!fgets (buf, size, inf))
+ return 0;
+ if ((cp = strchr (buf, '\n')))
+ *cp = '\0';
+ return 1;
+}
+
static int set_change;
static int obtain_set (ZASS zass, struct gw_user_set *set)
set_change = 1;
set->present_flag = 1;
set->hits = p->num;
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Set %s researched", set->name);
return 0;
}
case CCL_RPN_SET:
set = user_set_search (rpn->u.setname);
if (!set)
+ {
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Set %s not there at all",
+ rpn->u.setname);
return 1;
+ }
if (set->present_flag)
+ {
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Set %s already there",
+ rpn->u.setname);
return 0;
+ }
}
return obtain_set (zass, set);
}
return NULL;
if (!set->present_flag)
{
- int r = obtain_set (zass, set);
- if (r)
- return NULL;
+ const struct zass_searchent *p;
+
+ p = zass_p_search (zass, set->rpn, result_set, set->database,
+ info.sets);
+ if (!p)
+ return NULL;
}
return zass_present (zass, (char*) result_set, offset, number);
}
{
struct ccl_rpn_node *rpn;
struct ccl_rpn_attr **attrp;
- char *cp;
int type, value, no_read;
+ char *cp;
- if (!fgets (buf, 1024, inf))
+ if (!fgetsx (buf, 1024, inf))
return NULL;
- if ((cp = strchr (buf, '\n')))
- *cp = '\0';
switch (*buf)
{
case 'A':
rpn->u.t.term = gw_strdup (buf+2);
attrp = &rpn->u.t.attr_list;
- if (!fgets (buf, 1024, inf))
+ if (!fgetsx (buf, 1024, inf))
return NULL;
cp = buf;
while (sscanf (cp, "%d %d%n", &type, &value, &no_read) > 1)
"Couldn't open %s", fname);
return -1;
}
- gw_log (GW_LOG_FATAL, KERNEL_LOG,
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG,
"Reading persistence file %s", fname);
- if (!fgets (fline, 1024, inf))
+
+ if (!fgetsx (fline, 1024, inf))
return -1;
if (sscanf (fline, "%s", info.target) != 1)
*info.target = '\0';
- gw_log (GW_LOG_FATAL, KERNEL_LOG,
- "Reading persistence file %s (2)", fname);
read_kernel_res ();
- gw_log (GW_LOG_FATAL, KERNEL_LOG, "reopen_target start");
+
+ if (!fgetsx (fline, 1024, inf))
+ return -1;
+ free (info.database);
+ info.database = gw_strdup (fline);
+
+ if (!fgetsx (fline, 1024, inf))
+ return -1;
+ if (sscanf (fline, "%d", &info.setno) != 1)
+ return -1;
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG,
+ "Reading persistence file %s (2)", fname);
reopen_target ();
- gw_log (GW_LOG_FATAL, KERNEL_LOG, "reopen_target end");
- while (fgets (fline, 1024, inf))
+ while (fgetsx (fline, 1024, inf))
{
- gw_log (GW_LOG_FATAL, KERNEL_LOG,
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG,
"Reading persistence file %s (3)", fname);
if (sscanf (fline, "%s %d %s", resultname, &hits, database) != 3)
return -1;
- gw_log (GW_LOG_FATAL, KERNEL_LOG,
+ if (!fgetsx (fline, 1024, inf)) /* search string */
+ return -1;
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG,
"Adding %s, %d hits, database %s",
resultname, hits, database);
- set = user_set_add (resultname, hits, database, NULL, 0);
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Search string %s", fline);
+ set = user_set_add (resultname, hits, database, NULL, 0, fline);
set->rpn = load_rpn (fline, inf);
ccl_pr_tree (set->rpn, stderr);
- fgets (fline, 1024, inf);
+ fgetsx (fline, 1024, inf);
}
fclose (inf);
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Finished reading %s", fname);
return 0;
}
}
}
+static void save_sets (FILE *of, struct gw_user_set *sp)
+{
+ if (!sp)
+ return;
+ save_sets (of, sp->prev);
+ fprintf (of, "%s %d %s\n%s\n", sp->name, sp->hits, sp->database,
+ sp->search_str);
+ save_rpn (sp->rpn, of);
+ fprintf (of, "X\n");
+}
+
int save_p_state (int userid)
{
FILE *of;
char fname[128];
- struct gw_user_set *sp;
sprintf (fname, "persist.%d", userid);
return -1;
}
gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Writing persistence file %s", fname);
- fprintf (of, "%s\n", info.target);
- for (sp = info.sets; sp; sp = sp->prev)
- {
- fprintf (of, "%s %d %s\n", sp->name, sp->hits, sp->database);
- save_rpn (sp->rpn, of);
- fprintf (of, "X\n");
- }
+ fprintf (of, "%s\n%s\n%d\n", info.target, info.database, info.setno);
+ save_sets (of, info.sets);
fclose (of);
return 0;
}
-
* Europagate, 1995
*
* $Log: urp.c,v $
- * Revision 1.26 1995/04/19 07:31:12 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
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;
}
fprintf (reply_fd, "%d %s\n", p->num,
gw_res_get (info.kernel_res, "gw.msg.hits", "hit(s)"));
- us = user_set_add (setname, p->num, info.database, rpn, 1);
+ 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 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;
}
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;
}