From 78302ce933693aca5740e6f901592b6f07f65342 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 15 Apr 2017 16:10:39 +0200 Subject: weechat: Support NET_NUMBER server responses --- weechat/net.c | 16 ++++++++++++++++ weechat/net.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/weechat/net.c b/weechat/net.c index fb9ec8e..b8e3827 100644 --- a/weechat/net.c +++ b/weechat/net.c @@ -138,6 +138,22 @@ void net_handle_recv(int fd,const char *msg){ if(cmdlen==2&&memcmp(cmd,"ok",2)==0){ cb(fd,(struct net_response){.type=NET_OK},payload); + } else if(cmdlen==6&&memcmp(cmd,"number",6)==0){ + if(*p=='\0'){ + fprintf(debugf,"net_handle_recv: no number argument <%s>\n",msg); + return; + } + const char *nump=p+1; + struct net_response res=(struct net_response){ + .type=NET_NUMBER + }; + const char *endp; + res.number=strtol(nump,(char**)&endp,10); + if(nump[0]=='\0'||*endp!='\0'){ + fprintf(debugf,"net_handle_recv: invalid number argument <%s>\n",msg); + return; + } + cb(fd,res,payload); } else if(cmdlen==5&&memcmp(cmd,"error",5)==0){ struct net_response res=(struct net_response){ .type=NET_ERROR, diff --git a/weechat/net.h b/weechat/net.h index 86aa271..7e18f4c 100644 --- a/weechat/net.h +++ b/weechat/net.h @@ -6,6 +6,7 @@ enum net_response_type{ NET_OK, + NET_NUMBER, NET_ERROR, NET_NAME, NET_LIST, @@ -25,6 +26,7 @@ struct net_history_item{ struct net_response{ enum net_response_type type; union { + i64 number; char *error; char *name; struct { -- cgit v1.2.3-70-g09d2