diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-04-15 16:10:39 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-04-15 16:10:49 +0200 |
commit | 78302ce933693aca5740e6f901592b6f07f65342 (patch) | |
tree | 60ff60d54e140241ab5658c98c3e9b8d91a5bba4 /weechat | |
parent | 3b3f2f3168c80e53055891f9afcfc5c5120dabd7 (diff) |
weechat: Support NET_NUMBER server responses
Diffstat (limited to 'weechat')
-rw-r--r-- | weechat/net.c | 16 | ||||
-rw-r--r-- | weechat/net.h | 2 |
2 files changed, 18 insertions, 0 deletions
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 { |