From 2246d92f10155cf988ad1dcdfe407b5c5488182a Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 25 Aug 2015 20:19:00 +0200 Subject: m + add header composing macros MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libmdsclient/comm.h | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'src/libmdsclient/comm.h') 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 #include #include +#include @@ -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 -- cgit v1.2.3-70-g09d2