* Europagate, 1995
*
* $Log: persist.c,v $
- * Revision 1.2 1995/04/19 10:46:19 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.
+ *
+ * Revision 1.3 1995/04/19 13:19:09 adam
+ * New command: account - for authentication.
+ *
+ * Revision 1.2 1995/04/19 10:46:19 adam
* Persistency works much better now. New command: status - history-like
*
* Revision 1.1 1995/04/19 07:31:10 adam
{
const struct zass_searchent *p;
- p = zass_search (zass, set->rpn, set->name, set->database);
+ p = zass_search (zass, set->rpn, set->name, set->database, NULL);
if (!p)
return 2;
if (p->errcode != -1)
r = obtain_sets (zass, rpn, sets);
if (r)
return NULL;
- return zass_search (zass, rpn, (char*) result_set, (char*) database);
+ return zass_search (zass, rpn, (char*) result_set, (char*) database, NULL);
}
const struct zass_presentent *zass_p_present (ZASS zass,
if (!p)
return NULL;
}
- return zass_present (zass, (char*) result_set, offset, number);
+ return zass_present (zass, (char*) result_set, offset, number, NULL);
}
struct ccl_rpn_node *load_rpn (char *buf, FILE *inf)
if (!fgetsx (buf, 1024, inf))
return NULL;
+ rpn = malloc (sizeof (*rpn));
+ if (!rpn)
+ return NULL;
switch (*buf)
{
case 'A':
- rpn = malloc (sizeof (*rpn));
- if (!rpn)
- return NULL;
rpn->kind = CCL_RPN_AND;
rpn->u.p[0] = load_rpn (buf, inf);
rpn->u.p[1] = load_rpn (buf, inf);
break;
case 'O':
- rpn = malloc (sizeof (*rpn));
- if (!rpn)
- return NULL;
rpn->kind = CCL_RPN_OR;
rpn->u.p[0] = load_rpn (buf, inf);
rpn->u.p[1] = load_rpn (buf, inf);
break;
case 'N':
- rpn = malloc (sizeof (*rpn));
- if (!rpn)
- return NULL;
rpn->kind = CCL_RPN_NOT;
rpn->u.p[0] = load_rpn (buf, inf);
rpn->u.p[1] = load_rpn (buf, inf);
break;
case 'P':
- rpn = malloc (sizeof (*rpn));
- if (!rpn)
- return NULL;
rpn->kind = CCL_RPN_PROX;
rpn->u.p[0] = load_rpn (buf, inf);
rpn->u.p[1] = load_rpn (buf, inf);
break;
case 'T':
- rpn = malloc (sizeof (*rpn));
- if (!rpn)
- return NULL;
rpn->kind = CCL_RPN_TERM;
rpn->u.t.term = gw_strdup (buf+2);
*attrp = NULL;
break;
case 'S':
- rpn = malloc (sizeof (*rpn));
- if (!rpn)
- return NULL;
rpn->kind = CCL_RPN_SET;
rpn->u.setname = gw_strdup (buf+2);
+ break;
+ default:
+ free (rpn);
+ return NULL;
}
return rpn;
}
int hits;
struct gw_user_set *set;
- sprintf (fname, "persist.%d", userid);
+ sprintf (fname, "user.%d.p", userid);
inf = fopen (fname, "r");
if (!inf)
if (!fgetsx (fline, 1024, inf))
return -1;
+ if (sscanf (fline, "%s", info.account) != 1)
+ *info.account = '\0';
+
+ if (!fgetsx (fline, 1024, inf))
+ return -1;
free (info.database);
info.database = gw_strdup (fline);
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,
FILE *of;
char fname[128];
- sprintf (fname, "persist.%d", userid);
+ sprintf (fname, "user.%d.p", userid);
of = fopen (fname, "w");
if (!of)
return -1;
}
gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Writing persistence file %s", fname);
- fprintf (of, "%s\n%s\n%d\n", info.target, 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);
+}
+