aboutsummaryrefslogtreecommitdiff
path: root/src/irc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/irc.c')
-rw-r--r--src/irc.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/src/irc.c b/src/irc.c
index 8343897..a67cf56 100644
--- a/src/irc.c
+++ b/src/irc.c
@@ -26,7 +26,7 @@ char bell_type = 3;
static char msgbuf[MAX_MSG] = { 0 };
static char *msg; /* with source removed */
-static int msgbuf_len = 0, msg_len = 0;
+static int msgbuf_len = 0;
static char regged = 0, hilite = 0;
static char scr_prev = SCR_PRIV;
@@ -81,21 +81,31 @@ static void do_chan_nick(void) {
}
static void do_priv_nick(void) {
- scr_print_active("*");
- scr_print_active(msg_src);
- scr_print_active("* ");
- bell();
+ if(msg_src) {
+ scr_print_active("*");
+ scr_print_active(msg_src);
+ scr_print_active("* ");
+ bell();
+ }
}
+/* this ping calculation relies on the assumption that
+ nobody's ping time will ever be more than 9 minutes. anyone
+ that lagged will have been disconnected from the server already.
+ if this assumption turns out to be false, the ping time displayed
+ will be wrong (module ~9 mins). I don't think it's ever going to be
+ a real problem.
+ Why do it this way? Because using longs instead of ints bloats the
+ code by 778 bytes! */
static void print_ping_time(char *p) {
- static long now, pingtime;
- static int sec, frac;
+ static unsigned int now, pingtime;
+ static unsigned int sec, frac;
now = read_rtclok();
- pingtime = atol(p);
+ pingtime = (unsigned int)atoi(p);
- /* correct for rtclock rollover (every 77 hours) */
- if(now < pingtime) now |= 0x01000000L;
+ /* correct for rtclock rollover (every ~9 mins) */
+ if(now < pingtime) now |= 0x8000;
pingtime = now - pingtime;
@@ -114,9 +124,10 @@ static void print_ping_time(char *p) {
scr_print_active(numbuf);
scr_print_active(" sec");
- /* for debugging:
+ /*
+ // for debugging:
scr_print_active(" ");
- ltoa(pingtime, numbuf, 10);
+ itoa(pingtime, numbuf, 10);
scr_print_active(numbuf);
*/
}
@@ -339,7 +350,6 @@ static void permute_nick(void) {
}
static void do_numeric(void) {
- char s;
unsigned int num = atoi(msg_cmd);
switch(num) {
@@ -379,15 +389,19 @@ static void do_numeric(void) {
/* don't print these, just noise */
case RPL_MOTDSTART:
+ break;
+
+ /* don't print, but do trigger rejoin */
case RPL_ENDOFMOTD:
case ERR_NOMOTD:
+ cmd_rejoin_chans();
break;
case RPL_NAMREPLY:
scr_print_active(msg_args[2]);
scr_print_active(" users: ");
scr_print_active(msg_text);
- scr_print_active("\n");
+ scr_eol_active();
break;
case RPL_ENDOFNAMES:
@@ -399,13 +413,13 @@ static void do_numeric(void) {
scr_print_active(msg_args[1]);
scr_print_active(": ");
scr_print_active(msg_text);
- scr_print_active("\n");
+ scr_eol_active();
break;
case RPL_TOPICWHOTIME:
scr_print_active("Topic set by ");
scr_print_active(msg_args[2]);
- scr_print_active("\n");
+ scr_eol_active();
break;
default:
@@ -483,7 +497,7 @@ static void parse_msg(void) {
/*
scr_print_active("RAW: ");
scr_print_active(msg);
- scr_print_active("\n");
+ scr_eol_active();
*/
/* if there's a final multiword arg... */
@@ -538,7 +552,7 @@ static void parse_msg(void) {
if(msg_dest) {
scr_print_current("got here, msg_dest is: ");
scr_print_current(msg_dest);
- scr_print_current("\n");
+ scr_eol_current();
}
*/
@@ -610,7 +624,7 @@ int irc_read(void) {
}
// Get # of bytes waiting, no more than size of rx_buf
- rxbuflen = OS.dvstat[1] * 256 + OS.dvstat[0];
+ rxbuflen = (OS.dvstat[1] << 8) | OS.dvstat[0];
if(rxbuflen > MAX_MSG)
rxbuflen = MAX_MSG;
@@ -618,7 +632,6 @@ int irc_read(void) {
if(rxbuflen > 0) {
err = nread(url, rx_buf, rxbuflen);
if(err != 1) {
- scr_print_current("READ ERROR: ");
print_errnum();
return 0;
}