hirc

IRC client
Log | Files | Refs

commit f2566b59c9134617d935a4eafdb24fd5e49cd097
parent 326041e1039b80137549ba3942c0a4ec7cac0ca9
Author: hhvn <dev@hhvn.uk>
Date:   Sat, 20 Nov 2021 17:53:20 +0000

commands.c hirc.h: /format command (for future use)

Diffstat:
Mcommands.c | 21+++++++++++++++++++++
Mhirc.h | 1+
2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/commands.c b/commands.c @@ -46,6 +46,10 @@ struct Command commands[] = { " /set <variable> string....", "Set a configuration variable.", "Passing only the name prints content.", NULL}}, + {"format", command_format, { + "usage: /format <format> string...", + "Set a formatting variable.", + "This is equivalent to /set format.<format> string...", NULL}}, {"server", command_server, { "usage: /server <server> cmd....", "Run (non-raw) command with server as target.", NULL}}, @@ -301,6 +305,23 @@ command_set(struct Server *server, char *str) { } void +command_format(struct Server *server, char *str) { + char *newstr; + int len; + + if (!str) { + ui_error("/format requires argument", NULL); + return; + } + + len = strlen(str) + strlen("format.") + 1; + newstr = malloc(len); + snprintf(newstr, len, "format.%s", str); + command_set(server, newstr); + free(newstr); +} + +void command_server(struct Server *server, char *str) { struct Server *nserver; char *tserver, *cmd, *arg; diff --git a/hirc.h b/hirc.h @@ -147,6 +147,7 @@ void command_quote(struct Server *server, char *str); void command_connect(struct Server *server, char *str); void command_select(struct Server *server, char *str); void command_set(struct Server *server, char *str); +void command_format(struct Server *server, char *str); void command_server(struct Server *server, char *str); void command_names(struct Server *server, char *str); void command_topic(struct Server *server, char *str);