#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); }