--- /dev/null
+# 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
+
* 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
#include <unistd.h>
#include "kernel.h"
-#include <iso2709.h>
#define LINE_MAX 256
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;
}
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;
}
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 = <name> ? */
+ {
+ 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 = <name> ? */
+ format_token = li;
+ else if (modifier_no == 2) /* p = <name> ? */
+ {
+ if (li->kind != CCL_TOK_EOL /* p = <name> - <name> ? */
+ && 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 = <name> ? */
+ {
+ if (li->kind != CCL_TOK_EOL /* p = <name> - <name> ? */
+ && 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)
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;
}
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
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++;