aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-08-25 10:36:48 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2022-08-25 10:39:24 +0200
commite9b746b7471f62061255d625c7958dffb2eee5c3 (patch)
treea598509c8c42207a753985d1e7cc8c8d2279a88e
parentlog: add print_log macro (diff)
downloadcimple-e9b746b7471f62061255d625c7958dffb2eee5c3.tar.gz
cimple-e9b746b7471f62061255d625c7958dffb2eee5c3.zip
msg: add msg_dump_unknown
-rw-r--r--src/msg.c8
-rw-r--r--src/msg.h2
-rw-r--r--src/server.c4
3 files changed, 11 insertions, 3 deletions
diff --git a/src/msg.c b/src/msg.c
index ba6c474..b87052c 100644
--- a/src/msg.c
+++ b/src/msg.c
@@ -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;
+}
diff --git a/src/msg.h b/src/msg.h
index 028aaa0..fca230e 100644
--- a/src/msg.h
+++ b/src/msg.h
@@ -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 *)