More work on Def-settings.
[egate.git] / kernel / persist.c
index 9158d40..6eced3a 100644 (file)
@@ -2,7 +2,20 @@
  * Europagate, 1995
  *
  * $Log: persist.c,v $
- * Revision 1.4  1995/04/20 16:10:46  adam
+ * Revision 1.7  1995/05/03 16:34:19  adam
+ * CCL def command, i.e. user definitions - saved as resource files.
+ *
+ * Revision 1.6  1995/05/03  07:37:44  adam
+ * CCL commands stop/continue implemented. New functions gw_res_{int,bool}
+ * are used when possible.
+ *
+ * Revision 1.5  1995/05/02  15:26:00  adam
+ * Monitor observes death of child (email kernel). The number
+ * of simultanous processes is controlled now. Email requests are
+ * queued if necessary. This scheme should only be forced if no kernels
+ * are idle.
+ *
+ * Revision 1.4  1995/04/20  16:10:46  adam
  * Modified to work with non-blocking zass-api. Not using non-blocking
  * facility yet.
  *
@@ -200,7 +213,7 @@ int load_p_state (int userid)
     int hits;
     struct gw_user_set *set;
 
-    sprintf (fname, "persist.%d", userid);
+    sprintf (fname, "user.%d.p", userid);
 
     inf = fopen (fname, "r");
     if (!inf)
@@ -232,9 +245,15 @@ int load_p_state (int userid)
         return -1;
     if (sscanf (fline, "%d", &info.setno) != 1)
         return -1;
+    if (!fgetsx (fline, 1024, inf))
+        return -1;
+    if (sscanf (fline, "%d", &info.next_position) != 1)
+        return -1;
     gw_log (GW_LOG_DEBUG, KERNEL_LOG, 
            "Reading persistence file %s (2)", fname);
+#if 0
     reopen_target ();
+#endif
     while (fgetsx (fline, 1024, inf))
     {
         gw_log (GW_LOG_DEBUG, KERNEL_LOG, 
@@ -310,7 +329,7 @@ int save_p_state (int userid)
     FILE *of;
     char fname[128];
 
-    sprintf (fname, "persist.%d", userid);
+    sprintf (fname, "user.%d.p", userid);
 
     of = fopen (fname, "w");
     if (!of)
@@ -320,9 +339,18 @@ int save_p_state (int userid)
         return -1;
     }
     gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Writing persistence file %s", fname);
-    fprintf (of, "%s\n%s\n%s\n%d\n", info.target, info.account,
-             info.database, info.setno);
+    fprintf (of, "%s\n%s\n%s\n%d\n%d\n", info.target, info.account,
+             info.database, info.setno, info.next_position);
     save_sets (of, info.sets);
     fclose (of);
     return 0;
 }
+
+void del_p_state (int userid)
+{
+    char fname[128];
+
+    sprintf (fname, "user.%d.p", userid);
+    unlink (fname);
+}
+