aboutsummaryrefslogtreecommitdiff
path: root/dpip/dpip.h
diff options
context:
space:
mode:
Diffstat (limited to 'dpip/dpip.h')
-rw-r--r--dpip/dpip.h44
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
}