X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=kernel%2Fmain.c;h=0d5345304952439fcd83f4872673deb766cb3aa0;hb=8467171ebdb5f018740de8d82149c8ccc53d2815;hp=b5f403038190d3b1cccc5df4f4085ab182d65c2c;hpb=3bdafbe35f519fcdd6ec307764eefb14bf1e0d68;p=egate.git diff --git a/kernel/main.c b/kernel/main.c index b5f4030..0d53453 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -2,7 +2,23 @@ * Europagate, 1995 * * $Log: main.c,v $ - * Revision 1.4 1995/02/17 17:06:16 adam + * Revision 1.9 1995/02/23 08:32:17 adam + * Changed header. + * + * Revision 1.7 1995/02/22 15:22:33 adam + * Much more checking of run-time state. Show command never retrieves + * more records than indicated by the previous search request. Help + * command available. The maximum number of records retrieved can be + * controlled now. + * + * Revision 1.6 1995/02/22 08:51:34 adam + * Output function can be customized in fml, which is used to print + * the reply to reply_fd. + * + * 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 +59,10 @@ int main (int argc, char **argv) info.override_portno = NULL; info.override_hostname = NULL; info.databases = NULL; +#if USE_FML + info.fml = NULL; +#endif + info.sets = NULL; gw_log_init (*argv); info.kernel_res = gw_res_init (); @@ -152,6 +172,58 @@ int main (int argc, char **argv) return 0; } +struct gw_user_set *user_set_add (const char *name, int hits) +{ + struct gw_user_set *s; + + s = malloc (sizeof (*s)); + assert (s); + + s->name = gw_strdup (name); + s->hits = hits; + s->prev = info.sets; + info.sets = s; + return s; +} + +void user_set_init (void) +{ + struct gw_user_set *s, *s1; + + for (s = info.sets; s; s = s1) + { + free (s->name); + s1 = s->prev; + free (s); + } + info.sets = NULL; +} + +struct gw_user_set *user_set_search (const char *name) +{ + struct gw_user_set *s; + + if (!name) + return info.sets; + for (s = info.sets; s; s = s->prev) + if (!strcmp (s->name, name)) + return s; + return NULL; +} + +#if USE_FML +static void fml_inf_write (int ch) +{ + putc (ch, reply_fd); +} +static FILE *fml_inf; + +static int fml_inf_read (void) +{ + return getc (fml_inf); +} +#endif + void read_kernel_res (void) { char path_prefix[128]; @@ -160,6 +232,8 @@ void read_kernel_res (void) char *cp; char resource_name[256]; + user_set_init (); + if (info.bibset) ccl_qual_rm (&info.bibset); info.bibset = ccl_qual_mk (); @@ -251,10 +325,8 @@ void read_kernel_res (void) } if (info.databases) free (info.databases); - v = gw_res_get (info.kernel_res, "gw.databases", "Default"); - info.databases = malloc (1+strlen(v)); - assert (info.databases); - strcpy (info.databases, v); + v = gw_res_get (info.kernel_res, "gw.databases", ""); + info.databases = gw_strdup (v); for (cp = info.databases; (cp = strchr (cp, ' ')); cp++) *cp = ','; if (info.override_portno) @@ -262,4 +334,23 @@ 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; + info.fml->write_func = fml_inf_write; + fml_preprocess (info.fml); + fml_exec (info.fml); + fclose (fml_inf); + } + } +#endif }