aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormcpcpc <michaelczigler@icloud.com>2020-09-16 22:35:39 -0400
committermcpcpc <michaelczigler@icloud.com>2020-09-16 22:35:39 -0400
commit90c6d716283fb9305426ea04341aa44b1f79f9ac (patch)
tree37d23cd10bc3f00abb36deca0e5d41f92f17f98b
parentUpdate README.md (diff)
downloadkirc-90c6d716283fb9305426ea04341aa44b1f79f9ac.tar.gz
kirc-90c6d716283fb9305426ea04341aa44b1f79f9ac.tar.bz2
kirc-90c6d716283fb9305426ea04341aa44b1f79f9ac.tar.xz
kirc-90c6d716283fb9305426ea04341aa44b1f79f9ac.tar.zst
kirc-90c6d716283fb9305426ea04341aa44b1f79f9ac.zip
add '/h' command
-rw-r--r--README.md1
-rw-r--r--kirc.c16
2 files changed, 15 insertions, 2 deletions
diff --git a/README.md b/README.md
index 5666d96..3e9f185 100644
--- a/README.md
+++ b/README.md
@@ -51,6 +51,7 @@ usage: kirc [-s hostname] [-p port] [-c channel] [-n nick] [-r real name] [-u us
/p <channel> Leave (part) a specified channel.
/n List all users on the current channel.
/q Close the host connection.
+/h Print a list of available kirc commands.
```
* Color scheme definition via [ANSI 8-bit colors](https://en.wikipedia.org/wiki/ANSI_escape_code). Therefore, one could theoretically achieve uniform color definition across all shell applications and tools.
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 "\
+<message> Send a message to the current channel.\n\
+/m <nick|channel> <message> Send a message to a specified channel or nick.\n\
+/M <message> Send a message to NickServ.\n\
+/Q <message> Send a message and close the host connection.\n\
+/x <message> Send a message directly to the server.\n\
+/j <channel> Join a specified channel.\n\
+/p <channel> 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;