diff options
Diffstat (limited to 'weechat/net.c')
-rw-r--r-- | weechat/net.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/weechat/net.c b/weechat/net.c index 12e3625..8c6cee5 100644 --- a/weechat/net.c +++ b/weechat/net.c @@ -285,6 +285,45 @@ void net_handle_recv(int fd,const char *msg){ free(res.room); free(res.username); free(res.message); + } else if(cmdlen==4&&memcmp(cmd,"join",4)==0){ + const char *q; + if(*p=='\0'||(q=strchr(p+1,' '))==NULL){ + fprintf(debugf,"net_handle_recv: not enough arguments to 'join' <%s>\n",msg); + return; + } + const char *roomp=p+1; + i64 roomlen=q-roomp; + const char *userp=q+1; + i64 userlen=msglen-(userp-msg); + + struct net_response res; + res.type=NET_JOIN; + res.room=malloc(roomlen+1); + res.username=malloc(userlen+1); + assert(res.room&&res.username); + memcpy(res.room,roomp,roomlen); + res.room[roomlen]='\0'; + memcpy(res.username,userp,userlen); + res.username[userlen]='\0'; + cb(fd,res,payload); + free(res.room); + free(res.username); + } else if(cmdlen==6&&memcmp(cmd,"invite",6)==0){ + if(*p=='\0'){ + fprintf(debugf,"net_handle_recv: no arguments to 'invite' <%s>\n",msg); + return; + } + const char *roomp=p+1; + i64 roomlen=msglen-(roomp-msg); + + struct net_response res; + res.type=NET_INVITE; + res.room=malloc(roomlen+1); + assert(res.room); + memcpy(res.room,roomp,roomlen); + res.room[roomlen]='\0'; + cb(fd,res,payload); + free(res.room); } else { fprintf(debugf,"net_handle_recv: unknown command <%s>\n",msg); } |