-
Notifications
You must be signed in to change notification settings - Fork 2
/
cash.ml
1119 lines (1087 loc) · 44.2 KB
/
cash.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
(***********************************************************************)
(* Cash *)
(* *)
(* Bruno Verlyck, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 2002 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the GNU Lesser General Public License. *)
(* *)
(* Cash is based on Scsh, by Olin Shivers. *)
(***********************************************************************)
value version = "0.20";
include
(Unix :
sig
type seek_command =
Unix.seek_command ==
[ SEEK_SET
| SEEK_CUR
| SEEK_END ]
;
type open_flag =
Unix.open_flag ==
[ O_RDONLY
| O_WRONLY
| O_RDWR
| O_NONBLOCK
| O_APPEND
| O_CREAT
| O_TRUNC
| O_EXCL
| O_NOCTTY
| O_DSYNC
| O_SYNC
| O_RSYNC ]
;
type file_perm = int;
type file_kind =
Unix.file_kind ==
[ S_REG
| S_DIR
| S_CHR
| S_BLK
| S_LNK
| S_FIFO
| S_SOCK ]
;
type process_status =
Unix.process_status ==
[ WEXITED of int
| WSIGNALED of int
| WSTOPPED of int ]
;
type process_times =
Unix.process_times ==
{ tms_utime : float; tms_stime : float; tms_cutime : float; tms_cstime : float }
;
type wait_flag =
Unix.wait_flag ==
[ WNOHANG
| WUNTRACED ]
;
type socket_domain =
Unix.socket_domain ==
[ PF_UNIX
| PF_INET ]
;
type socket_type =
Unix.socket_type ==
[ SOCK_STREAM
| SOCK_DGRAM
| SOCK_RAW
| SOCK_SEQPACKET ]
;
type inet_addr = Unix.inet_addr;
type sockaddr =
Unix.sockaddr ==
[ ADDR_UNIX of string
| ADDR_INET of inet_addr and int ]
;
type shutdown_command =
Unix.shutdown_command ==
[ SHUTDOWN_RECEIVE
| SHUTDOWN_SEND
| SHUTDOWN_ALL ]
;
type msg_flag =
Unix.msg_flag ==
[ MSG_OOB
| MSG_DONTROUTE
| MSG_PEEK ]
;
type socket_bool_option =
Unix.socket_bool_option ==
[ SO_DEBUG
| SO_BROADCAST
| SO_REUSEADDR
| SO_KEEPALIVE
| SO_DONTROUTE
| SO_OOBINLINE
| SO_ACCEPTCONN ]
;
type socket_int_option =
Unix.socket_int_option ==
[ SO_SNDBUF
| SO_RCVBUF
| SO_ERROR
| SO_TYPE
| SO_RCVLOWAT
| SO_SNDLOWAT ]
;
type socket_optint_option =
Unix.socket_optint_option ==
[ SO_LINGER ]
;
type socket_float_option =
Unix.socket_float_option ==
[ SO_RCVTIMEO
| SO_SNDTIMEO ]
;
end);
type itimer =
Unix.interval_timer ==
[ ITIMER_REAL
| ITIMER_VIRTUAL
| ITIMER_PROF ]
;
type itimer_status =
Unix.interval_timer_status == { it_interval : float; it_value : float }
;
type fd = int;
(* Comes from Procobj, in fact; but we need it before for Pf_2_3_to_6. *)
include (Proc_3_4 : sig type proc = Proc_3_4.proc; end);
include
(Pf_2_3_to_6 :
sig
value string_of_in_channel : in_channel -> string;
value string_list_of_in_channel : in_channel -> list string;
value sexp_list_of_in_channel : in_channel -> list Sexp.simple;
value list_of_in_channel : (in_channel -> 'a) -> in_channel -> list 'a;
value fold_in_channel :
in_channel -> (in_channel -> 'a) -> ('a -> 'b -> 'b) -> 'b -> 'b;
value run_with_in_channel : (unit -> unit) -> in_channel;
value run_with_out_channel : (unit -> unit) -> out_channel;
value run_with_file : (unit -> unit) -> string;
value run_with_string : (unit -> unit) -> string;
value run_with_strings : (unit -> unit) -> list string;
value run_with_sexp : (unit -> unit) -> Sexp.simple;
value run_with_sexps : (unit -> unit) -> list Sexp.simple;
value run_with_inchan_plus_proc : (unit -> unit) -> (in_channel * Procobj.proc);
value run_with_outchan_plus_proc : (unit -> unit) -> (out_channel * Procobj.proc);
value run_with_collecting :
list fd -> (unit -> unit) -> (process_status * list in_channel);
value char_filter : (char -> char) -> unit -> unit;
value string_filter : ?buflen: int -> (string -> string) -> unit -> unit;
value make_string_in_channel : string -> in_channel;
value make_string_out_channel : unit -> out_channel;
value string_out_channel_output : ?close: bool -> out_channel -> string;
value call_with_string_out_channel : ?close: bool -> (out_channel -> unit) -> string;
end);
include
(Io_3_2 :
sig
value close_fd_after : fd -> (fd -> 'a) -> 'a;
value close_in_after : in_channel -> (in_channel -> 'a) -> 'a;
value close_out_after : out_channel -> (out_channel -> 'a) -> 'a;
value with_stdin : in_channel -> (unit -> 'a) -> 'a;
value with_stdout : out_channel -> (unit -> 'a) -> 'a;
value with_stderr : out_channel -> (unit -> 'a) -> 'a;
value set_stdin : in_channel -> unit;
value set_stdout : out_channel -> unit;
value set_stderr : out_channel -> unit;
value close_fd : fd -> bool;
value close_in : in_channel -> bool;
value close_out : out_channel -> bool;
value stdchans_to_stdio : unit -> unit;
value stdio_to_stdchans : unit -> unit;
value with_stdio_chans : (unit -> 'a) -> 'a;
value in_channel_of_fd : fd -> in_channel;
value out_channel_of_fd : fd -> out_channel;
value fd_of_in_channel : in_channel -> fd;
value fd_of_out_channel : out_channel -> fd;
value call_with_fdes_in : (fd -> 'a) -> in_channel -> 'a;
value call_with_fdes_out : (fd -> 'a) -> out_channel -> 'a;
value move_fd_to_fdes : fd -> fd -> fd;
value move_in_channel_to_fdes : in_channel -> fd -> in_channel;
value move_out_channel_to_fdes : out_channel -> fd -> out_channel;
value dup_fd : ?newfd: fd -> fd -> fd;
value fdes_of_dup_in : ?newfd: fd -> in_channel -> fd;
value fdes_of_dup_out : ?newfd: fd -> out_channel -> fd;
value in_channel_of_dup_fd : ?newfd: fd -> fd -> in_channel;
value dup_in : ?newfd: fd -> in_channel -> in_channel;
value in_channel_of_dup_out : ?newfd: fd -> out_channel -> in_channel;
value out_channel_of_dup_fd : ?newfd: fd -> fd -> out_channel;
value out_channel_of_dup_in : ?newfd: fd -> in_channel -> out_channel;
value dup_out : ?newfd: fd -> out_channel -> out_channel;
value seek_fd : ?whence: seek_command -> fd -> int -> int;
value seek_in : ?whence: seek_command -> in_channel -> int -> int;
value seek_out : ?whence: seek_command -> out_channel -> int -> int;
value tell_fd : fd -> int;
value tell_in : in_channel -> int;
value tell_out : out_channel -> int;
value open_file_out : ?perms: file_perm -> string -> list open_flag -> out_channel;
value open_file_in : ?perms: file_perm -> string -> list open_flag -> in_channel;
value open_input_file : ?flags: (list open_flag) -> string -> in_channel;
value open_output_file :
?flags: (list open_flag) -> ?perms: file_perm -> string -> out_channel;
value with_input_from_file : string -> (unit -> 'a) -> 'a;
value with_output_to_file : string -> (unit -> 'a) -> 'a;
value with_errors_to_file : string -> (unit -> 'a) -> 'a;
value call_with_input_file : string -> (in_channel -> 'a) -> 'a;
value call_with_output_file : string -> (out_channel -> 'a) -> 'a;
value call_with_fdes_fn :
?perms: file_perm -> string -> list open_flag -> (fd -> 'a) -> 'a;
value open_fdes : ?perms: file_perm -> string -> list open_flag -> fd;
value openfile : string -> list open_flag -> file_perm -> Unix.file_descr;
type fdes_flags =
[ FD_CLOEXEC ]
;
value fdes_flags_fd : fd -> list fdes_flags;
value fdes_flags_in : in_channel -> list fdes_flags;
value fdes_flags_out : out_channel -> list fdes_flags;
value set_fdes_flags_fd : fd -> list fdes_flags -> unit;
value set_fdes_flags_in : in_channel -> list fdes_flags -> unit;
value set_fdes_flags_out : out_channel -> list fdes_flags -> unit;
value fdes_status_fd : fd -> list open_flag;
value fdes_status_in : in_channel -> list open_flag;
value fdes_status_out : out_channel -> list open_flag;
value set_fdes_status_fd : fd -> list open_flag -> unit;
value set_fdes_status_in : in_channel -> list open_flag -> unit;
value set_fdes_status_out : out_channel -> list open_flag -> unit;
value pipe : unit -> (in_channel * out_channel);
type error_packet =
[ Sys__error of string
| Unix__error of (Unix.error * string * string) ]
;
exception String_io_error of (error_packet * string * string * int * int * int);
value read_string : ?src: fd -> int -> string;
value read_string_in : ?src: in_channel -> int -> string;
value read_string_bang : ?src: fd -> ?start: int -> ?end_: int -> string -> int;
value read_string_bang_in :
?src: in_channel -> ?start: int -> ?end_: int -> string -> int;
value read_string_partial : ?src: fd -> int -> string;
value read_string_partial_in : ?src: in_channel -> int -> string;
value read_string_bang_partial :
?src: fd -> ?start: int -> ?end_: int -> string -> int;
value read_string_bang_partial_in :
?src: in_channel -> ?start: int -> ?end_: int -> string -> int;
value write_string : ?dst: fd -> ?start: int -> ?end_: int -> string -> unit;
value write_string_out :
?dst: out_channel -> ?start: int -> ?end_: int -> string -> unit;
value write_string_partial : ?dst: fd -> ?start: int -> ?end_: int -> string -> int;
value write_string_partial_out :
?dst: out_channel -> ?start: int -> ?end_: int -> string -> int;
type selectable =
[ Nothing
| Read_in of in_channel
| Read_fd of fd
| Write_out of out_channel
| Write_fd of fd
| Except_in of in_channel
| Except_fd of fd ]
;
value select_bang : ?timeout: float -> array selectable -> (int * int * int);
value select : ?timeout: float -> array selectable -> array selectable;
type bufpolicy =
[ Block
| Line
| Nobuf ]
;
value set_chan_buffering_in : in_channel -> ?size: int -> bufpolicy -> unit;
value set_chan_buffering_out : out_channel -> ?size: int -> bufpolicy -> unit;
value force_output : out_channel -> unit;
value flush_all_chans : unit -> unit;
end);
external in_channel_revealed : in_channel -> int = "chan_revealed_count";
external out_channel_revealed : out_channel -> int = "chan_revealed_count";
external release_in_channel_handle : in_channel -> unit = "release_chan_handle";
external release_out_channel_handle : out_channel -> unit = "release_chan_handle";
type file_info =
Unix.stats ==
{ st_dev : int;
st_ino : int;
st_kind : file_kind;
st_perm : file_perm;
st_nlink : int;
st_uid : int;
st_gid : int;
st_rdev : int;
st_size : int;
st_atime : float;
st_mtime : float;
st_ctime : float }
;
include
(Io_3_3 :
sig
value errno_error : Unix.error -> string -> string -> 'a;
type override =
Io_3_3.override ==
[ Don't
| Delete
| Query ]
;
value create_directory : ?perms: file_perm -> ?override: override -> string -> unit;
value create_fifo : ?perms: file_perm -> ?override: override -> string -> unit;
value create_hard_link : ?override: override -> string -> string -> unit;
value create_symlink : ?override: override -> string -> string -> unit;
value delete_file : string -> unit;
value delete_directory : string -> unit;
value delete_filesys_object : string -> bool;
value read_symlink : string -> string;
value rename_file : ?override: override -> string -> string -> unit;
value set_file_mode_fn : string -> file_perm -> unit;
value set_file_mode_fd : fd -> file_perm -> unit;
value set_file_mode_in : in_channel -> file_perm -> unit;
value set_file_mode_out : out_channel -> file_perm -> unit;
value set_file_owner_fn : string -> int -> unit;
value set_file_owner_fd : fd -> int -> unit;
value set_file_owner_in : in_channel -> int -> unit;
value set_file_owner_out : out_channel -> int -> unit;
value set_file_group_fn : string -> int -> unit;
value set_file_group_fd : fd -> int -> unit;
value set_file_group_in : in_channel -> int -> unit;
value set_file_group_out : out_channel -> int -> unit;
value set_file_times : ?times: (float * float) -> string -> unit;
value sync_file_fd : int -> unit;
value sync_file_out : out_channel -> unit;
value sync_file_system : unit -> unit;
value truncate_file_fn : string -> int -> unit;
value truncate_file_fd : fd -> int -> unit;
value truncate_file_in : in_channel -> int -> unit;
value truncate_file_out : out_channel -> int -> unit;
value file_info_fn : ?chase: bool -> string -> file_info;
value file_info_fd : fd -> file_info;
value file_info_in : in_channel -> file_info;
value file_info_out : out_channel -> file_info;
value file_type_fn : ?chase: bool -> string -> file_kind;
value file_type_fd : fd -> file_kind;
value file_type_in : in_channel -> file_kind;
value file_type_out : out_channel -> file_kind;
value file_inode_fn : ?chase: bool -> string -> int;
value file_inode_fd : fd -> int;
value file_inode_in : in_channel -> int;
value file_inode_out : out_channel -> int;
value file_mode_fn : ?chase: bool -> string -> file_perm;
value file_mode_fd : fd -> file_perm;
value file_mode_in : in_channel -> file_perm;
value file_mode_out : out_channel -> file_perm;
value file_nlinks_fn : ?chase: bool -> string -> int;
value file_nlinks_fd : fd -> int;
value file_nlinks_in : in_channel -> int;
value file_nlinks_out : out_channel -> int;
value file_owner_fn : ?chase: bool -> string -> int;
value file_owner_fd : fd -> int;
value file_owner_in : in_channel -> int;
value file_owner_out : out_channel -> int;
value file_group_fn : ?chase: bool -> string -> int;
value file_group_fd : fd -> int;
value file_group_in : in_channel -> int;
value file_group_out : out_channel -> int;
value file_size_fn : ?chase: bool -> string -> int;
value file_size_fd : fd -> int;
value file_size_in : in_channel -> int;
value file_size_out : out_channel -> int;
value file_last_access_fn : ?chase: bool -> string -> float;
value file_last_access_fd : fd -> float;
value file_last_access_in : in_channel -> float;
value file_last_access_out : out_channel -> float;
value file_last_mod_fn : ?chase: bool -> string -> float;
value file_last_mod_fd : fd -> float;
value file_last_mod_in : in_channel -> float;
value file_last_mod_out : out_channel -> float;
value file_last_status_change_fn : ?chase: bool -> string -> float;
value file_last_status_change_fd : fd -> float;
value file_last_status_change_in : in_channel -> float;
value file_last_status_change_out : out_channel -> float;
value is_file_directory_fn : ?chase: bool -> string -> bool;
value is_file_directory_fd : fd -> bool;
value is_file_directory_in : in_channel -> bool;
value is_file_directory_out : out_channel -> bool;
value is_file_fifo_fn : ?chase: bool -> string -> bool;
value is_file_fifo_fd : fd -> bool;
value is_file_fifo_in : in_channel -> bool;
value is_file_fifo_out : out_channel -> bool;
value is_file_regular_fn : ?chase: bool -> string -> bool;
value is_file_regular_fd : fd -> bool;
value is_file_regular_in : in_channel -> bool;
value is_file_regular_out : out_channel -> bool;
value is_file_socket_fn : ?chase: bool -> string -> bool;
value is_file_socket_fd : fd -> bool;
value is_file_socket_in : in_channel -> bool;
value is_file_socket_out : out_channel -> bool;
value is_file_special_fn : ?chase: bool -> string -> bool;
value is_file_special_fd : fd -> bool;
value is_file_special_in : in_channel -> bool;
value is_file_special_out : out_channel -> bool;
value is_file_symlink_fn : string -> bool;
value is_file_symlink_fd : fd -> bool;
value is_file_symlink_in : in_channel -> bool;
value is_file_symlink_out : out_channel -> bool;
type accessibility =
[ Accessible
| Unaccessible
| Permission
| No_directory
| Nonexistent ]
;
value is_file_not_readable_fn : string -> accessibility;
value is_file_not_readable_fd : fd -> accessibility;
value is_file_not_readable_in : in_channel -> accessibility;
value is_file_not_readable_out : out_channel -> accessibility;
value is_file_not_writable_fn : string -> accessibility;
value is_file_not_writable_fd : fd -> accessibility;
value is_file_not_writable_in : in_channel -> accessibility;
value is_file_not_writable_out : out_channel -> accessibility;
value is_file_not_executable_fn : string -> accessibility;
value is_file_not_executable_fd : fd -> accessibility;
value is_file_not_executable_in : in_channel -> accessibility;
value is_file_not_executable_out : out_channel -> accessibility;
value is_file_readable_fn : string -> bool;
value is_file_readable_fd : fd -> bool;
value is_file_readable_in : in_channel -> bool;
value is_file_readable_out : out_channel -> bool;
value is_file_writable_fn : string -> bool;
value is_file_writable_fd : fd -> bool;
value is_file_writable_in : in_channel -> bool;
value is_file_writable_out : out_channel -> bool;
value is_file_executable_fn : string -> bool;
value is_file_executable_fd : fd -> bool;
value is_file_executable_in : in_channel -> bool;
value is_file_executable_out : out_channel -> bool;
type existing =
[ Existing
| Unexisting
| Search_denied ]
;
value file_not_exists_fn : ?chase: bool -> string -> existing;
value file_not_exists_fd : fd -> existing;
value file_not_exists_in : in_channel -> existing;
value file_not_exists_out : out_channel -> existing;
value is_file_existing_fn : ?chase: bool -> string -> bool;
value is_file_existing_fd : fd -> bool;
value is_file_existing_in : in_channel -> bool;
value is_file_existing_out : out_channel -> bool;
value fold_input : ('a -> 'b -> 'a) -> 'a -> ('c -> 'b) -> 'c -> 'a;
value fold_directory : ('a -> string -> 'a) -> 'a -> string -> 'a;
value directory_files : ?dot_files: bool -> string -> list string;
value create_temp_file : ?prefix: string -> unit -> string;
value set_temp_file_template : (string * string) -> unit;
value with_temp_file_template : (string * string) -> (unit -> 'a) -> 'a;
value temp_file_iterate :
?template: (string * string) -> (string -> option 'a) -> 'a;
value temp_file_channel : unit -> (in_channel * out_channel);
end);
include
(Glob :
sig
value glob : list string -> list string;
value glob_quote : string -> string;
type file_match_pattern =
[ String_pat of string
| Regexp_pat of Pcre.regexp
| Predicate_pat of string -> bool ]
;
value file_match : ?dot_files: bool -> string -> list file_match_pattern -> list string;
end);
include
(Proc_3_4 :
sig
value exec : string -> list string -> unit;
value exec_path : string -> list string -> 'a;
value exec_with_env :
string -> ?env: (list (string * string)) -> list string -> unit;
value exec_path_with_env :
string -> ?env: (list (string * string)) -> list string -> 'a;
value low_exec : string -> ?env: (list (string * string)) -> list string -> unit;
value exec_path_search : string -> list string -> string;
value call_terminally : option (unit -> unit) -> option 'a;
value suspend : unit -> unit;
value fork : unit -> option proc;
value fork_child : (unit -> unit) -> proc;
value low_fork : ?child: (unit -> unit) -> unit -> option proc;
value fork_with_pipe : unit -> option proc;
value fork_child_with_pipe : (unit -> unit) -> proc;
value low_fork_with_pipe : ?child: (unit -> unit) -> unit -> option proc;
value fork_with_pipe_plus : list (list fd) -> option proc;
value fork_child_with_pipe_plus : (unit -> 'a) -> list (list fd) -> proc;
value low_fork_with_pipe_plus :
?child: (unit -> 'a) -> list (list fd) -> option proc;
value pid_of_proc : proc -> int;
type probe_pid =
Proc_3_4.probe_pid ==
[ Probe
| Create
| Don't_probe ]
;
value proc_of_pid : ?probe: probe_pid -> int -> option proc;
type autoreap_policy =
Proc_3_4.autoreap_policy ==
[ No_autoreaping
| Early
| Late ]
;
value autoreap_policy : ?policy: autoreap_policy -> unit -> autoreap_policy;
type wait_any =
Proc_3_4.wait_any ==
[ None_ready
| No_children
| Exited of (proc * process_status) ]
;
value reap_zombies : unit -> bool;
value wait : ?wflags: (list wait_flag) -> proc -> process_status;
value wait_pid : ?wflags: (list wait_flag) -> int -> process_status;
value wait_any : ?wflags: (list wait_flag) -> unit -> wait_any;
value wait_process_group : ?wflags: (list wait_flag) -> proc -> wait_any;
value wait_process_group_pgrp : ?wflags: (list wait_flag) -> int -> wait_any;
end);
exception Child_not_ready = Proc_3_4.Child_not_ready;
value exit = Pervasives.exit;
external low_exit : int -> 'a = "sys_exit";
include
(Proc_state_3_5 :
sig
value umask : unit -> int;
value set_umask : int -> unit;
value with_umask : int -> (unit -> 'a) -> 'a;
value chdir : ?dir:string -> unit -> unit;
value cwd : unit -> string;
value with_cwd : string -> (unit -> 'a) -> 'a;
value pid : unit -> int;
value parent_pid : unit -> int;
value process_group : unit -> int;
value set_process_group : ?proc: proc -> int -> unit;
value set_process_group_pid : int -> int -> unit;
type prio =
Proc_state_3_5.prio ==
[ Prio_process
| Prio_pgrp
| Prio_user ]
;
value set_priority : ?who: proc -> prio -> int -> unit;
value set_priority_pid : int -> prio -> int -> unit;
value priority : ?who: proc -> prio -> int;
value priority_pid : int -> prio -> int;
value nice : ?proc: proc -> int -> unit;
value nice_pid : int -> int -> unit;
value user_login_name : unit -> string;
value user_uid : unit -> int;
value user_effective_uid : unit -> int;
value user_gid : unit -> int;
value user_effective_gid : unit -> int;
value user_supplementary_gids : unit -> array int;
value set_uid : int -> unit;
value set_gid : int -> unit;
value process_times : unit -> process_times;
value cpu_ticks_per_sec : unit -> int;
end);
include
(User_group_3_6 :
sig
type user_info =
User_group_3_6.user_info ==
{ ui_name : string;
ui_uid : int;
ui_gid : int;
ui_home_dir : string;
ui_shell : string }
;
value user_info : int -> user_info;
value user_info_name : string -> user_info;
value username_to_uid : string -> int;
value uid_to_username : int -> string;
type group_info =
User_group_3_6.group_info ==
{ gi_name : string; gi_gid : int; gi_members : list string }
;
value group_info : int -> group_info;
value group_info_name : string -> group_info;
value groupname_to_gid : string -> int;
value gid_to_groupname : int -> string;
end);
include
(Arg_3_7 :
sig
value command_line_arguments : ref (option (list string));
value command_line : unit -> list string;
value make_command_line_arguments : unit -> list string;
value arg : ?default: 'a -> list 'a -> int -> 'a;
value arg_star : ?default_thunk: (unit -> 'a) -> list 'a -> int -> 'a;
value argv : ?default: string -> int -> string;
end);
value system_name = Unix.gethostname;
include
(Signal_3_9 :
sig
value signal_process : proc -> int -> unit;
value signal_process_pid : int -> int -> unit;
value signal_process_group : proc -> int -> unit;
value signal_process_group_pgrp : int -> int -> unit;
value itimer : ?newstat: itimer_status -> itimer -> itimer_status;
value pause_until_interrupt : unit -> unit;
value sleep : int -> unit;
value sleep_until : float -> unit;
end);
include
(Time_3_10 :
sig
type date =
Time_3_10.date ==
{ seconds : int;
minute : int;
hour : int;
month_day : int;
month : int;
year : int;
tz_name : option string;
tz_secs : option int;
is_summer : option bool;
week_day : int;
year_day : int }
;
value make_date :
?tzn: string -> ?tzs: int -> ?summ: bool -> ?wday: int -> ?yday: int -> int ->
int -> int -> int -> int -> int -> date;
value time_plus_ticks : unit -> float;
value ticks_per_sec : unit -> float;
type time_zone =
Time_3_10.time_zone ==
[ Tz_local
| Tz_secs of int
| Tz_name of string ]
;
value date : unit -> date;
value date_of_time : ?tz: time_zone -> float -> date;
value time : unit -> float;
value time_of_date : date -> float;
value string_of_date : date -> string;
value format_date : string -> date -> string;
end);
include
(Env_3_11 :
sig
value unwind_protect : (unit -> 'a) -> ('b -> unit) -> 'b -> 'a;
value getenv : string -> string;
value setenv : ?sval: string -> string -> unit;
value alist_of_env : unit -> list (string * string);
value setenv_from_alist : list (string * string) -> unit;
value alist_delete : 'a -> list ('a * 'b) -> list ('a * 'b);
value alist_update : 'a -> 'b -> list ('a * 'b) -> list ('a * 'b);
value alist_compress : list ('a * bool) -> list ('a * bool);
value with_env : list (string * string) -> (unit -> 'a) -> 'a;
value with_total_env : list (string * string) -> (unit -> 'a) -> 'a;
value add_before : 'a -> 'a -> list 'a -> list 'a;
value add_after : 'a -> 'a -> list 'a -> list 'a;
value home_directory : ref string;
value exec_path_list : unit -> list string;
value set_exec_path_list : list string -> unit;
value with_exec_path_list : list string -> (unit -> 'a) -> 'a;
end);
ignore (exec_path_list ()); (* Start-up time access to $PATH. *)
include
(Tty_3_12 :
sig
value is_tty_fd : fd -> bool;
value is_tty_in : in_channel -> bool;
value is_tty_out : out_channel -> bool;
value tty_file_name_fd : fd -> string;
value tty_file_name_in : in_channel -> string;
value tty_file_name_out : out_channel -> string;
type tty_info =
{ control_chars : string;
input_flags : nativeint;
output_flags : nativeint;
control_flags : nativeint;
local_flags : nativeint;
input_speed : int;
output_speed : int;
min : int;
time : int }
;
type tty_chars =
{ delete_char : int;
delete_line : int;
eof : int;
eol : int;
interrupt : int;
quit : int;
suspend : int;
start : int;
stop : int;
delayed_suspend : int;
delete_word : int;
discard : int;
eol2 : int;
literal_next : int;
reprint : int;
status : int }
;
value ttychar : tty_chars;
value disable_tty_char : char;
type tty_in =
{ check_parity : nativeint;
ignore_bad_parity_chars : nativeint;
mark_parity_errors : nativeint;
ignore_break : nativeint;
interrupt_on_break : nativeint;
seven_bits : nativeint;
cr_to_nl : nativeint;
ignore_cr : nativeint;
nl_to_cr : nativeint;
input_flow_ctl : nativeint;
output_flow_ctl : nativeint;
xon_any : nativeint;
beep_on_overflow : nativeint;
lowercase : nativeint }
;
value ttyin : tty_in;
type tty_out =
{ enable : nativeint;
nl_to_crnl : nativeint;
discard_eot : nativeint;
expand_tabs : nativeint;
cr_to_nl : nativeint;
nl_does_cr : nativeint;
no_col0_cr : nativeint;
delay_with_fill_char : nativeint;
fill_with_del : nativeint;
uppercase : nativeint;
bs_delay : nativeint;
bs_delay0 : nativeint;
bs_delay1 : nativeint;
cr_delay : nativeint;
cr_delay0 : nativeint;
cr_delay1 : nativeint;
cr_delay2 : nativeint;
cr_delay3 : nativeint;
ff_delay : nativeint;
ff_delay0 : nativeint;
ff_delay1 : nativeint;
tab_delay : nativeint;
tab_delay0 : nativeint;
tab_delay1 : nativeint;
tab_delay2 : nativeint;
tab_delayx : nativeint;
nl_delay : nativeint;
nl_delay0 : nativeint;
nl_delay1 : nativeint;
vtab_delay : nativeint;
vtab_delay0 : nativeint;
vtab_delay1 : nativeint;
all_delay : nativeint }
;
value ttyout : tty_out;
type tty_c =
{ char_size : nativeint;
char_size5 : nativeint;
char_size6 : nativeint;
char_size7 : nativeint;
char_size8 : nativeint;
enable_parity : nativeint;
odd_parity : nativeint;
enable_read : nativeint;
hup_on_close : nativeint;
no_modem_sync : nativeint;
two_stop_bits : nativeint;
ignore_flags : nativeint;
cts_output_flow_control : nativeint;
rts_input_flow_control : nativeint;
carrier_flow_ctl : nativeint }
;
value ttyc : tty_c;
type tty_l =
{ canonical : nativeint;
echo : nativeint;
echo_delete_lines : nativeint;
echo_nl : nativeint;
visual_delete : nativeint;
enable_signals : nativeint;
extended : nativeint;
no_flush_on_interrupt : nativeint;
ttou_signal : nativeint;
echo_ctl : nativeint;
flush_output : nativeint;
hardcopy_delete : nativeint;
reprint_unread_chars : nativeint;
visual_delete_line : nativeint;
alt_delete_word : nativeint;
no_kernel_status : nativeint;
case_map : nativeint }
;
value ttyl : tty_l;
value make_tty_info :
nativeint -> nativeint -> nativeint -> nativeint -> int -> int -> int -> int ->
tty_info;
value copy_tty_info : tty_info -> tty_info;
value tty_info_fd : fd -> tty_info;
value tty_info_in : in_channel -> tty_info;
value tty_info_out : out_channel -> tty_info;
value tty_info_fn : string -> tty_info;
value set_tty_info_now_fd : fd -> tty_info -> unit;
value set_tty_info_now_in : in_channel -> tty_info -> unit;
value set_tty_info_now_out : out_channel -> tty_info -> unit;
value set_tty_info_now_fn : string -> tty_info -> unit;
value set_tty_info_drain_fd : fd -> tty_info -> unit;
value set_tty_info_drain_in : in_channel -> tty_info -> unit;
value set_tty_info_drain_out : out_channel -> tty_info -> unit;
value set_tty_info_drain_fn : string -> tty_info -> unit;
value set_tty_info_flush_fd : fd -> tty_info -> unit;
value set_tty_info_flush_in : in_channel -> tty_info -> unit;
value set_tty_info_flush_out : out_channel -> tty_info -> unit;
value set_tty_info_flush_fn : string -> tty_info -> unit;
value send_tty_break_fd : ?duration: int -> fd -> unit;
value send_tty_break_in : ?duration: int -> in_channel -> unit;
value send_tty_break_out : ?duration: int -> out_channel -> unit;
value send_tty_break_fn : ?duration: int -> string -> unit;
value drain_tty_fd : fd -> unit;
value drain_tty_in : in_channel -> unit;
value drain_tty_out : out_channel -> unit;
value drain_tty_fn : string -> unit;
value flush_tty_input_fd : fd -> unit;
value flush_tty_input_in : in_channel -> unit;
value flush_tty_input_out : out_channel -> unit;
value flush_tty_input_fn : string -> unit;
value flush_tty_output_fd : fd -> unit;
value flush_tty_output_in : in_channel -> unit;
value flush_tty_output_out : out_channel -> unit;
value flush_tty_output_fn : string -> unit;
value flush_tty_both_fd : fd -> unit;
value flush_tty_both_in : in_channel -> unit;
value flush_tty_both_out : out_channel -> unit;
value flush_tty_both_fn : string -> unit;
value start_tty_output_fd : fd -> unit;
value start_tty_output_in : in_channel -> unit;
value start_tty_output_out : out_channel -> unit;
value start_tty_output_fn : string -> unit;
value stop_tty_output_fd : fd -> unit;
value stop_tty_output_in : in_channel -> unit;
value stop_tty_output_out : out_channel -> unit;
value stop_tty_output_fn : string -> unit;
value start_tty_input_fd : fd -> unit;
value start_tty_input_in : in_channel -> unit;
value start_tty_input_out : out_channel -> unit;
value start_tty_input_fn : string -> unit;
value stop_tty_input_fd : fd -> unit;
value stop_tty_input_in : in_channel -> unit;
value stop_tty_input_out : out_channel -> unit;
value stop_tty_input_fn : string -> unit;
value open_control_tty_in : ?flags: (list open_flag) -> string -> in_channel;
value open_control_tty_out : ?flags: (list open_flag) -> string -> out_channel;
value become_session_leader : unit -> int;
value tty_process_group_fd : fd -> int;
value tty_process_group_in : in_channel -> int;
value tty_process_group_out : out_channel -> int;
value tty_process_group_fn : string -> int;
value set_tty_process_group_fd : fd -> int -> int;
value set_tty_process_group_in : in_channel -> int -> int;
value set_tty_process_group_out : out_channel -> int -> int;
value set_tty_process_group_fn : string -> int -> int;
value control_tty_file_name : unit -> string;
value make_pty_generator : unit -> unit -> string;
value tty_name_of_pty_name : string -> string;
value pty_name_of_tty_name : string -> string;
value open_pty : unit -> (in_channel * string);
value fork_pty_session :
(unit -> unit) -> (Proc_3_4.proc * in_channel * out_channel * string);
end);
type protocol_family = socket_domain;
type host_info =
Unix.host_entry ==
{ h_name : string;
h_aliases : array string;
h_addrtype : socket_domain;
h_addr_list : array inet_addr }
;
type service_info =
Unix.service_entry ==
{ s_name : string; s_aliases : array string; s_port : int; s_proto : string }
;
type protocol_info =
Unix.protocol_entry == { p_name : string; p_aliases : array string; p_proto : int }
;
include
(Network_4 :
sig
type socket =
{ family : protocol_family; sock_in : in_channel; sock_out : out_channel }
;
value socket_connect : sockaddr -> socket_type -> unit;
value sockaddr_of_host_and_port : string -> int -> sockaddr;
value sockaddr_of_host_and_service : string -> string -> sockaddr;
value bind_listen_accept_loop_unix : string -> (socket -> sockaddr -> unit) -> unit;
value bind_listen_accept_loop_port : int -> (socket -> sockaddr -> unit) -> unit;
value bind_listen_accept_loop_service :
string -> (socket -> sockaddr -> unit) -> unit;
value create_socket : ?protocol: int -> protocol_family -> socket_type -> socket;
value create_socket_pair : socket_type -> (socket * socket);
value close_socket : socket -> unit;
value socket_address_of_unix_address : string -> sockaddr;
value socket_address_of_internet_address : inet_addr -> int -> sockaddr;
value inet_addr_any : inet_addr;
value inet_addr_loopback : inet_addr;
value inet_addr_broadcast : inet_addr;
value unix_address_of_socket_address : sockaddr -> string;
value internet_address_of_socket_address : sockaddr -> (inet_addr * int);
value connect_socket : socket -> sockaddr -> unit;
value bind_socket : socket -> sockaddr -> unit;
value listen_socket : socket -> int -> unit;
value accept_connection : socket -> (socket * sockaddr);
value socket_local_address : socket -> sockaddr;
value socket_remote_address : socket -> sockaddr;
value shutdown_socket : socket -> shutdown_command -> unit;
value receive_message :
?flags: (list msg_flag) -> socket -> int -> (string * sockaddr);
value receive_message_bang :
?start: int -> ?end_: int -> ?flags: (list msg_flag) -> socket -> string ->
(int * sockaddr);
value receive_message_partial :
?flags: (list msg_flag) -> socket -> int -> (string * sockaddr);
value receive_message_bang_partial :
?start: int -> ?end_: int -> ?flags: (list msg_flag) -> socket -> string ->
(int * sockaddr);
value send_message :
?start: int -> ?end_: int -> ?flags: (list msg_flag) -> ?sockaddr: sockaddr ->
socket -> string -> unit;
value send_message_partial :
?start: int -> ?end_: int -> ?flags: (list msg_flag) -> ?sockaddr: sockaddr ->
socket -> string -> int;
type protocol_level =
Network_4.protocol_level ==
[ SOL_SOCKET ]
;
value socket_option_bool : socket -> protocol_level -> socket_bool_option -> bool;
value set_socket_option_bool :
socket -> protocol_level -> socket_bool_option -> bool -> unit;
value socket_option_int : socket -> protocol_level -> socket_int_option -> int;
value set_socket_option_int :
socket -> protocol_level -> socket_int_option -> int -> unit;
value socket_option_optint :
socket -> protocol_level -> socket_optint_option -> option int;
value set_socket_option_optint :
socket -> protocol_level -> socket_optint_option -> option int -> unit;
value socket_option_float : socket -> protocol_level -> socket_float_option -> float;
value set_socket_option_float :
socket -> protocol_level -> socket_float_option -> float -> unit;
type herror =
[ HOST_NOT_FOUND
| TRY_AGAIN
| NO_RECOVERY
| NO_DATA
| NO_ADDRESS ]
;
exception Netdb_error of herror;
value host_info_name : string -> host_info;
value host_info_addr : sockaddr -> host_info;
type network_info =
{ n_name : string;
n_aliases : array string;
n_addrtype : protocol_family;
n_net : int32 }
;
value network_info_name : string -> network_info;
value network_info_addr : sockaddr -> network_info;
value service_info_name : ?protocol: string -> string -> service_info;
value service_info_port : ?protocol: string -> int -> service_info;
value protocol_info_name : string -> protocol_info;
value protocol_info_port : int -> protocol_info;
end);
include
(Strings_5_1 :
sig
value index : ?from: int -> string -> char -> option int;