* Europagate, 1995
*
* $Log: urp.c,v $
- * Revision 1.1 1995/02/15 17:45:30 adam
+ * Revision 1.2 1995/02/16 13:21:00 adam
+ * Organization of resource files for targets and conversion
+ * language implemented.
+ *
+ * Revision 1.1 1995/02/15 17:45:30 adam
* First version of email gateway kernel. Email requests are read
* from stdin. The output is transferred to an MTA if 'From' is
* found in the header - or stdout if absent. No Z39.50 client is used.
{ "continue", "continue" },
{ "status", "status" },
{ "cancel", "cancel" },
+{ "target", "target" },
{ NULL, NULL }
};
return 0;
}
+static struct error_no_struct {
+ int no;
+ char *resource_name;
+} error_ccl_tab[] = {
+{ CCL_ERR_OK, "ok"},
+{ CCL_ERR_TERM_EXPECTED, "term.expected" },
+{ CCL_ERR_RP_EXPECTED, "rp.expected" },
+{ CCL_ERR_SETNAME_EXPECTED, "setname.expected" },
+{ CCL_ERR_OP_EXPECTED, "op.expected" },
+{ CCL_ERR_BAD_RP, "bad.rp" },
+{ CCL_ERR_UNKNOWN_QUAL, "unknown.qual" },
+{ CCL_ERR_DOUBLE_QUAL, "double.qual" },
+{ CCL_ERR_EQ_EXPECTED, "eq.expected" },
+{ CCL_ERR_BAD_RELATION, "bad.relation" },
+{ CCL_ERR_TRUNC_NOT_LEFT, "trunc.not.left" },
+{ CCL_ERR_TRUNC_NOT_BOTH, "trunc.not.both" },
+{ CCL_ERR_TRUNC_NOT_RIGHT, "trunc.not.right" },
+{ 0, NULL }
+};
+
+static char *error_no_search (struct error_no_struct *tab, int no)
+{
+ struct error_no_struct *p = tab;
+ while (p->resource_name)
+ {
+ if (no == p->no)
+ return p->resource_name;
+ p++;
+ }
+ return NULL;
+}
+
static int email_header (FILE *inf, char *from_str)
{
*from_str = '\0';
rpn = ccl_find (bibset, list, &error, &pos);
if (!rpn)
{
- fprintf (reply_fd, " %*s^ - ", pos - line_buf, " ");
- fprintf (reply_fd, "%s\n", ccl_err_msg (error));
+ const char *v = NULL, *n;
+ char name[128];
+
+ fprintf (reply_fd, " %*s^ - ", pos - line_buf, " ");
+
+ n = error_no_search (error_ccl_tab, error);
+ if (n)
+ {
+ sprintf (name, "gw.err.%s", n);
+ v = gw_res_get (kernel_res, name, NULL);
+ }
+ if (!v)
+ v = ccl_err_msg (error);
+ fprintf (reply_fd, "%s\n", v);
return -1;
}
ccl_pr_tree (rpn, reply_fd);
struct ccl_token *cmd = ccl_tokenize (str);
int no;
- ccl_token_and = gw_res_get (kernel_res, "ccl.token.and", "and");
- ccl_token_or = gw_res_get (kernel_res, "ccl.token.or", "or");
- ccl_token_not = gw_res_get (kernel_res, "ccl.token.not", "not");
- ccl_token_set = gw_res_get (kernel_res, "ccl.token.set", "set");
-
fprintf (reply_fd, "> %s", str);
- if (cmd->kind == CCL_TOK_TERM &&
+ if (cmd->kind != CCL_TOK_EOL &&
(no = command_search (command_tab, cmd, "ccl.command.")))
{
switch (no)
case 1:
return exec_find (cmd->next);
break;
- case 2:
- fprintf (reply_fd, " show found\n");
- break;
default:
- fprintf (reply_fd, " unimplemented command\n");
+ fprintf (reply_fd, " %s\n",
+ gw_res_get (kernel_res, "gw.err.unimplemented",
+ "Not implemented yet"));
}
}
else
- fprintf (reply_fd, " ^ unknown command\n");
+ {
+ fprintf (reply_fd, " ^ %s\n",
+ gw_res_get (kernel_res, "gw.err.unknown.command",
+ "unknown command"));
+ }
return 0;
}
return -1;
}
}
+ else
+ gw_log (GW_LOG_WARN, "urp", "No From in email header");
fprintf (reply_fd, "%s\n", gw_res_get (kernel_res, "gw.msg.greeting",
"Email->Z39.50 gateway"));
while (fgets (line_buf, LINE_MAX, inf))
{
if (line_buf[0] == '\n')
break;
+ ccl_token_and = gw_res_get (kernel_res, "ccl.token.and", "and");
+ ccl_token_or = gw_res_get (kernel_res, "ccl.token.or", "or");
+ ccl_token_not = gw_res_get (kernel_res, "ccl.token.not", "not");
+ ccl_token_set = gw_res_get (kernel_res, "ccl.token.set", "set");
if (isalpha (line_buf[0]))
exec_command (line_buf);
command_no++;