Commits

Kristian Fiskerstrand  committed 778bc30

Revert to a613f7afff06

  • Participants
  • Parent commits 728e419

Comments (0)

Files changed (112)

   nginx example from Daniel Kahn Gillmor
     -------------------
     server {
-        listen  209.234.253.170:11371;
-        listen  80;
-        server_name keys.mayfirst.org;
-        access_log  off;
-        location / {
-            proxy_pass http://localhost:11371/;
-        }
+	listen  209.234.253.170:11371;
+	listen  80;
+	server_name keys.mayfirst.org;
+	access_log  off;
+	location / {
+		proxy_pass http://localhost:11371/;
+	}
     }
     server {
-        listen  443;
-        server_name zimmermann.mayfirst.org;
-        ssl on;
-        ssl_certificate /etc/ssl/keys-m.o.crt;
-        ssl_certificate_key /etc/ssl/private/keys.m.o-key.pem;
-        ssl_ciphers HIGH:MEDIUM:!ADH;
-        access_log  off;
-        location / {
-            proxy_pass http://localhost:11371/;
-        }
+	listen  443;
+	server_name zimmermann.mayfirst.org;
+	ssl on;
+	ssl_certificate /etc/ssl/keys-m.o.crt;
+	ssl_certificate_key /etc/ssl/private/keys.m.o-key.pem;
+	ssl_ciphers HIGH:MEDIUM:!ADH;
+	access_log  off;
+	location / {
+		proxy_pass http://localhost:11371/;
+	}
     }
     -------------------
 
     the header, to let a client poll for how many results exist, without
     retrieving any. Submitted by Phil Pennock. See:
     http://lists.nongnu.org/archive/html/sks-devel/2010-11/msg00015.html
-  - Add UPGRADING document to explain upgrading Berkeley DB without
-    rebuilding. System bdb versions often change with new SKS releases
+  - Add UPGRADING document to explain upgrading Berkeley DB without 
+    rebuilding. System bdb versions often change with new SKS releases 
     for .deb and .rpm distros.
   - Cleanup build errors for bdb/bdb_stubs.c. Patch from Mike Doty
   - Update cryptokit from version 1.0 to 1.5 without requiring OASIS
     compatible version. This has been fixed.
   - Added new server mime-types, and trying another default document (Issue 6)
     In addition to the new MIME types added in 1.1.[23], the server now
-    looks over a list and and serves the first index file that it finds
+    looks over a list and and serves the first index file that it finds 
     Current list: index.html, index.htm, index.xhtml, index.xhtm, index.xml.
-  - options=mr now works on get as well as (v)index operations. This is
+  - options=mr now works on get as well as (v)index operations. This is 
     described in http://tools.ietf.org/html/draft-shaw-openpgp-hkp-00
     sections 3.2.1.1. and 5.1.
   - Updated copyright notices in source files
   - Added sksclient tool, similar to old pksclient
-  - Add no-cache instructions to HTTP response (in order for reverse proxies
-    not to cache the output from SKS)
-  - Use unique timestamps for keydb to reduce occurrances of Ptree corruption.
+  - Add no-cache instructions to HTTP response (in order for reverse proxies 
+    not to cache the output from SKS) 
+  - Use unique timestamps for keydb to reduce occurrances of Ptree corruption. 
   - Added Interface specifications (.mli files) for modules that were missing
     them
   - Yaron pruned some no longer needed source files from the tree.
-  - Improved the HTTP status and HTTP error codes returned for various
+  - Improved the HTTP status and HTTP error codes returned for various 
     situations and added checks for more error conditions.
   - Add a suffix to version (+) indicating non-release or development builds
   - Add an option to specify the contact details of the server administrator
     that shows in the status page of the server. The information is in the
     form of an OpenPGP KeyID and set by server_contact: in sksconf
-  - Add a `sks version` command to provide information on the setup.
+  - Add a `sks version` command to provide information on the setup. 
   - Added configuration settings for the remaining database table files. If
     no pagesize settings are in sksconf, SKS will use 2048 bytes for key
     and 512 for ptree. The remainining files' pagesize will be set by BDB
   - Makefile fix for 'make dep' if .depend does not exist. Issue #4
   - Makefile fix: sks and sks_add_mail fail to link w/o '-ccopt -pg'
     Issue #23
-  - Added -disable_mailsync and -disable_log_diffs to sks.pod
+  - Added -disable_mailsync and -disable_log_diffs to sks.pod 
   - Added file extensions .css, .jpeg, .htm, .es, .js, .xml, .shtml, .xhtm,
     .xhtml and associated MIME types to server code. Part of Issue #6
   - Added sample configuration files in sampleConfig directory
   - Added sample web page files in sampleWeb directory. Issues #7, 9, 19
-  - Allow requests for non-official options hget, hash, status, & clean to
-    be preceded by '-x'. Closes issues #10, 11, 13, & 14.
+  - Allow requests for non-official options hget, hash, status, & clean to 
+    be preceded by '-x'. Closes issues #10, 11, 13, & 14. 
   - Allow &search with long subkey ID (16 digit) and subkey fingerprint
     subkey lookup was failing with other than a short key ID. However,
     public key lookup was working with short and long key ID and fingerprints.
   - HTML generated by SKS has been cleaned up to pass XHTML 1.0 Strict
     without error or warnings
   - Added HTTP/1.0 after POST, '-' added to safe characters for webserver,
-    Add '.html' (text/html) to list of supported file extensions for web server
+    Add '.html' (text/html) to list of supported file extensions for web server 
   - Johan van Selst's patch implementing Phil Pennock's suggestion
       of an X-HKP-Results-Count: header to returned web server queries
   - Johan van Selst's patch to add Content-length header to web results
   - Work-around in bdb_stubs.c for DB_XA_CREATE dropped after DB 4.7
   - Import debian patch 508_build_fastbuild.patch for improved sks_build script
   - always display number of hashes received for better statistics in recon.log
-  - Fix 'sks dump' usage: help message syntax
-  - Fix documentation to explicit that hkp_address and recon_address can
+  - Fix 'sks dump' usage: help message syntax 
+  - Fix documentation to explicit that hkp_address and recon_address can 
     contain both IP addresses and domain names.
   - Fix documentation with ambiguity of -n when used with build and fastbuild
   - Spelling corrections
   - fixed bug in handling of send_mailsyncs flag
   - BUGFIX: The last word of a user id was not properly case converted.
   - Makefile fixes
-  - imported patch sksdump-recursion
+  - imported patch sksdump-recursion 
   - imported patch reconsever-resilience
-  - imported patch multiple-addresses
-  - imported patch full-rrset
-  - imported patch dbsyc-on-sigusr1
-  - imported patch ignore-sigusr2
-  - imported patch increase-wserver-timeout
-  - imported patch spider-set-starthost
-  - imported patch spider-add-buildtarget
-  - [mq]: dns-refresh-patch
+  - imported patch multiple-addresses 
+  - imported patch full-rrset 
+  - imported patch dbsyc-on-sigusr1 
+  - imported patch ignore-sigusr2 
+  - imported patch increase-wserver-timeout 
+  - imported patch spider-set-starthost 
+  - imported patch spider-add-buildtarget 
+  - [mq]: dns-refresh-patch 
   - imported patch spider-target-fix
   - [mq]: pdp-smallfixes
 
        sks_db.  This should make it easier to put sks on port 80.  Also,
        sks can now be launched from any directory, as long as the -basedir
        command-line option is used to specify the location of the sks
-       directory.
+       directory. 
 
 1.0.2: Serious database corruption bug in fastbuild and build fixed.  Also,
-       client.ml modified to avoid Yet Another Deadlock Bug.
+       client.ml modified to avoid Yet Another Deadlock Bug. 
 
 (...many versions skipped...)
 
 #   You should have received a copy of the GNU General Public License
 #   along with this program; if not, write to the Free Software
 #   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-#   USA
+#   USA 
 #
 CINCLUDES=-I`ocamlc -where`
 CC=gcc
 ifndef PREFIX
 	PREFIX=/usr/local
 endif
-ifeq ($(BDBLIB),)
+ifeq ($(BDBLIB),) 
 	OCAMLLIB=
-else
+else 
 	OCAMLLIB= -ccopt $(BDBLIB)
 endif
 
 CAMLP4=-pp $(CAMLP4O)
 CAMLINCLUDE= -I lib -I bdb
 COMMONCAMLFLAGS=$(CAMLINCLUDE) $(OCAMLLIB) -ccopt -Lbdb -dtypes -warn-error A
-OCAMLDEP=ocamldep $(CAMLP4)
+OCAMLDEP=ocamldep $(CAMLP4) 
 CAMLLIBS=unix.cma str.cma bdb.cma nums.cma bigarray.cma cryptokit.cma
 OCAMLFLAGS=$(COMMONCAMLFLAGS) -g $(CAMLLIBS)
-OCAMLOPTFLAGS=$(COMMONCAMLFLAGS) -inline 40 $(CAMLLIBS:.cma=.cmxa)
+OCAMLOPTFLAGS=$(COMMONCAMLFLAGS) -inline 40 $(CAMLLIBS:.cma=.cmxa) 
 
 EXE=sks sks_add_mail
 ALL=$(EXE) sks.8.gz
 ALL.bc=$(EXE:=.bc) sks.8.gz
 
-all: $(ALL)
-all.bc: $(ALL.bc)
+all: $(ALL) 
+all.bc: $(ALL.bc) 
 
 COBJS=crc.o
 
 keyMerge.cmx: keyMerge.ml
 	$(OCAMLOPT) $(OCAMLOPTFLAGS) $(CAMLP4) -c $<
 
