From 5bff40593f4331466e27ac3a4c947654884325be Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Wed, 29 Sep 2021 18:59:09 +0200 Subject: [PATCH] Merge pull request #41 from ailin-nemui/ports fix /server modify port argument order (cherry picked from commit 235c5b03281a3ae5c7849921cebbf7d46d39a4fc) --- src/fe-common/core/fe-server.c | 24 +++++++++++++++--------- src/fe-common/core/module-formats.c | 6 ++++-- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/fe-common/core/fe-server.c b/src/fe-common/core/fe-server.c index 78e7202c..ab76c363 100644 --- a/src/fe-common/core/fe-server.c +++ b/src/fe-common/core/fe-server.c @@ -124,17 +124,17 @@ static void cmd_server_add_modify(const char *data, gboolean add) port = old_port = -1; - if (*portstr != '\0') - port = add_port = atoi(portstr); + value = g_hash_table_lookup(optlist, "port"); + if (value != NULL && *value != '\0') + port = add_port = atoi(value); else if (g_hash_table_lookup(optlist, "tls") || g_hash_table_lookup(optlist, "ssl")) add_port = DEFAULT_SERVER_ADD_TLS_PORT; else add_port = DEFAULT_SERVER_ADD_PORT; - value = g_hash_table_lookup(optlist, "port"); - if (value != NULL && *value != '\0') - old_port = atoi(value); + if (*portstr != '\0') + old_port = atoi(portstr); chatnet = g_hash_table_lookup(optlist, "network"); @@ -307,12 +307,14 @@ static void cmd_server_remove(const char *data) SERVER_SETUP_REC *rec; char *addr, *port, *chatnet; void *free_arg; + int portnum; if (!cmd_get_params(data, &free_arg, 3, &addr, &port, &chatnet)) return; if (*addr == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); if (*port == '\0') { + portnum = DEFAULT_SERVER_ADD_PORT; if (*chatnet == '\0') rec = server_setup_find(addr, -1, NULL); else @@ -320,17 +322,21 @@ static void cmd_server_remove(const char *data) } else { + portnum = atoi(port); if (*chatnet == '\0') - rec = server_setup_find(addr, atoi(port), NULL); + rec = server_setup_find(addr, portnum, NULL); else - rec = server_setup_find(addr, atoi(port), chatnet); + rec = server_setup_find(addr, portnum, chatnet); } if (rec == NULL) - printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_SETUPSERVER_NOT_FOUND, addr, port); + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_SETUPSERVER_NOT_FOUND, addr, + portnum); else { + portnum = rec->port; server_setup_remove(rec); - printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_SETUPSERVER_REMOVED, addr, port); + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_SETUPSERVER_REMOVED, addr, + portnum); } cmd_params_free(free_arg); diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c index 0319ee11..e22b5e78 100644 --- a/src/fe-common/core/module-formats.c +++ b/src/fe-common/core/module-formats.c @@ -22,6 +22,7 @@ #include FORMAT_REC fecommon_core_formats[] = { + /* clang-format off */ { MODULE_NAME, "Core", 0 }, /* ---- */ @@ -87,8 +88,8 @@ FORMAT_REC fecommon_core_formats[] = { { "server_reconnect_removed", "Removed reconnection to server {server $0} port {hilight $1}", 3, { 0, 1, 0 } }, { "server_reconnect_not_found", "Reconnection tag {server $0} not found", 1, { 0 } }, { "setupserver_added", "Server {server $0} saved", 2, { 0, 1 } }, - { "setupserver_removed", "Server {server $0} removed", 2, { 0, 1 } }, - { "setupserver_not_found", "Server {server $0} not found", 2, { 0, 1 } }, + { "setupserver_removed", "Server {server $0} {hilight $1} removed", 2, { 0, 1 } }, + { "setupserver_not_found", "Server {server $0} {hilight $1} not found", 2, { 0, 1 } }, { "your_nick", "Your nickname is {nick $0}", 1, { 0 } }, /* ---- */ @@ -316,4 +317,5 @@ FORMAT_REC fecommon_core_formats[] = { { "tls_protocol_version", "Protocol: {hilight $0} ({hilight $1} bit, {hilight $2})", 3, { 0, 1, 0 } }, { NULL, NULL, 0 } + /* clang-format on */ };