* Europagate, 1995
*
* $Log: urp.c,v $
- * Revision 1.20 1995/03/03 17:19:17 adam
+ * Revision 1.21 1995/03/27 08:24:04 adam
+ * First use of gip interface and gw-db.
+ * First work on eti program.
+ *
+ * Revision 1.20 1995/03/03 17:19:17 adam
* Smarter presentation. Bug fix in email header interpretation.
*
* Revision 1.19 1995/03/02 09:32:11 adam
tty_emit (*s++);
}
+int lgets (char *buf, int max, int fd)
+{
+ int r, no = 0;
+
+ --max;
+ while (no <= max)
+ {
+ if ((r=read (fd, buf+no, 1)) != 1)
+ {
+ if (r == -1)
+ gw_log (GW_LOG_WARN, KERNEL_LOG, "read fail");
+ buf[no] = '\0';
+ return 0;
+ }
+ if (buf[no] == 1)
+ return 0;
+ if (buf[no++] == '\n')
+ break;
+ }
+ buf[no] = '\0';
+ return 1;
+}
+
static int reopen_target (void)
{
const char *v;
return NULL;
}
-static int email_header (FILE *inf, char *from_str, char *subject_str)
+static int email_header (int fd, char *from_str, char *subject_str)
{
*from_str = '\0';
*subject_str = '\0';
- while (fgets (line_buf, LINE_MAX, inf))
+ while (lgets (line_buf, LINE_MAX, fd))
{
if (line_buf[0] == '\n')
return 0;
static int exec_help (struct ccl_token *list)
{
+ static char *sep = "-------------------------------\\n";
help_general ();
#if 1
+ put_esc_str (sep);
put_esc_str (gw_res_get (info.kernel_res, "gw.help.target",
"target <name> - selects a given target\n"));
+ put_esc_str (sep);
put_esc_str (gw_res_get (info.kernel_res, "gw.help.base",
"base <base>.. - selects databases\n"));
+ put_esc_str (sep);
put_esc_str (gw_res_get (info.kernel_res, "gw.help.find",
"find <query> - performs a search request\n"));
+ put_esc_str (sep);
put_esc_str (gw_res_get (info.kernel_res, "gw.help.show",
"show <spec> - retrieves and displays "
"records\n"));
return 0;
}
-int urp (FILE *inf)
+int urp (int fd)
{
char from_str[128];
char subject_str[128];
int command_no = 0;
char *reply_fname = NULL;
- if (email_header (inf, from_str, subject_str))
+ if (email_header (fd, from_str, subject_str))
{
gw_log (GW_LOG_WARN, KERNEL_LOG, "No message body");
return -1;
gw_log (GW_LOG_WARN, KERNEL_LOG, "No From in email header");
fprintf (reply_fd, "%s\n", gw_res_get (info.kernel_res, "gw.msg.greeting",
"Email->Z39.50 gateway"));
- while (fgets (line_buf, LINE_MAX, inf))
+ while (lgets (line_buf, LINE_MAX, fd))
{
char *cp;
if (line_buf[0] == '\n')
if (command_no)
+ {
+ while (lgets (line_buf, LINE_MAX, fd))
+ ;
break;
+ }
else
continue;
if ((cp = strchr (line_buf, '\n')))