Permalink
Browse files

[fix] database: Added dbmDB files.

  • Loading branch information...
1 parent 50975e4 commit f0f07a4ec55afd11b23a0b3e12ca14c040f25973 @nrs135 nrs135 committed with Louis Gesbert Aug 8, 2011
Showing with 94 additions and 0 deletions.
  1. +36 −0 database/light/DbSig.ml
  2. +38 −0 database/light/dbmDB.ml
  3. +20 −0 database/light/dbmDB.mli
View
36 database/light/DbSig.ml
@@ -0,0 +1,36 @@
+(*
+ Copyright © 2011 MLstate
+
+ This file is part of OPA.
+
+ OPA is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License, version 3, as published by
+ the Free Software Foundation.
+
+ OPA is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with OPA. If not, see <http://www.gnu.org/licenses/>.
+*)
+
+module type DB =
+sig
+
+ type t
+
+ type flags = DB_create | DB_rdwr | DB_rdonly
+
+ exception DB_error of string
+
+ val opendb : string -> flags list -> int -> t
+ val find : t -> string -> string
+ val replace : t -> string -> string -> unit
+ val remove : t -> string -> unit
+ val iter : (string -> string -> unit) -> t -> unit
+ val close : t -> unit
+
+end
+
View
38 database/light/dbmDB.ml
@@ -0,0 +1,38 @@
+(*
+ Copyright © 2011 MLstate
+
+ This file is part of OPA.
+
+ OPA is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License, version 3, as published by
+ the Free Software Foundation.
+
+ OPA is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with OPA. If not, see <http://www.gnu.org/licenses/>.
+*)
+
+type t = Dbm.t
+
+type flags = DB_create | DB_rdwr | DB_rdonly
+
+exception DB_error of string
+
+let _conv_flag = function
+ | DB_create -> Dbm.Dbm_create
+ | DB_rdwr -> Dbm.Dbm_rdwr
+ | DB_rdonly -> Dbm.Dbm_rdonly
+let _conv_flags = List.map _conv_flag
+
+let _conv_exn f a = try f a with Dbm.Dbm_error str -> raise (DB_error str)
+
+let opendb file flags perms = _conv_exn (Dbm.opendbm file (_conv_flags flags)) perms
+let find t k = _conv_exn (Dbm.find t) k
+let replace t k v = _conv_exn (Dbm.replace t) k v
+let remove t k = _conv_exn (Dbm.remove t) k
+let iter f t = _conv_exn (Dbm.iter f) t
+let close t = _conv_exn Dbm.close t
View
20 database/light/dbmDB.mli
@@ -0,0 +1,20 @@
+(*
+ Copyright © 2011 MLstate
+
+ This file is part of OPA.
+
+ OPA is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License, version 3, as published by
+ the Free Software Foundation.
+
+ OPA is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
+ more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with OPA. If not, see <http://www.gnu.org/licenses/>.
+*)
+
+include DbSig.DB
+

0 comments on commit f0f07a4

Please sign in to comment.