From 54064158d84fc4006e651deb314cde156cc383e8 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Tue, 14 Mar 2017 11:05:35 +0100 Subject: Register working --- command.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 command.c (limited to 'command.c') diff --git a/command.c b/command.c new file mode 100644 index 0000000..deaeabe --- /dev/null +++ b/command.c @@ -0,0 +1,121 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include "command.h" +#include "db.h" + + +static bool send_raw_text(int fd,const char *text,i64 len){ + i64 cursor=0; + while(cursor=linelen){ + debug("Connection %d sent too few parameters to command %s",fd,commands[cmdi].cmdname); + return true; + } + if(i==nargs-1&&commands[cmdi].longlast){ + sepp=line+linelen; + } else { + sepp=memchr(line+cursor,' ',linelen-cursor); + if(sepp==NULL)sepp=line+linelen; + } + *sepp='\0'; + args[i]=line+cursor; + cursor=sepp-line+1; + } + if(sepp-line<(i64)linelen){ + debug("Connection %d sent too many parameters to command %s",fd,commands[cmdi].cmdname); + return true; + } + + return commands[cmdi].handler(fd,tag,(const char**)args); +} -- cgit v1.2.3-54-g00ecf