Minor changes.
[egate.git] / kernel / main.c
index 7427d97..a96b0f2 100644 (file)
@@ -2,7 +2,13 @@
  * Europagate, 1995
  *
  * $Log: main.c,v $
- * Revision 1.3  1995/02/16 18:35:09  adam
+ * 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
  * First use of Zdist library. Search requests are supported.
  * Present requests are not supported yet.
  *
@@ -40,6 +46,9 @@ int main (int argc, char **argv)
     info.override_portno = NULL;
     info.override_hostname = NULL;
     info.databases = NULL;
+#if USE_FML
+    info.fml = NULL;
+#endif
 
     gw_log_init (*argv);
     info.kernel_res = gw_res_init ();
@@ -122,6 +131,20 @@ int main (int argc, char **argv)
                     exit (1);
                 }
                 break;
+            case 'g':
+                if (argv[0][2])
+                    gw_log_file (GW_LOG_ALL, argv[0]+2);
+                else if (argc > 0)
+                {
+                    --argc;
+                    gw_log_file (GW_LOG_ALL, *++argv);
+                }
+                else
+                {
+                    gw_log (GW_LOG_FATAL, "main", "missing log filename");
+                    exit (1);
+                }
+                break;
             default:
                 gw_log (GW_LOG_FATAL, "main", "unknown option %s", *argv);
                 exit (1);
@@ -134,6 +157,14 @@ int main (int argc, char **argv)
     urp (stdin);
     return 0;
 }
+#if USE_FML
+static FILE *fml_inf;
+
+static int fml_inf_read (void)
+{
+    return getc (fml_inf);
+}
+#endif
 
 void read_kernel_res (void)
 {
@@ -234,7 +265,7 @@ void read_kernel_res (void)
     }
     if (info.databases)
         free (info.databases);
-    v = gw_res_get (info.kernel_res, "gw.databases", "Default");
+    v = gw_res_get (info.kernel_res, "gw.databases", "");
     info.databases = malloc (1+strlen(v));
     assert (info.databases);
     strcpy (info.databases, v);
@@ -245,4 +276,22 @@ 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;
+            fml_preprocess (info.fml);
+            fml_exec (info.fml);
+            fclose (fml_inf);
+        }
+    }
+#endif
 }