-# Special targets
+# Special targets 
 
-install:
+install: 
 	mkdir -p $(PREFIX)/bin
 	install sks_build.sh sks sks_add_mail $(PREFIX)/bin
 	mkdir -p $(MANDIR)/man8
 	install sks.8.gz $(MANDIR)/man8
 
-install.bc:
+install.bc: 
 	mkdir -p $(PREFIX)/bin
 	install sks_build.bc.sh sks.bc sks_add_mail.bc $(PREFIX)/bin
 	mkdir -p $(MANDIR)/man8
 Makefile.local:
 	@if [ ! -a Makefile.local ]; then echo "Makefile.local has to be defined before building. See Makefile.local.unused"; exit 1; fi;
 
-src:
+src: 
 	if [ ! -x $(VERSIONPREFIX) ]; then ln -s . $(VERSIONPREFIX); fi
 	tar cfz $(VERSIONPREFIX).tgz $(FILES)
 	rm $(VERSIONPREFIX)
 sks.bc: $(LIBS.bc) $(ALLOBJS.bc) sks.cmo
 	$(OCAMLC) -o sks.bc $(OCAMLFLAGS) $(ALLOBJS.bc) sks.cmo
 
-nbtest.bc: $(LIBS.bc) $(ALLOBJS.bc) nbtest.cmo
-	$(OCAMLC) -o nbtest.bc $(OCAMLFLAGS) $(ALLOBJS.bc) nbtest.cmo
+nbtest.bc: $(LIBS.bc) $(ALLOBJS.bc) nbtest.cmo 
+	$(OCAMLC) -o nbtest.bc $(OCAMLFLAGS) $(ALLOBJS.bc) nbtest.cmo 
 
 ptest: $(LIBS) $(ALLOBJS) ptest.cmx
 	$(OCAMLOPT) -o ptest $(OCAMLOPTFLAGS) $(ALLOBJS) \
 	$(OCAMLOPT) -o sks_logdump $(OCAMLOPTFLAGS) $(ALLOBJS) \
 	logdump.cmx
 
-bugscript: $(LIBS) $(ALLOBJS) reconPTreeDb.cmx bugscript.cmx
+bugscript: $(LIBS) $(ALLOBJS) reconPTreeDb.cmx bugscript.cmx 
 	$(OCAMLOPT) -o bugscript $(OCAMLOPTFLAGS) $(ALLOBJS) \
 	reconPTreeDb.cmx bugscript.cmx
 
 	$(OCAMLC) -o bugscript.bc $(OCAMLFLAGS) $(ALLOBJS.bc) \
 	reconPTreeDb.cmo bugscript.cmo
 
-ptree_replay: $(LIBS) $(ALLOBJS) reconPTreeDb.cmx ptree_replay.cmx
+ptree_replay: $(LIBS) $(ALLOBJS) reconPTreeDb.cmx ptree_replay.cmx 
 	$(OCAMLOPT) -o ptree_replay $(OCAMLOPTFLAGS) $(ALLOBJS) \
 	reconPTreeDb.cmx ptree_replay.cmx
 
 CKVER=cryptokit-1.5
 CKDIR=$(CKVER)/src
 
-$(CKVER)/README.txt:
+$(CKVER)/README.txt: 
 	tar xmvfz $(CKVER).tar.gz
 
 $(CKDIR)/cryptokit.cma: $(CKVER)/README.txt
 	$(ROBJS) pdiskTest.cmo
 
 script: $(LIBS) $(ALLOBJS) script.cmo
-	$(OCAMLC) -o script $(OCAMLFLAGS) $(ALLOBJS) script.cmo
+	$(OCAMLC) -o script $(OCAMLFLAGS) $(ALLOBJS) script.cmo 
 
 dbtest.bc: $(LIBS.bc) $(ALLOBJS.bc) dbtest.cmo
-	$(OCAMLC) -o dbtest.bc $(OCAMLFLAGS) $(ALLOBJS.bc) dbtest.cmo
+	$(OCAMLC) -o dbtest.bc $(OCAMLFLAGS) $(ALLOBJS.bc) dbtest.cmo 
 
 dbtest: $(LIBS) $(ALLOBJS) dbtest.cmx
 	$(OCAMLOPT) -o dbtest $(OCAMLOPTFLAGS) $(ALLOBJS) dbtest.cmx
 
 tester: $(LIBS) $(ALLOBJS) tester.cmo
-	$(OCAMLC) -o tester $(OCAMLFLAGS) $(ALLOBJS) tester.cmo
+	$(OCAMLC) -o tester $(OCAMLFLAGS) $(ALLOBJS) tester.cmo 
 
 dumbloop: $(LIBS) $(ALLOBJS) dumbloop.cmo
 	$(OCAMLC) -o dumbloop $(OCAMLFLAGS) $(ALLOBJS) dumbloop.cmo
 krecode: $(ALLOBJS.opt) $(LIBS) recode.ml
 	$(OCAMLOPT) -o krecode $(OCAMLOPTFLAGS) $(ALLOBJS.opt) recode.ml
 
-rcaml: $(LIBS.bc) $(ALLOBJS.bc)
+rcaml: $(LIBS.bc) $(ALLOBJS.bc) 
 	ocamlmktop -o rcaml -custom $(CAMLLIBS) $(CAMLINCLUDE) \
 	$(ALLOBJS.bc) $(OCAMLLIB)
 
 .SUFFIXES: .mli .ml .cmo .cmi .cmx
 
 .ml.o:
-	$(OCAMLOPT) -output-obj $(OCAMLOPTFLAGS) $<
+	$(OCAMLOPT) -output-obj $(OCAMLOPTFLAGS) $< 
 
 .cpp.o:
 	$(CXX) $(CXXFLAGS) -c $<
 
 .c.o:
-	$(CC) $(CFLAGS) -c $<
+	$(CC) $(CFLAGS) -c $< 
 
 .c.obj:
-	$(CC) $(CFLAGS) /c $<
+	$(CC) $(CFLAGS) /c $< 
 
 .ml.cmo:
 	$(OCAMLC) $(OCAMLFLAGS) -c $<
 
 # Dependencies
 
-dep:
+dep: 
 	$(OCAMLDEP) $(INCLUDES) *.mli *.ml > .depend
 
 -include .depend
 There are a few prerequisites to building this code.  You need:
 
 * ocaml-3.10.2 or later.  Get it from <http://www.ocaml.org>
-* Berkeley DB version 4.6.* or later.  You can find the
-  appropriate versions at
+* Berkeley DB version 4.6.* or later.  You can find the 
+  appropriate versions at 
   <http://www.oracle.com/technetwork/database/berkeleydb/downloads/index.html>
 
   Verifying the integrity of the download
 ----------------------------
 Releases of SKS are signed using the SKS Keyserver Signing Key
-available on public keyservers with the KeyID
+available on public keyservers with the KeyID 
 
     0x41259773973A612A
 	
 
     gpg --keyid-format long --fingerprint 0x41259773973A612A
 
-should produce:
+should produce: 
 
     pub   4096R/41259773973A612A 2012-06-27
     Key fingerprint = C90E F143 0B3A C0DF D00E 6EA5 4125 9773 973A 612A
 		
-A check should also be made that the key is signed by
-trustworthy other keys;
+A check should also be made that the key is signed by 
+trustworthy other keys; 
 
     gpg --list-sigs 0x41259773973A612A
 
-and the fingerprint should be verified through other trustworthy sources.
+and the fingerprint should be verified through other trustworthy sources. 
 			
 Once you are certain that you have the correct key downloaded, you can create
-a local signature, in order to remember that you have verified the key.
+a local signature, in order to remember that you have verified the key. 
 
      gpg --lsign-key 0x41259773973A612A
 
 Finally; verifying the downloaded file can be done using
 
-    gpg --keyid-format long --verify sks-x.y.z.tgz.asc
+    gpg --keyid-format long --verify sks-x.y.z.tgz.asc 
 
 The resulting output should be similar to
 	
     gpg: Signature made Wed Jun 27 12:52:39 2012 CEST
     gpg:                using RSA key 41259773973A612A
     gpg: Good signature from "SKS Keyserver Signing Key"
-
+  
   Compilation and Installation
 ----------------------------
 
   * Compile
 
         make dep
-        make all
+        make all   
         make all.bc # if you want the bytecode versions
-        make install # puts executables in $PREFIX/bin, as defined
+        make install # puts executables in $PREFIX/bin, as defined 
                      # in Makefile.local
 
     There are some other useful compilation targets, mostly useful for
     development.
 
       - `make doc`
-
+  
         creates a doc directory with ocamldoc-generated documentation
         of the individual modules.  These are mostly useful as
         documentation to the source code, not a user's guide.
 
     PATH=/path/of/sks/exectuables
 
-    :0
+    :0 
     * ^Subject: incremental
     | sks_add_mail sks_directory_name
 
 + Fix build (and verify that fastbuild is fixed) so that it doesn't barf out
   entirely if a deeply bogus key is found in the stream.
 
-+ Fix partial
++ Fix partial 
 
 + Allow for partial progress: if some elements are recovered, and then
   there's a timeout, add those elements in.
   with 30 seconds, give up immediatly.
 
 + Update build and fastbuild to canonicalize all elements (and discard
-  non-canonicalized elements), as well as to mark the key with the
+  non-canonicalized elements), as well as to mark the key with the 
   yminsky.dedup filter, as appropriate.
 
 + Update clean_keydb to apply canonicalize to all elements.  Also add
 
 + change timeouts on reconciliation so that if config does not come back
   immediatly, you time out, and otherwise the timeout is lengthened
