]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/gdome_xslt/ocaml/gdome_xslt/ocaml-io.h
ocaml 3.09 transition
[helm.git] / helm / DEVEL / gdome_xslt / ocaml / gdome_xslt / ocaml-io.h
1 /**********************************************************************/
2 /*                                                                    */
3 /*                           Objective Caml                           */
4 /*                                                                    */
5 /*            Xavier Leroy, projet Cristal, INRIA Rocquencourt        */
6 /*                                                                    */
7 /*  Copyright 1996 Institut National de Recherche en Informatique et  */
8 /*  en Automatique.  All rights reserved.  This file is distributed   */
9 /*  under the terms of the GNU Library General Public License, with   */
10 /*  the special exception on linking described in file                */
11 /*  ../../LICENSE-INRIA.                                              */
12 /*                                                                    */
13 /**********************************************************************/
14
15 /* Buffered input/output */
16
17 #ifndef __IO_H__
18 #define __IO_H__
19
20 #ifndef IO_BUFFER_SIZE
21 #define IO_BUFFER_SIZE 4096
22 #endif
23
24 typedef long file_offset;
25
26 struct channel {
27   int fd;                       /* Unix file descriptor */
28   file_offset offset;           /* Absolute position of fd in the file */
29   char * end;                   /* Physical end of the buffer */
30   char * curr;                  /* Current position in the buffer */
31   char * max;                   /* Logical end of the buffer (for input) */
32   void * mutex;                 /* Placeholder for mutex (for systhreads) */
33   struct channel * next;        /* Linear chaining of channels (flush_all) */
34   int revealed;                 /* For Cash only */
35   int old_revealed;             /* For Cash only */
36   int refcount;                 /* For flush_all and for Cash */
37   char buff[IO_BUFFER_SIZE];    /* The buffer itself */
38 };
39
40 /* For an output channel:
41      [offset] is the absolute position of the beginning of the buffer [buff].
42    For an input channel:
43      [offset] is the absolute position of the logical end of the buffer, [max].
44 */
45
46 /* Functions and macros that can be called from C.  Take arguments of
47    type struct channel *.  No locking is performed. */
48
49 /* Extract a struct channel * from the heap object representing it */
50
51 #define Channel(v) (*((struct channel **) (Data_custom_val(v))))
52
53 #endif /* __IO_H__ */
54