diff options
author | Jorge Arellano Cid <jcid@dillo.org> | 2009-11-01 16:31:59 -0300 |
---|---|---|
committer | Jorge Arellano Cid <jcid@dillo.org> | 2009-11-01 16:31:59 -0300 |
commit | e769c45c8c5559c5ad9cea2e3038f6a5da968b01 (patch) | |
tree | d1a9aa73f8104c5f023fd164232b3f9996800785 /dpip/dpip.h | |
parent | f22fea661d0755029173a21fa72f7c131ee884e7 (diff) |
Introduced the new tokenizing dsh API to DPIP
The new DPIP sock handler API returns tokens, taking care to assemble token
splits, wait if necessary, or indicate EAGAIN in case of nonblocking mode.
This is a mayor simplification because the details are transparent to the
API user (i.e. dpi developer).
Diffstat (limited to 'dpip/dpip.h')
-rw-r--r-- | dpip/dpip.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/dpip/dpip.h b/dpip/dpip.h index 372b588a..ddc66ed4 100644 --- a/dpip/dpip.h +++ b/dpip/dpip.h @@ -9,6 +9,40 @@ extern "C" { #endif /* __cplusplus */ +#include "../dlib/dlib.h" + +/* + * Communication mode flags + */ +#define DPIP_TAG 1 /* Dpip tags in the socket */ +#define DPIP_LAST_TAG 2 /* Dpip mode-switching tag */ +#define DPIP_RAW 4 /* Raw data in the socket */ +#define DPIP_NONBLOCK 8 /* Nonblocking IO */ + +typedef enum { + DPIP_EAGAIN, + DPIP_ERROR, + DPIP_EOF +} DpipDshStatus; + +/* + * Dpip socket handler type. + */ +typedef struct _DpipSocketHandler Dsh; +struct _DpipSocketHandler { + int fd_in; + int fd_out; + /* FILE *in; --Unused. The stream functions block when reading. */ + FILE *out; + + Dstr *dbuf; /* write buffer */ + Dstr *rd_dbuf; /* read buffer */ + int flush_sz; /* max size before flush */ + + int mode; /* mode flags: DPIP_TAG | DPIP_LAST_TAG | DPIP_RAW */ + int status; /* status code: DPIP_EAGAIN | DPIP_ERROR | DPIP_EOF */ +}; + /* * Printf like function for building dpip commands. @@ -28,6 +62,16 @@ char *a_Dpip_get_attr_l(char *tag, size_t tagsize, const char *attrname); int a_Dpip_check_auth(const char *auth); +/* + * Dpip socket API + */ +Dsh *a_Dpip_dsh_new(int fd_in, int fd_out, int flush_sz); +int a_Dpip_dsh_write(Dsh *dsh, int flush, const char *Data, int DataSize); +int a_Dpip_dsh_write_str(Dsh *dsh, int flush, const char *str); +char *a_Dpip_dsh_read_token(Dsh *dsh); +void a_Dpip_dsh_close(Dsh *dsh); +void a_Dpip_dsh_free(Dsh *dsh); + #ifdef __cplusplus } |