-  considerably.
+  considerably. 
 
 + improve error message for contact from unknown host. (now seems to raise
-  Not_found)
+  Not_found) 
 
 + Make initiator of reconciliation act as server.  That way, the one who
   makes the requests also has to work harder.
-In general, it is possible to upgrade a database to a new version of
-Berkeley DB without rebuilding as most upgrades of bdb only require a
-change to the log file.
+In general, it is possible to upgrade a database to a new version of 
+Berkeley DB without rebuilding as most upgrades of bdb only require a 
+change to the log file. 
 
 For example, if one wishes to upgrade sks and bdb from db51 to db53:
 
     db53_archive    -dh $DB  # remove old log files
   done
   #
-  <Install new SKS release from distro or cd to SKS src dir and
+  <Install new SKS release from distro or cd to SKS src dir and 
    'make install' the SKS version linked with libdb5.3>
   <restart SKS>
 

File Unique_time.ml

 (************************************************************************)
-(* Unique_time.ml - Module to return unique time                        *)
+(* Unique_time.ml - Module to return unique time 					    *)
 (*                 @author Yaron M. Minsky                              *)
 (*                                                                      *)
 (* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,  *)

File Unique_time.mli

 (************************************************************************)
-(* Unique_time.mli - Module to return unique time                       *)
+(* Unique_time.mli - Module to return unique time 					    *)
 (*                 @author Yaron M. Minsky                              *)
 (*                                                                      *)
 (* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,  *)
 (************************************************************************)
 
 (* An interface to Unix.gettimeofday() which enforces that time always goes
- * up and never repeats.
+ * up and never repeats. 
  * get() returns seconds & microseconds, so minimum meaningful
  * increment is 1 microsecond; OCaml uses IEEE 754 double-precision floats,
  * which gives 53 bits of mantissa.  Assuming 32 bits for time until 32-bit
  * we don't use epsilon_float, as that's only guaranteed to give a different
  * result when added to 1.0, not for other numbers.
  * If wallclock time goes backwards, we won't, but time will appear to go
- * forward very very slowly until wallclock catches back up
+ * forward very very slowly until wallclock catches back up 
  *)
 
-val get : 'a -> float
+val get : 'a -> float
 
 let anonymous = ref []
 
-let usage_string =
+let usage_string = 
   Sys.argv.(0) ^ " sks_directory_name"
 
-let anon_options option =
+let anon_options option = 
   anonymous := option::!anonymous
 
 let parse_spec = [ ]
 
-let dirname =
+let dirname = 
   Arg.parse parse_spec anon_options usage_string;
-  if List.length !anonymous <> 1
+  if List.length !anonymous <> 1 
   then (
-    printf "Wrong number (%d) of arguments given.  %s\n"
-          (List.length !anonymous)
-          usage_string;
+    printf "Wrong number (%d) of arguments given.  %s\n" 
+	  (List.length !anonymous)
+	  usage_string;
     exit (-1)
   ) else
     Filename.concat (List.hd !anonymous) "messages"
 
 (** dumps contents of one file into another *)
-let pipe_file =
+let pipe_file = 
   let blocksize = 100 * 1024 in
   let buf = String.create blocksize in
-  let rec pipe_file file1 file2 =
+  let rec pipe_file file1 file2 = 
     let bytes_read = input file1 buf 0 blocksize in
     if bytes_read <> 0 then (
       output file2 buf 0 bytes_read;
       pipe_file file1 file2
     )
   in
-  pipe_file
+  pipe_file 
 
 let run () =
   if not (Sys.file_exists dirname)
   close_out f;
   Sys.rename fname (fname ^ ".ready")
 
-let () =
+let () = 
   Random.self_init ();
   run ()
 
 external crc_of_string : string -> int = "caml_crc_octets"
 
-let base64crc input =
+let base64crc input = 
   let encoder = Cryptokit.Base64.encode_multiline () in
   encoder#put_string input;
   encoder#finish;
   encoder#put_char (char_of_int ((crc lsr 8) land 0xFF));
   encoder#put_char (char_of_int (crc land 0xFF));
   encoder#finish;
-  let base64 =
-    if base64.[String.length base64 - 1] <> '\n'
+  let base64 = 
+    if base64.[String.length base64 - 1] <> '\n' 
     then base64 ^ "\n" else base64 in
   base64 ^ "=" ^ encoder#get_string
 
-let pubkey_armor_header = "-----BEGIN PGP PUBLIC KEY BLOCK-----"
-let pubkey_armor_tail = "-----END PGP PUBLIC KEY BLOCK-----"
+let pubkey_armor_header = "-----BEGIN PGP PUBLIC KEY BLOCK-----" 
+let pubkey_armor_tail = "-----END PGP PUBLIC KEY BLOCK-----" 
 
 (* pubkey *)
-let encode_pubkey key =
+let encode_pubkey key = 
   let armor_header = pubkey_armor_header
   and armor_tail = pubkey_armor_tail
   and version = (sprintf "Version: SKS %s%s" Common.version Common.version_suffix)
   hostname ^ "\n\n" ^
   base64crc input ^ "\n" ^
   armor_tail
-
-let encode_pubkey_string keystr =
+    
+let encode_pubkey_string keystr = 
   let armor_header = pubkey_armor_header
   and armor_tail = pubkey_armor_tail
   and version = (sprintf "Version: SKS %s%s" Common.version Common.version_suffix)
   base64crc input ^ "\n" ^
   armor_tail
 
-let decode_crc s =
+let decode_crc s = 
   let decoder = Cryptokit.Base64.decode () in
   decoder#put_string s;
   decoder#finish;
   let b1 = decoder#get_byte in
   let b2 = decoder#get_byte in
   let b3 = decoder#get_byte in
-  b1 lsl 16 + b2 lsl 8 + b3
+  b1 lsl 16 + b2 lsl 8 + b3 
 
 let eol = Str.regexp "[ \t]*\r?\n"
 
   let rec read_adata lines = match lines with
       [] -> failwith "Error while decoding ascii-armored key: text terminated before reaching CRC sum"
     | line::tl ->
-        if line.[0] = '='
-        then ( (* close the decoder and return the CRC string *)
-          decoder#finish;
-          let crc = decode_crc (String.sub ~pos:1
-                                  ~len:(String.length line - 1) line)
-          and data = decoder#get_string in
-          (data,crc)
-        )
-        else (
-          decoder#put_string line;
-          read_adata tl
-        )
+	if line.[0] = '=' 
+	then ( (* close the decoder and return the CRC string *)
+	  decoder#finish;
+	  let crc = decode_crc (String.sub ~pos:1 
+				  ~len:(String.length line - 1) line)
+	  and data = decoder#get_string in
+	  (data,crc)
+	)
+	else (
+	  decoder#put_string line;
+	  read_adata tl
+	)
   and read_full lines = match lines with
       [] -> failwith "Error while decoding ascii-armored key:  text terminated before reaching PGP public key header line"
     | line::tl ->
-        if line = pubkey_armor_header then read_block tl
-        else read_full tl
+	if line = pubkey_armor_header then read_block tl
+	else read_full tl
   and read_block lines = match lines with
       [] -> failwith "Error while decoding ascii-armored key: text terminated before beginning of ascii block"
     | line::tl ->
-        if line = "" then read_adata tl
-        else read_block tl
+	if line = "" then read_adata tl
+	else read_block tl
   in
   let (data,crc) = read_full lines in
   let data_crc = crc_of_string data in
   assert (data_crc = crc);
   Key.of_string_multiple data
 
-
+ 

File bdb/Makefile

 RANLIB=ranlib
 OCAMLDEP=ocamldep $(PP)
 CAMLINCLUDE=
-COMMONCAMLFLAGS= $(CAMLINCLUDE) $(PP) #-thread
-CAMLLIBS=unix.cma str.cma mylibs.cma
-OCAMLFLAGS=$(COMMONCAMLFLAGS) -g
-OCAMLOPTFLAGS=$(COMMONCAMLFLAGS) -inline 40
+COMMONCAMLFLAGS= $(CAMLINCLUDE) $(PP) #-thread 
+CAMLLIBS=unix.cma str.cma mylibs.cma 
+OCAMLFLAGS=$(COMMONCAMLFLAGS) -g 
+OCAMLOPTFLAGS=$(COMMONCAMLFLAGS) -inline 40 
 
 ifndef LIBDB
 LIBDB=-ldb-4.6
 .SUFFIXES: .ml .mli .cmo .cmi .cmx
 
 .ml.o:
-	$(OCAMLOPT) -output-obj $(OCAMLOPTFLAGS) $<
+	$(OCAMLOPT) -output-obj $(OCAMLOPTFLAGS) $< 
 
 .cpp.o:
 	$(CXX) $(CXXFLAGS) -c $<
 
 .c.o:
-	$(CC) $(CFLAGS) -c $<
+	$(CC) $(CFLAGS) -c $< 
 
 .c.obj:
-	$(CC) $(CFLAGS) /c $<
+	$(CC) $(CFLAGS) /c $< 
 
 .ml.cmo:
 	$(OCAMLC) $(OCAMLFLAGS) -c $<

File bdb/bdb_stubs.c

     UW_dbenv(dbenv)->close(UW_dbenv(dbenv),0) : \
    0 )
 
