12 #ifndef _CEPTR_STREAM_H
13 #define _CEPTR_STREAM_H
19 enum StreamTypes {UnixStream,SocketStream};
20 enum {StreamHasData=0x0001,StreamCloseOnFree=0x0002,StreamReader=0x0004,StreamWaiting=0x0008,StreamAlive=0x8000,StreamCloseAfterOneWrite=0x0010,StreamDying=0x0100,StreamLoadByLine=0x0200};
24 typedef void (*hasDataCallbackFn)(
Stream *);
26 enum ScanStates {StreamScanInitial,StreamScanSuccess,StreamScanPartial,StreamScanComplete};
35 pthread_mutex_t mutex;
44 hasDataCallbackFn callback;
58 typedef void (*lisenterConnectionCallbackFn)(
Stream *,
void *);
64 lisenterConnectionCallbackFn callback;
73 #define DEFAULT_READER_BUFFER_SIZE 1000
74 #define _st_new_unix_stream(s,r) __st_new_unix_stream(s,r?DEFAULT_READER_BUFFER_SIZE:0)
76 Stream *__st_alloc_stream();
78 #define __st_init_scan(s) s->scan_state = StreamScanInitial
79 #define __st_buf_full(s) (s->bytes_used == s->buf_size)
88 #define _st_is_alive(st) ((st->flags & StreamAlive) || (st->flags & StreamReader && (st->scan_state != StreamScanComplete)))
91 #define _st_data(st) (&(st)->buf[st->unit_start])
92 #define _st_data_size(st) (st)->unit_size
Stream * __st_new_unix_stream(FILE *stream, size_t reader_buffer_size)
SocketListener * _st_new_socket_listener(int port, lisenterConnectionCallbackFn fn, void *callback_arg, char *delim)
void _st_kill(Stream *st)
void _st_data_consumed(Stream *st)
void __st_scan(Stream *st)
int _st_writeln(Stream *stream, char *buf)
void _st_start_read(Stream *st)
void _st_close_listener(SocketListener *l)
int _st_write(Stream *stream, char *buf, size_t len)
size_t __st_unix_stream_load(Stream *st)