forked from dagwieers/vsftpd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ftpcmdio.h
97 lines (85 loc) · 3.24 KB
/
ftpcmdio.h
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef VSF_FTPCMDIO_H
#define VSF_FTPCMDIO_H
struct mystr;
struct vsf_session;
/* vsf_cmdio_sock_setup()
* PURPOSE
* Initialise a few socket settings (keepalive, nonagle, etc). on the FTP
* control connection.
*/
void vsf_cmdio_sock_setup(void);
/* vsf_cmdio_write()
* PURPOSE
* Write a response to the FTP control connection.
* PARAMETERS
* p_sess - the current session object
* status - the status code to report
* p_text - the text to report
*/
void vsf_cmdio_write(struct vsf_session* p_sess, int status,
const char* p_text);
/* vsf_cmdio_write_hyphen()
* PURPOSE
* Write a response to the FTP control connection, with a hyphen '-'
* continuation indicator.
* PARAMETERS
* p_sess - the current session object
* status - the status code to report
* p_text - the text to report
*/
void vsf_cmdio_write_hyphen(struct vsf_session* p_sess, int status,
const char* p_text);
/* vsf_cmdio_write_raw()
* PURPOSE
* Write a raw response to the FTP control connection. A status code is
* not prepended, and it is also the client's responsibility to include
* newline characters if required.
* PARAMETERS
* p_sess - the current session object
* p_text - the text to report
*/
void vsf_cmdio_write_raw(struct vsf_session* p_sess, const char* p_text);
/* vsf_cmdio_write_exit()
* PURPOSE
* The same as vsf_cmdio_write(), and then the calling process is exited. The
* write is _guaranteed_ to not block (ditching output if neccessary).
*/
void vsf_cmdio_write_exit(struct vsf_session* p_sess, int status,
const char* p_text, int exit_val);
/* vsf_cmdio_write_str()
* PURPOSE
* The same as vsf_cmdio_write(), apart from the text is specified as a
* string buffer object "p_str".
*/
void vsf_cmdio_write_str(struct vsf_session* p_sess, int status,
const struct mystr* p_str);
/* vsf_cmdio_write_str_hyphen()
* PURPOSE
* The same as vsf_cmdio_write_str(), apart from the response line is
* output with the continuation indicator '-' between the response code and
* the response text. This indicates there are more lines of response.
*/
void vsf_cmdio_write_str_hyphen(struct vsf_session* p_sess, int status,
const struct mystr* p_str);
/* vsf_cmdio_set_alarm()
* PURPOSE
* Activate the control connection inactivity timeout. This is explicitly
* exposed in the API so that we can play it safe, and activate the alarm
* before _any_ potentially blocking calls.
* PARAMETERS
* p_sess - The current session object
*/
void vsf_cmdio_set_alarm(struct vsf_session* p_sess);
/* vsf_cmdio_get_cmd_and_arg()
* PURPOSE
* Read an FTP command (and optional argument) from the FTP control connection.
* PARAMETERS
* p_sess - The current session object
* p_cmd_str - Where to put the FTP command string (may be empty)
* p_arg_str - Where to put the FTP argument string (may be empty)
* set_alarm - If true, the control connection inactivity monitor is used
*/
void vsf_cmdio_get_cmd_and_arg(struct vsf_session* p_sess,
struct mystr* p_cmd_str,
struct mystr* p_arg_str, int set_alarm);
#endif /* VSF_FTPCMDIO_H */