00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _ABLE_CLIB_INTERNAL_DATABUFFER_H
00030 #define _ABLE_CLIB_INTERNAL_DATABUFFER_H 1
00031
00032
00033 #define DATABUFF_NOTINSERVICE (1)
00034
00035 #define DATABUF_INIT(parent,buff) { parent, buff, 0, 0, sizeof(x), 0 }
00036 #define DATABUF_NULL(parent) { parent, NULL, 0, 0, 0, DATABUFF_NOTINSERVICE }
00037
00038 #define DATABUFFER_EOF (-1)
00039 #define DATABUFFER_INPUT_ERROR (-2)
00040 #define DATABUFFER_ISERROR(x) ((x) < 0)
00041
00042 typedef struct data_buffer_io_s {
00043 ssize_t (*read)(void *param, void *to, size_t maxsz);
00044 ssize_t (*write)(void *param, void *to, size_t size);
00045 } data_buffer_io_t;
00046
00047
00048 typedef struct data_buffer_t_s {
00049 data_buffer_io_t io;
00050 void *param;
00051 char *buffer;
00052 int ptr;
00053 int size;
00054 int maxsize;
00055 int flags;
00056 } data_buffer_t;
00057
00058 extern int databuffer_readbyte(data_buffer_t *);
00059 extern ssize_t databuffer_read(data_buffer_t *, char *to, size_t wanted);
00060 extern ssize_t databuffer_write(data_buffer_t *, char *to, size_t got);
00061 extern int databuffer_flush(data_buffer_t *buf);
00062
00063 #endif