This commit is contained in:
parent
45648f15c1
commit
0372f50225
2 changed files with 26 additions and 26 deletions
|
|
@ -5,7 +5,7 @@
|
||||||
(libraries cmdliner bos fmt mirage-crypto ptime mte vif))
|
(libraries cmdliner bos fmt mirage-crypto ptime mte vif))
|
||||||
|
|
||||||
(executable
|
(executable
|
||||||
(public_name gen_signatures_registry)
|
(public_name gen_taler_signatures)
|
||||||
(name gen_signatures_registry)
|
(name gen_taler_signatures)
|
||||||
(modules gen_signatures_registry)
|
(modules gen_taler_signatures)
|
||||||
(libraries angstrom bos fmt))
|
(libraries angstrom bos fmt))
|
||||||
|
|
|
||||||
|
|
@ -51,12 +51,7 @@ module Recfile = struct
|
||||||
let parse s = parse_string ~consume:All recfile s
|
let parse s = parse_string ~consume:All recfile s
|
||||||
end
|
end
|
||||||
|
|
||||||
let url =
|
let download ~output ~url =
|
||||||
"https://git-www.gnunet.org/gana.git/plain/gnunet-signatures/registry.rec"
|
|
||||||
|
|
||||||
let registry_file = "registry.rec"
|
|
||||||
|
|
||||||
let download () =
|
|
||||||
let open Bos in
|
let open Bos in
|
||||||
let res =
|
let res =
|
||||||
OS.Cmd.run
|
OS.Cmd.run
|
||||||
|
|
@ -65,7 +60,7 @@ let download () =
|
||||||
% "--silent"
|
% "--silent"
|
||||||
% "--show-error"
|
% "--show-error"
|
||||||
% "-o"
|
% "-o"
|
||||||
% registry_file
|
% output
|
||||||
% "-X"
|
% "-X"
|
||||||
% "GET"
|
% "GET"
|
||||||
% url)
|
% url)
|
||||||
|
|
@ -74,8 +69,6 @@ let download () =
|
||||||
| Error (`Msg s) -> Fmt.failwith "download failure: %s" s
|
| Error (`Msg s) -> Fmt.failwith "download failure: %s" s
|
||||||
| Ok () -> ()
|
| Ok () -> ()
|
||||||
|
|
||||||
let read_file file = In_channel.with_open_bin file In_channel.input_all
|
|
||||||
|
|
||||||
type purpose = {
|
type purpose = {
|
||||||
number: int32;
|
number: int32;
|
||||||
name: string;
|
name: string;
|
||||||
|
|
@ -100,19 +93,26 @@ let parse_purposes records =
|
||||||
| _ -> None)
|
| _ -> None)
|
||||||
|> List.filter (fun v -> v.number >= 1000_l)
|
|> List.filter (fun v -> v.number >= 1000_l)
|
||||||
|
|
||||||
let () =
|
let print_module purposes =
|
||||||
download ();
|
let header =
|
||||||
let content = read_file registry_file in
|
{|(* This file was generated from the GANA database:
|
||||||
|
https://git-www.gnunet.org/gana.git/tree/gnunet-signatures/registry.rec *)|}
|
||||||
|
in
|
||||||
|
let pp ppf { number; name; comment } =
|
||||||
|
Fmt.pf ppf "(** %s *)\nlet %s : int32 = %ld_l\n\n" comment name number
|
||||||
|
in
|
||||||
|
Fmt.pr "%s\n\n%a@." header (Fmt.list ~sep:Fmt.nop pp) purposes;
|
||||||
|
()
|
||||||
|
|
||||||
|
let url =
|
||||||
|
"https://git-www.gnunet.org/gana.git/plain/gnunet-signatures/registry.rec"
|
||||||
|
|
||||||
|
let main () =
|
||||||
|
let tmp_file = Bos.OS.File.tmp "registry.rec.%s" |> Result.get_ok in
|
||||||
|
download ~output:(Fpath.to_string tmp_file) ~url;
|
||||||
|
let content = Bos.OS.File.read tmp_file |> Result.get_ok in
|
||||||
match Recfile.parse content with
|
match Recfile.parse content with
|
||||||
| Error msg -> Fmt.failwith "Recfile parse error: %s" msg
|
| Error msg -> Fmt.failwith "Recfile parse error: %s" msg
|
||||||
| Ok records ->
|
| Ok records -> print_module (parse_purposes records)
|
||||||
let purposes = parse_purposes records in
|
|
||||||
let header =
|
let () = main ()
|
||||||
{|(* This file was generated from the GANA database:
|
|
||||||
https://git-www.gnunet.org/gana.git/tree/gnunet-signatures/registry.rec *)|}
|
|
||||||
in
|
|
||||||
let pp ppf { number; name; comment } =
|
|
||||||
Fmt.pf ppf "(** %s *)\nlet %s : int32 = %ld_l\n\n" comment name number
|
|
||||||
in
|
|
||||||
Fmt.pr "%s\n\n%a@." header (Fmt.list ~sep:Fmt.nop pp) purposes;
|
|
||||||
()
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue