aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsserver/mds-message.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-04-27 04:11:12 +0200
committerMattias Andrée <maandree@operamail.com>2014-04-27 04:11:12 +0200
commiteb4b9376d963d7a34688c5ee92c5342f1bba7de4 (patch)
tree179848b15519d4ec1921ba6ce156cef7dfd658e9 /src/libmdsserver/mds-message.h
parentipc message class, does not do reading yet (diff)
downloadmds-eb4b9376d963d7a34688c5ee92c5342f1bba7de4.tar.gz
mds-eb4b9376d963d7a34688c5ee92c5342f1bba7de4.tar.bz2
mds-eb4b9376d963d7a34688c5ee92c5342f1bba7de4.tar.xz
finish mds-message
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/libmdsserver/mds-message.h')
-rw-r--r--src/libmdsserver/mds-message.h26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/libmdsserver/mds-message.h b/src/libmdsserver/mds-message.h
index f04a8c6..5cc1916 100644
--- a/src/libmdsserver/mds-message.h
+++ b/src/libmdsserver/mds-message.h
@@ -33,6 +33,7 @@ typedef struct mds_message
* name and its associated value, joined by ": ". A header
* cannot be `NULL` (unless its memory allocation failed,)
* but `headers` itself is NULL if there are not headers.
+ * The "Length" should be included in this list.
*/
char** headers;
@@ -52,20 +53,30 @@ typedef struct mds_message
size_t payload_size;
/**
- * Internal buffer for the reading function
+ * How much of the payload that has been stored (internal data)
+ */
+ size_t payload_ptr;
+
+ /**
+ * Internal buffer for the reading function (internal data)
*/
char* buffer;
/**
- * The size allocated to `buffer`
+ * The size allocated to `buffer` (internal data)
*/
size_t buffer_size;
/**
- * The number of bytes used in `buffer`
+ * The number of bytes used in `buffer` (internal data)
*/
size_t buffer_ptr;
+ /**
+ * 0 while reading headers, 1 while reading payload, and 2 when done (internal data)
+ */
+ int stage;
+
} mds_message_t;
@@ -92,8 +103,13 @@ void mds_message_destroy(mds_message_t* this);
*
* @param this Memory slot in which to store the new message
* @param fd The file descriptor
- * @return Non-zero on error, errno will be set accordingly.
- * Destroy the message on error.
+ * @return Non-zero on error or interruption, errno will be
+ * set accordingly. Destroy the message on error,
+ * be aware that the reading could have been
+ * interrupted by a signal rather than canonical error.
+ * If -2 is returned errno will not have been set,
+ * -2 indicates that the message is malformated,
+ * which is a state that cannot be recovered from.
*/
int mds_message_read(mds_message_t* this, int fd);