[Nym3-commit] r21 - trunk
nym3-devel@lists.noreply.org
nym3-devel@lists.noreply.org
Sat, 15 May 2004 00:46:46 +0200
Author: laurent
Date: 2004-05-15 00:46:45 +0200 (Sat, 15 May 2004)
New Revision: 21
Added:
trunk/config.ml
trunk/user.ml
Modified:
trunk/synopsis.ml
Log:
Start user data management.
Added: trunk/config.ml
===================================================================
--- trunk/config.ml 2004-05-14 21:19:14 UTC (rev 20)
+++ trunk/config.ml 2004-05-14 22:46:45 UTC (rev 21)
@@ -0,0 +1,4 @@
+(* $Id$ *)
+
+let userdb = "/var/lib/nym3/userdb";; (* TODO : this should be read
+ from a conffile *)
Property changes on: trunk/config.ml
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/synopsis.ml
===================================================================
--- trunk/synopsis.ml 2004-05-14 21:19:14 UTC (rev 20)
+++ trunk/synopsis.ml 2004-05-14 22:46:45 UTC (rev 21)
@@ -1,4 +1,7 @@
+(* $Id$ *)
+open Str;;
+
(* Grep the relevant headers and cut at 80 chars *)
let synopsize_headers headers =
let good_headers = [ "Cc"; "From"; "Date"; "Subject";
Property changes on: trunk/synopsis.ml
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/user.ml
===================================================================
--- trunk/user.ml 2004-05-14 21:19:14 UTC (rev 20)
+++ trunk/user.ml 2004-05-14 22:46:45 UTC (rev 21)
@@ -0,0 +1,37 @@
+(* $Id$ *)
+
+(* Types for the user data, utilities to fetch them from the disk,
+ etc *)
+
+open Dbm
+open Marshal
+open Unix
+open Config
+
+type policy;; (* TODO : define that *)
+
+type hold = Never | Quota | Always;;
+
+type userdata = { idkey : string; cipherkey: string; policy : policy;
+ email_latency : int; syn_latency : int;
+ surb_rate : int; max_clear_syn : int;
+ hold_policy : hold; shutdown : string };;
+
+let lockopen_userdb path =
+ (* TODO : add the "lock" part *)
+ Dbm.opendbm path [Dbm.Dbm_rdwr; Dbm.Dbm_create] (6 * 64 + 4 * 8);;
+
+let unlockclose_userdb db =
+ (* TODO : add the "unlock" part *)
+ Dbm.close db;;
+
+let read_userdata nym =
+ let db = lockopen_userdb Config.userdb in
+ let marshalled =
+ try
+ Dbm.find db nym
+ with
+ Not_found -> unlockclose_userdb db; raise Not_found; ""
+ in
+ unlockclose_userdb db;
+ (Marshal.from_string marshalled 0 : userdata);;
Property changes on: trunk/user.ml
___________________________________________________________________
Name: svn:keywords
+ Id