-static void finalize_caml_dbenv(value dbenv) {
+static void finalize_caml_dbenv(value dbenv) { 
   //fprintf(stderr,"GC: Finalizing Dbenv\n"); fflush(stderr);
-  caml_dbenv_close_internal(dbenv);
+  caml_dbenv_close_internal(dbenv); 
   //fprintf(stderr,"GC: Dbenv Finalized\n"); fflush(stderr);
 }
 
-static struct custom_operations dbenv_custom = {
-  "sks.bdb.dbenv",
-  finalize_caml_dbenv,
-  custom_compare_default,
+static struct custom_operations dbenv_custom = { 
+  "sks.bdb.dbenv",  
+  finalize_caml_dbenv,  
+  custom_compare_default,  
   custom_hash_default,
-  custom_serialize_default,
-  custom_deserialize_default
-};
+  custom_serialize_default,  
+  custom_deserialize_default 
+}; 
 
 // ###### DB ######
 
    UW_db(db)->close(UW_db(db),0) : \
    0 )
 
-static void finalize_caml_db(value db) {
+static void finalize_caml_db(value db) { 
   //fprintf(stderr,"GC: Finalizing Db\n"); fflush(stderr);
-  caml_db_close_internal(db);
+  caml_db_close_internal(db); 
   //fprintf(stderr,"GC: Db Finalized\n"); fflush(stderr);
 }
 
-static struct custom_operations db_custom = {
-  "sks.bdb.db",
-  finalize_caml_db,
-  custom_compare_default,
+static struct custom_operations db_custom = { 
+  "sks.bdb.db",  
+  finalize_caml_db,  
+  custom_compare_default,  
   custom_hash_default,
-  custom_serialize_default,
-  custom_deserialize_default
-};
+  custom_serialize_default,  
+  custom_deserialize_default 
+}; 
 
 // ###### Cursor ######
 
 
 static void finalize_caml_cursor(value cursor) {
   //fprintf(stderr,"GC: Finalizing Cursor\n"); fflush(stderr);
-  caml_cursor_close_internal(cursor);
+  caml_cursor_close_internal(cursor); 
   //fprintf(stderr,"GC: Cursor Finalized\n"); fflush(stderr);
 }
 
-static struct custom_operations cursor_custom = {
-  "sks.bdb.cursor",
-  finalize_caml_cursor,
-  custom_compare_default,
+static struct custom_operations cursor_custom = { 
+  "sks.bdb.cursor",  
+  finalize_caml_cursor,  
+  custom_compare_default,  
   custom_hash_default,
-  custom_serialize_default,
-  custom_deserialize_default
-};
+  custom_serialize_default,  
+  custom_deserialize_default 
+}; 
 
 // ###### Transaction ######
 
 static void finalize_caml_txn(value txn) {
   //fprintf(stderr,"GC: Finalizing Txn\n"); fflush(stderr);
 
-  /* Try to abort any transaction that gets GC'd
+  /* Try to abort any transaction that gets GC'd 
      without being closed first */
-  if (!UW_txn_closed(txn)) {
-    //fprintf(stderr,"GC: Aborting unclosed transaction\n");
+  if (!UW_txn_closed(txn)) { 
+    //fprintf(stderr,"GC: Aborting unclosed transaction\n"); 
     //fflush(stderr);
-    UW_txn(txn)->abort(UW_txn(txn));
+    UW_txn(txn)->abort(UW_txn(txn)); 
   }
 
   //fprintf(stderr,"GC: Txn Finalized\n"); fflush(stderr);
 }
 
-static struct custom_operations txn_custom = {
-  "sks.bdb.txn",
-  finalize_caml_txn,
-  custom_compare_default,
+static struct custom_operations txn_custom = { 
+  "sks.bdb.txn",  
+  finalize_caml_txn,  
+  custom_compare_default,  
   custom_hash_default,
-  custom_serialize_default,
-  custom_deserialize_default
-};
+  custom_serialize_default,  
+  custom_deserialize_default 
+}; 
 
 /************************************************************/
 /************ Exception buckets *****************************/
 
 value caml_db_init(value v){
   CAMLparam1(v);
-  if (caml_db_exn == NULL)
+  if (caml_db_exn == NULL) 
     caml_db_exn = caml_named_value("dberror");
-  if (caml_key_exists_exn == NULL)
+  if (caml_key_exists_exn == NULL) 
     caml_key_exists_exn = caml_named_value("keyexists");
-  if (caml_db_run_recovery_exn == NULL)
+  if (caml_db_run_recovery_exn == NULL) 
     caml_db_run_recovery_exn = caml_named_value("dbrunrecovery");
   CAMLreturn (Val_unit);
 }
 //+ (* GENERATED FILE -- DO NOT EDIT -- see bdb_stubs.c *)
 //+
 //+ (* Exception declarations *)
-//+
+//+ 
 //+ exception DBError of string
 //+ let _ = Callback.register_exception "dberror" (DBError "")
 //+
 //+ external version : unit -> string = "caml_db_version"
 value caml_db_version() {
   int major, minor, patch;
-  char version[10];
-
-  db_version(&major, &minor, &patch);
-  sprintf(version, "%d.%d.%d", major, minor, patch);
-
+  char version[10]; 
+  
+  db_version(&major, &minor, &patch);  
+  sprintf(version, "%d.%d.%d", major, minor, patch); 
+  
   return caml_copy_string(version);
 }
 
 //+
 //+ module Dbenv =
 //+ struct
-//+
+//+ 
 //+   type t = dbenv
 
 
 // Declaration of flag enums in ocaml must be in same order as in C
 
 static int dbenv_open_flags[] = {
-  DB_JOINENV, DB_INIT_CDB, DB_INIT_LOCK, DB_INIT_LOG, DB_INIT_MPOOL,
+  DB_JOINENV, DB_INIT_CDB, DB_INIT_LOCK, DB_INIT_LOG, DB_INIT_MPOOL, 
   DB_INIT_TXN, DB_RECOVER, DB_RECOVER_FATAL, DB_USE_ENVIRON,
-  DB_USE_ENVIRON_ROOT, DB_CREATE, DB_LOCKDOWN, DB_PRIVATE,
+  DB_USE_ENVIRON_ROOT, DB_CREATE, DB_LOCKDOWN, DB_PRIVATE, 
   DB_SYSTEM_MEM, DB_THREAD
 };
 
-//+
-//+   type open_flag =
-//+       JOINENV | INIT_CDB | INIT_LOCK | INIT_LOG
-//+     | INIT_MPOOL | INIT_TXN | RECOVER | RECOVER_FATAL
-//+     | USE_ENVIRON | USE_ENVIRON_ROOT | CREATE
+//+ 
+//+   type open_flag = 
+//+       JOINENV | INIT_CDB | INIT_LOCK | INIT_LOG 
+//+     | INIT_MPOOL | INIT_TXN | RECOVER | RECOVER_FATAL 
+//+     | USE_ENVIRON | USE_ENVIRON_ROOT | CREATE 
 //+     | LOCKDOWN | PRIVATE | SYSTEM_MEM | THREAD
 
 static int dbenv_verbose_flags[] = {
   DB_VERB_DEADLOCK, DB_VERB_RECOVERY, DB_VERB_WAITSFOR
 };
 
-//+
-//+   type verbose_flag =
+//+ 
+//+   type verbose_flag = 
 //+       VERB_CHKPOINT | VERB_DEADLOCK | VERB_RECOVERY | VERB_WAITSFOR
 
 /**  DBENV Calls  *******************************************/
   int err;
   int flags = 0;
   DB_ENV *dbenv;
-
+  
   err = db_env_create(&dbenv,flags);
   if (err != 0) { raise_db(db_strerror(err)); }
 
 }
 
 
-//+   external dopen : t -> string -> open_flag list -> int -> unit =
+//+   external dopen : t -> string -> open_flag list -> int -> unit = 
 //+        "caml_dbenv_open"
-value caml_dbenv_open(value dbenv, value vdirectory,
-                      value vflags, value vmode){
+value caml_dbenv_open(value dbenv, value vdirectory, 
+		      value vflags, value vmode){
   CAMLparam4(dbenv,vdirectory,vflags,vmode);
   int err;
   char *directory = String_val(vdirectory);
 
   test_dbenv_closed(dbenv);
 
-  err = UW_dbenv(dbenv)->open(UW_dbenv(dbenv), directory,
-                              flags,
-                              Long_val(vmode) );
-  if (err != 0) {
+  err = UW_dbenv(dbenv)->open(UW_dbenv(dbenv), directory, 
+			      flags, 
+			      Long_val(vmode) ); 
+  if (err != 0) { 
     UW_dbenv(dbenv)->err(UW_dbenv(dbenv),err,
-                         "caml_dbenv_open: open failed.");
+			 "caml_dbenv_open: open failed."); 
   }
 
   CAMLreturn (Val_unit);
 }
 // simple open, combination of create and open
-//+   let sopen dirname flags mode =
+//+   let sopen dirname flags mode = 
 //+     let dbenv = create () in
 //+     dopen dbenv dirname flags mode;
 //+     dbenv
 
 void db_msgcall_fcn(const DB_ENV *dbenv, const char *msg)
 {
-        if(strlen(msg) < 254)
-        strcpy(db_message, msg);
-}
+	if(strlen(msg) < 254)
+        strcpy(db_message, msg); 
+}  
 
-//+             external get_dbenv_stats : t -> string = "caml_dbenv_get_stats"
+//+		external get_dbenv_stats : t -> string = "caml_dbenv_get_stats"
 value caml_dbenv_get_stats(value dbenv){
-        CAMLparam1(dbenv);
-
-        char output_message[255];
-        char nl[] = {"\n"};
-        int err;
-
-        UW_dbenv(dbenv)->set_msgcall(UW_dbenv(dbenv), *db_msgcall_fcn);
-        err = UW_dbenv(dbenv)->stat_print(UW_dbenv(dbenv), DB_STAT_ALL);
-        if(err == 0){
-                if(strlen(db_message) < 253){
-                    strcpy(output_message, db_message);
-                    strcat(output_message, nl);
-                }
-
-                UW_dbenv(dbenv)->stat_print(UW_dbenv(dbenv), DB_STAT_ALL | DB_STAT_SUBSYSTEM);
-                if(strlen(output_message) + strlen(db_message) < 253){
-                    strcat(output_message, db_message);
-                    strcat(output_message, nl);
-                }
-        }
-        else
-        {
-                strcpy(output_message, "Unable to open environment");
-        }
-
+	CAMLparam1(dbenv);
+	
+	char output_message[255];
+	char nl[] = {"\n"};
+	int err;
+	
+	UW_dbenv(dbenv)->set_msgcall(UW_dbenv(dbenv), *db_msgcall_fcn);
+	err = UW_dbenv(dbenv)->stat_print(UW_dbenv(dbenv), DB_STAT_ALL);
+	if(err == 0){
+		if(strlen(db_message) < 253){
+		    strcpy(output_message, db_message);
+		    strcat(output_message, nl);
+		}
+		
+		UW_dbenv(dbenv)->stat_print(UW_dbenv(dbenv), DB_STAT_ALL | DB_STAT_SUBSYSTEM);
+		if(strlen(output_message) + strlen(db_message) < 253){
+		    strcat(output_message, db_message);
+		    strcat(output_message, nl);
+		}
+	}
+	else
+	{
+		strcpy(output_message, "Unable to open environment");
+	}
+    
     return caml_copy_string(output_message);
 }
 
 }
 
 
