00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef LIO_H
00023
00024
00025
00026
00027
00028
00029
00030 #include "luti.h"
00031 #include "lll.h"
00032
00033
00034
00035
00036
00037
00038
00039 typedef struct Tm {
00040 lll millis;
00041 } Tm;
00042
00046 extern int timeUpd ( Tm * );
00053 extern char *timeGtf ( char *buf, Tm * );
00058 extern char *timeGtfm ( char *buf, Tm * );
00062 extern void timeSleep ( Tm * );
00063
00064
00065
00066
00067
00068
00076 #define LIO_WANT 0xfff00000
00077 #define LIO_FD 0x0000ffff
00078 #define LIO_STAT 0x000f0000
00079
00080
00081 #define LIO_IN 0x00010000
00082 #define LIO_OUT 0x00020000
00083 #define LIO_INOUT 0x00030000
00084 #define LIO_ISOPEN( file ) (LIO_INOUT & (file))
00085
00086
00087 #define LIO_RD 0x00100000
00088 #define LIO_WR 0x00200000
00089 #define LIO_RDWR 0x00300000
00090 #define LIO_SYNC 0x00400000
00091 #define LIO_NBLK 0x00800000
00092
00093
00094 #define LIO_CREAT 0x01000000
00095 #define LIO_TRY 0x01000000
00096 #define LIO_TRUNC 0x02000000
00097 #define LIO_SEEK 0x04000000
00098 #define LIO_SOCK 0x08000000
00099
00100
00101 #define LIO_TLOCK 0x10000000
00102 #define LIO_WLOCK 0x20000000
00103 #define LIO_FLOCK 0x30000000
00104
00105
00110 extern int lio_open ( const char *name, int flags );
00111 extern int lio_close ( int *file, int flags );
00112 extern int lio_size ( int file );
00113 extern unsigned lio_time ( int file );
00114
00115 extern int lio_in;
00116 extern int lio_out;
00117 extern int lio_err;
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 extern int lio_read ( int *file, void *buf, unsigned count );
00135 extern int lio_write ( int *file, const void *buf, unsigned count );
00136 extern int lio_pread ( int *file, void *buf, unsigned count, int offset );
00137 extern int lio_pwrite ( int *file, const void *buf, unsigned count, int offset );
00138 extern int lio_seek ( int *file, int offset );
00139 extern int lio_trunc ( int *file, int offset );
00150 extern int lio_mmap ( int *file, void **map, int length );
00151
00152
00161 extern int lio_slurp ( char **buf, int sz, const char *name, int opt );
00162
00163
00164
00165
00166
00167
00168
00181 typedef int lio_sfunc ( struct Ios *s, int op );
00182
00183 enum {
00184 LIO_BUFSIZ = 8192
00185 };
00186
00187 typedef struct Buf {
00188
00189 short fill;
00190 short done;
00191 unsigned char c[LIO_BUFSIZ];
00192 } Buf;
00193
00194 #define LIO_BAVAIL( b ) ((b)->fill - (b)->done)
00195 #define LIO_BINIT( b ) do { \
00196 (b)->fill = 0; (b)->done = 0; \
00197 } while (0)
00198 #define LIO_BINITIALIZER { 0,0,"" }
00199
00200 typedef struct Ios {
00201 lio_sfunc *func;
00202 const char *name;
00203 int file;
00204 int pos;
00205 Buf b;
00206 } Ios;
00207
00208 #define LIO_SISOPEN( s ) LIO_ISOPEN( (s)->file )
00209 #define LIO_SAVAIL( s ) LIO_BAVAIL( &(s)->b )
00210 #define LIO_SINIT( s, fun, nam, fil ) do { \
00211 (s)->func = fun; (s)->name = nam; (s)->file = fil; \
00212 (s)->pos = 0; \
00213 LIO_BINIT( &(s)->b ); \
00214 } while (0)
00215 #define LIO_STDINIT( s, nam, fil ) LIO_SINIT( s, lio_stdio, nam, fil )
00216 #define LIO_SINITIALIZER( fun, nam, fil ) { fun, nam, fil, 0, LIO_BINITIALIZER }
00217 #define LIO_STDINITIALIZER( nam, fil ) LIO_SINITIALIZER( lio_stdio, nam, fil )
00218
00219
00222 enum {
00223 LIO_SSIZE,
00224 LIO_SOPEN,
00225 LIO_SCLOSE,
00226 LIO_SPURGE,
00227 LIO_SFILL,
00228 LIO_SFLUSH,
00229 LIO_SPUSH
00230 };
00231
00236 extern int ioStream ( Ios *s, int op );
00237
00243 extern int ioStdio ( Ios *s, int op );
00244
00245 #define LIO_OPEN( s ) (s)->func( (s), LIO_SOPEN )
00246 #define LIO_CLOSE( s ) (s)->func( (s), LIO_SCLOSE )
00247 #define LIO_FILL( s ) (s)->func( (s), LIO_SFILL )
00248 #define LIO_FLUSH( s ) (s)->func( (s), LIO_SFLUSH )
00249
00250
00251
00252
00253
00254
00255
00256
00257 extern CLockFunc *lio_lock;
00258 #define LIO_LOCK() (NULL != lio_lock && lio_lock(OPENISIS_LOCK))
00259 #define LIO_RELE() (NULL != lio_lock && lio_lock(OPENISIS_RELE))
00260 #define LIO_WAIT( c ) (NULL != lio_lock && lio_lock(OPENISIS_WAIT \
00261 | (OPENISIS_COND & (c))))
00262 #define LIO_WAKE( c ) (NULL != lio_lock && lio_lock(OPENISIS_WAKE \
00263 | (OPENISIS_COND & (c))))
00264
00265 #define LIO_H
00266 #endif