1#ifndef VSFTP_ASCII_H 2#define VSFTP_ASCII_H 3 4struct mystr; 5 6/* vsf_ascii_ascii_to_bin() 7 * PURPOSE 8 * This function converts an input buffer from ascii format to binary format. 9 * This entails ripping out all occurences of '\r' that are followed by '\n'. 10 * The result is stored in "p_out". 11 * PARAMETERS 12 * p_in - the input and output buffer, which MUST BE at least as big as 13 * "in_len" PLUS ONE. This is to cater for a leading '\r' in the 14 * buffer if certain conditions are met. 15 * in_len - the length in bytes of the buffer. 16 * prev_cr - set to non-zero if this buffer fragment was immediately 17 * preceeded by a '\r'. 18 * RETURNS 19 * The number of characters stored in the buffer, the buffer address, and 20 * if we ended on a '\r'. 21 */ 22struct ascii_to_bin_ret 23{ 24 unsigned int stored; 25 int last_was_cr; 26 char* p_buf; 27}; 28struct ascii_to_bin_ret vsf_ascii_ascii_to_bin( 29 char* p_in, unsigned int in_len, int prev_cr); 30 31/* vsf_ascii_bin_to_ascii() 32 * PURPOSE 33 * This function converts an input buffer from binary format to ascii format. 34 * This entails replacing all occurences of '\n' with '\r\n'. The result is 35 * stored in "p_out". 36 * PARAMETERS 37 * p_in - the input buffer, which is not modified 38 * p_out - the output buffer, which MUST BE at least TWICE as big as 39 * "in_len" 40 * in_len - the length in bytes of the input buffer 41 * RETURNS 42 * The number of characters stored in the output buffer 43 */ 44unsigned int vsf_ascii_bin_to_ascii(const char* p_in, char* p_out, 45 unsigned int in_len); 46 47#endif /* VSFTP_ASCII_H */ 48 49