-//+   external set_verbose_internal : t -> verbose_flag list ->
+//+   external set_verbose_internal : t -> verbose_flag list -> 
 //+           bool -> unit =  "caml_dbenv_set_verbose"
-//+   let set_verbose dbenv flag onoff =
+//+   let set_verbose dbenv flag onoff = 
 //+       set_verbose_internal dbenv [flag] onoff
-value caml_dbenv_set_verbose(value dbenv, value vflags,
-                             value v_onoff) {
+value caml_dbenv_set_verbose(value dbenv, value vflags, 
+			     value v_onoff) {
   CAMLparam3(dbenv,vflags,v_onoff);
   int err;
 
   int which = convert_flag_list(vflags,dbenv_verbose_flags) + 1;
   int onoff = Bool_val(v_onoff);
-
+  
   test_dbenv_closed(dbenv);
 
   err = UW_dbenv(dbenv)->set_verbose(UW_dbenv(dbenv),which,onoff);
 
   if (err != 0) {
     UW_dbenv(dbenv)->err(UW_dbenv(dbenv),err,
-                         "caml_dbenv_set_verbose:");
+			 "caml_dbenv_set_verbose:"); 
   }
   CAMLreturn (Val_unit);
 }
 
-//+   external set_cachesize : t -> gbytes:int -> bytes:int ->
+//+   external set_cachesize : t -> gbytes:int -> bytes:int -> 
 //+          ncache:int -> unit = "caml_dbenv_set_cachesize"
-value caml_dbenv_set_cachesize(value dbenv, value gbytes,
-                               value bytes, value ncache) {
+value caml_dbenv_set_cachesize(value dbenv, value gbytes, 
+			       value bytes, value ncache) {
   CAMLparam4(dbenv, gbytes, bytes, ncache);
   int err;
 
-  err = UW_dbenv(dbenv)->set_cachesize(UW_dbenv(dbenv),Int_val(gbytes),
-                                       Int_val(bytes), Int_val(ncache));
+  err = UW_dbenv(dbenv)->set_cachesize(UW_dbenv(dbenv),Int_val(gbytes), 
+				       Int_val(bytes), Int_val(ncache));
   if (err != 0) { UW_dbenv(dbenv)->err(UW_dbenv(dbenv),err,
-                                       "caml_dbenv_set_cachesize"); }
+				       "caml_dbenv_set_cachesize"); }
 
   CAMLreturn (Val_unit);
 }
 
 
 // Termination of Dbenv module
-//+
+//+ 
 //+ end
 
 
 //+
 //+ module Db =
 //+ struct
-//+
+//+ 
 //+   type t = db
 
 
 //+   type create_flag
 
 static int db_open_flags[] = {
-  DB_CREATE, DB_EXCL, DB_NOMMAP, DB_RDONLY, DB_THREAD,
+  DB_CREATE, DB_EXCL, DB_NOMMAP, DB_RDONLY, DB_THREAD, 
   DB_TRUNCATE, DB_AUTO_COMMIT
 };
 
-//+
-//+   type open_flag =
+//+ 
+//+   type open_flag = 
 //+      CREATE | EXCL | NOMMAP | RDONLY | THREAD | TRUNCATE | AUTO_COMMIT
 
 static int db_types[] = {
   DB_BTREE, DB_HASH, DB_QUEUE, DB_RECNO, DB_UNKNOWN
 };
 
-//+
+//+ 
 //+   type db_type = BTREE | HASH | QUEUE | RECNO | UNKNOWN
 
 
 //+   type put_flag = APPEND | NODUPDATA | NOOVERWRITE
 
 // DB_GET_BOTH is omitted because it doesn't make sense given our interface
-static int db_get_flags[] = {
+static int db_get_flags[] = { 
   DB_CONSUME, DB_CONSUME_WAIT, DB_SET_RECNO, DB_RMW
 };
 
-//+
+//+ 
 //+   type get_flag = CONSUME | CONSUME_WAIT | SET_RECNO | RMW
 
 
   DB_DUP, DB_DUPSORT, DB_RECNUM, DB_REVSPLITOFF, DB_RENUMBER, DB_SNAPSHOT
 };
 
-//+
-//+   type set_flag = DUP | DUPSORT | RECNUM | REVSPLITOFF
+//+ 
+//+   type set_flag = DUP | DUPSORT | RECNUM | REVSPLITOFF 
 //+                 | RENUMBER | SNAPSHOT
 
 /** DB Calls **************************************************/
 //+
 
