From: Adam Dickmeiss Date: Mon, 20 Feb 1995 21:16:16 +0000 (+0000) Subject: FML support. Bug fixes. Profile for drewdb. X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=7cadd9d7cdd1e5be63750c3d7063ead1f9a11f22;p=egate.git FML support. Bug fixes. Profile for drewdb. --- diff --git a/kernel/Makefile b/kernel/Makefile index a0110ed..69b3a28 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -2,7 +2,10 @@ # Europagate, 1995 # # $Log: Makefile,v $ -# Revision 1.3 1995/02/17 09:08:35 adam +# Revision 1.4 1995/02/20 21:16:16 adam +# FML support. Bug fixes. Profile for drewdb. +# +# Revision 1.3 1995/02/17 09:08:35 adam # Reply with subject. CCL base command implemented. # # Revision 1.2 1995/02/16 18:35:07 adam @@ -22,14 +25,14 @@ CFLAGS=-g -Wall TPROG1=kernel O=main.o urp.o CPP=cc -E -USELIBS=../lib/ccl.a ../lib/fml.a ../lib/libzass.a ../lib/libres+log.a \ +USELIBS1=../lib/ccl.a ../lib/fml.a ../lib/libzass.a ../lib/libres+log.a \ ../lib/util.a /home/proj/zdist/zdist102b1-1/libz3950/libz3950.a -DEFS=$(INCLUDE) +DEFS=$(INCLUDE) -DUSE_FML=1 all: $(TPROG1) -$(TPROG1): $(O) $(USELIBS) - $(CC) $(CFLAGS) -o $(TPROG1) $(O) $(USELIBS) +$(TPROG1): $(O) $(USELIBS1) + $(CC) $(CFLAGS) -o $(TPROG1) $(O) $(USELIBS1) .c.o: $(CC) -c $(DEFS) $(CFLAGS) $< diff --git a/kernel/default.bib b/kernel/default.bib index 29091c4..83db237 100644 --- a/kernel/default.bib +++ b/kernel/default.bib @@ -1,10 +1,10 @@ # Subset of bib-1 attributes map to CCL qualifiers -# $Id: default.bib,v 1.2 1995/02/16 18:35:07 adam Exp $ +# $Id: default.bib,v 1.3 1995/02/20 21:16:17 adam Exp $ # -term t=l,r s=pw -clean t=l -au u=1 s=pw -ti u=4 s=pw +term t=l,r,b s=pw +clean t=l,r,b +au u=1 t=l,r,b s=pw +ti u=4 t=l,r,b s=pw isbn u=7 issn u=8 cc u=20 diff --git a/kernel/default.res b/kernel/default.res index 0558f06..d2a915b 100644 --- a/kernel/default.res +++ b/kernel/default.res @@ -1,5 +1,5 @@ # Email gateway - general kernel resources -# $Id: default.res,v 1.6 1995/02/17 17:06:16 adam Exp $ +# $Id: default.res,v 1.7 1995/02/20 21:16:17 adam Exp $ # # Important directories, programs, etc. gw.reply.mta: /usr/bin/smail @@ -12,10 +12,12 @@ gw.portno: 2000 gw.hostname: localhost gw.bibset: default.bib gw.target.loc: loc.res -gw.databases: Default +gw.target.drewdb: drewdb.res +gw.databases: # Language definitions gw.lang.dk: lang.dk.res +gw.lang.uk: lang.uk.res # Messages gw.msg.subject: Your Z39.50 Query... diff --git a/kernel/drewdb.res b/kernel/drewdb.res new file mode 100644 index 0000000..1d08091 --- /dev/null +++ b/kernel/drewdb.res @@ -0,0 +1,8 @@ +# Email gateway - resource for a specific target +# $Id: drewdb.res,v 1.1 1995/02/20 21:16:18 adam Exp $ +# See p. 17 in Europagate, Background Study, Part II +gw.portno: 210 +gw.hostname: dranet.dra.com +gw.description: Data Research Associates server +gw.databases: DREWDB + diff --git a/kernel/kernel.h b/kernel/kernel.h index f604dac..2ac7b19 100644 --- a/kernel/kernel.h +++ b/kernel/kernel.h @@ -2,7 +2,10 @@ * Europagate, 1995 * * $Log: kernel.h,v $ - * Revision 1.3 1995/02/16 18:35:08 adam + * Revision 1.4 1995/02/20 21:16:18 adam + * FML support. Bug fixes. Profile for drewdb. + * + * Revision 1.3 1995/02/16 18:35:08 adam * First use of Zdist library. Search requests are supported. * Present requests are not supported yet. * @@ -22,6 +25,11 @@ #include #include +#include +#if USE_FML +#include +#endif + int urp (FILE *inf); struct gw_kernel_info { @@ -37,6 +45,9 @@ struct gw_kernel_info { const char *override_hostname; char *databases; ZASS zass; +#if USE_FML + Fml fml; +#endif }; extern struct gw_kernel_info info; diff --git a/kernel/lang.dk.res b/kernel/lang.dk.res index 789d330..aa1c103 100644 --- a/kernel/lang.dk.res +++ b/kernel/lang.dk.res @@ -1,18 +1,20 @@ # Email gateway - resources for danish conversation -# $Id: lang.dk.res,v 1.2 1995/02/16 18:35:08 adam Exp $ +# $Id: lang.dk.res,v 1.3 1995/02/20 21:16:18 adam Exp $ # # Beskeder gw.msg.subject: Din forespørgsel gw.msg.greeting: Europagate email-Z39.50 gateway, dansk udgave. gw.msg.hits: fund gw.msg.z39errcode: Z39.50 fejl kode -gw.msg.databases: Følgende databaser er til rådighed i +gw.msg.connect: Forbindelse oprettet til server +gw.msg.databases: Databaser +gw.msg.msg.records: %d poster fundet # Fejlmeddelelser +gw.err.no.database: Database skal vælges inden find-forespørgsel gw.err.nullbody: Ingen email-krop. Ingen forespørgsel foretaget. gw.err.unimplemented: Kommandoen er endnu ikke implementeret gw.err.unknown.command: Ukendt kommando -gw.err.notarget: Target er ikke defineret gw.err.connect: Kan ikke få forbindelse med gw.err.term.expected: Søgeord forventet gw.err.rp.expected: ')' forventet diff --git a/kernel/lang.uk.res b/kernel/lang.uk.res new file mode 100644 index 0000000..5411f43 --- /dev/null +++ b/kernel/lang.uk.res @@ -0,0 +1,46 @@ +# Email gateway - resources for english conversation +# $Id: lang.uk.res,v 1.1 1995/02/20 21:16:19 adam Exp $ +# +# Messages +gw.msg.subject: Your Z39.50 Query +gw.msg.greeting: Europagate email-Z39.50 gateway +gw.msg.hits: hit(s) +gw.msg.z39errcode: Z39.50 error code +gw.msg.connect: Connection established to target +gw.msg.databases: Known databases +gw.msg.msg.records: %d records found + +# Error messages +gw.err.no.database: You must choose database before issuing a find-query +gw.err.nullbody: No email-body - no query performed +gw.err.unimplemented: The command is not implemented - yet +gw.err.unknown.command: Unknown command +gw.err.connect: Cannot connect to target +gw.err.term.expected: Search term expected +gw.err.rp.expected: ')' expected +gw.err.setname.expected: Search set name expected +gw.err.op.expected: Operator expected +gw.err.bad.rp: Unbalanced ')' +gw.err.unknown.qual: Unknown qualifier +gw.err.double.qual: Quailifiers applied more than once +gw.err.eq.qual: '=' expected +gw.err.bad.relation: Error in relation +gw.err.trunc.not.left: Left truncation not allowed +gw.err.trunc.not.both: Bot left and right truncation not allowed +gw.err.trunc.not.right: Right truncation not allowed + +# Command names and operators +ccl.command.find: find f +ccl.command.target: server target +ccl.command.show: show +ccl.command.base: base +ccl.command.help: help h +ccl.command.info: info i +ccl.command.continue: cont continue +ccl.command.status: status +ccl.command.cancel: cancel +ccl.token.and: and +ccl.token.or: or +ccl.token.not: not +ccl.token.set: s + diff --git a/kernel/main.c b/kernel/main.c index b5f4030..a96b0f2 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -2,7 +2,10 @@ * Europagate, 1995 * * $Log: main.c,v $ - * Revision 1.4 1995/02/17 17:06:16 adam + * Revision 1.5 1995/02/20 21:16:20 adam + * FML support. Bug fixes. Profile for drewdb. + * + * Revision 1.4 1995/02/17 17:06:16 adam * Minor changes. * * Revision 1.3 1995/02/16 18:35:09 adam @@ -43,6 +46,9 @@ int main (int argc, char **argv) info.override_portno = NULL; info.override_hostname = NULL; info.databases = NULL; +#if USE_FML + info.fml = NULL; +#endif gw_log_init (*argv); info.kernel_res = gw_res_init (); @@ -151,6 +157,14 @@ int main (int argc, char **argv) urp (stdin); return 0; } +#if USE_FML +static FILE *fml_inf; + +static int fml_inf_read (void) +{ + return getc (fml_inf); +} +#endif void read_kernel_res (void) { @@ -251,7 +265,7 @@ void read_kernel_res (void) } if (info.databases) free (info.databases); - v = gw_res_get (info.kernel_res, "gw.databases", "Default"); + v = gw_res_get (info.kernel_res, "gw.databases", ""); info.databases = malloc (1+strlen(v)); assert (info.databases); strcpy (info.databases, v); @@ -262,4 +276,22 @@ void read_kernel_res (void) if (info.override_hostname) strncpy (info.hostname, info.override_hostname, sizeof(info.hostname)-1); +#if USE_FML + if (!info.fml) + { + v = gw_res_get (info.kernel_res, "gw.fml", "default.fml"); + sprintf (fname, "%s/%s", path_prefix, v); + fml_inf = fopen (fname, "r"); + if (!fml_inf) + gw_log (GW_LOG_WARN, "main", "cannot open fml script %s", fname); + else + { + info.fml = fml_open (); + info.fml->read_func = fml_inf_read; + fml_preprocess (info.fml); + fml_exec (info.fml); + fclose (fml_inf); + } + } +#endif } diff --git a/kernel/urp.c b/kernel/urp.c index 29b0e62..0f6e61a 100644 --- a/kernel/urp.c +++ b/kernel/urp.c @@ -2,7 +2,10 @@ * Europagate, 1995 * * $Log: urp.c,v $ - * Revision 1.6 1995/02/17 14:41:14 quinn + * Revision 1.7 1995/02/20 21:16:20 adam + * FML support. Bug fixes. Profile for drewdb. + * + * Revision 1.6 1995/02/17 14:41:14 quinn * Added simple display of records. * * Revision 1.5 1995/02/17 14:22:13 adam @@ -34,7 +37,6 @@ #include #include "kernel.h" -#include #define LINE_MAX 256 @@ -55,10 +57,15 @@ static int reopen_target (void) v = gw_res_get (info.kernel_res, "gw.description", NULL); if (v) fprintf (reply_fd, "%s\n", v); - fprintf (reply_fd, "%s %s:%d\n %s\n", - gw_res_get (info.kernel_res, "gw.msg.databases", - "Available databases on"), - info.hostname, info.port, info.databases); + fprintf (reply_fd, "%s %s:%d\n", + gw_res_get (info.kernel_res, "gw.msg.connect", + "Connection established to"), + info.hostname, info.port); + if (*info.databases) + fprintf (reply_fd, "%s:\n%s\n", + gw_res_get (info.kernel_res, "gw.msg.databases", + "Available databases"), + info.databases); return 0; } @@ -201,16 +208,26 @@ static int exec_find (struct ccl_token *list) if (!info.zass) return -2; + if (!*info.databases) + { + fprintf (reply_fd, "%s\n", + gw_res_get (info.kernel_res, "gw.err.no.database", + "You must select database")); + return -3; + } + gw_log (GW_LOG_DEBUG, "urp", "Searching in database %s", + info.databases); p = zass_search (info.zass, rpn, "Default", info.databases); if (!p) return -1; - fprintf (reply_fd, "%d %s\n", p->num, - gw_res_get (info.kernel_res, "gw.msg.hits", "hit(s)")); if (p->errcode != -1) fprintf (reply_fd, "%s %d: %s\n", gw_res_get (info.kernel_res, "gw.msg.z39errcode", "Z39.50 error code"), p->errcode, p->errstring); + else + fprintf (reply_fd, "%d %s\n", p->num, + gw_res_get (info.kernel_res, "gw.msg.hits", "hit(s)")); return 0; } @@ -259,20 +276,177 @@ static int exec_base (struct ccl_token *list) return 0; } +struct command_word show_tab [] = +{ +{ "f", "format"}, +{ "p", "position"}, +{ NULL, NULL } +}; + static int exec_show (struct ccl_token *list) { const struct zass_presentent *zp; - zass_record *pp; char num_str[20]; - int num; + struct ccl_token *set_token = NULL; + struct ccl_token *format_token = NULL; + struct ccl_token *li = list; if (list->kind == CCL_TOK_EOL) return -1; if (!info.zass) return -2; - - memcpy (num_str, list->name, list->len); - num_str[list->len] = '\0'; + while (li->kind != CCL_TOK_EOL) + { + int modifier_no = 0; + if (li->next->kind == CCL_TOK_EQ) + { + if (li->kind == CCL_TOK_SET) /* set = ? */ + { + li = li->next->next; + set_token = li; + } + else + { + modifier_no = command_search (show_tab, li, "ccl.token."); + if (!modifier_no) + { + fprintf (reply_fd, "Unknown modifier in show\n"); + return -1; + } + li = li->next->next; + if (modifier_no == 1) /* f = ? */ + format_token = li; + else if (modifier_no == 2) /* p = ? */ + { + if (li->kind != CCL_TOK_EOL /* p = - ? */ + && li->next->kind == CCL_TOK_MINUS + && li->next->next != CCL_TOK_EOL) + li = li->next->next; + } + } + li = li->next; + } + else + li = li->next; + } + if (set_token) + gw_log (GW_LOG_DEBUG, "urp", "Got set=%.*s", set_token->len, + set_token->name); + if (format_token) + gw_log (GW_LOG_DEBUG, "urp", "Got format=%.*s", format_token->len, + format_token->name); + + li = list; + while (li->kind != CCL_TOK_EOL) + { + int modifier_no = 0; + int offset = 0; + int number = 0; + int len; + if (li->next->kind == CCL_TOK_EQ && li->kind != CCL_TOK_SET) + { + modifier_no = command_search (show_tab, li, "ccl.token."); + li = li->next->next; + if (modifier_no == 2) /* p = ? */ + { + if (li->kind != CCL_TOK_EOL /* p = - ? */ + && li->next->kind == CCL_TOK_MINUS + && li->next->next != CCL_TOK_EOL) + { + len = li->len; + memcpy (num_str, li->name, len); + num_str [len] = '\0'; + offset = atoi (num_str); + li = li->next->next; + + len = li->len; + memcpy (num_str, li->name, len); + num_str [len] = '\0'; + number = atoi (num_str) - offset + 1; + } + else + { + len = li->len; + memcpy (num_str, li->name, len); + num_str [len] = '\0'; + offset = atoi (num_str); + number = 1; + } + } + li = li->next; + } + else + { + len = li->len; + memcpy (num_str, li->name, len); + num_str[len] = '\0'; + number = atoi (num_str); + offset = 1; + li = li->next; + } + if (offset > 0 && number > 0) + { + if (set_token) + { + len = set_token->len; + memcpy (num_str, set_token->name, len); + num_str[len] = '\0'; + } + else + strcpy (num_str, "Default"); + gw_log (GW_LOG_DEBUG, "urp", "zass_present of %d records from" + " offset %d in set %s", number, offset, num_str); + zp = zass_present(info.zass, num_str, offset, number); + if (zp && zp->presentstatus == ZASS_PRES_SUCCESS) + { + int i; + zass_record *pp; + + fprintf (reply_fd, gw_res_get (info.kernel_res, + "gw.msg.records", + "Got %d records"), + zp->num); + fprintf (reply_fd, "\n"); + for (i = 1, pp = zp->records; pp; pp = pp->next, i++) + { + Iso2709Rec rec; +#if USE_FML + const char *arg_ar[5]; +#endif + + rec = iso2709_cvt (pp->record); + fprintf (reply_fd, "--- %d/%d ---\n", i, zp->num); +#if USE_FML + if (format_token) + { + len = format_token->len; + memcpy (num_str, format_token->name, len); + num_str[len] = '\0'; + } + if (format_token && + (!strcmp (num_str, "0") || !strcmp (num_str, "1"))) + { + arg_ar[0] = "\\f"; + arg_ar[1] = num_str; + arg_ar[2] = " \\list"; + arg_ar[3] = marc_to_str (info.fml, rec); + arg_ar[4] = NULL; + fml_exec_call_argv (info.fml, arg_ar); + } + else + iso2709_display (rec, reply_fd); +#else + iso2709_display (rec, reply_fd); +#endif + iso2709_rm (rec); + } + } + } + } +#if 0 + len = list->len; + memcpy (num_str, list->name, len); + num_str[len] = '\0'; num = atoi (num_str); if (!num) @@ -281,14 +455,33 @@ static int exec_show (struct ccl_token *list) zp = zass_present(info.zass, "Default", 1, num); if (zp) { - fprintf(reply_fd, "Got %d records\n", zp->num); - for (pp = zp->records; pp; pp = pp->next) + int i; + zass_record *pp; + + fprintf (reply_fd, gw_res_get (info.kernel_res, + "gw.msg.records", "Got %d records"), + zp->num); + fprintf (reply_fd, "\n"); + for (i = 1, pp = zp->records; pp; pp = pp->next, i++) { - Iso2709Rec p = iso2709_cvt(pp->record); - iso2709_display(p, reply_fd); - iso2709_rm(p); +#if USE_FML + const char *arg_ar[3]; +#endif + Iso2709Rec rec = iso2709_cvt (pp->record); + + fprintf (reply_fd, "--- %d/%d ---\n", i, zp->num); +#if USE_FML + arg_ar[0] = "\\f0 \\list"; + arg_ar[1] = marc_to_str (info.fml, rec); + arg_ar[2] = NULL; + fml_exec_call_argv (info.fml, arg_ar); +#else + iso2709_display (rec, reply_fd); +#endif + iso2709_rm (rec); } } +#endif return 0; } @@ -361,7 +554,7 @@ int urp (FILE *inf) else fprintf (reply_fd, "%s\n", gw_res_get (info.kernel_res, "gw.msg.subject", - "Your Z39.50 Query")); + "Your Query")); fprintf (reply_fd, "\n"); } else @@ -375,7 +568,7 @@ int urp (FILE *inf) 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"); + ccl_token_set = gw_res_get (info.kernel_res, "ccl.token.set", "set"); if (isalpha (line_buf[0])) exec_command (line_buf); command_no++;