-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcommon.h
More file actions
50 lines (37 loc) · 692 Bytes
/
common.h
File metadata and controls
50 lines (37 loc) · 692 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef __COMMON_H__
#define __COMMON_H__
#define _STR(a) #a
#define STR(a) _STR(a)
#define RSHELL_F_LISTEN (1 << 0)
#define RSHELL_F_NOFORK (1 << 1)
struct plugin;
struct rshell
{
char *host;
char *service;
uint16_t port;
int family;
char *shell;
unsigned flags;
int backlog;
char *peer;
struct plugin *plugin;
};
#include <ctype.h>
#define CMD_BUFFER_LEN 4096
static inline char *trim(char *str, ssize_t *plen)
{
char *end;
ssize_t len = *plen;
while ( len && isspace(*str) )
str++, len--;
if ( len )
{
end = str + len - 1;
while ( end > str && isspace(*end) )
len--, *end = '\0', end--;
}
*plen = len;
return str;
}
#endif /* __COMMON_H__ */