diff options
| author | B. Watson <urchlay@slackware.uk> | 2026-03-11 06:26:04 -0400 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2026-03-11 06:26:39 -0400 |
| commit | d92bf1f7cf76d0c678ccbaea10a5ff6d41630e52 (patch) | |
| tree | d890d17b83013c6f0a975f8431d478eff94f5542 /src | |
| parent | ea47f06b8fa0ebab649ea1f7b323246d7e482438 (diff) | |
| download | fujinet-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')
| -rw-r--r-- | src/cmd.c | 5 | ||||
| -rw-r--r-- | src/config.c | 3 | ||||
| -rw-r--r-- | src/config.h | 14 | ||||
| -rw-r--r-- | src/edbox.c | 39 | ||||
| -rw-r--r-- | src/edbox.h | 11 | ||||
| -rw-r--r-- | src/irc.c | 40 | ||||
| -rw-r--r-- | src/irc.h | 3 | ||||
| -rw-r--r-- | src/main.c | 36 |
8 files changed, 53 insertions, 98 deletions
@@ -5,6 +5,7 @@ #include "irc.h" #include "addrs.h" #include "screen.h" +#include "config.h" /* A "command" is actually anything the user types, whether or not it starts with a /character. */ @@ -74,7 +75,7 @@ static void cmd_chan_text(void) { /* 0x02 = ^B = enable bold */ scr_print_active("<\x02"); - scr_print_active(usernick); + scr_print_active(conf->nick); scr_print_active("\x02"); /* @@ -305,7 +306,7 @@ static void do_me(void) { txbuf_send(); scr_print_current("\x02* "); - scr_print_current(usernick); + scr_print_current(conf->nick); scr_print_current("\x02 "); scr_print_current(arg1); scr_eol_current(); diff --git a/src/config.c b/src/config.c new file mode 100644 index 0000000..f7c8982 --- /dev/null +++ b/src/config.c @@ -0,0 +1,3 @@ +#include "config.h" + +conf_t *conf = (conf_t *)0x0400; diff --git a/src/config.h b/src/config.h new file mode 100644 index 0000000..f051fed --- /dev/null +++ b/src/config.h @@ -0,0 +1,14 @@ + +typedef struct { + char url[128]; + char nick[25]; + char real_name[25]; + char colors[2]; + char channels[5][33]; + char alert_type; + char show_ping; + char hide_motd; + char atract_away; +} conf_t; + +extern conf_t *conf; diff --git a/src/edbox.c b/src/edbox.c index 167bdc2..efbd19d 100644 --- a/src/edbox.c +++ b/src/edbox.c @@ -57,45 +57,6 @@ void edbox_putc(char c) { edbox_show(); } -void edbox_append(char *s) { - while(*s) - edit_box[edbox_pos++] = *s++; - edbox_len = edbox_pos; -} - -void edbox_preset(char *s) { - edbox_clear(); - edbox_append(s); -} - -static char readline_done, readline_len; -static char *readline_dest; -static void readline_callback(void) { - strncpy(readline_dest, edit_box, readline_len); - readline_done = 1; -} - -void edbox_readline(char *dest, char len) { - void (*old_callback)(void); - - edbox_clear(); - if(*dest) - edbox_preset(dest); - edbox_show(); - - old_callback = edbox_callback; - edbox_callback = readline_callback; - readline_dest = dest; - readline_len = len; - - readline_done = 0; - - while(!readline_done) - edbox_keystroke(); - - edbox_callback = old_callback; -} - static void special_keystroke(char c) { keyclick(); OS.ch = 0xff; diff --git a/src/edbox.h b/src/edbox.h index 3344353..548dc87 100644 --- a/src/edbox.h +++ b/src/edbox.h @@ -20,16 +20,5 @@ void edbox_putc(char c); is pressed, edbox_callback gets called (if it's set!) */ void edbox_keystroke(void); -/* append a string to the edit box. */ -void edbox_append(char *s); - -/* explicitly set the edit box's contents. wipes out whatever was there - before. */ -void edbox_preset(char *s); - -/* read a complete line into the edit box; doesn't return until the user - pressed Return. copies it to dest, up to len characters. */ -void edbox_readline(char *dest, char len); - /* called when the user presses Return */ extern void (*edbox_callback)(void); @@ -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(); @@ -5,8 +5,6 @@ #define streq_i(x,y) !strcasecmp(x,y) /**** main.c */ -extern char url[256]; -extern char usernick[32]; extern char *rx_buf; extern unsigned short rxbuflen; extern unsigned char err; @@ -42,6 +40,7 @@ void print_error(unsigned char err); /**** irc.c */ #define MAX_MSG_ARGS 8 +extern char bell_type; extern char numbuf[10]; extern char *msg_src, *msg_cmd, *msg_dest, *msg_text; extern char *msg_args[MAX_MSG_ARGS]; @@ -4,10 +4,6 @@ #define VERSION "0.0" #define BANNER SELF " v" VERSION " (B. Watson)\n" -#define DEF_URL "N:TCP://irc.libera.chat:6667" -#define DEF_NICK "FNChatTest" -#define DEF_CHANNEL "##atari" - #include <atari.h> #include <stdlib.h> #include <stdio.h> @@ -18,9 +14,8 @@ #include "irc.h" #include "screen.h" #include "edbox.h" +#include "config.h" -char url[256] = DEF_URL; // URL. -char usernick[32] = DEF_NICK; // our current nick (can be changed by the server) unsigned char err; // error code of last operation. unsigned char trip = 0; // if trip == 1, fujinet is asking us for attention. char old_enabled = 0; // were interrupts enabled for old vector @@ -33,23 +28,6 @@ char hz; /* 50 for PAL, 60 for NSTC */ extern void ih(); // defined in intr.s -void get_config(void) { - scr_print_current(BANNER); - - while(1) { - scr_print_current("URL?\n"); - edbox_readline(url, sizeof(url)); - scr_print_current("Nick?\n"); - edbox_readline(usernick, sizeof(usernick)); - - /* - scr_print_current("Are these settings OK [Y/n]?\n"); - if(tolower(cgetc()) != 'n') - */ - break; - } -} - void txbuf_init(void) { txbuflen = tx_buf[0] = 0; } @@ -94,7 +72,7 @@ void txbuf_send(void) { if(tx_buf[txbuflen - 1] != '\n') tx_buf[txbuflen++] = '\n'; - nwrite(url, tx_buf, txbuflen); + nwrite(conf->url, tx_buf, txbuflen); txbuf_init(); } @@ -106,10 +84,10 @@ void txbuf_send_str(const char *str) { int fn_connect(void) { scr_print(SCR_SERVER, "Connecting to: "); - scr_print(SCR_SERVER, url); + scr_print(SCR_SERVER, conf->url); scr_print(SCR_SERVER, "\n"); - err = nopen(url, FNET_TRANSLATION); + err = nopen(conf->url, FNET_TRANSLATION); if(err != SUCCESS) { scr_print(SCR_SERVER, "Connection failed: "); @@ -135,10 +113,11 @@ void fn_disconnect(void) { } int main(void) { + bell_type = conf->alert_type; /* TODO: have bell.s read staight from the struct */ OS.shflok = 0; // turn off shift-lock. OS.soundr = 0; // Turn off SIO beeping sound - OS.color2 = 0xc0; /* darkest green background */ - OS.color1 = 0x0c; /* bright text */ + OS.color2 = conf->colors[0]; + OS.color1 = conf->colors[1]; hz = (GTIA_READ.pal & 0x0e) ? 60 : 50; @@ -146,7 +125,6 @@ int main(void) { scr_init(); while(1) { - get_config(); edbox_callback = cmd_execute; if(fn_connect()) { irc_register(); |
