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){
|
if (tmp != NULL){
|
||||||
//Message
|
//Message
|
||||||
char *val = strchr(tmp, ':');
|
char *val = strchr(tmp, ':');
|
||||||
if (val == NULL)
|
if (val != NULL) {
|
||||||
return;
|
|
||||||
|
|
||||||
val[0] = '\0';
|
val[0] = '\0';
|
||||||
irc->msg = val + 1;
|
irc->msg = val + 1;
|
||||||
|
|
||||||
//Del space before :
|
//Del space before :
|
||||||
*(val - 1) = '\0';
|
*(val - 1) = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
//Channel
|
//Channel
|
||||||
val = strchr(tmp, ' ');
|
val = strchr(tmp, ' ');
|
||||||
if (val == NULL)
|
if (val != NULL) {
|
||||||
return;
|
|
||||||
|
|
||||||
val[0] = '\0';
|
val[0] = '\0';
|
||||||
irc->channel = val + 1;
|
irc->channel = val + 1;
|
||||||
|
}
|
||||||
|
|
||||||
//Nickname
|
//Nickname
|
||||||
val = strchr(irc->raw, '!');
|
val = strchr(irc->raw, '!');
|
||||||
if (val == NULL)
|
if (val != NULL) {
|
||||||
return;
|
|
||||||
|
|
||||||
val[0] = '\0';
|
val[0] = '\0';
|
||||||
irc->nick = irc->raw + 1;
|
irc->nick = irc->raw + 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int IRCC_recv(IRCC_client *irc){
|
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){
|
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 : "");
|
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)
|
if (send(irc->socket, irc->raw, bytes, 0) == -1)
|
||||||
return IRCC_SUCCESS;
|
|
||||||
|
|
||||||
return IRCC_ERROR;
|
return IRCC_ERROR;
|
||||||
|
|
||||||
|
return IRCC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IRCC_send(IRCC_client *irc, const char *channel, const char *msg){
|
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);
|
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)
|
if (send(irc->socket, irc->raw, bytes, 0) == -1)
|
||||||
return IRCC_SUCCESS;
|
|
||||||
|
|
||||||
return IRCC_ERROR;
|
return IRCC_ERROR;
|
||||||
|
|
||||||
|
return IRCC_SUCCESS;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int IRCC_init(IRCC_client *irc) {
|
int IRCC_init(IRCC_client *irc) {
|
||||||
|
Loading…
Reference in New Issue
Block a user