From 90c6d716283fb9305426ea04341aa44b1f79f9ac Mon Sep 17 00:00:00 2001 From: mcpcpc Date: Wed, 16 Sep 2020 22:35:39 -0400 Subject: add '/h' command --- kirc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'kirc.c') diff --git a/kirc.c b/kirc.c index f9bafd4..3be051b 100644 --- a/kirc.c +++ b/kirc.c @@ -18,6 +18,18 @@ #define USAGE "kirc [-s hostname] [-p port] [-c channel] [-n nick] \ [-r real name] [-u username] [-k password] [-x init command] [-w columns] \ [-W columns] [-o path] [-h|v|V]" +#define HELP "\ + Send a message to the current channel.\n\ +/m Send a message to a specified channel or nick.\n\ +/M Send a message to NickServ.\n\ +/Q Send a message and close the host connection.\n\ +/x Send a message directly to the server.\n\ +/j Join a specified channel.\n\ +/p Leave (part) a specified channel.\n\ +/n List all users on the current channel.\n\ +/q Close the host connection.\n\ +/h Print a list of available kirc commands." + static int conn; /* connection socket */ static int verb = 0; /* verbose output (e.g. raw stream) */ @@ -174,7 +186,6 @@ handle_server_message(void) { ssize_t sl = read(conn, &message_buffer[message_end], MSG_MAX - message_end); if (sl == -1) { if (errno == EAGAIN || errno == EWOULDBLOCK) { - /* Let's wait for new input */ return 0; } else { perror("read"); @@ -217,10 +228,11 @@ handle_user_input(void) { char usrin[MSG_MAX], v1[MSG_MAX - CHA_MAX], v2[CHA_MAX], c1; if (fgets(usrin, MSG_MAX, stdin) != NULL && (sscanf(usrin, "/%[m] %s %[^\n]\n", &c1, v2, v1) > 2 || - sscanf(usrin, "/%[xMQqnjp] %[^\n]\n", &c1, v1) > 0)) { + sscanf(usrin, "/%[xMQhqnjp] %[^\n]\n", &c1, v1) > 0)) { switch (c1) { case 'x': raw("%s\r\n", v1); break; case 'q': raw("quit\r\n"); break; + case 'h': puts(HELP); break; case 'Q': raw("quit %s\r\n", v1); break; case 'j': raw("join %s\r\n", v1); break; case 'p': raw("part %s\r\n", v1); break; -- cgit v1.2.3