rewrite parser

This commit is contained in:
Your Name 2023-12-13 16:15:52 +03:00
parent d6d2f02367
commit 751260e234
5 changed files with 77 additions and 64 deletions

View file

@ -22,9 +22,6 @@ void recvinfo(void) {
if (irc_status == IRCC_DISCONNECTED)
die("Disconnected");
else if (irc_status == IRCC_CONNECTED)
return;
//Print
if (CHECK_NULL() && irc_status == IRCC_PRIVMSG)
printf("[%s %s] %s\n", client.channel, client.nick, client.msg);
@ -55,20 +52,12 @@ int main(void) {
IRCC_register(&client, NICK);
//Recv motd and join in channel
recvinfo();
sleep(5);
for (size_t i = 0; i < sizeof(channels) / sizeof(char *); i++) {
if (channels[i] == NULL)
break;
size_t join_size = strlen("JOIN \r\n") + strlen(channels[i]) + 1;
char *tmp = malloc(join_size);
if (tmp == NULL)
die("malloc retured NULL");
snprintf(tmp, join_size, "JOIN %s\r\n", channels[i]);
send(client.socket, tmp, join_size, 0);
free(tmp);
IRCC_join(&client, channels[i], NULL);
}
recvinfo();