I have wrote a simple program for connecting irc servers. It's Ok but the parsing is the thing that i am confused about.
During the main loop ( while (1) thing) when i try the parse the lines, the bot is exiting like Client exited.Actually when i try this the bot can't stay in server.
./bot
Connection OK.
Client exited.
Here is the samples:
Code:
void send_nickname_joined(Socket sock, char *buf)
{
char *nick;
nick = strtok(buf, "!");
clearit(':', nick);
send_server(sock, "%s has joinied", nick);
return;
}
Code:
int main ()
{
//variables
//socket routines
//irc connection routines
//background routins
/* Connection Ok. Parsing.. */
while (1)
{
readaline(sock, buf, sizeof(buf));
//check pings for pong
send_nickname_joined(sock, buf);
}
}
When i am commented out "send_nickname_joined(buf);" line the bot stays in server as long as i keep it.
Any ideas, samples, codes would be appreciated.
Thanks in advanced.