aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmdsclient
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-08-25 20:19:00 +0200
committerMattias Andrée <maandree@operamail.com>2015-08-25 20:19:00 +0200
commit2246d92f10155cf988ad1dcdfe407b5c5488182a (patch)
tree95dfd9d4f794ac3f6a58531424982aeb999b8129 /src/libmdsclient
parentm (diff)
downloadmds-2246d92f10155cf988ad1dcdfe407b5c5488182a.tar.gz
mds-2246d92f10155cf988ad1dcdfe407b5c5488182a.tar.bz2
mds-2246d92f10155cf988ad1dcdfe407b5c5488182a.tar.xz
m + add header composing macros
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/libmdsclient')
-rw-r--r--src/libmdsclient/comm.h37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/libmdsclient/comm.h b/src/libmdsclient/comm.h
index 4a47b2a..46f9ed1 100644
--- a/src/libmdsclient/comm.h
+++ b/src/libmdsclient/comm.h
@@ -24,6 +24,7 @@
#include <pthread.h>
#include <time.h>
#include <errno.h>
+#include <inttypes.h>
@@ -108,7 +109,7 @@ int libmds_connection_send_unlocked(libmds_connection_t* restrict this, const ch
* Lock the connection descriptor for being modified,
* or used to send data to the display, by another thread
*
- * @param this:libmds_connection_t* The connection descriptor
+ * @param this:libmds_connection_t* The connection descriptor, must not be `NULL`
* @return :int Zero on success, -1 on error, `errno`
* will have been set accordingly on error
* @throws See pthread_mutex_lock(3)
@@ -120,7 +121,7 @@ int libmds_connection_send_unlocked(libmds_connection_t* restrict this, const ch
* Lock the connection descriptor for being modified,
* or used to send data to the display, by another thread
*
- * @param this:libmds_connection_t* The connection descriptor
+ * @param this:libmds_connection_t* The connection descriptor, must not be `NULL`
* @return :int Zero on success, -1 on error, `errno`
* will have been set accordingly on error
* @throws See pthread_mutex_trylock(3)
@@ -132,8 +133,9 @@ int libmds_connection_send_unlocked(libmds_connection_t* restrict this, const ch
* Lock the connection descriptor for being modified,
* or used to send data to the display, by another thread
*
- * @param this:libmds_connection_t* The connection descriptor
- * @param deadline:const struct timespec *restrict The CLOCK_REALTIME time when the function shall fail
+ * @param this:libmds_connection_t* The connection descriptor, must not be `NULL`
+ * @param deadline:const struct timespec *restrict The absolute `CLOCK_REALTIME` time when the
+ * function shall fail, must not be `NULL`
* @return :int Zero on success, -1 on error, `errno`
* will have been set accordingly on error
* @throws See pthread_mutex_timedlock(3)
@@ -145,7 +147,7 @@ int libmds_connection_send_unlocked(libmds_connection_t* restrict this, const ch
* Undo the action of `libmds_connection_lock`, `libmds_connection_trylock`
* or `libmds_connection_timedlock`
*
- * @param this:libmds_connection_t* The connection descriptor
+ * @param this:libmds_connection_t* The connection descriptor, must not be `NULL`
* @return :int Zero on success, -1 on error, `errno`
* will have been set accordingly on error
* @throws See pthread_mutex_unlock(3)
@@ -153,6 +155,31 @@ int libmds_connection_send_unlocked(libmds_connection_t* restrict this, const ch
#define libmds_connection_unlock(this) \
(errno = pthread_mutex_unlock(&((this)->mutex)), (errno ? 0 : -1))
+/**
+ * Arguments for `libmds_compose` to compose the `Client ID`-header
+ *
+ * @param this: libmds_connection_t* The connection descriptor, must not be `NULL`
+ */
+#define LIBMDS_HEADER_CLIENT_ID(this) \
+ "?Client ID: %s", (this)->client_id != NULL, (this)->client_id
+
+/**
+ * Arguments for `libmds_compose` to compose the `Message ID`-header
+ *
+ * @param this: libmds_connection_t* The connection descriptor, must not be `NULL`
+ */
+#define LIBMDS_HEADER_MESSAGE_ID(this) \
+ "Message ID: %"PRIu32, (this)->message_id
+
+/**
+ * Arguments for `libmds_compose` to compose the standard headers:
+ * `Client ID` and `Message ID`
+ *
+ * @param this: libmds_connection_t* The connection descriptor, must not be `NULL`
+ */
+#define LIBMDS_HEADERS_STANDARD(this) \
+ LIBMDS_HEADER_CLIENT_ID(this), LIBMDS_HEADER_MESSAGE_ID(this)
+
#endif