00001 #ifndef VSF_FTPCMDIO_H 00002 #define VSF_FTPCMDIO_H 00003 00004 struct mystr; 00005 struct vsf_session; 00006 00007 /* vsf_cmdio_sock_setup() 00008 * PURPOSE 00009 * Initialise a few socket settings (keepalive, nonagle, etc). on the FTP 00010 * control connection. 00011 */ 00012 void vsf_cmdio_sock_setup(void); 00013 00014 /* vsf_cmdio_write() 00015 * PURPOSE 00016 * Write a response to the FTP control connection. 00017 * PARAMETERS 00018 * p_sess - the current session object 00019 * status - the status code to report 00020 * p_text - the text to report 00021 */ 00022 void vsf_cmdio_write(struct vsf_session* p_sess, int status, 00023 const char* p_text); 00024 00025 /* vsf_cmdio_write_hyphen() 00026 * PURPOSE 00027 * Write a response to the FTP control connection, with a hyphen '-' 00028 * continuation indicator. 00029 * PARAMETERS 00030 * p_sess - the current session object 00031 * status - the status code to report 00032 * p_text - the text to report 00033 */ 00034 void vsf_cmdio_write_hyphen(struct vsf_session* p_sess, int status, 00035 const char* p_text); 00036 00037 /* vsf_cmdio_write_raw() 00038 * PURPOSE 00039 * Write a raw response to the FTP control connection. A status code is 00040 * not prepended, and it is also the client's responsibility to include 00041 * newline characters if required. 00042 * PARAMETERS 00043 * p_sess - the current session object 00044 * p_text - the text to report 00045 */ 00046 void vsf_cmdio_write_raw(struct vsf_session* p_sess, const char* p_text); 00047 00048 /* vsf_cmdio_write_exit() 00049 * PURPOSE 00050 * The same as vsf_cmdio_write(), and then the calling process is exited. The 00051 * write is _guaranteed_ to not block (ditching output if neccessary). 00052 */ 00053 void vsf_cmdio_write_exit(struct vsf_session* p_sess, int status, 00054 const char* p_text); 00055 00056 /* vsf_cmdio_write_str() 00057 * PURPOSE 00058 * The same as vsf_cmdio_write(), apart from the text is specified as a 00059 * string buffer object "p_str". 00060 */ 00061 void vsf_cmdio_write_str(struct vsf_session* p_sess, int status, 00062 const struct mystr* p_str); 00063 00064 /* vsf_cmdio_write_str_hyphen() 00065 * PURPOSE 00066 * The same as vsf_cmdio_write_str(), apart from the response line is 00067 * output with the continuation indicator '-' between the response code and 00068 * the response text. This indicates there are more lines of response. 00069 */ 00070 void vsf_cmdio_write_str_hyphen(struct vsf_session* p_sess, int status, 00071 const struct mystr* p_str); 00072 00073 /* vsf_cmdio_set_alarm() 00074 * PURPOSE 00075 * Activate the control connection inactivity timeout. This is explicitly 00076 * exposed in the API so that we can play it safe, and activate the alarm 00077 * before _any_ potentially blocking calls. 00078 * PARAMETERS 00079 * p_sess - The current session object 00080 */ 00081 void vsf_cmdio_set_alarm(struct vsf_session* p_sess); 00082 00083 /* vsf_cmdio_get_cmd_and_arg() 00084 * PURPOSE 00085 * Read an FTP command (and optional argument) from the FTP control connection. 00086 * PARAMETERS 00087 * p_sess - The current session object 00088 * p_cmd_str - Where to put the FTP command string (may be empty) 00089 * p_arg_str - Where to put the FTP argument string (may be empty) 00090 * set_alarm - If true, the control connection inactivity monitor is used 00091 */ 00092 void vsf_cmdio_get_cmd_and_arg(struct vsf_session* p_sess, 00093 struct mystr* p_cmd_str, 00094 struct mystr* p_arg_str, int set_alarm); 00095 00096 #endif /* VSF_FTPCMDIO_H */ 00097