diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2022-08-25 10:36:48 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2022-08-25 10:39:24 +0200 |
commit | e9b746b7471f62061255d625c7958dffb2eee5c3 (patch) | |
tree | a598509c8c42207a753985d1e7cc8c8d2279a88e | |
parent | log: add print_log macro (diff) | |
download | cimple-e9b746b7471f62061255d625c7958dffb2eee5c3.tar.gz cimple-e9b746b7471f62061255d625c7958dffb2eee5c3.zip |
msg: add msg_dump_unknown
-rw-r--r-- | src/msg.c | 8 | ||||
-rw-r--r-- | src/msg.h | 2 | ||||
-rw-r--r-- | src/server.c | 4 |
3 files changed, 11 insertions, 3 deletions
@@ -190,3 +190,11 @@ void msg_free(const struct msg *msg) free(msg->argv[i]); free(msg->argv); } + +int msg_dump_unknown(const struct msg *msg) +{ + print_log("Received an unknown message:\n"); + for (int i = 0; i < msg->argc; ++i) + print_log("\t%s\n", msg->argv[i]); + return -1; +} @@ -18,4 +18,6 @@ int msg_recv_and_send_result(int fd, msg_handler, void *arg); void msg_free(const struct msg *); +int msg_dump_unknown(const struct msg *); + #endif diff --git a/src/server.c b/src/server.c index 035adbe..9604bd6 100644 --- a/src/server.c +++ b/src/server.c @@ -21,9 +21,7 @@ void server_destroy(const struct server *server) static int msg_handle(const struct msg *msg, void *) { - for (int i = 0; i < msg->argc; ++i) - printf("msg[%d]: %s\n", i, msg->argv[i]); - return 0; + return msg_dump_unknown(msg); } static int server_handle(int fd, void *) |