From e3c904a1a36e9f402ffc2c19d8946070d320e41d Mon Sep 17 00:00:00 2001 From: epoch Date: Sat, 8 Jun 2019 11:06:10 +0000 Subject: added an EOF check for irc_handler. fixed PONG --- libirc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libirc.c b/libirc.c index e35d732..7c414a5 100644 --- a/libirc.c +++ b/libirc.c @@ -125,11 +125,16 @@ void (*g_extra_handler)(); //kek int g_extra_fd; void irc_handler(struct shit *me,char *line) { - fprintf(stderr,"debug: %s\n",line); +// fprintf(stderr,"debug: %s\n",line); + if(!line) { + //we're EOFd + //we need to reconnect to the server. + return; + } if(!strncmp(line,"PING ",5)) { //I write back to the me->fd fprintf(stderr,"libirc: GOT A PING. SENDING PONG.\n"); - dprintf(me->fd,"PONG :%s\r\n",line+5); + dprintf(me->fd,"PONG %s\r\n",line+5); return;//we probably don't need to let the bot know that it pinged. right? } //I need a way to get the line_handler passed to runem in here. @@ -156,7 +161,7 @@ int runem(int *fds,void (*line_handler)(),void (*extra_handler)()) { //wrap sele add_fd(fds[i],irc_handler); } select_on_everything(); - return 0; + return 1; } //wrap runem to keep runit around :P -- cgit v1.2.3