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 /config/config.c | |
| 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 'config/config.c')
| -rw-r--r-- | config/config.c | 130 |
1 files changed, 98 insertions, 32 deletions
diff --git a/config/config.c b/config/config.c index 212d36b..28e0f6d 100644 --- a/config/config.c +++ b/config/config.c @@ -2,6 +2,7 @@ #include <fcntl.h> #include <unistd.h> #include <string.h> +#include <stdlib.h> #include <atari.h> #include <conio.h> @@ -19,22 +20,36 @@ conf_t defaults = { 1 }; -char filename[100] = "D:FNCHAT.CFG"; -char buf[100]; -char server[100]; +char have_dos = 0; +char filename[101] = "D:FNCHAT.CFG"; +char buf[128]; +char numbuf[4]; +char server[101]; char port[6]; +void detect_dos(void) { + char i, j; + + for(i = 0; i < 11; i++) { + j = OS.hatabs[i].id; + if(j == 'D' || j == 'H') { + have_dos = 1; + break; + } + } +} + void print(const char *text) { fputs(text, stdout); } -void prompt(const char *text, char *p) { +void prompt(const char *text, char *p, char limit) { print(text); print(" ["); print(p); print("]? "); gets(buf); - if(buf[0]) strcpy(p, buf); + if(buf[0]) strncpy(p, buf, limit); } char yn(const char *text) { @@ -50,16 +65,60 @@ char yn(const char *text) { return (c == '\n' || c == 'Y' || c == 'y'); } -void save(void) { - int fh, bad; +void prompt_config_file(void) { + OS.shflok = 0x40; + prompt("Config File", filename, 100); + OS.shflok = 0x00; +} + +void prompt_color(const char *text, char which) { + itoa(conf->colors[which], numbuf, 10); + print(text); + prompt(" color", numbuf, 3); + conf->colors[which] = atoi(numbuf); +} + +void prompt_colors(void) { + char bad; + + do { + bad = 0; + prompt_color("Background", 0); + prompt_color("Text", 1); + if((conf->colors[0] & 0x0e) == (conf->colors[1] & 0x0e)) { + print("!! Unreadable, try again.\n"); + bad = 1; + } + } while(bad); + + OS.color2 = conf->colors[0]; + OS.color1 = conf->colors[1]; +} + +void prompt_alert_type(void) { + char c, bad; + print(" 0:None, 1:Beep, 2:Flash, 3:Both\n"); do { bad = 0; + itoa(conf->alert_type, numbuf, 10); + prompt("Alert type", numbuf, 2); + c = atoi(numbuf); + if(c < 0 || c > 3) { + bad = 1; + print("!! Range is 0-3, try again.\n"); + } + } while(bad); - OS.shflok = 0x40; - prompt("Config File", filename); - OS.shflok = 0x00; + conf->alert_type = c; +} +void save(void) { + int fh, bad; + + do { + bad = 0; + prompt_config_file(); if((fh = open(filename, O_WRONLY | O_CREAT)) < 0) { print("!! I/O error (open)\n"); bad = 1; @@ -79,23 +138,26 @@ void save(void) { void load(void) { int fh, bad = 0; - if(!yn("Load Config")) { - bad = 1; - print("OK"); - } else { - OS.shflok = 0x40; - prompt("Config File", filename); - OS.shflok = 0x00; - - if((fh = open(filename, O_RDONLY)) < 0) { - print("Not found"); - bad = 1; - } else if((read(fh, conf, sizeof(conf_t))) != sizeof(conf_t)) { - print("Invalid"); + if(have_dos) { + if(!yn("Load Config")) { bad = 1; + print("OK"); + } else { + prompt_config_file(); + + if((fh = open(filename, O_RDONLY)) < 0) { + print("Not found"); + bad = 1; + } else if((read(fh, conf, sizeof(conf_t))) != sizeof(conf_t)) { + print("Invalid"); + bad = 1; + } + + if(fh >= 0) close(fh); } - - if(fh >= 0) close(fh); + } else { + print("No DOS booted"); + bad = 1; } if(bad) { @@ -120,6 +182,7 @@ void main(void) { cursor(1); puts("\x7d" "FujiNetChat Setup\n"); + detect_dos(); load(); OS.color2 = conf->colors[0]; @@ -138,11 +201,12 @@ void main(void) { strcpy(port, p); while(1) { - prompt("\nServer", server); - prompt("Port ", port); - prompt("Nick ", conf->nick); - // prompt_colors(); - // prompt_alert_type(); + prompt("\nServer", server, 100); + prompt("Port ", port, 5); + prompt("Nick ", conf->nick, 25); + prompt("'Real' Name ", conf->real_name, 25); + prompt_colors(); + prompt_alert_type(); conf->show_ping = yn("Show PING/PONG"); conf->atract_away = yn("Set AWAY on ATRACT"); conf->hide_motd = yn("Hide MOTD"); @@ -156,8 +220,10 @@ void main(void) { break; } - if(yn("Save to disk")) - save(); + if(have_dos) { + if(yn("Save to disk")) + save(); + } print("\nClient loading..."); } |
