aboutsummaryrefslogtreecommitdiff
path: root/src/irc.c
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-03-11 06:26:04 -0400
committerB. Watson <urchlay@slackware.uk>2026-03-11 06:26:39 -0400
commitd92bf1f7cf76d0c678ccbaea10a5ff6d41630e52 (patch)
treed890d17b83013c6f0a975f8431d478eff94f5542 /src/irc.c
parentea47f06b8fa0ebab649ea1f7b323246d7e482438 (diff)
downloadfujinet-chat-d92bf1f7cf76d0c678ccbaea10a5ff6d41630e52.tar.gz
Remove server/nick prompts from client, add a separate config tool that loads as an init segment, with lots more options.
Diffstat (limited to 'src/irc.c')
-rw-r--r--src/irc.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/irc.c b/src/irc.c
index 9a5b7a9..34957f1 100644
--- a/src/irc.c
+++ b/src/irc.c
@@ -12,6 +12,7 @@
#include <atari.h>
#include <conio.h>
#include "nio.h"
+#include "config.h"
#define MAX_MSG 512
@@ -22,7 +23,7 @@ char *msg_args[MAX_MSG_ARGS];
int msg_argcount;
char irc_away = 0;
-char bell_type = 3;
+char bell_type;
static char msgbuf[MAX_MSG] = { 0 };
static char *msg; /* with source removed */
@@ -44,7 +45,7 @@ static void join_channel(void) {
*/
static void send_nick(void) {
- txbuf_set_str2("NICK ", usernick);
+ txbuf_set_str2("NICK ", conf->nick);
txbuf_send();
}
@@ -57,7 +58,8 @@ static void print_reason(void) {
}
static void do_pong(void) {
- scr_print_server("PING/PONG\n"); /* make hiding this a preference, or just ditch it */
+ if(conf->show_ping)
+ scr_print_server("PING/PONG\n");
txbuf_set_str2("PONG ", msg_args[0]);
txbuf_send();
}
@@ -203,7 +205,7 @@ static void do_ctcp(int is_notice) {
static void do_privmsg(void) {
/* TODO: this shouldn't be case-sensitive */
- if(strstr(msg_text, usernick))
+ if(strstr(msg_text, conf->nick))
hilite = 1;
else
hilite = 0;
@@ -232,7 +234,7 @@ static void do_notice(void) {
}
static void do_join(void) {
- if(streq_i(usernick, msg_src)) {
+ if(streq_i(conf->nick, msg_src)) {
scr_print_active("You have ");
} else {
scr_print_active(msg_src);
@@ -244,9 +246,9 @@ static void do_join(void) {
}
static void do_nick(void) {
- if(streq_i(usernick, msg_src)) {
+ if(streq_i(conf->nick, msg_src)) {
scr_print_active("You are ");
- strncpy(usernick, msg_dest, 32);
+ strncpy(conf->nick, msg_dest, 32);
} else {
scr_print_active(msg_src);
scr_print_active(" is ");
@@ -339,7 +341,7 @@ static void do_catchall(int arg) {
static void permute_nick(void) {
char *last;
- last = usernick + strlen(usernick) - 1;
+ last = conf->nick + strlen(conf->nick) - 1;
if((*last >= '1' && *last < '9') || (*last >= 'A' && *last < 'Z')) {
(*last)++;
@@ -359,7 +361,7 @@ static void do_numeric(void) {
/* use the server's idea of what our nick is, in case it got
truncated. */
case RPL_WELCOME:
- strcpy(usernick, msg_args[0]);
+ strcpy(conf->nick, msg_args[0]);
regged = 1;
do_catchall(1);
break;
@@ -394,6 +396,12 @@ static void do_numeric(void) {
case RPL_MOTDSTART:
break;
+ case RPL_MOTD:
+ /* FIXME: this prevents the user using /MOTD on purpose, too */
+ if(!conf->hide_motd)
+ do_catchall(0);
+ break;
+
/* don't print, but do trigger rejoin */
case RPL_ENDOFMOTD:
case ERR_NOMOTD:
@@ -616,7 +624,7 @@ void print_errnum(void) {
int irc_read(void) {
if(!trip) return 1;
- err = nstatus(url);
+ err = nstatus(conf->url);
if(err != 1) {
regged = 0;
@@ -638,7 +646,7 @@ int irc_read(void) {
rxbuflen = MAX_MSG;
if(rxbuflen > 0) {
- err = nread(url, rx_buf, rxbuflen);
+ err = nread(conf->url, rx_buf, rxbuflen);
if(err != 1) {
print_errnum();
return 0;
@@ -661,7 +669,7 @@ void irc_register(void) {
/* 2nd arg: local (UNIX) username, just use the nick */
/* 3rd arg: "real" name (make it a pref?) */
- txbuf_set_str3("USER ", usernick, " 0 * :FujiNetChat User");
+ txbuf_set_str3("USER ", conf->nick, " 0 * :FujiNetChat User");
txbuf_send();
send_nick();
@@ -781,9 +789,11 @@ static void keystroke(void) {
/* only exits on error (e.g. connection closed, which might be via /QUIT). */
void irc_loop(void) {
while(1) {
- if(!irc_away && (OS.atract & 0x80)) {
- irc_away = 1;
- txbuf_send_str("AWAY :ATRACT mode");
+ if(conf->atract_away) {
+ if(!irc_away && (OS.atract & 0x80)) {
+ irc_away = 1;
+ txbuf_send_str("AWAY :ATRACT mode");
+ }
}
if(!irc_read()) return;
keystroke();