diff options
author | epoch <epoch@hack.thebackupbox.net> | 2019-06-08 11:06:10 +0000 |
---|---|---|
committer | epoch <epoch@hack.thebackupbox.net> | 2019-06-08 11:06:10 +0000 |
commit | e3c904a1a36e9f402ffc2c19d8946070d320e41d (patch) | |
tree | 0dfa08e1c1311e0ea0ef6ae3b8ddeff1ab43667d | |
parent | 61afdc45958819e693fce9e8646e57729fca0359 (diff) | |
download | libirc-e3c904a1a36e9f402ffc2c19d8946070d320e41d.tar.gz libirc-e3c904a1a36e9f402ffc2c19d8946070d320e41d.zip |
added an EOF check for irc_handler. fixed PONG
-rw-r--r-- | libirc.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -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 |