fix
This commit is contained in:
parent
751260e234
commit
fa2b540550
23
C/irc.c
23
C/irc.c
@ -32,31 +32,28 @@ void IRCC_parse(char *tmp, IRCC_client *irc){
|
||||
if (tmp != NULL){
|
||||
//Message
|
||||
char *val = strchr(tmp, ':');
|
||||
if (val == NULL)
|
||||
return;
|
||||
|
||||
if (val != NULL) {
|
||||
val[0] = '\0';
|
||||
irc->msg = val + 1;
|
||||
|
||||
//Del space before :
|
||||
*(val - 1) = '\0';
|
||||
}
|
||||
|
||||
//Channel
|
||||
val = strchr(tmp, ' ');
|
||||
if (val == NULL)
|
||||
return;
|
||||
|
||||
if (val != NULL) {
|
||||
val[0] = '\0';
|
||||
irc->channel = val + 1;
|
||||
}
|
||||
|
||||
//Nickname
|
||||
val = strchr(irc->raw, '!');
|
||||
if (val == NULL)
|
||||
return;
|
||||
|
||||
if (val != NULL) {
|
||||
val[0] = '\0';
|
||||
irc->nick = irc->raw + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int IRCC_recv(IRCC_client *irc){
|
||||
@ -147,18 +144,18 @@ int IRCC_register(IRCC_client *irc, const char *nickname){
|
||||
int IRCC_join(IRCC_client *irc, const char *channel, const char *key){
|
||||
off_t bytes = snprintf(irc->raw, sizeof(irc->raw), "JOIN %s %s\r\n", channel, (key) ? key : "");
|
||||
if (send(irc->socket, irc->raw, bytes, 0) == -1)
|
||||
return IRCC_SUCCESS;
|
||||
|
||||
return IRCC_ERROR;
|
||||
|
||||
return IRCC_SUCCESS;
|
||||
}
|
||||
|
||||
int IRCC_send(IRCC_client *irc, const char *channel, const char *msg){
|
||||
off_t bytes = snprintf(irc->raw, sizeof(irc->raw), "PRIVMSG %s :%s\r\n", channel, msg);
|
||||
if (send(irc->socket, irc->raw, bytes, 0) == -1)
|
||||
return IRCC_SUCCESS;
|
||||
|
||||
return IRCC_ERROR;
|
||||
|
||||
return IRCC_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
int IRCC_init(IRCC_client *irc) {
|
||||
|
Loading…
Reference in New Issue
Block a user