s/qmail 4.2.29a
Next generation secure email transport
Loading...
Searching...
No Matches
commands.c
Go to the documentation of this file.
1#include "commands.h"
2#include "buffer.h"
3#include "stralloc.h"
4#include "str.h"
5#include "case.h"
6
7static stralloc cmd = {0};
8
9int commands(buffer *b,struct commands *c)
10{
11 int i;
12 char *arg;
13
14 for (;;) {
15 if (!stralloc_copys(&cmd,"")) return -1;
16
17 for (;;) {
18 if (!stralloc_readyplus(&cmd,1)) return -1;
19 i = buffer_get(b,cmd.s + cmd.len,1);
20 if (i != 1) return i;
21 if (cmd.s[cmd.len] == '\n') break;
22 ++cmd.len;
23 }
24
25 if (cmd.len > 0) if (cmd.s[cmd.len - 1] == '\r') --cmd.len;
26
27 cmd.s[cmd.len] = 0;
28
29 i = str_chr(cmd.s,' ');
30 arg = cmd.s + i;
31 while (*arg == ' ') ++arg;
32 cmd.s[i] = 0;
33
34 for (i = 0; c[i].text; ++i)
35 if (case_equals(c[i].text,cmd.s)) break;
36
37 c[i].fun(arg);
38 if (c[i].flush) c[i].flush();
39 }
40}
buffer b
Definition: auto-gid.c:10
int stralloc_copys(stralloc *, char const *)
void c(char *, char *, char *, int, int, int)
Definition: install.c:57
stralloc text
Definition: maildirwatch.c:21
void flush()
Definition: qmail-pop3d.c:56