From 87d0b33b3b1dde3c92c00219987813beed79470e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Tue, 9 Jul 2019 19:09:17 +0300 Subject: [PATCH] Allow for status telling other end is going offline --- ethermess.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ethermess.c b/ethermess.c index 817a22a..f59e407 100644 --- a/ethermess.c +++ b/ethermess.c @@ -33,6 +33,7 @@ #define EMS_AVAILABLE 0 #define EMS_UNAVAILABLE 1 +#define EMS_OFFLINE 2 bool running = true; @@ -283,7 +284,7 @@ void handle_status(const unsigned char source_mac[6], const unsigned char *data, unsigned char status = data[0]; - if (status != EMS_AVAILABLE && status != EMS_UNAVAILABLE) { + if (status != EMS_AVAILABLE && status != EMS_UNAVAILABLE && status != EMS_OFFLINE) { // Unknown status, throw away fprintf(stderr, "Unknown status %u\n", status); // debg return; @@ -315,11 +316,15 @@ void handle_status(const unsigned char source_mac[6], const unsigned char *data, err(1, "printf"); } + errno = 0; if (status == EMS_UNAVAILABLE) { - errno = 0; if (printf("(unavailable) ") == -1) { err(1, "printf"); } + } else if (status == EMS_OFFLINE) { + if (printf("(offline) ") == -1) { + err(1, "printf"); + } } for (size_t i = 0; i < (size_t)nick_length; i++) {