-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlxr.ml
3608 lines (2631 loc) · 96.2 KB
/
lxr.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(** val negb : bool -> bool **)
let negb = function
| true -> false
| false -> true
type nat =
| O
| S of nat
(** val fst : ('a1 * 'a2) -> 'a1 **)
let fst = function
| (x, _) -> x
(** val snd : ('a1 * 'a2) -> 'a2 **)
let snd = function
| (_, y) -> y
(** val length : 'a1 list -> nat **)
let rec length = function
| [] -> O
| _ :: l' -> S (length l')
(** val app : 'a1 list -> 'a1 list -> 'a1 list **)
let rec app l m =
match l with
| [] -> m
| a :: l1 -> a :: (app l1 m)
type comparison =
| Eq
| Lt
| Gt
module Coq__1 = struct
(** val add : nat -> nat -> nat **)
let rec add n0 m =
match n0 with
| O -> m
| S p -> S (add p m)
end
include Coq__1
(** val eqb : nat -> nat -> bool **)
let rec eqb n0 m =
match n0 with
| O -> (match m with
| O -> true
| S _ -> false)
| S n' -> (match m with
| O -> false
| S m' -> eqb n' m')
(** val leb : nat -> nat -> bool **)
let rec leb n0 m =
match n0 with
| O -> true
| S n' -> (match m with
| O -> false
| S m' -> leb n' m')
type positive =
| XI of positive
| XO of positive
| XH
type n =
| N0
| Npos of positive
type z =
| Z0
| Zpos of positive
| Zneg of positive
module type EqLtLe =
sig
type t
end
module MakeOrderTac =
functor (O:EqLtLe) ->
functor (P:sig
end) ->
struct
end
module Pos =
struct
type mask =
| IsNul
| IsPos of positive
| IsNeg
end
module Coq_Pos =
struct
(** val succ : positive -> positive **)
let rec succ = function
| XI p -> XO (succ p)
| XO p -> XI p
| XH -> XO XH
(** val add : positive -> positive -> positive **)
let rec add x y =
match x with
| XI p ->
(match y with
| XI q -> XO (add_carry p q)
| XO q -> XI (add p q)
| XH -> XO (succ p))
| XO p ->
(match y with
| XI q -> XI (add p q)
| XO q -> XO (add p q)
| XH -> XI p)
| XH -> (match y with
| XI q -> XO (succ q)
| XO q -> XI q
| XH -> XO XH)
(** val add_carry : positive -> positive -> positive **)
and add_carry x y =
match x with
| XI p ->
(match y with
| XI q -> XI (add_carry p q)
| XO q -> XO (add_carry p q)
| XH -> XI (succ p))
| XO p ->
(match y with
| XI q -> XO (add_carry p q)
| XO q -> XI (add p q)
| XH -> XO (succ p))
| XH ->
(match y with
| XI q -> XI (succ q)
| XO q -> XO (succ q)
| XH -> XI XH)
(** val pred_double : positive -> positive **)
let rec pred_double = function
| XI p -> XI (XO p)
| XO p -> XI (pred_double p)
| XH -> XH
type mask = Pos.mask =
| IsNul
| IsPos of positive
| IsNeg
(** val succ_double_mask : mask -> mask **)
let succ_double_mask = function
| IsNul -> IsPos XH
| IsPos p -> IsPos (XI p)
| IsNeg -> IsNeg
(** val double_mask : mask -> mask **)
let double_mask = function
| IsPos p -> IsPos (XO p)
| x0 -> x0
(** val double_pred_mask : positive -> mask **)
let double_pred_mask = function
| XI p -> IsPos (XO (XO p))
| XO p -> IsPos (XO (pred_double p))
| XH -> IsNul
(** val sub_mask : positive -> positive -> mask **)
let rec sub_mask x y =
match x with
| XI p ->
(match y with
| XI q -> double_mask (sub_mask p q)
| XO q -> succ_double_mask (sub_mask p q)
| XH -> IsPos (XO p))
| XO p ->
(match y with
| XI q -> succ_double_mask (sub_mask_carry p q)
| XO q -> double_mask (sub_mask p q)
| XH -> IsPos (pred_double p))
| XH -> (match y with
| XH -> IsNul
| _ -> IsNeg)
(** val sub_mask_carry : positive -> positive -> mask **)
and sub_mask_carry x y =
match x with
| XI p ->
(match y with
| XI q -> succ_double_mask (sub_mask_carry p q)
| XO q -> double_mask (sub_mask p q)
| XH -> IsPos (pred_double p))
| XO p ->
(match y with
| XI q -> double_mask (sub_mask_carry p q)
| XO q -> succ_double_mask (sub_mask_carry p q)
| XH -> double_pred_mask p)
| XH -> IsNeg
(** val mul : positive -> positive -> positive **)
let rec mul x y =
match x with
| XI p -> add y (XO (mul p y))
| XO p -> XO (mul p y)
| XH -> y
(** val compare_cont : comparison -> positive -> positive -> comparison **)
let rec compare_cont r x y =
match x with
| XI p ->
(match y with
| XI q -> compare_cont r p q
| XO q -> compare_cont Gt p q
| XH -> Gt)
| XO p ->
(match y with
| XI q -> compare_cont Lt p q
| XO q -> compare_cont r p q
| XH -> Gt)
| XH -> (match y with
| XH -> r
| _ -> Lt)
(** val compare : positive -> positive -> comparison **)
let compare =
compare_cont Eq
(** val min : positive -> positive -> positive **)
let min p p' =
match compare p p' with
| Gt -> p'
| _ -> p
(** val max : positive -> positive -> positive **)
let max p p' =
match compare p p' with
| Gt -> p
| _ -> p'
(** val eqb : positive -> positive -> bool **)
let rec eqb p q =
match p with
| XI p0 -> (match q with
| XI q0 -> eqb p0 q0
| _ -> false)
| XO p0 -> (match q with
| XO q0 -> eqb p0 q0
| _ -> false)
| XH -> (match q with
| XH -> true
| _ -> false)
(** val iter_op : ('a1 -> 'a1 -> 'a1) -> positive -> 'a1 -> 'a1 **)
let rec iter_op op p a =
match p with
| XI p0 -> op a (iter_op op p0 (op a a))
| XO p0 -> iter_op op p0 (op a a)
| XH -> a
(** val to_nat : positive -> nat **)
let to_nat x =
iter_op Coq__1.add x (S O)
(** val of_nat : nat -> positive **)
let rec of_nat = function
| O -> XH
| S x -> (match x with
| O -> XH
| S _ -> succ (of_nat x))
(** val of_succ_nat : nat -> positive **)
let rec of_succ_nat = function
| O -> XH
| S x -> succ (of_succ_nat x)
end
module N =
struct
(** val succ_double : n -> n **)
let succ_double = function
| N0 -> Npos XH
| Npos p -> Npos (XI p)
(** val double : n -> n **)
let double = function
| N0 -> N0
| Npos p -> Npos (XO p)
(** val add : n -> n -> n **)
let add n0 m =
match n0 with
| N0 -> m
| Npos p -> (match m with
| N0 -> n0
| Npos q -> Npos (Coq_Pos.add p q))
(** val sub : n -> n -> n **)
let sub n0 m =
match n0 with
| N0 -> N0
| Npos n' ->
(match m with
| N0 -> n0
| Npos m' ->
(match Coq_Pos.sub_mask n' m' with
| Coq_Pos.IsPos p -> Npos p
| _ -> N0))
(** val mul : n -> n -> n **)
let mul n0 m =
match n0 with
| N0 -> N0
| Npos p -> (match m with
| N0 -> N0
| Npos q -> Npos (Coq_Pos.mul p q))
(** val compare : n -> n -> comparison **)
let compare n0 m =
match n0 with
| N0 -> (match m with
| N0 -> Eq
| Npos _ -> Lt)
| Npos n' -> (match m with
| N0 -> Gt
| Npos m' -> Coq_Pos.compare n' m')
(** val eqb : n -> n -> bool **)
let eqb n0 m =
match n0 with
| N0 -> (match m with
| N0 -> true
| Npos _ -> false)
| Npos p -> (match m with
| N0 -> false
| Npos q -> Coq_Pos.eqb p q)
(** val leb : n -> n -> bool **)
let leb x y =
match compare x y with
| Gt -> false
| _ -> true
(** val ltb : n -> n -> bool **)
let ltb x y =
match compare x y with
| Lt -> true
| _ -> false
(** val pos_div_eucl : positive -> n -> n * n **)
let rec pos_div_eucl a b =
match a with
| XI a' ->
let (q, r) = pos_div_eucl a' b in
let r' = succ_double r in
if leb b r' then ((succ_double q), (sub r' b)) else ((double q), r')
| XO a' ->
let (q, r) = pos_div_eucl a' b in
let r' = double r in
if leb b r' then ((succ_double q), (sub r' b)) else ((double q), r')
| XH ->
(match b with
| N0 -> (N0, (Npos XH))
| Npos p -> (match p with
| XH -> ((Npos XH), N0)
| _ -> (N0, (Npos XH))))
(** val div_eucl : n -> n -> n * n **)
let div_eucl a b =
match a with
| N0 -> (N0, N0)
| Npos na -> (match b with
| N0 -> (N0, a)
| Npos _ -> pos_div_eucl na b)
(** val div : n -> n -> n **)
let div a b =
fst (div_eucl a b)
(** val to_nat : n -> nat **)
let to_nat = function
| N0 -> O
| Npos p -> Coq_Pos.to_nat p
(** val of_nat : nat -> n **)
let of_nat = function
| O -> N0
| S n' -> Npos (Coq_Pos.of_succ_nat n')
end
(** val removelast : 'a1 list -> 'a1 list **)
let rec removelast = function
| [] -> []
| a :: l0 -> (match l0 with
| [] -> []
| _ :: _ -> a :: (removelast l0))
(** val rev : 'a1 list -> 'a1 list **)
let rec rev = function
| [] -> []
| x :: l' -> app (rev l') (x :: [])
(** val map : ('a1 -> 'a2) -> 'a1 list -> 'a2 list **)
let rec map f = function
| [] -> []
| a :: t0 -> (f a) :: (map f t0)
(** val fold_left : ('a1 -> 'a2 -> 'a1) -> 'a2 list -> 'a1 -> 'a1 **)
let rec fold_left f l a0 =
match l with
| [] -> a0
| b :: t0 -> fold_left f t0 (f a0 b)
(** val fold_right : ('a2 -> 'a1 -> 'a1) -> 'a1 -> 'a2 list -> 'a1 **)
let rec fold_right f a0 = function
| [] -> a0
| b :: t0 -> f b (fold_right f a0 t0)
(** val filter : ('a1 -> bool) -> 'a1 list -> 'a1 list **)
let rec filter f = function
| [] -> []
| x :: l0 -> if f x then x :: (filter f l0) else filter f l0
(** val seq : nat -> nat -> nat list **)
let rec seq start = function
| O -> []
| S len0 -> start :: (seq (S start) len0)
(** val compare0 : char -> char -> comparison **)
let compare0 = fun c1 c2 ->
let cmp = Char.compare c1 c2 in
if cmp < 0 then Lt else if cmp = 0 then Eq else Gt
(** val compare1 : string -> string -> comparison **)
let rec compare1 s1 s2 =
(* If this appears, you're using String internals. Please don't *)
(fun f0 f1 s ->
let l = String.length s in
if l = 0 then f0 () else f1 (String.get s 0) (String.sub s 1 (l-1)))
(fun _ ->
(* If this appears, you're using String internals. Please don't *)
(fun f0 f1 s ->
let l = String.length s in
if l = 0 then f0 () else f1 (String.get s 0) (String.sub s 1 (l-1)))
(fun _ -> Eq)
(fun _ _ -> Lt)
s2)
(fun c1 s1' ->
(* If this appears, you're using String internals. Please don't *)
(fun f0 f1 s ->
let l = String.length s in
if l = 0 then f0 () else f1 (String.get s 0) (String.sub s 1 (l-1)))
(fun _ -> Gt)
(fun c2 s2' ->
match compare0 c1 c2 with
| Eq -> compare1 s1' s2'
| x -> x)
s2)
s1
module Conversion =
struct
(** val pos2N : positive -> n **)
let pos2N p =
Npos p
(** val nat2N : nat -> n **)
let nat2N =
N.of_nat
(** val i2p : int -> positive **)
let i2p =
let rec i2p = function
1 -> XH
| n -> let n' = i2p (n/2) in if (n mod 2)=0 then XO n' else XI n'
in i2p
(** val p2i : positive -> int **)
let p2i =
let rec p2i = function
XH -> 1
| XO p -> 2*(p2i p)
| XI p -> 2*(p2i p)+1
in p2i
(** val i2z : int -> z **)
let i2z =
function
0 -> Z0
| n -> if n < 0 then Zneg (i2p (-n)) else Zpos (i2p n)
(** val z2i : z -> int **)
let z2i =
function
Z0 -> 0
| Zpos p -> p2i p
| Zneg p -> -(p2i p)
(** val i2n : int -> n **)
let i2n =
function
0 -> N0
| n -> Npos (i2p n)
(** val n2i : n -> int **)
let n2i =
function
N0 -> 0
| Npos p -> p2i p
(** val i2s : int -> string **)
let i2s = string_of_int
end
module Nchunks =
struct
(** val max_n : positive **)
let max_n =
XO (XO (XO (XO (XO (XO (XO (XO XH)))))))
(** val min_n : positive **)
let min_n =
XO (XO (XO (XO XH)))
module Private =
struct
type t = positive
(** val from_positive : positive -> t **)
let from_positive n0 =
Coq_Pos.min max_n (Coq_Pos.max n0 min_n)
(** val from_int : int -> t **)
let from_int i =
from_positive (Conversion.i2p i)
(** val to_positive : t -> positive **)
let to_positive x =
x
(** val to_N : t -> n **)
let to_N =
Conversion.pos2N
end
type t = Private.t
(** val from_positive : positive -> Private.t **)
let from_positive =
Private.from_positive
(** val from_int : int -> Private.t **)
let from_int =
Private.from_int
(** val to_positive : Private.t -> positive **)
let to_positive =
Private.to_positive
(** val to_N : Private.t -> n **)
let to_N =
Private.to_N
end
module Cstdio =
struct
type coq_EncryptionState =
| Plain
| Encrypted
(** val coq_EncryptionState_rect :
'a1 -> 'a1 -> coq_EncryptionState -> 'a1 **)
let coq_EncryptionState_rect f f0 = function
| Plain -> f
| Encrypted -> f0
(** val coq_EncryptionState_rec :
'a1 -> 'a1 -> coq_EncryptionState -> 'a1 **)
let coq_EncryptionState_rec f f0 = function
| Plain -> f
| Encrypted -> f0
type cstdio_buffer = Mlcpp_cstdio.Cstdio.File.Buffer.ta
type mode = string
(** val read_mode : mode **)
let read_mode =
"rb"
(** val write_mode : mode **)
let write_mode =
"wb"
(** val write_new_mode : mode **)
let write_new_mode =
"wx"
(** val append_mode : mode **)
let append_mode =
"ab"
type fptr = Mlcpp_cstdio.Cstdio.File.file
(** val fopen : string -> mode -> fptr option **)
let fopen = fun fname mode ->
match Mlcpp_cstdio.Cstdio.File.fopen fname mode with
| Ok fptr -> Some fptr
| Error (errno, errstr) -> Printf.printf "fopen '%s' error: %d/%s\n" fname errno errstr; None
(** val fclose : fptr -> unit option **)
let fclose = fun fptr ->
match Mlcpp_cstdio.Cstdio.File.fclose fptr with
| Ok () -> Some ()
| Error (errno, errstr) -> Printf.printf "fclose error: %d/%s\n" errno errstr; None
(** val fflush : fptr -> fptr option **)
let fflush = fun fptr ->
match Mlcpp_cstdio.Cstdio.File.fflush fptr with
| Ok () -> Some fptr
| Error (errno, errstr) -> Printf.printf "fflush error: %d/%s\n" errno errstr; None
(** val fread : fptr -> n -> (n * cstdio_buffer) option **)
let fread = fun fptr sz ->
let b = Mlcpp_cstdio.Cstdio.File.Buffer.create (Conversion.n2i sz) in
match Mlcpp_cstdio.Cstdio.File.fread b (Conversion.n2i sz) fptr with
| Ok nread -> Some (Conversion.i2n nread, b)
| Error (errno, errstr) -> Printf.printf "fread error: %d/%s\n" errno errstr; None
(** val fwrite : fptr -> n -> cstdio_buffer -> n option **)
let fwrite = fun fptr sz b ->
match Mlcpp_cstdio.Cstdio.File.fwrite b (Conversion.n2i sz) fptr with
| Ok nwritten -> Some (Conversion.i2n nwritten)
| Error (errno, errstr) -> Printf.printf "fwrite error: %d/%s\n" errno errstr; None
(** val ftell : fptr -> n option **)
let ftell = fun fptr ->
match Mlcpp_cstdio.Cstdio.File.ftell fptr with
| Ok pos -> Some (Conversion.i2n pos)
| Error (errno, errstr) -> Printf.printf "ftell error: %d/%s\n" errno errstr; None
(** val fseek : fptr -> n -> fptr option **)
let fseek = fun fptr pos ->
match Mlcpp_cstdio.Cstdio.File.fseek fptr (Conversion.n2i pos) with
| Ok () -> Some fptr
| Error (errno, errstr) -> Printf.printf "fseek error: %d/%s\n" errno errstr; None
module type BUF =
sig
type buffer_t
val buffer_create : n -> buffer_t
val buffer_len : buffer_t -> n
val calc_checksum : buffer_t -> string
val copy_sz_pos : buffer_t -> n -> n -> buffer_t -> n -> n
val from_buffer : cstdio_buffer -> buffer_t
val to_buffer : buffer_t -> cstdio_buffer
val state : coq_EncryptionState
end
module BufferEncrypted =
struct
type buffer_t = Mlcpp_cstdio.Cstdio.File.Buffer.ta
(** val buffer_create : n -> buffer_t **)
let buffer_create = fun n -> Mlcpp_cstdio.Cstdio.File.Buffer.create (Conversion.n2i n)
(** val buffer_len : buffer_t -> n **)
let buffer_len = fun b -> Conversion.i2n (Mlcpp_cstdio.Cstdio.File.Buffer.size b)
(** val calc_checksum : buffer_t -> string **)
let calc_checksum = fun b -> Elykseer_crypto.Sha3_256.buffer b
(** val copy_sz_pos : buffer_t -> n -> n -> buffer_t -> n -> n **)
let copy_sz_pos =
fun bsrc npos1 nsz btgt npos2 -> Conversion.i2n @@
Mlcpp_cstdio.Cstdio.File.Buffer.copy_sz_pos bsrc ~pos1:(Conversion.n2i npos1) ~sz:(Conversion.n2i nsz) btgt ~pos2:(Conversion.n2i npos2)
(** val from_buffer : cstdio_buffer -> buffer_t **)
let from_buffer = fun b -> Helper.cpp_buffer_id b
(** val to_buffer : buffer_t -> cstdio_buffer **)
let to_buffer = fun b -> Helper.cpp_buffer_id b
(** val state : coq_EncryptionState **)
let state =
Encrypted
end
module BufferPlain =
struct
type buffer_t = Mlcpp_cstdio.Cstdio.File.Buffer.ta
(** val buffer_create : n -> buffer_t **)
let buffer_create = fun n -> Mlcpp_cstdio.Cstdio.File.Buffer.create (Conversion.n2i n)
(** val buffer_len : buffer_t -> n **)
let buffer_len = fun b -> Conversion.i2n (Mlcpp_cstdio.Cstdio.File.Buffer.size b)
(** val calc_checksum : buffer_t -> string **)
let calc_checksum = fun b -> Elykseer_crypto.Sha3_256.buffer b
(** val copy_sz_pos : buffer_t -> n -> n -> buffer_t -> n -> n **)
let copy_sz_pos =
fun bsrc npos1 nsz btgt npos2 -> Conversion.i2n @@
Mlcpp_cstdio.Cstdio.File.Buffer.copy_sz_pos bsrc ~pos1:(Conversion.n2i npos1) ~sz:(Conversion.n2i nsz) btgt ~pos2:(Conversion.n2i npos2)
(** val from_buffer : cstdio_buffer -> buffer_t **)
let from_buffer = fun b -> Helper.cpp_buffer_id b
(** val to_buffer : buffer_t -> cstdio_buffer **)
let to_buffer = fun b -> Helper.cpp_buffer_id b
(** val state : coq_EncryptionState **)
let state =
Plain
end
(** val cpp_encrypt_buffer :
BufferPlain.buffer_t -> string -> string -> BufferEncrypted.buffer_t **)
let cpp_encrypt_buffer = fun b siv spk -> Elykseer_crypto.Aes256.encrypt (Elykseer_crypto.Key128.from_hex siv) (Elykseer_crypto.Key256.from_hex spk) b
(** val encrypt :
BufferPlain.buffer_t -> string -> string -> BufferEncrypted.buffer_t **)
let encrypt =
cpp_encrypt_buffer
(** val cpp_decrypt_buffer :
BufferEncrypted.buffer_t -> string -> string -> BufferPlain.buffer_t **)
let cpp_decrypt_buffer = fun b siv spk -> Elykseer_crypto.Aes256.decrypt (Elykseer_crypto.Key128.from_hex siv) (Elykseer_crypto.Key256.from_hex spk) b
(** val decrypt :
BufferEncrypted.buffer_t -> string -> string -> BufferPlain.buffer_t **)
let decrypt =
cpp_decrypt_buffer
(** val cpp_ranbuf128 : unit -> cstdio_buffer **)
let cpp_ranbuf128 = fun () -> Helper.ranbuf128 ()
(** val ranbuf128 : unit -> BufferPlain.buffer_t **)
let ranbuf128 _ =
let rb = cpp_ranbuf128 () in BufferPlain.from_buffer rb
end
module Tracer =
struct
type loglevel =
| Coq_debug
| Coq_info
| Coq_warning
| Coq_error
(** val loglevel_rect : 'a1 -> 'a1 -> 'a1 -> 'a1 -> loglevel -> 'a1 **)
let loglevel_rect f f0 f1 f2 = function
| Coq_debug -> f
| Coq_info -> f0
| Coq_warning -> f1
| Coq_error -> f2
(** val loglevel_rec : 'a1 -> 'a1 -> 'a1 -> 'a1 -> loglevel -> 'a1 **)
let loglevel_rec f f0 f1 f2 = function
| Coq_debug -> f
| Coq_info -> f0
| Coq_warning -> f1
| Coq_error -> f2
type tracer = { logDebug : (string -> unit option);
logInfo : (string -> unit option);
logWarning : (string -> unit option);
logError : (string -> unit option) }
(** val logDebug : tracer -> string -> unit option **)
let logDebug t0 =
t0.logDebug
(** val logInfo : tracer -> string -> unit option **)
let logInfo t0 =
t0.logInfo
(** val logWarning : tracer -> string -> unit option **)
let logWarning t0 =
t0.logWarning
(** val logError : tracer -> string -> unit option **)
let logError t0 =
t0.logError
(** val ignore : 'a1 -> unit option **)
let ignore _ =
None
(** val nullTracer : tracer **)
let nullTracer =
{ logDebug = ignore; logInfo = ignore; logWarning = ignore; logError =
ignore }
(** val output_stdout : loglevel -> string -> unit option **)
let output_stdout = fun ll m ->
let _ = match ll with
| Coq_debug -> print_string "DEBUG "
| Coq_info -> print_string "INFO "
| Coq_warning -> print_string "WARNING "
| Coq_error -> print_string "ERROR "
in
print_endline m; Some ()
(** val stdoutTracerDebug : tracer **)
let stdoutTracerDebug =
{ logDebug = (output_stdout Coq_debug); logInfo =
(output_stdout Coq_info); logWarning = (output_stdout Coq_warning);
logError = (output_stdout Coq_error) }
(** val stdoutTracerInfo : tracer **)
let stdoutTracerInfo =
{ logDebug = ignore; logInfo = (output_stdout Coq_info); logWarning =
(output_stdout Coq_warning); logError = (output_stdout Coq_error) }
(** val stdoutTracerWarning : tracer **)
let stdoutTracerWarning =
{ logDebug = ignore; logInfo = ignore; logWarning =
(output_stdout Coq_warning); logError = (output_stdout Coq_error) }
(** val stdoutTracerError : tracer **)
let stdoutTracerError =
{ logDebug = ignore; logInfo = ignore; logWarning = ignore; logError =
(output_stdout Coq_error) }
(** val log : tracer -> loglevel -> string -> unit option **)
let log t0 ll m =
match ll with
| Coq_debug -> t0.logDebug m
| Coq_info -> t0.logInfo m
| Coq_warning -> t0.logWarning m
| Coq_error -> t0.logError m
(** val conditionalTrace :
tracer -> bool -> loglevel -> string option -> (unit -> 'a1 option) ->
loglevel -> string option -> (unit -> 'a1 option) -> 'a1 option **)
let conditionalTrace t0 condition ll_true true_msg true_computation ll_false false_msg false_computation =
if condition
then (match true_msg with
| Some m ->
(match log t0 ll_true m with
| Some _ -> true_computation ()
| None -> None)
| None -> true_computation ())
else (match false_msg with
| Some m ->
(match log t0 ll_false m with
| Some _ -> false_computation ()
| None -> None)
| None -> false_computation ())
(** val optionalTrace :
tracer -> 'a2 option -> loglevel -> string option -> (unit -> 'a1
option) -> loglevel -> string option -> ('a2 -> 'a1 option) -> 'a1
option **)