ucspi-tcp6
1.13.02
ucspi-tcp6
Loading...
Searching...
No Matches
ucspi-tcp6-1.13.02
src
commands.c
Go to the documentation of this file.
1
#include "buffer.h"
2
#include "stralloc.h"
3
#include "str.h"
4
#include "case.h"
5
#include "
commands.h
"
6
7
static
stralloc cmd = {0};
8
9
int
commands
(buffer *ss,
struct
commands
*c)
10
{
11
int
i;
12
char
*arg;
13
char
ch;
14
15
for
(;;) {
16
if
(!stralloc_copys(&cmd,
""
))
return
-1;
17
18
for
(;;) {
19
i = buffer_get(ss,&ch,1);
20
if
(i != 1)
return
i;
21
if
(ch ==
'\n'
)
break
;
22
if
(!ch) ch =
'\n'
;
23
if
(!stralloc_append(&cmd,&ch))
return
-1;
24
}
25
26
if
(cmd.len > 0)
if
(cmd.s[cmd.len - 1] ==
'\r'
) --cmd.len;
27
28
if
(!stralloc_0(&cmd))
return
-1;
29
30
i = str_chr(cmd.s,
' '
);
31
arg = cmd.s + i;
32
while
(*arg ==
' '
) ++arg;
33
cmd.s[i] = 0;
34
35
for
(i = 0;
c
[i].verb; ++i)
36
if
(case_equals(
c
[i].verb,cmd.s))
break
;
37
c
[i].action(arg);
38
if
(
c
[i].flush)
c
[i].flush();
39
}
40
}
c
struct cdb_make c
Definition:
tcprules.c:31
commands.h
commands
Definition:
commands.h:4
Generated on Mon Sep 23 2024 11:33:28 for ucspi-tcp6 by
1.9.6