aboutsummaryrefslogtreecommitdiff
path: root/weechat
diff options
context:
space:
mode:
Diffstat (limited to 'weechat')
-rw-r--r--weechat/net.c16
-rw-r--r--weechat/net.h2
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 {