aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-03-29 07:27:13 -0400
committerB. Watson <urchlay@slackware.uk>2026-03-29 07:27:13 -0400
commita6649022d758c88f2ae1834730b11a8404b364b7 (patch)
tree8ffa8ba99cd2e829c31b8cd8c9a2d315e65366af
parent1e695442aa92b65cecc1b046d32d5ecc341064f8 (diff)
downloadfujinet-chat-a6649022d758c88f2ae1834730b11a8404b364b7.tar.gz
Save 185 bytes in cmd.c.
-rw-r--r--src/cmd.c49
1 files changed, 6 insertions, 43 deletions
diff --git a/src/cmd.c b/src/cmd.c
index b7d9e68..bdba91e 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -25,16 +25,14 @@ static void do_j1(void);
static void do_list(void);
static void do_me(void);
static void do_msg(void);
-static void do_names(void);
-static void do_part(void);
static void do_ping(void);
static void do_query(void);
static void do_quit(void);
static void do_quote(void);
-static void do_topic(void);
static void do_ver(void);
static void do_reset(void);
static void do_reboot(void);
+static void do_optional_chan(void);
typedef struct {
char *cmd;
@@ -60,14 +58,14 @@ cmd_t command_defs[] = {
{ "LIST", do_list, 1 },
{ "M", do_msg, 1 },
{ "ME", do_me, 1 },
- { "NAMES", do_names, 0 },
- { "PART", do_part, 0 },
+ { "NAMES", do_optional_chan, 0 },
+ { "PART", do_optional_chan, 0 },
{ "PING", do_ping, 0 },
{ "Q", do_query, 1 },
{ "QUERY", do_query, 1 },
{ "QUIT", do_quit, 0 },
{ "QUOTE", do_quote, 1 },
- { "TOPIC", do_topic, 0 },
+ { "TOPIC", do_optional_chan, 0 },
{ "REBOOT", do_reboot, 0 },
{ "RESET", do_reset, 0 },
{ "VER", do_ver, 0 },
@@ -210,7 +208,7 @@ static void do_reboot(void) {
asm("jmp $e477");
}
-static void do_part(void) {
+static void do_optional_chan(void) {
if(arg1[0] == '#') {
target = arg1;
arg2 = nextarg(arg1);
@@ -223,47 +221,12 @@ static void do_part(void) {
return;
}
- txbuf_set_str2("PART ", target);
+ txbuf_set_str3(cmd_def->cmd, " ", target);
if(arg2)
txbuf_append_str2(" :", arg2);
txbuf_send();
}
-static void do_topic(void) {
- if(arg1[0] == '#') {
- target = arg1;
- arg2 = nextarg(arg1);
- } else {
- arg2 = arg1;
- }
-
- if(!target) {
- err_no_scr_target();
- return;
- }
-
- txbuf_set_str2("TOPIC ", target);
- if(arg2)
- txbuf_append_str2(" :", arg2);
- txbuf_send();
-}
-
-static void do_names(void) {
- if(arg1[0] == '#') {
- target = arg1;
- arg2 = nextarg(arg1);
- } else {
- arg2 = arg1;
- }
-
- if(!target) {
- err_no_scr_target();
- return;
- }
- txbuf_set_str2("NAMES ", target);
- txbuf_send();
-}
-
static void do_server_info(void) {
txbuf_send_str("INFO");
}