123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112typeerror_location=(* Concerns the subtable with the given name and number. *)|Subtableofstring*int(* Concerns the main table. *)|Table(* Undetermined. *)|Anytypeerror=(* The file does not exist or is not readable. *)|File_not_foundofstring(* Overwriting an existing file is not allowed. *)|File_overwriteofstring(* Append mode: the file does not exist, or is not readable, or is not writeable. *)|File_not_appendableofstring(* Write mode: the given permission does not allow writing to the file. *)|File_not_writeableofstring(* The file format is wrong.
* Bad_format (expected, found) *)|Bad_formatofstring*string(* A wrong password was given to open a subtable or the database itself. *)|Bad_passwordoferror_location(* The signature found in the file or in a subtable is wrong. *)|Bad_signatureoferror_location(* No signature was found. *)|No_signatureoferror_location(* The table, or subtable, cannot be used because it is already closed. *)|Is_Closedoferror_location(* This subtable cannot be opened because it has already been opened. *)|Is_Already_Openoferror_location(* No subtable with the given name exists.
* This error occurs when trying to open a standard subtable with open_uncrypted_subtable,
* or when trying to open an explicitly uncrypted subtable with open_subtable. *)|No_subtableofstring(* A subtable with the given name already exists and cannot be overwritten. *)|Subtable_existsofstring(* Too many subtables created. Current maximum is 2^14 - 1. *)|Subtable_overflow(* Trying to overwrite a key, while may_overwrite was false. *)|Overwriteofstring*error_location(* Trying to read a key that is not bound. *)|Unboundofstring*error_location(* Error when accessing the underlying database. *)|DB_Errorofexn(* Corrupted file: it does not have the expected structure. (An error message is given). *)|Corruptedoferror_location*string(* Error when trying to create the backup. *)|Backup_failureofexn(* Constructors *)letbad_passwordl=Bad_passwordlletbad_signaturel=Bad_signaturelletno_signaturel=No_signaturelletis_closedl=Is_Closedlletis_already_openl=Is_Already_OpenlexceptionErroroferrorletraiserrore=raise(Errore)letloc2s=function|Subtable(nm,nb)->Printf.sprintf"Subtable #%d (%s)"nbnm|Table->"database"|Any->"Undetermined!"leterror2s=function|File_not_foundfile->Printf.sprintf"File '%s' cannot be found"file|File_overwritefile->Printf.sprintf"File '%s' cannot be overwritten"file|File_not_appendablefile->Printf.sprintf"File '%s' cannot be appended"file|File_not_writeablefile->Printf.sprintf"File '%s' cannot be written"file|Bad_format(fmt1,fmt2)->Printf.sprintf"Expecting format %s, found format %s"fmt1fmt2|Bad_passwordloc->Printf.sprintf"Bad password in %s"(loc2sloc)|Bad_signatureloc->Printf.sprintf"Bad signature in %s"(loc2sloc)|No_signatureloc->Printf.sprintf"No signature in %s"(loc2sloc)|Is_Closedloc->Printf.sprintf"The %s is closed."(loc2sloc)|Is_Already_Openloc->Printf.sprintf"The %s is already open."(loc2sloc)|No_subtablesub->Printf.sprintf"No subtable named '%s' exists."sub|Subtable_existssub->Printf.sprintf"Subtable %s already exists, it cannot be overwritten."sub|Overwrite(key,loc)->Printf.sprintf"Trying to overwrite key '%s' in %s."key(loc2sloc)|Unbound(key,loc)->Printf.sprintf"Key '%s' does not exist in %s."key(loc2sloc)|DB_Errorexn->Printf.sprintf"Error while accessing the database: %s."(Printexc.to_stringexn)|Corrupted(loc,msg)->Printf.sprintf"%s is corrupted: %s"(loc2sloc)msg|Subtable_overflow->"Too many subtables in this table."|Backup_failureexn->Printf.sprintf"Error while creating the backup: %s."(Printexc.to_stringexn)let()=Printexc.register_printerbeginfunction|Errorerr->Some("Cryptodbm.Error: "^error2serr)|_->Noneend