aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoe <rbo@gmx.us>2025-10-17 15:33:51 +0200
committerjoe <rbo@gmx.us>2025-10-17 15:33:51 +0200
commit8bcff2ddfe51b1f3b48cb167835410921ddf51a5 (patch)
tree36d6fb624f56e5aa02a85e853c2e7434a9cdcbb4
parenttime format (diff)
downloadkirc-8bcff2ddfe51b1f3b48cb167835410921ddf51a5.tar.gz
kirc-8bcff2ddfe51b1f3b48cb167835410921ddf51a5.tar.bz2
kirc-8bcff2ddfe51b1f3b48cb167835410921ddf51a5.tar.xz
kirc-8bcff2ddfe51b1f3b48cb167835410921ddf51a5.tar.zst
kirc-8bcff2ddfe51b1f3b48cb167835410921ddf51a5.zip
flag to filter joins and more msg
Diffstat (limited to '')
-rw-r--r--Makefile5
-rw-r--r--kirc.115
-rw-r--r--kirc.c53
-rw-r--r--kirc.h1
4 files changed, 42 insertions, 32 deletions
diff --git a/Makefile b/Makefile
index 0ab5a50..1ecb5b8 100644
--- a/Makefile
+++ b/Makefile
@@ -3,8 +3,9 @@ ALL_WARNING = -Wall -Werror -Wextra -Wno-unused-result -pedantic -std=c99
PREFIX ?= /usr/local
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man
-CFLAGS = -O0 -g3
-CFLAGS += -fsanitize=address
+CFLAGS = -march=native -O3 -pipe
+# CFLAGS = -march=native -O0 -pipe -g3
+# CFLAGS += -fsanitize=address
kirc: kirc.c kirc.h
$(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 $(LDFLAGS) ${ALL_WARNING} kirc.c -o kirc
diff --git a/kirc.1 b/kirc.1
index 7da5776..04752aa 100644
--- a/kirc.1
+++ b/kirc.1
@@ -66,6 +66,9 @@ Toggle DCC support
.BI \-f
Filter ansi color codes
.TP
+.BI \-F
+Filter join/part/leave/nick messages
+.TP
.BI \-e
Specifies SASL EXTERNAL mechanism
.TP
@@ -114,12 +117,12 @@ to specified
.I <channel>
or
.I <nick>
-(if no
-.I <channel>
-or
-.I <nick>
-is specified, the
-.I <message>
+(if no
+.I <channel>
+or
+.I <nick>
+is specified, the
+.I <message>
will be sent to the default message channel)
.SH AUTHOR
Michael Czigler <michaelczigler at icloud dot com>
diff --git a/kirc.c b/kirc.c
index 53b27fc..bf24b8a 100644
--- a/kirc.c
+++ b/kirc.c
@@ -1067,7 +1067,7 @@ static void param_print_private(param p)
*(p->nickname + p->nicklen - 8) = '\0';
}
strcpy(timestamp, "\x1b[90m");
- char buf[16];
+ char buf[7];
if (timeinfo->tm_hour < 10) {
strcat(timestamp, "0");
}
@@ -1143,12 +1143,7 @@ static void raw_parser(char *string)
.offset = 0
};
- if (WRAP_LEN > p.maxcols / 3) {
- p.nicklen = p.maxcols / 3;
- }
- else {
- p.nicklen = WRAP_LEN;
- }
+ p.nicklen = WRAP_LEN;
if (*chan != '\0' && !memcmp(p.command, "001", sizeof("001") - 1)) {
static char not_first_time = 0;
if (not_first_time) {
@@ -1174,22 +1169,29 @@ static void raw_parser(char *string)
memmove(chan, tok, ptr - tok + 1);
return;
}
- if (!memcmp(p.command, "QUIT", sizeof("QUIT") - 1)) {
- param_print_quit(&p);
- printf("\x1b[0m\r\n");
- return;
- }if (!memcmp(p.command, "PART", sizeof("PART") - 1)) {
- param_print_part(&p);
- printf("\x1b[0m\r\n");
- return;
- }if (!memcmp(p.command, "JOIN", sizeof("JOIN") - 1)) {
- param_print_join(&p);
- printf("\x1b[0m\r\n");
- return;
- }if (!memcmp(p.command, "NICK", sizeof("NICK") - 1)) {
- param_print_nick(&p);
- printf("\x1b[0m\r\n");
- return;
+ if (filter_joins == 1 &&
+ (!memcmp(p.command, "QUIT", sizeof("QUIT") - 1) ||
+ !memcmp(p.command, "PART", sizeof("PART") - 1) ||
+ !memcmp(p.command, "JOIN", sizeof("JOIN") - 1) ||
+ !memcmp(p.command, "NICK", sizeof("NICK") - 1))) {
+ return;
+ }
+ if (!memcmp(p.command, "QUIT", sizeof("QUIT") - 1)) {
+ param_print_quit(&p);
+ printf("\xb[0m\r\n");
+ return;
+ }if (!memcmp(p.command, "PART", sizeof("PART") - 1)) {
+ param_print_part(&p);
+ printf("\x1b[0m\r\n");
+ return;
+ }if (!memcmp(p.command, "JOIN", sizeof("JOIN") - 1)) {
+ param_print_join(&p);
+ printf("\x1b[0m\r\n");
+ return;
+ }if (!memcmp(p.command, "NICK", sizeof("NICK") - 1)) {
+ param_print_nick(&p);
+ printf("\x1b[0m\r\n");
+ return;
}if ((!memcmp(p.command, "PRIVMSG", sizeof("PRIVMSG") - 1)) || (!memcmp(p.command, "NOTICE", sizeof("NOTICE") - 1))) {
filter_colors(p.message); /* this can be slow if -f is passed to kirc */
param_print_private(&p);
@@ -1804,7 +1806,7 @@ int main(int argc, char **argv)
{
char buf[BUFSIZ];
int cval;
- while ((cval = getopt(argc, argv, "s:p:o:m:n:k:c:u:r:a:D:46dfexvV")) != -1) {
+ while ((cval = getopt(argc, argv, "s:p:o:m:n:k:c:u:r:a:D:46dfFexvV")) != -1) {
switch (cval) {
case 'v':
version();
@@ -1827,6 +1829,9 @@ int main(int argc, char **argv)
case 'f':
filter = 1;
break;
+ case 'F':
+ filter_joins = 1;
+ break;
case 's':
host = optarg;
break;
diff --git a/kirc.h b/kirc.h
index 4e1c4a0..102803e 100644
--- a/kirc.h
+++ b/kirc.h
@@ -57,6 +57,7 @@ static char sasl = 0; /* SASL method */
static char isu8 = 0; /* UTF-8 flag */
static char dcc = 0; /* DCC flag */
static char filter = 0; /* flag to filter ansi colors */
+static char filter_joins = 0; /* filter join/part/nick/quit messages */
static char* dcc_dir = NULL; /* DCC download directory */
static mode_t dcc_mode = DCC_MODE; /* file permissions for downloaded files */
static const char *host = "irc.libera.chat"; /* host address */