aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-03-30 03:25:35 -0400
committerB. Watson <urchlay@slackware.uk>2026-03-30 03:25:35 -0400
commitddfe09f3b8336630dd0f87e446306bc1e012f20b (patch)
treeecffd52c482e987099b7a03383ec62763009e4fb
parent28c0a056ce806a357371d7102fb25d72e358ff09 (diff)
downloadfujinet-chat-ddfe09f3b8336630dd0f87e446306bc1e012f20b.tar.gz
Trim down nio API (no parameter passing), now at 4852 free.
-rw-r--r--src/irc.c2
-rw-r--r--src/main.c16
-rw-r--r--src/nio.c16
-rw-r--r--src/nio.h12
4 files changed, 23 insertions, 23 deletions
diff --git a/src/irc.c b/src/irc.c
index 5dd3916..3a7d901 100644
--- a/src/irc.c
+++ b/src/irc.c
@@ -739,7 +739,7 @@ int irc_read(void) {
ind_net_rx();
if(rxbuflen > 0) {
- err = nread(rx_buf, rxbuflen);
+ err = nread_rxbuf();
if(err != 1) {
ind_net_down();
print_errnum();
diff --git a/src/main.c b/src/main.c
index a705714..8b6fc28 100644
--- a/src/main.c
+++ b/src/main.c
@@ -28,17 +28,19 @@ unsigned int txbuflen; // TX buffer length
char hz; /* 50 for PAL, 60 for NSTC */
char reconnect_timeout = 1;
-/* TODO: user modes (default +iw), fg/bg color... */
-
extern void ih(); // defined in intr.s
+void txbuf_append_chr(char c) {
+ tx_buf[txbuflen++] = c;
+}
+
void txbuf_init(void) {
txbuflen = tx_buf[0] = 0;
}
void txbuf_append_str(const char *str) {
while(*str) {
- tx_buf[txbuflen++] = *str++;
+ txbuf_append_chr(*str++);
}
}
@@ -74,11 +76,13 @@ void txbuf_send(void) {
/* always terminate with *ASCII* CRLF.
DO NOT USE '\n' or even '\x0a', cc65 turns it into $9b! */
- tx_buf[txbuflen++] = 0x0d;
- tx_buf[txbuflen++] = 0x0a;
+ // tx_buf[txbuflen++] = 0x0d;
+ // tx_buf[txbuflen++] = 0x0a;
+ txbuf_append_chr(0x0d);
+ txbuf_append_chr(0x0a);
ind_net_tx();
- nwrite(tx_buf, txbuflen);
+ nwrite_txbuf();
ind_net_idle();
txbuf_init();
}
diff --git a/src/nio.c b/src/nio.c
index 9deae3c..d848e18 100644
--- a/src/nio.c
+++ b/src/nio.c
@@ -73,23 +73,27 @@ char nstatus(void) {
return OS.dvstat[DVSTAT_EXTENDED_ERROR]; // return extended status
}
-char nread(char *buf, unsigned short len) {
+char nread_rxbuf(void) {
+ extern unsigned int rxbuflen;
+ extern char *rx_buf;
set_defaults();
OS.dcb.dcomnd = 'R'; // read
OS.dcb.dstats = DREAD;
- OS.dcb.dbuf = buf;
- OS.dcb.dbyt = OS.dcb.daux = len; // Set the buffer size AND daux with length
+ OS.dcb.dbuf = rx_buf;
+ OS.dcb.dbyt = OS.dcb.daux = rxbuflen; // Set the buffer size AND daux with length
siov();
return get_status();
}
-char nwrite(char *buf, unsigned short len) {
+char nwrite_txbuf(void) {
+ extern unsigned int txbuflen;
+ extern char *tx_buf;
set_defaults();
OS.dcb.dcomnd = 'W'; // write
OS.dcb.dstats = DWRITE;
- OS.dcb.dbuf = buf;
- OS.dcb.dbyt = OS.dcb.daux = len;
+ OS.dcb.dbuf = tx_buf;
+ OS.dcb.dbyt = OS.dcb.daux = txbuflen;
siov();
return get_status();
diff --git a/src/nio.h b/src/nio.h
index 63b4997..01aa61e 100644
--- a/src/nio.h
+++ b/src/nio.h
@@ -25,16 +25,8 @@
char nopen(void);
char nclose(void);
char nstatus(void);
-char nread(char *buf, unsigned short len);
-char nwrite(char *buf, unsigned short len);
+char nread_rxbuf(void);
+char nwrite_txbuf(void);
char nreset(void);
-/**
- * Send username and password credentials
- * @param devicespec - The devicespec.
- * @param login - The username to send
- * @param password - The password to send
- */
-// unsigned char nlogin(char* devicespec, char* login, char* password);
-
#endif /* NIO_H */