1 #ifndef VSF_FTPCMDIO_H 2 #define VSF_FTPCMDIO_H 3 4 struct mystr; 5 struct vsf_session; 6 7 /* vsf_cmdio_sock_setup() 8 * PURPOSE 9 * Initialise a few socket settings (keepalive, nonagle, etc). on the FTP 10 * control connection. 11 */ 12 void vsf_cmdio_sock_setup(void); 13 14 /* vsf_cmdio_write() 15 * PURPOSE 16 * Write a response to the FTP control connection. 17 * PARAMETERS 18 * p_sess - the current session object 19 * status - the status code to report 20 * p_text - the text to report 21 */ 22 void vsf_cmdio_write(struct vsf_session* p_sess, int status, 23 const char* p_text); 24 25 /* vsf_cmdio_write_hyphen() 26 * PURPOSE 27 * Write a response to the FTP control connection, with a hyphen '-' 28 * continuation indicator. 29 * PARAMETERS 30 * p_sess - the current session object 31 * status - the status code to report 32 * p_text - the text to report 33 */ 34 void vsf_cmdio_write_hyphen(struct vsf_session* p_sess, int status, 35 const char* p_text); 36 37 /* vsf_cmdio_write_raw() 38 * PURPOSE 39 * Write a raw response to the FTP control connection. A status code is 40 * not prepended, and it is also the client's responsibility to include 41 * newline characters if required. 42 * PARAMETERS 43 * p_sess - the current session object 44 * p_text - the text to report 45 */ 46 void vsf_cmdio_write_raw(struct vsf_session* p_sess, const char* p_text); 47 48 /* vsf_cmdio_write_raw_quiet() 49 * PURPOSE 50 * Write a raw response to the FTP control connection. A status code is 51 * not prepended, and it is also the client's responsibility to include 52 * newline characters if required. Response do not writen to log. 53 * PARAMETERS 54 * p_sess - the current session object 55 * p_text - the text to report 56 */ 57 void vsf_cmdio_write_raw_quiet(struct vsf_session* p_sess, const char* p_text); 58 59 /* vsf_cmdio_write_exit() 60 * PURPOSE 61 * The same as vsf_cmdio_write(), and then the calling process is exited. The 62 * write is _guaranteed_ to not block (ditching output if neccessary). 63 */ 64 void vsf_cmdio_write_exit(struct vsf_session* p_sess, int status, 65 const char* p_text, int exit_val); 66 67 /* vsf_cmdio_write_str() 68 * PURPOSE 69 * The same as vsf_cmdio_write(), apart from the text is specified as a 70 * string buffer object "p_str". 71 */ 72 void vsf_cmdio_write_str(struct vsf_session* p_sess, int status, 73 const struct mystr* p_str); 74 75 /* vsf_cmdio_write_str_hyphen() 76 * PURPOSE 77 * The same as vsf_cmdio_write_str(), apart from the response line is 78 * output with the continuation indicator '-' between the response code and 79 * the response text. This indicates there are more lines of response. 80 */ 81 void vsf_cmdio_write_str_hyphen(struct vsf_session* p_sess, int status, 82 const struct mystr* p_str); 83 84 /* vsf_cmdio_set_alarm() 85 * PURPOSE 86 * Activate the control connection inactivity timeout. This is explicitly 87 * exposed in the API so that we can play it safe, and activate the alarm 88 * before _any_ potentially blocking calls. 89 * PARAMETERS 90 * p_sess - The current session object 91 */ 92 void vsf_cmdio_set_alarm(struct vsf_session* p_sess); 93 94 /* vsf_cmdio_get_cmd_and_arg() 95 * PURPOSE 96 * Read an FTP command (and optional argument) from the FTP control connection. 97 * PARAMETERS 98 * p_sess - The current session object 99 * p_cmd_str - Where to put the FTP command string (may be empty) 100 * p_arg_str - Where to put the FTP argument string (may be empty) 101 * set_alarm - If true, the control connection inactivity monitor is used 102 * is_quiet - Don't log processed command 103 */ 104 void vsf_cmdio_get_cmd_and_arg(struct vsf_session* p_sess, 105 struct mystr* p_cmd_str, 106 struct mystr* p_arg_str, 107 int set_alarm, 108 int is_quiet); 109 110 #endif /* VSF_FTPCMDIO_H */ 111 112