/** * Echo the received message payload * * @return Zero on success -1 on error or interruption, * errno will be set accordingly */ int echo_message(void) { char *old_buffer = NULL; const char *recv_client_id = NULL; const char *recv_message_id = NULL; const char *recv_length = NULL; size_t i, n; int saved_errno; /* Fetch headers. */ #define __get_header(storage, header, skip)\ (startswith(received.headers[i], header))\ storage = received.headers[i] + skip * strlen(header) for (i = 0; i < received.header_count; i++) { if __get_header(recv_client_id, "Client ID: ", 1); else if __get_header(recv_message_id, "Message ID: ", 1); else if __get_header(recv_length, "Length: ", 0);
/** * Handle the received message * * @return Zero on success, -1 on error */ int handle_message(void) { /* Fetch message headers. */ const char* recv_client_id = "0:0"; const char* recv_message_id = NULL; const char* recv_graphical = "neither"; const char* recv_exclusive = "neither"; const char* recv_command = NULL; size_t i; #define __get_header(storage, header) \ (startswith(received.headers[i], header)) \ storage = received.headers[i] + strlen(header) for (i = 0; i < received.header_count; i++) { if __get_header(recv_client_id, "Client ID: "); else if __get_header(recv_message_id, "Message ID: "); else if __get_header(recv_graphical, "Graphical: ");
/** * Handle the received message * * @return Zero on success, -1 on error */ int handle_message(void) { const char *recv_command = NULL; const char *recv_client_id = "0:0"; const char *recv_message_id = NULL; const char *recv_include_values = NULL; const char *recv_name = NULL; const char *recv_remove = NULL; const char *recv_bytes = NULL; const char *recv_red = NULL; const char *recv_green = NULL; const char *recv_blue = NULL; size_t i; #define __get_header(storage, header)\ (startswith(received.headers[i], header))\ storage = received.headers[i] + strlen(header) for (i = 0; i < received.header_count; i++) { if __get_header(recv_command, "Command: "); else if __get_header(recv_client_id, "Client ID: "); else if __get_header(recv_message_id, "Message ID: ");