several are known.
# Europagate, 1995
#
# $Log: Makefile,v $
-# Revision 1.9 1995/02/23 08:32:14 adam
+# Revision 1.10 1995/03/01 14:32:24 adam
+# Better diagnostics. Default is, that only one database selected when
+# several are known.
+#
+# Revision 1.9 1995/02/23 08:32:14 adam
# Changed header.
#
# Revision 1.7 1995/02/22 08:51:34 adam
O=main.o urp.o
CPP=$(CC) -E
USELIBS1=../lib/ccl.a ../lib/fml.a ../lib/libzass.a ../lib/libres+log.a \
-../lib/util.a $(ZLIB)
+../lib/util.a $(ZLIB) $(REGEXOBJ)
DEFS=$(INCLUDE) -DUSE_FML=1
all: $(TPROG1)
# Subset of bib-1 attributes map to CCL qualifiers
-# $Id: default.bib,v 1.5 1995/02/23 08:32:15 adam Exp $
+# $Id: default.bib,v 1.6 1995/03/01 14:32:24 adam Exp $
#
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
+ts u=5 t=l,r,b w=pw
isbn u=7
issn u=8
+lccn u=9
cc u=20
-su u=21 s=pw
+sh u=21 s=pw
date u=30 r=o
dp u=31 r=o
da u=32 r=o
# Email gateway - general kernel resources
-# $Id: default.res,v 1.11 1995/02/28 13:16:26 adam Exp $
+# $Id: default.res,v 1.12 1995/03/01 14:32:24 adam Exp $
#
# Important directories, programs, etc.
gw.reply.mta: /usr/lib/sendmail
gw.reply.tmp.prefix: gwr
gw.reply.tmp.dir: /tmp
#gw.path: /home/adam/egate/kernel
+gw.marc.log: marc.log
# Retrieval settings
gw.ignore.which: 1
gw.max.show: 100
# Target definitions
-gw.portno: 2000
+gw.portno: 210
gw.hostname: localhost
gw.bibset: default.bib
gw.target.loc: loc.res
ccl.token.not: not
ccl.token.set: set
+# Diagnostic Conditions
+gw.bib1.diag.1: Permanent system error
+gw.bib1.diag.2: Temporary system error
+gw.bib1.diag.3: Unsupported search
+gw.bib1.diag.4: Terms only exclusion (stop) words
+gw.bib1.diag.5: Too many argument words
+gw.bib1.diag.6: Too many boolean operators
+gw.bib1.diag.7: Too many truncated words
+gw.bib1.diag.8: Too many incomplete subfields
+gw.bib1.diag.9: Truncated words too short
+gw.bib1.diag.10: Invalid format for record number (search term)
+gw.bib1.diag.11: Too many characters in search statement
+gw.bib1.diag.12: Too many records retrieved
+gw.bib1.diag.13: Present request out of range
+gw.bib1.diag.14: System error in presenting records
+gw.bib1.diag.15: Record no authorized to be sent intersystem
+gw.bib1.diag.16: Record exceeds Preferred-message-size
+gw.bib1.diag.17: Record exceeds Maximum-record-size
+gw.bib1.diag.18: Result set not supported as a search term
+gw.bib1.diag.19: Only single result set as search term supported
+gw.bib1.diag.20: Only ANDing of a single result set as search term supported
+gw.bib1.diag.21: Result set exists and replace indicator off
+gw.bib1.diag.22: Result set naming not supported
+gw.bib1.diag.23: Combination of specified databases not supported
+gw.bib1.diag.24: Element set names not supported
+gw.bib1.diag.25: Specified element set name not valid for specified database
+gw.bib1.diag.26: Only a single element set name supported
+gw.bib1.diag.27: Result set no longer exists - unilaterally deleted by target
+gw.bib1.diag.28: Result set is in use
+gw.bib1.diag.29: One of the specified databases is locked
+gw.bib1.diag.30: Specified result set does not exist
+gw.bib1.diag.31: Resources exhausted - no results available
+gw.bib1.diag.32: Resources exhausted - unpredictable partial results available
+gw.bib1.diag.33: Resources exhausted - valid subset of results available
+gw.bib1.diag.100: Unspecified error
+gw.bib1.diag.101: Access-control failure
+gw.bib1.diag.102: Security challenge required but could not be
+ issued - request terminated
+gw.bib1.diag.103: Security challenge required but could not be
+ issued - record not included
+gw.bib1.diag.104: Security challenge failed - record not included
+gw.bib1.diag.105: Terminated by negative continue response
+gw.bib1.diag.106: No abstract syntaxes agreed to for this record
+gw.bib1.diag.107: Query type not supported
+gw.bib1.diag.108: Malformed query
+gw.bib1.diag.109: Database unavailable
+gw.bib1.diag.110: Operator unsupported
+gw.bib1.diag.111: Too many databases specified
+gw.bib1.diag.112: Too many result sets created
+gw.bib1.diag.113: Unsupported attribute type
+gw.bib1.diag.114: Unsupported Use attribute
+gw.bib1.diag.115: Unsupported value for Use attribute
+gw.bib1.diag.116: Use attribute required but not supplied
+gw.bib1.diag.117: Unsupported Relation attribute
+gw.bib1.diag.118: Unsupported Structure attribute
+gw.bib1.diag.119: Unsupported Position attribute
+gw.bib1.diag.120: Unsupported Truncation attribute
+gw.bib1.diag.121: Unsupported Attribute Set
+gw.bib1.diag.122: Unsupported Completeness attribute
+gw.bib1.diag.123: Unsupported attribute combination
+gw.bib1.diag.124: Unsupported coded value for term
+gw.bib1.diag.125: Malformed search term
+gw.bib1.diag.126: Illegal term value for attribute
+gw.bib1.diag.127: Unparsable format for un-normalized value
+gw.bib1.diag.128: Illegal result set name
+gw.bib1.diag.129: Proximity search of sets not supported
+gw.bib1.diag.130: Illegal result set in proximity search
+gw.bib1.diag.131: Unsupported proximity relation
+gw.bib1.diag.132: Unsupported proximity unit code
+
# Help messages
gw.help.general: You
have triggered the "help"-information on the Email gateway. \n\n
* Europagate, 1995
*
* $Log: kernel.h,v $
- * Revision 1.7 1995/02/23 08:32:16 adam
+ * Revision 1.8 1995/03/01 14:32:24 adam
+ * Better diagnostics. Default is, that only one database selected when
+ * several are known.
+ *
+ * Revision 1.7 1995/02/23 08:32:16 adam
* Changed header.
*
* Revision 1.5 1995/02/22 15:22:32 adam
const char *override_portno;
const char *override_hostname;
char *databases;
+ char *database;
ZASS zass;
#if USE_FML
Fml fml;
struct gw_user_set *user_set_add (const char *name, int hits);
struct gw_user_set *user_set_search (const char *name);
void user_set_init (void);
+
+#define KERNEL_LOG "kernel"
# Email gateway - resources for danish conversation
-# $Id: lang.dk.res,v 1.5 1995/02/23 08:32:16 adam Exp $
+# $Id: lang.dk.res,v 1.6 1995/03/01 14:32:25 adam Exp $
#
# Beskeder
gw.msg.subject: Din forespørgsel
gw.msg.hits: fund
gw.msg.z39errcode: Z39.50 fejl kode
gw.msg.connect: Forbindelse oprettet til server
-gw.msg.databases: Databaser
-gw.msg.msg.records: %d poster fundet
+gw.msg.databases: Databaser til stede
+gw.msg.database: Valgte databaser
+gw.msg.records: %d poster modtaget
# Fejlmeddelelser
gw.err.no.database: Database skal vælges inden find-forespørgsel
+gw.err.no.set: Intet resultat genereret
gw.err.nullbody: Ingen email-krop. Ingen forespørgsel foretaget.
gw.err.unimplemented: Kommandoen er endnu ikke implementeret
gw.err.unknown.command: Ukendt kommando
# Email gateway - resources for english conversation
-# $Id: lang.uk.res,v 1.4 1995/02/23 08:32:16 adam Exp $
+# $Id: lang.uk.res,v 1.5 1995/03/01 14:32:25 adam Exp $
#
# Messages
gw.msg.subject: Your Z39.50 Query
gw.msg.z39errcode: Z39.50 error code
gw.msg.connect: Connection established to target
gw.msg.databases: Known databases
+gw.msg.database: Selected databases
gw.msg.msg.records: %d records found
# Error messages
* Europagate, 1995
*
* $Log: main.c,v $
- * Revision 1.9 1995/02/23 08:32:17 adam
+ * Revision 1.10 1995/03/01 14:32:25 adam
+ * Better diagnostics. Default is, that only one database selected when
+ * several are known.
+ *
+ * Revision 1.9 1995/02/23 08:32:17 adam
* Changed header.
*
* Revision 1.7 1995/02/22 15:22:33 adam
info.override_portno = NULL;
info.override_hostname = NULL;
info.databases = NULL;
+ info.database = NULL;
#if USE_FML
info.fml = NULL;
#endif
}
else
{
- gw_log (GW_LOG_FATAL, "main", "missing target name");
+ gw_log (GW_LOG_FATAL, KERNEL_LOG, "missing target name");
exit (1);
}
break;
}
else
{
- gw_log (GW_LOG_FATAL, "main", "missing language name");
+ gw_log (GW_LOG_FATAL, KERNEL_LOG, "missing language name");
exit (1);
}
break;
}
else
{
- gw_log (GW_LOG_FATAL, "main", "missing language name");
+ gw_log (GW_LOG_FATAL, KERNEL_LOG, "missing language name");
exit (1);
}
break;
}
else
{
- gw_log (GW_LOG_FATAL, "main", "missing portno");
+ gw_log (GW_LOG_FATAL, KERNEL_LOG, "missing portno");
exit (1);
}
break;
}
else
{
- gw_log (GW_LOG_FATAL, "main", "missing hostname");
+ gw_log (GW_LOG_FATAL, KERNEL_LOG, "missing hostname");
exit (1);
}
break;
}
else
{
- gw_log (GW_LOG_FATAL, "main", "missing log filename");
+ gw_log (GW_LOG_FATAL, KERNEL_LOG, "missing log filename");
exit (1);
}
break;
default:
- gw_log (GW_LOG_FATAL, "main", "unknown option %s", *argv);
+ gw_log (GW_LOG_FATAL, KERNEL_LOG, "unknown option %s", *argv);
exit (1);
}
}
gw_res_close (info.kernel_res);
info.kernel_res = gw_res_init ();
- gw_log (GW_LOG_DEBUG, "main", "reading kernel resource, default %s",
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "reading kernel resource, default %s",
info.default_res);
if (*info.target)
- gw_log (GW_LOG_DEBUG, "main", "reading kernel resource, target %s",
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "reading kernel resource, target %s",
info.target);
if (info.lang)
- gw_log (GW_LOG_DEBUG, "main", "reading kernel resource, lang %s",
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "reading kernel resource, lang %s",
info.lang);
if (gw_res_merge (info.kernel_res, info.default_res))
{
- gw_log (GW_LOG_WARN, "main", "Couldn't read resource file %s",
+ gw_log (GW_LOG_WARN, KERNEL_LOG, "Couldn't read resource file %s",
info.default_res);
return;
}
sprintf (fname, "%s/%s", path_prefix, v);
bib_inf = fopen (fname, "r");
if (!bib_inf)
- gw_log (GW_LOG_WARN, "main", "cannot open %s", fname);
+ gw_log (GW_LOG_WARN, KERNEL_LOG, "cannot open %s", fname);
else
{
- gw_log (GW_LOG_DEBUG, "main", "reading bib file %s", fname);
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "reading bib file %s", fname);
ccl_qual_file (info.bibset, bib_inf);
fclose (bib_inf);
}
}
if (info.databases)
free (info.databases);
+ if (info.database)
+ free (info.database);
v = gw_res_get (info.kernel_res, "gw.databases", "");
info.databases = gw_strdup (v);
for (cp = info.databases; (cp = strchr (cp, ' ')); cp++)
*cp = ',';
+ v = gw_res_get (info.kernel_res, "gw.database", "");
+ if (*v == '\0' && *info.databases)
+ {
+ int len;
+ cp = strchr (info.databases, ',');
+
+ len = cp ? (cp-info.databases) : strlen (info.databases);
+ info.database = malloc (len+1);
+ assert (info.database);
+ memcpy (info.database, info.databases, len);
+ info.database[len] = '\0';
+ }
+ else
+ {
+ info.database = gw_strdup (v);
+ for (cp = info.database; (cp = strchr (cp, ' ')); cp++)
+ *cp = ',';
+ }
if (info.override_portno)
info.port = atoi (info.override_portno);
if (info.override_hostname)
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);
+ gw_log (GW_LOG_WARN, KERNEL_LOG,
+ "cannot open fml script %s", fname);
else
{
info.fml = fml_open ();
* Europagate, 1995
*
* $Log: urp.c,v $
- * Revision 1.17 1995/02/28 13:16:26 adam
+ * Revision 1.18 1995/03/01 14:32:26 adam
+ * Better diagnostics. Default is, that only one database selected when
+ * several are known.
+ *
+ * Revision 1.17 1995/02/28 13:16:26 adam
* Configurable From: added.
*
* Revision 1.16 1995/02/23 10:08:20 adam
#include <ctype.h>
#include <string.h>
#include <unistd.h>
+#include <fcntl.h>
#include "kernel.h"
{
const char *v;
if (info.zass)
- gw_log (GW_LOG_WARN, "urp", "Zass free...");
+ gw_log (GW_LOG_WARN, KERNEL_LOG, "Zass free...");
info.zass = zass_open (info.hostname, info.port);
if (!info.zass)
{
}
v = gw_res_get (info.kernel_res, "gw.description", NULL);
if (v)
- fprintf (reply_fd, "%s\n", v);
+ {
+ put_esc_str (v);
+ fprintf (reply_fd, "\n");
+ }
fprintf (reply_fd, "%s %s:%d\n",
gw_res_get (info.kernel_res, "gw.msg.connect",
"Connection established to"),
gw_res_get (info.kernel_res, "gw.msg.databases",
"Available databases"),
info.databases);
+ if (*info.database)
+ fprintf (reply_fd, "%s:\n%s\n",
+ gw_res_get (info.kernel_res, "gw.msg.database",
+ "Selected databases"),
+ info.database);
return 0;
}
return 0;
}
+static void display_diag_error (int code, const char *addinfo)
+{
+ static char str[20];
+
+ sprintf (str, "gw.bib1.diag.%d", code);
+ fprintf (reply_fd, "%s %d:\n %s: '%s'\n",
+ gw_res_get (info.kernel_res, "gw.msg.z39errcode",
+ "Z39.50 Error"),
+ code,
+ gw_res_get (info.kernel_res, str, ""), addinfo);
+}
+
static int exec_find (struct ccl_token *list)
{
const struct zass_searchent *p;
ccl_pr_tree (rpn, reply_fd);
fprintf (reply_fd, "\n");
- if (!*info.databases)
+ if (!*info.database )
{
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);
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Searching in database %s",
+ info.database );
assert (info.zass);
- p = zass_search (info.zass, rpn, "Default", info.databases);
+ p = zass_search (info.zass, rpn, "Default", info.database );
if (!p)
return -1;
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);
+ display_diag_error (p->errcode, p->errstring);
return -2;
}
fprintf (reply_fd, "%d %s\n", p->num,
assert (info.zass);
if (list->kind == CCL_TOK_EOL)
return -1;
- free (info.databases);
+ free (info.database);
while (li->kind != CCL_TOK_EOL)
{
len += li->len + 1;
if (li->kind == CCL_TOK_COMMA)
li = li->next;
}
- info.databases = malloc (len);
- assert (info.databases);
+ info.database = malloc (len);
+ assert (info.database );
len = 0;
li = list;
while (li->kind != CCL_TOK_EOL)
{
- memcpy (info.databases+len, li->name, li->len);
+ memcpy (info.database+len, li->name, li->len);
len += li->len;
- info.databases[len++] = ',';
+ info.database[len++] = ',';
li = li->next;
if (li->kind == CCL_TOK_COMMA)
li = li->next;
}
- info.databases[len-1] = '\0';
+ info.database[len-1] = '\0';
return 0;
}
"200"));
if (number > max_number)
number = max_number;
- gw_log (GW_LOG_DEBUG, "urp", "present in set %s", set);
- gw_log (GW_LOG_DEBUG, "urp", "present of %d records from offset %d",
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "present in set %s", set);
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "present of %d records from offset %d",
number, offset);
zp = zass_present(info.zass, (char *) set, offset, number);
if (zp)
{
int i;
zass_record *pp;
-
+ char path[128];
+ int record_log_fd = -1;
+ const char *record_log_name;
+
+ record_log_name = gw_res_get (info.kernel_res, "gw.marc.log",
+ NULL);
+ if (record_log_name)
+ {
+ sprintf (path, "%s/%s", gw_res_get (info.kernel_res,
+ "gw.path", "."),
+ record_log_name );
+ record_log_fd = open (path, O_WRONLY|O_CREAT|O_APPEND, 0666);
+ if (record_log_fd == -1)
+ gw_log (GW_LOG_WARN, "Cannot open %s", path);
+ }
fprintf (reply_fd, gw_res_get (info.kernel_res,
"gw.msg.records",
"Got %d records"),
{
if (pp->which == ZASS_REC_DIAG)
{
- fprintf (reply_fd, "Record error %d: %s\n",
- pp->errcode, pp->errstring);
+ display_diag_error (pp->errcode, pp->errstring);
continue;
}
else if (pp->which != ZASS_REC_USMARC)
continue;
}
}
+ if (record_log_fd != -1)
+ write (record_log_fd, pp->record, strlen(pp->record));
rec = iso2709_cvt (pp->record);
if (rec)
{
else
fprintf (reply_fd, "Not a MARC record\n");
}
+ if (record_log_fd != -1)
+ close (record_log_fd);
}
}
li = li->next;
}
if (set_token)
- gw_log (GW_LOG_DEBUG, "urp", "Got set=%.*s", set_token->len,
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Got set=%.*s", set_token->len,
set_token->name);
if (format_token)
- gw_log (GW_LOG_DEBUG, "urp", "Got format=%.*s", format_token->len,
+ gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Got format=%.*s", format_token->len,
format_token->name);
li = list;
}
else
{
- fprintf (reply_fd, "\n> %s", str);
+ fprintf (reply_fd, "\n> %s\n", str);
fprintf (reply_fd, " ^ %s\n",
gw_res_get (info.kernel_res, "gw.err.unknown.command",
"unknown command. "
if (email_header (inf, from_str, subject_str))
{
- gw_log (GW_LOG_WARN, "urp", "No message body");
+ gw_log (GW_LOG_WARN, KERNEL_LOG, "No message body");
return -1;
}
if (*from_str)
reply_fd = fopen (reply_fname, "w");
if (!reply_fd)
{
- gw_log (GW_LOG_FATAL, "urp", "Cannot create %s",
+ gw_log (GW_LOG_FATAL, KERNEL_LOG, "Cannot create %s",
reply_fname);
return -1;
}
"gw.msg.subject",
"Your Query"));
fprintf (reply_fd, "\n");
- gw_log (GW_LOG_DEBUG, "urp", "Mail from %s", from_str);
+ gw_log (GW_LOG_ACCT, KERNEL_LOG, "User start %s", from_str);
}
else
- gw_log (GW_LOG_WARN, "urp", "No From in email header");
+ 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))
break;
if ((cp = strchr (line_buf, '\n')))
*cp = '\0';
- gw_log (GW_LOG_ACCT, "urp", "cmd: %s", line_buf);
+ gw_log (GW_LOG_ACCT, KERNEL_LOG, "cmd: %s", line_buf);
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");
mta_code = system (cmd);
if (mta_code)
- gw_log (GW_LOG_FATAL, "urp", "Reply '%s' got exit code %d",
+ gw_log (GW_LOG_FATAL, KERNEL_LOG, "Reply '%s' got exit code %d",
cmd, mta_code);
unlink (reply_fname);
- gw_log (GW_LOG_DEBUG, "urp", "Normal session for user %s", from_str);
+ gw_log (GW_LOG_ACCT, KERNEL_LOG, "User end %s", from_str);
}
return 0;
}