From 695a6a7d9bf8ffbe9378c6aff7c69aa259f2c8c7 Mon Sep 17 00:00:00 2001 From: Sebastian Thorarensen Date: Sat, 5 Jul 2014 03:58:16 +0200 Subject: [PATCH] Allow `server.split_message' being NULL Now a module can set `server.split_message = NULL' to disable message splitting, instead of having to implement the function. --- src/core/chat-commands.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/core/chat-commands.c b/src/core/chat-commands.c index e8c7e90f..235a9fc4 100644 --- a/src/core/chat-commands.c +++ b/src/core/chat-commands.c @@ -378,10 +378,22 @@ static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item) } } if (target != NULL) { - char **splitmsgs = server->split_message(server, target, msg); + char **splitmsgs; + char **tmp = NULL; + char *singlemsg[] = { msg, NULL }; char *m; int n = 0; + /* + * If split_message is NULL, the server doesn't need to split + * long messages. + */ + if (server->split_message != NULL) + splitmsgs = tmp = server->split_message(server, target, + msg); + else + splitmsgs = singlemsg; + while ((m = splitmsgs[n++])) { signal_emit("server sendmsg", 4, server, target, m, GINT_TO_POINTER(target_type)); @@ -390,7 +402,7 @@ static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item) "message own_private", 4, server, m, target, origtarget); } - g_strfreev(splitmsgs); + g_strfreev(tmp); } else { signal_emit("message own_private", 4, server, msg, target, origtarget);