Загрузить файлы в «C»

Fixed bugs in parser
This commit is contained in:
8nlight 2023-08-07 18:06:44 +03:00
parent a25dbc52fd
commit 614470bc94
2 changed files with 20 additions and 13 deletions

14
C/irc.c
View file

@ -42,15 +42,16 @@ unsigned int IRCC_register(IRCC_client *irc, const char *nickname){
}
void IRCC_parse(char *tmp, IRCC_client *irc){
irc->raw[strcspn(irc->raw, "\r\n")] = '\0';
if (tmp != NULL){
//Message
if (strstr(tmp, ":") != NULL)
irc->msg = strstr(tmp, ":");
//Channel
if (strstr(tmp, "#") != NULL){
irc->channel = strstr(tmp, "#");
irc->channel[strcspn(irc->channel, " ")] = '\0';
if (strstr(tmp, " ") != NULL){
irc->channel = strstr(tmp, " ") + 1;
irc->channel[strcspn(irc->channel, ":") - 1] = '\0';
}
//Nickname
@ -77,9 +78,12 @@ unsigned int IRCC_recv(IRCC_client *irc){
else {
//puts(irc->raw);
irc->raw[strcspn(irc->raw, "\r\n")] = '\0';
if (strstr(irc->raw, "PRIVMSG ")){
//Check end of motd
if (strstr(irc->raw, "PRIVMSG ") == NULL && strstr(irc->raw, "/MOTD"))
return IRCC_CONNECTED;
else if (strstr(irc->raw, "PRIVMSG ")){
IRCC_parse(strstr(irc->raw, "PRIVMSG "), irc);
return IRCC_PRIVMSG;
}