package gapi-ocaml

  1. Overview
  2. Docs
A simple OCaml client for Google Services

Install

Dune Dependency

Authors

Maintainers

Sources

v0.4.6.tar.gz
sha256=b84b680528a5e050014103a8e7a60a5d43efd5fefc3f838310bd46769775ab48
md5=8ee26acf1f6c6f5e24c7b57fa070a0a2

doc/src/gapi-ocaml.netstring-local/netdb.ml.html

Source file netdb.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(* $Id$
 * ----------------------------------------------------------------------
 *
 *)

let values = Hashtbl.create 13
let loaders = Hashtbl.create 13
let cksums = Hashtbl.create 13
let enabled = ref true


let read_db name =
  let v =
    try
      Hashtbl.find values name
    with
      | Not_found ->
          if not !enabled then
            failwith ("Ocamlnet: The lookup table `" ^ name ^
		        "' is not compiled into the program, and access to " ^
		          "the external file database is disabled");
          let loader =
            try
              Hashtbl.find loaders name
            with
              | Not_found ->
	          failwith ("Ocamlnet: No such lookup table: " ^ name) in
          loader name in
  try
    let cksum = Hashtbl.find cksums name in
    if Digest.string v <> cksum then
      failwith ("Netdb: checksum error for table: " ^ name);
    v
  with
    | Not_found -> v


let exists_db name =
  Hashtbl.mem values name || (!enabled && Hashtbl.mem loaders name)

let set_db name value =
  Hashtbl.replace values name value

let set_db_checksum name cksum =
  Hashtbl.replace cksums name cksum

let set_db_loader name loader =
  Hashtbl.replace loaders name loader

let enable_db_loaders b =
  enabled := b

OCaml

Innovation. Community. Security.