00001 #ifndef VSFTP_ASCII_H 00002 #define VSFTP_ASCII_H 00003 00004 struct mystr; 00005 00006 /* vsf_ascii_ascii_to_bin() 00007 * PURPOSE 00008 * This function converts an input buffer from ascii format to binary format. 00009 * This entails ripping out all occurences of '\r' that are followed by '\n'. 00010 * The result is stored in "p_out". 00011 * PARAMETERS 00012 * p_in - the input and output buffer, which MUST BE at least as big as 00013 * "in_len" PLUS ONE. This is to cater for a leading '\r' in the 00014 * buffer if certain conditions are met. 00015 * in_len - the length in bytes of the buffer. 00016 * prev_cr - set to non-zero if this buffer fragment was immediately 00017 * preceeded by a '\r'. 00018 * RETURNS 00019 * The number of characters stored in the buffer, the buffer address, and 00020 * if we ended on a '\r'. 00021 */ 00022 struct ascii_to_bin_ret 00023 { 00024 unsigned int stored; 00025 int last_was_cr; 00026 char* p_buf; 00027 }; 00028 struct ascii_to_bin_ret vsf_ascii_ascii_to_bin( 00029 char* p_in, unsigned int in_len, int prev_cr); 00030 00031 /* vsf_ascii_bin_to_ascii() 00032 * PURPOSE 00033 * This function converts an input buffer from binary format to ascii format. 00034 * This entails replacing all occurences of '\n' with '\r\n'. The result is 00035 * stored in "p_out". 00036 * PARAMETERS 00037 * p_in - the input buffer, which is not modified 00038 * p_out - the output buffer, which MUST BE at least TWICE as big as 00039 * "in_len" 00040 * in_len - the length in bytes of the input buffer 00041 * RETURNS 00042 * The number of characters stored in the output buffer 00043 */ 00044 unsigned int vsf_ascii_bin_to_ascii(const char* p_in, char* p_out, 00045 unsigned int in_len); 00046 00047 #endif /* VSFTP_ASCII_H */ 00048