Initial snarf.
[shack.git] / libmojave / util / lm_channel.mli
blob063dd753449fff11e75c04d7f1f7c3f08ed6461d
1 (*
2 * Generic buffered IO channel.
4 * ----------------------------------------------------------------
6 * @begin[license]
7 * Copyright (C) 2004 Mojave Group, Caltech
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation,
12 * version 2.1 of the License.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * Additional permission is given to link this library with the
24 * OpenSSL project's "OpenSSL" library, and with the OCaml runtime,
25 * and you may distribute the linked executables. See the file
26 * LICENSE.libmojave for more details.
28 * Author: Jason Hickey
29 * @email{jyh@cs.caltech.edu}
30 * @end[license]
32 open Lm_location
34 type channel
35 type t = channel
38 * The channel may be a file, pipe, or socket.
40 type kind =
41 FileChannel
42 | PipeChannel
43 | SocketChannel
45 type mode =
46 InChannel
47 | OutChannel
48 | InOutChannel
50 (* Creation *)
51 val create : string -> kind -> mode -> bool -> Unix.file_descr option -> t
52 val name : t -> string
53 val descr : t -> Unix.file_descr
54 val close : t -> unit
55 val info : t -> int * kind * mode * bool
57 val set_id : t -> int -> unit
59 val of_string : string -> t
60 val of_substring : string -> int -> int -> t
61 val of_loc_string : string -> int -> int -> string -> t
62 val of_fun : (string -> int -> int -> int) -> (string -> int -> int -> int) -> t
64 (* Output to strings *)
65 val create_string : unit -> t
66 val create_loc_string : string -> int -> int -> t
67 val to_string : t -> string
69 (* Set the file and line number *)
70 val set_line : t -> string -> int -> unit
73 * Set text vs binary mode.
74 * No effect unless on Win32.
76 val set_binary_mode : t -> bool -> unit
78 (* The write function is arbitrary and can be replaced *)
79 val set_io_functions : t ->
80 (string -> int -> int -> int) -> (* Reader *)
81 (string -> int -> int -> int) -> (* Writer *)
82 unit
84 (* Positioning *)
85 val tell : t -> int
86 val seek : t -> int -> Unix.seek_command -> int
87 val loc : t -> loc
89 (* Check if there is already input in the buffer *)
90 val poll : t -> bool
92 (* Buffered IO *)
93 val input_char : t -> char
94 val input_byte : t -> int
95 val input_buffer : t -> string -> int -> int -> unit
96 val input_line : t -> string
97 val input_entire_line : t -> string
98 val read : t -> string -> int -> int -> int
100 (* Flush data to the channel *)
101 val flush : t -> unit
103 (* Buffered IO *)
104 val output_char : t -> char -> unit
105 val output_byte : t -> int -> unit
106 val output_buffer : t -> string -> int -> int -> unit
107 val output_string : t -> string -> unit
108 val write : t -> string -> int -> int -> int
110 (* Select *)
111 val select : t list -> t list -> t list -> float -> t list * t list * t list
113 (* Lex-mode operations *)
114 module LexerInput :
116 type t = channel
118 val lex_start : t -> int
119 val lex_restart : t -> int -> unit
120 val lex_stop : t -> int -> unit
121 val lex_string : t -> int -> string
122 val lex_substring : t -> int -> int -> string
123 val lex_next : t -> int
124 val lex_pos : t -> int
125 val lex_buffer : t -> Buffer.t -> unit
126 val lex_loc : t -> int -> loc
127 val bof : int
128 val eof : int
132 * @docoff
134 * -*-
135 * Local Variables:
136 * Caml-master: "compile"
137 * End:
138 * -*-