1/* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License as 4 * published by the Free Software Foundation; either version 2 of 5 * the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software 14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 15 * MA 02111-1307 USA 16 */ 17#ifndef VSF_FTPCMDIO_H 18#define VSF_FTPCMDIO_H 19 20struct mystr; 21struct vsf_session; 22 23/* vsf_cmdio_sock_setup() 24 * PURPOSE 25 * Initialise a few socket settings (keepalive, nonagle, etc). on the FTP 26 * control connection. 27 */ 28void vsf_cmdio_sock_setup(void); 29 30/* vsf_cmdio_write() 31 * PURPOSE 32 * Write a response to the FTP control connection. 33 * PARAMETERS 34 * p_sess - the current session object 35 * status - the status code to report 36 * p_text - the text to report 37 */ 38void vsf_cmdio_write(struct vsf_session* p_sess, int status, 39 const char* p_text); 40 41/* vsf_cmdio_write_hyphen() 42 * PURPOSE 43 * Write a response to the FTP control connection, with a hyphen '-' 44 * continuation indicator. 45 * PARAMETERS 46 * p_sess - the current session object 47 * status - the status code to report 48 * p_text - the text to report 49 */ 50void vsf_cmdio_write_hyphen(struct vsf_session* p_sess, int status, 51 const char* p_text); 52 53/* vsf_cmdio_write_raw() 54 * PURPOSE 55 * Write a raw response to the FTP control connection. A status code is 56 * not prepended, and it is also the client's responsibility to include 57 * newline characters if required. 58 * PARAMETERS 59 * p_sess - the current session object 60 * p_text - the text to report 61 */ 62void vsf_cmdio_write_raw(struct vsf_session* p_sess, const char* p_text); 63 64/* vsf_cmdio_write_exit() 65 * PURPOSE 66 * The same as vsf_cmdio_write(), and then the calling process is exited. The 67 * write is _guaranteed_ to not block (ditching output if neccessary). 68 */ 69void vsf_cmdio_write_exit(struct vsf_session* p_sess, int status, 70 const char* p_text); 71 72/* vsf_cmdio_write_str() 73 * PURPOSE 74 * The same as vsf_cmdio_write(), apart from the text is specified as a 75 * string buffer object "p_str". 76 */ 77void vsf_cmdio_write_str(struct vsf_session* p_sess, int status, 78 const struct mystr* p_str); 79 80/* vsf_cmdio_write_str_hyphen() 81 * PURPOSE 82 * The same as vsf_cmdio_write_str(), apart from the response line is 83 * output with the continuation indicator '-' between the response code and 84 * the response text. This indicates there are more lines of response. 85 */ 86void vsf_cmdio_write_str_hyphen(struct vsf_session* p_sess, int status, 87 const struct mystr* p_str); 88 89/* vsf_cmdio_set_alarm() 90 * PURPOSE 91 * Activate the control connection inactivity timeout. This is explicitly 92 * exposed in the API so that we can play it safe, and activate the alarm 93 * before _any_ potentially blocking calls. 94 * PARAMETERS 95 * p_sess - The current session object 96 */ 97void vsf_cmdio_set_alarm(struct vsf_session* p_sess); 98 99/* vsf_cmdio_get_cmd_and_arg() 100 * PURPOSE 101 * Read an FTP command (and optional argument) from the FTP control connection. 102 * PARAMETERS 103 * p_sess - The current session object 104 * p_cmd_str - Where to put the FTP command string (may be empty) 105 * p_arg_str - Where to put the FTP argument string (may be empty) 106 * set_alarm - If true, the control connection inactivity monitor is used 107 */ 108void vsf_cmdio_get_cmd_and_arg(struct vsf_session* p_sess, 109 struct mystr* p_cmd_str, 110 struct mystr* p_arg_str, int set_alarm); 111 112#endif /* VSF_FTPCMDIO_H */ 113 114