-//+   external create : ?dbenv:Dbenv.t -> create_flag list -> t =
+//+   external create : ?dbenv:Dbenv.t -> create_flag list -> t = 
 //+        "caml_db_create"
 value caml_db_create(value dbenv_opt, value vflags){
   CAMLparam2(dbenv_opt,vflags);
   flags = convert_flag_list(vflags,db_create_flags);
 
   if (Is_None(dbenv_opt)) { dbenv = NULL; }
-  else {
+  else { 
     test_dbenv_closed(Some_val(dbenv_opt));
-    dbenv = UW_dbenv(Some_val(dbenv_opt));
+    dbenv = UW_dbenv(Some_val(dbenv_opt)); 
   }
-
+  
   err = db_create(&db,dbenv,flags);
   if (err != 0) { raise_db(db_strerror(err)); }
 
   UW_db(rval) = db;
   UW_db_closed(rval) = False;
   CAMLreturn (rval);
-
+  
 }
 
-//+   external dopen : t -> string -> db_type -> open_flag list
+//+   external dopen : t -> string -> db_type -> open_flag list 
 //+        -> int -> unit =  "caml_db_open"
-value caml_db_open(value db, value vfname,
-                   value vdbtype, value vflags,
-                   value vmode){
+value caml_db_open(value db, value vfname, 
+		   value vdbtype, value vflags, 
+		   value vmode){
   CAMLparam5(db, vfname, vdbtype, vflags, vmode);
   int err;
   char *fname = String_val(vfname);
 
   test_db_closed(db);
 
-  err = UW_db(db)->open(UW_db(db),
-                        NULL,
-                        fname,
-                        NULL, /* no support for multiple databases in
-                                 a single file */
-                        dbtype,
-                        flags, /* automatic transaction on database open */
-                        Long_val(vmode) );
-  if (err != 0) {
+  err = UW_db(db)->open(UW_db(db), 
+			NULL,
+			fname, 
+			NULL, /* no support for multiple databases in 
+				 a single file */
+			dbtype, 
+			flags, /* automatic transaction on database open */
+			Long_val(vmode) ); 
+  if (err != 0) { 
     UW_db(db)->err(UW_db(db),err,
-                         "caml_db_open");
+			 "caml_db_open"); 
   }
 
   CAMLreturn (Val_unit);
   DB_TXN *txn;
 
   if (Is_None(txn_opt)) { txn = NULL; }
-  else {
+  else { 
     test_txn_closed(Some_val(txn_opt));
-    txn = UW_txn(Some_val(txn_opt));
+    txn = UW_txn(Some_val(txn_opt)); 
   }
 
   test_db_closed(db);
   dbt.data = String_val(key);
   dbt.size = string_length(key);
 
-
+  
   err = UW_db(db)->del(UW_db(db), txn, &dbt, 0);
   if (err != 0) { UW_db(db)->err(UW_db(db),err, "caml_db_del"); }
 
 }
 
 
-//+   external put : t -> ?txn:txn -> key:string -> data:string
+//+   external put : t -> ?txn:txn -> key:string -> data:string 
 //+             -> put_flag list -> unit = "caml_db_put"
-value caml_db_put(value db, value txn_opt, value vkey,
-                  value vdata, value vflags) {
+value caml_db_put(value db, value txn_opt, value vkey, 
+		  value vdata, value vflags) {
   CAMLparam5(db, txn_opt, vkey, vdata, vflags);
   DBT key, data;
   int flags, err;
   DB_TXN *txn;
 
   if (Is_None(txn_opt)) { txn = NULL; }
-  else {
+  else { 
     test_txn_closed(Some_val(txn_opt));
-    txn = UW_txn(Some_val(txn_opt));
+    txn = UW_txn(Some_val(txn_opt)); 
   }
 
   test_db_closed(db);
-
+  
   zerob(&key,sizeof(DBT)); zerob(&data,sizeof(DBT));
 
   key.data = String_val(vkey);
   flags = convert_flag_list(vflags, db_put_flags);
 
   err = UW_db(db)->put(UW_db(db), txn, &key, &data, flags);
-  if (err != 0) {
+  if (err != 0) { 
     if (err  == DB_KEYEXIST) {raise_key_exists();}
-    UW_db(db)->err(UW_db(db),err,"caml_db_put");
+    UW_db(db)->err(UW_db(db),err,"caml_db_put"); 
   }
 
   CAMLreturn (Val_unit);
   CAMLparam4(db, txn_opt, vkey, vflags);
   DBT key,data;
   int flags, err;
-  DB_TXN *txn;
+  DB_TXN *txn; 
   CAMLlocal1(rval);
 
   if (Is_None(txn_opt)) { txn = NULL; }
-  else {
+  else { 
     test_txn_closed(Some_val(txn_opt));
-    txn = UW_txn(Some_val(txn_opt));
+    txn = UW_txn(Some_val(txn_opt)); 
   }
 
   test_db_closed(db);
 
 
   err = UW_db(db)->get(UW_db(db), txn, &key, &data, flags);
-  if (err != 0) {
+  if (err != 0) { 
     ////fprintf(stderr,"Error found: %d\n",err); fflush(stderr);
     if (err == DB_NOTFOUND) { raise_not_found(); }
-    UW_db(db)->err(UW_db(db),err,"caml_db_get");
+    UW_db(db)->err(UW_db(db),err,"caml_db_get"); 
   }
 
   // FIX: this currently uses an extra, unnecessary copy in order to simplify
 
 //  More user-friendly version of dopen (simple open)
 //+
-//+   let sopen ?dbenv fname dbtype ?moreflags flags mode =
+//+   let sopen ?dbenv fname dbtype ?moreflags flags mode = 
 //+     let db = create ?dbenv [] in
-//+     (match moreflags with
+//+     (match moreflags with 
 //+         None -> ()
 //+       | Some flags -> set_flags db flags );
 //+     dopen db fname dbtype flags mode;
   CAMLreturn (Val_unit);
 }
 
-//+   external set_cachesize : t -> gbytes:int -> bytes:int
+//+   external set_cachesize : t -> gbytes:int -> bytes:int 
 //+          -> ncache:int -> unit = "caml_db_set_cachesize"
 value caml_db_set_cachesize(value db, value gbytes, value bytes, value ncache) {
   CAMLparam4(db, gbytes, bytes, ncache);
   test_db_closed(db);
 
   err = UW_db(db)->set_cachesize(UW_db(db),Int_val(gbytes), Int_val(bytes),
-                                 Int_val(ncache));
+				 Int_val(ncache));
   if (err != 0) { UW_db(db)->err(UW_db(db),err,"caml_db_set_cachesize"); }
 
   CAMLreturn (Val_unit);
 }
 
 // Termination of Db module
-//+
+//+ 
 //+ end
 //+
 
 //+
 //+ module Cursor =
 //+ struct
-//+
+//+ 
 //+   type t = cursor
 
 //*******************************************************************
 //*******************************************************************
 
-static int cursor_put_flags[] = {
-  DB_AFTER, DB_BEFORE, DB_CURRENT
+static int cursor_put_flags[] = { 
+  DB_AFTER, DB_BEFORE, DB_CURRENT 
 };
 
 //+
-//+   type put_flag = AFTER | BEFORE | CURRENT
+//+   type put_flag = AFTER | BEFORE | CURRENT 
 
 static int cursor_kput_flags[] = {
   DB_KEYFIRST, DB_KEYLAST, DB_NODUPDATA
 //+
 //+   type kput_flag = KEYFIRST | KEYLAST | NODUPDATA
 
-static int cursor_get_type[] = {
-  DB_CURRENT, DB_FIRST, DB_LAST,
+static int cursor_get_type[] = { 
+  DB_CURRENT, DB_FIRST, DB_LAST, 
   DB_NEXT, DB_PREV, DB_NEXT_DUP, DB_NEXT_NODUP, DB_PREV_NODUP, 0
 };
 
 //+
-//+   type get_type = CURRENT | FIRST | LAST
+//+   type get_type = CURRENT | FIRST | LAST 
 //+          | NEXT | PREV | NEXT_DUP | NEXT_NODUP
 //+          | PREV_NODUP | NULL
 
 //*******************************************************************
 //*******************************************************************
 
-//+   (* Note: A cursor created with a transaction must be closed before
+//+   (* Note: A cursor created with a transaction must be closed before 
 //+      the transaction is committed or aborted *)
-//+   external create : ?writecursor:bool -> ?txn:txn -> Db.t -> t
+//+   external create : ?writecursor:bool -> ?txn:txn -> Db.t -> t 
 //+               = "caml_cursor_create"
 value caml_cursor_create(value vwritecursor, value txn_opt, value db) {
   CAMLparam3(vwritecursor,txn_opt,db);
   DB_TXN *txn;
 
   if (Is_None(txn_opt)) { txn = NULL; }
-  else {
+  else { 
     test_txn_closed(Some_val(txn_opt));
-    txn = UW_txn(Some_val(txn_opt));
+    txn = UW_txn(Some_val(txn_opt)); 
   }
 
   test_db_closed(db);
 
   // setup flags from vwritecursor
-  if (Is_Some(vwritecursor) && Bool_val(Some_val(vwritecursor))) {
-    flags = DB_WRITECURSOR;
+  if (Is_Some(vwritecursor) && Bool_val(Some_val(vwritecursor))) { 
+    flags = DB_WRITECURSOR; 
   }
 
   //  printf("%d\n",ctr++); fflush(stdout);
 
   err = UW_db(db)->cursor(UW_db(db),txn,&cursor,flags);
   if (err != 0) {
-    UW_db(db)->err(UW_db(db),err, "caml_cursor_create");
+    UW_db(db)->err(UW_db(db),err, "caml_cursor_create"); 
   }
 
   rval = alloc_custom(&cursor_custom,Camlcursor_wosize,0,1);
   CAMLparam3(cursor,vdata,vflag);
   DBT key, data;
   int flags, err;
-
+  
   test_cursor_closed(cursor);
 
   zerob(&key,sizeof(DBT)); zerob(&data,sizeof(DBT));
   flags = Flag_val(vflag, cursor_put_flags);
 
   err = UW_cursor(cursor)->c_put(UW_cursor(cursor), &key, &data, flags);
-  if (err != 0) {
+  if (err != 0) { 
     if (err == DB_KEYEXIST) { raise_key_exists(); }
-    raise_db(db_strerror(err));
+    raise_db(db_strerror(err)); 
   }
 
   CAMLreturn (Val_unit);
   CAMLparam4(cursor,vkey,vdata,vflag);
   DBT key, data;
   int flags, err;
-
+  
   test_cursor_closed(cursor);
 
   zerob(&key,sizeof(DBT)); zerob(&data,sizeof(DBT));
   flags = Flag_val(vflag,cursor_kput_flags);
 
   err = UW_cursor(cursor)->c_put(UW_cursor(cursor), &key, &data, flags);
-  if (err != 0) {
+  if (err != 0) { 
     if (err == DB_KEYEXIST) { raise_key_exists(); }
-    raise_db(db_strerror(err));
+    raise_db(db_strerror(err)); 
   }
 
   CAMLreturn (Val_unit);
 
   key.data = String_val(vkey);
   key.size = string_length(vkey);
-
+  
   err = UW_cursor(cursor)->c_get(UW_cursor(cursor), &key, &data, flags);
-  if (err != 0) {
+  if (err != 0) { 
     if (err == DB_NOTFOUND) { raise_not_found(); }
     raise_db(db_strerror(err));
   }
   key.size = string_length(vkey);
 
   err = UW_cursor(cursor)->c_get(UW_cursor(cursor), &key, &data, flags);
-  if (err != 0) {
+  if (err != 0) { 
     if (err == DB_NOTFOUND) { raise_not_found(); }
     raise_db(db_strerror(err));
   }
   CAMLreturn (rpair);
 }
 
-//+   external init_both :  t -> key:string -> data:string
+//+   external init_both :  t -> key:string -> data:string 
 //+               -> get_flag list -> unit = "caml_cursor_init_both"
-value caml_cursor_init_both(value cursor, value vkey,
-                            value vdata , value vflags
-                            ) {
-   CAMLparam4(cursor,vkey,vdata,vflags);
+value caml_cursor_init_both(value cursor, value vkey, 
+			    value vdata , value vflags
+			    ) {
+   CAMLparam4(cursor,vkey,vdata,vflags); 
    DBT key,data;
-   int flags;
+   int flags; 
    int err;
-
+  
    int ctr = 0;
 
    flags = convert_flag_list(vflags,cursor_get_flags) | DB_GET_BOTH;
 
    key.data = String_val(vkey);
    key.size = string_length(vkey);
-
+  
    data.data = String_val(vdata);
    data.size = string_length(vdata);
 
    err = UW_cursor(cursor)->c_get(UW_cursor(cursor), &key, &data, flags);
-   if (err != 0) {
+   if (err != 0) { 
      if (err == DB_NOTFOUND) { raise_not_found (); }
      raise_db(db_strerror(err));
    }
   CAMLparam3(cursor,vtype,vflags);
   CAMLlocal3(rpair,rkey,rdata);
   DBT key,data;
-  int flags = Flag_val(vtype,cursor_get_type) |
+  int flags = Flag_val(vtype,cursor_get_type) | 
     convert_flag_list(vflags,cursor_get_flags);
   int err;
   zerob(&key,sizeof(DBT)); zerob(&data,sizeof(DBT));
   test_cursor_closed(cursor);
 
   err = UW_cursor(cursor)->c_get(UW_cursor(cursor), &key, &data,flags);
-  if (err != 0) {
+  if (err != 0) { 
     if (err == DB_NOTFOUND) { raise_not_found(); }
     raise_db(db_strerror(err));
   }
   CAMLparam3(cursor,vtype,vflags);
   CAMLlocal1(rkey);
   DBT key,data;
-  int flags = Flag_val(vtype,cursor_get_type) |
+  int flags = Flag_val(vtype,cursor_get_type) | 
     convert_flag_list(vflags,cursor_get_flags);
   int err;
   zerob(&key,sizeof(DBT)); zerob(&data,sizeof(DBT));
   test_cursor_closed(cursor);
 
   err = UW_cursor(cursor)->c_get(UW_cursor(cursor), &key, &data,flags);
-  if (err != 0) {
+  if (err != 0) { 
     if (err == DB_NOTFOUND) { raise_not_found(); }
     raise_db(db_strerror(err));
   }
 
   test_cursor_closed(cursor);
 
-  if (Is_Some(vkeep_position) && Bool_val(vkeep_position)) {
-    flags = DB_POSITION;
+  if (Is_Some(vkeep_position) && Bool_val(vkeep_position)) { 
+    flags = DB_POSITION; 
   }
-
+  
   err = UW_cursor(cursor)->c_dup(UW_cursor(cursor), &newcursor, flags);
   if (err != 0) { raise_db(db_strerror(err)); }
 
 //+                       cursor = "caml_join_cursors"
 //+   let join ?nosort  db cursor_list get_flag_list =
 //+        ajoin ?nosort db (Array.of_list cursor_list) get_flag_list
-value caml_join_cursors(value vnosort, value db,
-                        value vcursors, value vflags) {
+value caml_join_cursors(value vnosort, value db, 
+			value vcursors, value vflags) {
   CAMLparam4(vnosort,db,vcursors,vflags);
   CAMLlocal1(rval);
   DBC *jcurs; // pointer to joined cursor
   DBC *cursors[carray_len + 1];
   int i;
 
-  if (Is_Some(vnosort) && Bool_val(vnosort)) {
-    flags = flags | DB_JOIN_NOSORT;
+  if (Is_Some(vnosort) && Bool_val(vnosort)) { 
+    flags = flags | DB_JOIN_NOSORT; 
   }
 
-  for (i=0; i < carray_len; i++) {
+  for (i=0; i < carray_len; i++) { 
     if (UW_cursor_closed(Field(vcursors,i))) {
       invalid_argument("caml_join_cursors: Attempt to use closed cursor");
     }
   }
   cursors[i] = NULL;
   test_db_closed(db);
-
+  
   UW_db(db)->join(UW_db(db),cursors,&jcurs,flags);
-
+  
 
   rval = alloc_custom(&cursor_custom,Camlcursor_wosize,0,1);
   UW_cursor(rval) = jcurs;
 }
 
 // Termination of Cursor module
-//+
+//+ 
 //+ end
 //+
 
 //+
 //+ module Txn =
 //+ struct
-//+
+//+ 
 //+   type t = txn
 
 
-static int txn_begin_flags[] = {
+static int txn_begin_flags[] = { 
   /* DB_DIRTY_READ, */ DB_TXN_NOSYNC, DB_TXN_NOWAIT, DB_TXN_SYNC
 };
 
   err = UW_dbenv(dbenv)->set_tx_max(UW_dbenv(dbenv),max);
   if (err != 0) {
     //fprintf(stderr,"Error found: %d\n",err); fflush(stderr);
-    if (err == EINVAL) {
+    if (err == EINVAL) { 
       invalid_argument("set_txn_max called after dbenv opened");
     } else {
       UW_dbenv(dbenv)->err(UW_dbenv(dbenv), err, "caml_set_txn_max");
   }
 
   CAMLreturn(Val_unit);
-
+    
 }
 
 //+   external abort : t -> unit = "caml_txn_abort"
 value caml_txn_abort(value txn) {
   CAMLparam1(txn);
   int err;
-
+  
   test_txn_closed(txn);
 
   err = UW_txn(txn)->abort(UW_txn(txn));
   flags = convert_flag_list(vflags,txn_begin_flags);
 
   if (Is_None(parent_opt)) { parent = NULL; }
-  else {
+  else { 
     test_txn_closed(Some_val(parent_opt));
-    parent = UW_txn(Some_val(parent_opt));
+    parent = UW_txn(Some_val(parent_opt)); 
     //printf("********* parented transaction ***************\n"); fflush(stdout);
   }
-
+  
   err = UW_dbenv(dbenv)->txn_begin(UW_dbenv(dbenv), parent, &newtxn, flags);
   if (err != 0) {
-    if (err == ENOMEM) {
-      failwith("Maximum # of concurrent transactions reached");
+    if (err == ENOMEM) { 
+      failwith("Maximum # of concurrent transactions reached"); 
     } else {
       UW_dbenv(dbenv)->err(UW_dbenv(dbenv), err,"caml_txn_begin");
     }
 
 //+   external checkpoint: dbenv -> kbyte:int -> min:int
 //+       -> checkpoint_flag list -> unit = "caml_txn_checkpoint"
-value caml_txn_checkpoint(value dbenv, value vkbyte, value vmin,
-                          value vflags) {
+value caml_txn_checkpoint(value dbenv, value vkbyte, value vmin, 
+			  value vflags) {
   CAMLparam4(dbenv,vkbyte,vmin,vflags);
   int err, kbyte, min, flags;
 
 
   test_txn_closed(txn);
   flags = convert_flag_list(vflags,txn_commit_flags);
-
+  
   err = UW_txn(txn)->commit(UW_txn(txn),flags);
   UW_txn_closed(txn) = True; // transaction can never be used again
 
   if (err != 0) {
     //fprintf(stderr,"Error found: %d\n",err); fflush(stderr);
-    if (err == DB_RUNRECOVERY) raise_run_recovery();
+    if (err == DB_RUNRECOVERY) raise_run_recovery(); 
     else raise_db(db_strerror(err));
   }
 
 }
 
 // Termination of Txn module
-//+
+//+ 
 //+ end
 //+

File bdb/dbstubs.c

   DB *dbp;
   int err;
 
-  err = db_env_create(&dbenv,0);
+  err = db_env_create(&dbenv,0); 
   if (err != 0) { printf(raise_db("db_env_create error: ")); }
-
+  
   err = dbenv->open(dbenv,
-                    DIRNAME,
-                    DB_CREATE | DB_INIT_MPOOL,
-                    S_IRUSR | S_IWUSR );
-  if (err != 0) { raise_db("dbenv open error: "); }
+		    DIRNAME, 
+		    DB_CREATE | DB_INIT_MPOOL, 
+		    S_IRUSR | S_IWUSR ); 
+  if (err != 0) { raise_db("dbenv open error: "); } 
   camldbenv {
-
+    
   }
 
 }
 {
   /* close the db if needed */
   // DB_ENV dbenv;
-  // DBENV->close(&dbenv,0);
+  // DBENV->close(&dbenv,0); 
   if (!Camldb_closed(cdb)) {
     Camldb_closed(cdb) = 1;
     return Camldb_db(cdb)->close(Camldb_db(cdb));

File bdb/dbstubs.h

 struct camldbenv {
   final_fun f;
   DBENV *dbenv;
-  int closed;
+  int closed; 
 }
 
 #define Camldbenv_wosize \

File bdb/script.ml

 open Db3
 open Printf
 
-(* let _ = popt (Some 8)
+(* let _ = popt (Some 8) 
    let _ = popt None     *)
 
-(* let _ = Dbenv.sopen dbe "DBTEST"
+(* let _ = Dbenv.sopen dbe "DBTEST" 
    [Dbenv.DB_CREATE ; Dbenv.DB_INIT_MPOOL] 0o777 *)
 
 let db = Db.sopen "testdb" Db.BTREE [Db.CREATE] 0o777
-let _ =
+let _ = 
   (try
      let rval = Db.get db "foobar" [] in
      printf "Result unexpectedly found: %s\n" rval
      printf "Result unexpectedly found: %s\n" rval
    with
        Not_found -> printf "Not_found\n")
-
-
+  
+  
 
   type create_flag = CLIENT
 
-  type open_flag =
-      JOINENV | INIT_CDB | INIT_LOCK | INIT_LOG
-    | INIT_MPOOL | INIT_TXN | RECOVER | RECOVER_FATAL
-    | USE_ENVIRON | USE_ENVIRON_ROOT | CREATE
+  type open_flag = 
+      JOINENV | INIT_CDB | INIT_LOCK | INIT_LOG 
+    | INIT_MPOOL | INIT_TXN | RECOVER | RECOVER_FATAL 
+    | USE_ENVIRON | USE_ENVIRON_ROOT | CREATE 
     | LOCKDOWN | PRIVATE | SYSTEM_MEM | THREAD
 
-  type verbose_flag =
+  type verbose_flag = 
       VERB_CHKPOINT | VERB_DEADLOCK | VERB_RECOVERY | VERB_WAITSFOR
 
   external create : create_flag list -> t = "caml_dbenv_create"
-  external dopen : t -> string -> open_flag list -> int -> unit =
+  external dopen : t -> string -> open_flag list -> int -> unit = 
        "caml_dbenv_open"
-  let sopen dirname flags mode =
+  let sopen dirname flags mode = 
     let dbenv = create [] in
     dopen dbenv dirname flags mode;
     dbenv
   external close : t -> unit = "caml_dbenv_close"
-  external set_verbose_internal : t -> verbose_flag list ->
+  external set_verbose_internal : t -> verbose_flag list -> 
           bool -> unit =  "caml_dbenv_set_verbose"
-  let set_verbose dbenv flag onoff =
+  let set_verbose dbenv flag onoff = 
       set_verbose_internal dbenv [flag] onoff
-  external set_cachesize : t -> gbytes:int -> bytes:int ->
+  external set_cachesize : t -> gbytes:int -> bytes:int -> 
          ncache:int -> unit = "caml_dbenv_set_cachesize"
 
 end
 
   type create_flag = XA_CREATE
 
-  type open_flag =
-     CREATE | EXCL | NOMMAP | RDONLY | THREAD | TRUNCATE
+  type open_flag = 
+     CREATE | EXCL | NOMMAP | RDONLY | THREAD | TRUNCATE 
 
   type db_type = BTREE | HASH | QUEUE | RECNO | UNKNOWN
 
 
   type get_flag = CONSUME | CONSUME_WAIT | SET_RECNO | RMW
 
-  type set_flag = DUP | DUPSORT | RECNUM | REVSPLITOFF
+  type set_flag = DUP | DUPSORT | RECNUM | REVSPLITOFF 
                 | RENUMBER | SNAPSHOT
 
-  external create : ?dbenv:Dbenv.t -> create_flag list -> t =
+  external create : ?dbenv:Dbenv.t -> create_flag list -> t = 
        "caml_db_create"
-  external dopen : t -> string -> db_type -> open_flag list
+  external dopen : t -> string -> db_type -> open_flag list 
        -> int -> unit =  "caml_db_open"
   external close : t -> unit = "caml_db_close"
   external del : t -> ?txn:txn -> string -> unit = "caml_db_del"
-  external put : t -> ?txn:txn -> key:string -> data:string
+  external put : t -> ?txn:txn -> key:string -> data:string 
             -> put_flag list -> unit = "caml_db_put"
   external get : t -> ?txn:txn -> string -> get_flag list -> string
             = "caml_db_get"
   external set_flags : t -> set_flag list -> unit = "caml_db_set_flags"
 
-  let sopen ?dbenv fname dbtype ?moreflags flags mode =
+  let sopen ?dbenv fname dbtype ?moreflags flags mode = 
     let db = create ?dbenv [] in
-    (match moreflags with
+    (match moreflags with 
         None -> ()
       | Some flags -> set_flags db flags );
     dopen db fname dbtype flags mode;
          = "caml_db_set_h_ffactor"
   external set_pagesize : t -> int -> unit
          = "caml_db_set_pagesize"
-  external set_cachesize : t -> gbytes:int -> bytes:int
+  external set_cachesize : t -> gbytes:int -> bytes:int 
          -> ncache:int -> unit = "caml_db_set_cachesize"
   external sync : t -> unit = "caml_db_sync"
 
 
   type t = cursor
 
-  type put_flag = AFTER | BEFORE | CURRENT
+  type put_flag = AFTER | BEFORE | CURRENT 
 
   type kput_flag = KEYFIRST | KEYLAST | NODUPDATA
 
-  type get_type = CURRENT | FIRST | LAST
+  type get_type = CURRENT | FIRST | LAST 
          | NEXT | PREV | NEXT_DUP | NEXT_NODUP
          | PREV_NODUP | NULL
 
   type get_flag = RMW
-  (* Note: A cursor created with a transaction must be closed before
+  (* Note: A cursor created with a transaction must be closed before 
      the transaction is committed or aborted *)
-  external create : ?writecursor:bool -> ?txn:txn -> Db.t -> t
+  external create : ?writecursor:bool -> ?txn:txn -> Db.t -> t 
               = "caml_cursor_create"
   external close : t -> unit = "caml_cursor_close"
   external put : t -> string -> put_flag -> unit
          = "caml_cursor_init"
   external init_range :  t -> string -> get_flag list -> string * string
          = "caml_cursor_init_range"
-  external init_both :  t -> key:string -> data:string
+  external init_both :  t -> key:string -> data:string 
               -> get_flag list -> unit = "caml_cursor_init_both"
   external get : t -> get_type -> get_flag list -> string * string
                = "caml_cursor_get"
 let _ = Random.self_init ()
 
 let chars = "abcdefghijklmnopqrstuvwxyz123456789"
-let rand_string len =
+let rand_string len = 
   let s = String.create len in
-  for i = 0 to String.length s - 1 do
+  for i = 0 to String.length s - 1 do 
     s.[i] <- chars.[Random.int (String.length chars)]
   done;
   s
 
-let prepare_dir dirname =
-  if MUnix.exists dirname then
+let prepare_dir dirname = 
+  if MUnix.exists dirname then 
     ignore (Unix.system (sprintf "rm -r %s" dirname));
   Unix.mkdir dirname
-
-let prepare_file fname =
+  
+let prepare_file fname = 
   if MUnix.exists fname then Unix.unlink fname
 
 
-let simple_test () =
+let simple_test () = 
   let fname = "FOO" in
   prepare_file fname;
   let db = Db.sopen fname Db.HASH [ Db.CREATE ] 0o777 in
   let map = ref SMap.empty in
   for i = 0 to 1000 do
-    let key = rand_string 5
+    let key = rand_string 5 
     and data = rand_string 10
     in
     map := SMap.add key data !map;
     Db.put db ~key ~data []
   done;
-  SMap.iter ~f:(fun ~key ~data ->
-              let dbdata = Db.get db key [] in
-              if dbdata <> data
-              then raise (TestFailed "simple_test: values do not agree")) !map;
+  SMap.iter ~f:(fun ~key ~data -> 
+	      let dbdata = Db.get db key [] in
+	      if dbdata <> data 
+	      then raise (TestFailed "simple_test: values do not agree")) !map;
   SMap.iter ~f:(fun ~key ~data -> Db.del db key) !map;
-  SMap.iter ~f:(fun ~key ~data ->
-              try
-                let dbdata = Db.get db key [] in
-                raise (TestFailed "simple_test: deleted value found anyway")
-              with
-                  Not_found -> ()
-           ) !map;
+  SMap.iter ~f:(fun ~key ~data -> 
+	      try
+		let dbdata = Db.get db key [] in
+		raise (TestFailed "simple_test: deleted value found anyway")
+	      with
+		  Not_found -> ()
+	   ) !map;
   print_string "Simple Test passed\n"
 
-
-let leak_test () =
+  
+let leak_test () = 
   let size = 10000 in
   for i = 1 to size do
     let x = Dbenv.create [] in
   print_string "Leak Test completed\n"
 
 let cursor_get_all c =
-  let rec loop list =
+  let rec loop list = 
     try loop (Cursor.get c Cursor.NEXT_DUP [] :: list)
     with Not_found -> list
   in
   loop [first]
 
 let jcursor_get_all c =
-  let rec loop list =
-    match (try Some (Cursor.get c Cursor.NULL [])
-           with Not_found -> None)
+  let rec loop list = 
+    match (try Some (Cursor.get c Cursor.NULL []) 
+	   with Not_found -> None)
     with
-        Some (key,data) -> loop (data::list)
+	Some (key,data) -> loop (data::list)
       | None -> list
   in
   loop []
 
-let cursor_test () =
+let cursor_test () = 
   let idbname = "FOO" and pdbname = "BAR" in
   prepare_file idbname; prepare_file pdbname;
-  let idb = Db.sopen idbname Db.HASH
-             ~moreflags:[Db.DUP] [ Db.CREATE ] 0o777 in
+  let idb = Db.sopen idbname Db.HASH 
+	     ~moreflags:[Db.DUP] [ Db.CREATE ] 0o777 in
   let pdb = Db.sopen pdbname Db.HASH [ Db.CREATE ] 0o777 in
   let ci = Cursor.create idb and cp = Cursor.create pdb in
-  let common =
+  let common = 
     Set.of_list (MList.init 10 ~f:(fun i -> rand_string 30)) in
-  let s1 = Set.union common
-             (Set.of_list (MList.init 10 ~f:(fun i -> rand_string 30)))
-  and s2 = Set.union common
-             (Set.of_list (MList.init 10 ~f:(fun i -> rand_string 30)))
-  and s3 = Set.union common
-             (Set.of_list (MList.init 10 ~f:(fun i -> rand_string 30)))