This commit is contained in:
swrup 2026-02-08 16:27:30 +01:00
parent 49352fa7ca
commit 39b91016fb

View file

@ -57,7 +57,14 @@ type purpose = {
comment: string;
}
let f records =
let read_file file = In_channel.with_open_bin file In_channel.input_all
let () =
let content = read_file "registry.rec" in
match parse content with
| Error msg -> Fmt.failwith "Parse error: %s" msg
| Ok records ->
let purposes =
records
|> List.filter_map (fun l ->
match l with
@ -72,23 +79,18 @@ let f records =
comment= c.v;
})
| _ -> None)
|>
(*GNU Taler, >= 1000*)
List.filter (fun v -> v.number >= 1000_l)
|> List.filter (fun v -> v.number >= 1000_l)
in
let read_file file = In_channel.with_open_bin file In_channel.input_all
let file_header = {|...|}
let () =
let content = read_file "registry.rec" in
match parse content with
| Error msg -> Fmt.failwith "Parse error: %s" msg
| Ok records ->
let purposes = f records in
let header =
{|(* This file was generated from the GANA database:
https://git-www.gnunet.org/gana.git/tree/gnunet-signatures/registry.rec *)
|}
in
let pp_purpose ppf { number; name; comment } =
Fmt.pf ppf "(** %s *)\nlet %s : int32 = %ld\n\n" comment name number
in
Fmt.pr "%a@." (Fmt.list ~sep:Fmt.nop pp_purpose) purposes;
Fmt.pr "%s\n\n%a@." header (Fmt.list ~sep:Fmt.nop pp_purpose) purposes;
()