From a2e9ee2101d2f45dfd5ac180d669134cbb96a52a Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 21 Oct 2017 18:21:04 +0200 Subject: Add flags to functions using send MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libsbus.c | 12 ++++++------ libsbus.h | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libsbus.c b/libsbus.c index 146f58c..9b8b9ad 100644 --- a/libsbus.c +++ b/libsbus.c @@ -5,7 +5,7 @@ #include int -libsbus_subscribe(int fd, const char *pattern, char *buf) +libsbus_subscribe(int fd, const char *pattern, int flags, char *buf) { size_t n = strlen(pattern); if (n + 4 > LIBSBUS_BUFFER_SIZE) { @@ -14,11 +14,11 @@ libsbus_subscribe(int fd, const char *pattern, char *buf) } buf[0] = 'S', buf[1] = 'U', buf[2] = 'B', buf[3] = ' '; memcpy(&buf[4], pattern, n); - return -(send(fd, buf, n + 4, 0) < 0); + return -(send(fd, buf, n + 4, flags) < 0); } int -libsbus_unsubscribe(int fd, const char *pattern, char *buf) +libsbus_unsubscribe(int fd, const char *pattern, int flags, char *buf) { size_t n = strlen(pattern); if (n + 6 > LIBSBUS_BUFFER_SIZE) { @@ -27,11 +27,11 @@ libsbus_unsubscribe(int fd, const char *pattern, char *buf) } buf[0] = 'U', buf[1] = 'N', buf[2] = 'S', buf[3] = 'U', buf[4] = 'B', buf[5] = ' '; memcpy(&buf[6], pattern, n); - return -(send(fd, buf, n + 6, 0) < 0); + return -(send(fd, buf, n + 6, flags) < 0); } int -libsbus_publish(int fd, const char *key, const char *msg, size_t n, char *buf) +libsbus_publish(int fd, const char *key, const char *msg, size_t n, int flags, char *buf) { size_t len = strlen(key) + 1; if (len + n > LIBSBUS_BUFFER_SIZE - 4) { @@ -41,7 +41,7 @@ libsbus_publish(int fd, const char *key, const char *msg, size_t n, char *buf) buf[0] = 'M', buf[1] = 'S', buf[2] = 'G', buf[3] = ' '; memcpy(&buf[4], key, len); memcpy(&buf[4 + len], msg, n); - return -(send(fd, buf, len + n + 4, 0) < 0); + return -(send(fd, buf, len + n + 4, flags) < 0); } ssize_t diff --git a/libsbus.h b/libsbus.h index 4f2dc4a..8d8cad3 100644 --- a/libsbus.h +++ b/libsbus.h @@ -29,9 +29,9 @@ union libsbus_packet { struct libsbus_message message; }; -int libsbus_subscribe(int fd, const char *pattern, char *buf); -int libsbus_unsubscribe(int fd, const char *pattern, char *buf); -int libsbus_publish(int fd, const char *key, const char *msg, size_t n, char *buf); +int libsbus_subscribe(int fd, const char *pattern, int flags, char *buf); +int libsbus_unsubscribe(int fd, const char *pattern, int flags, char *buf); +int libsbus_publish(int fd, const char *key, const char *msg, size_t n, int flags, char *buf); ssize_t libsbuf_prepare_message(const char *key, char *buf, size_t *remaining); int libsbus_receive(int fd, int flags, char *buf, union libsbus_packet *packet); -- cgit v1.2.3-70-g09d2