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 VSFTP_ASCII_H
18#define VSFTP_ASCII_H
19
20struct mystr;
21
22/* vsf_ascii_ascii_to_bin()
23 * PURPOSE
24 * This function converts an input buffer from ascii format to binary format.
25 * This entails ripping out all occurences of '\r' that are followed by '\n'.
26 *  The result is stored in "p_out".
27 * PARAMETERS
28 * p_in         - the input and output buffer, which MUST BE at least as big as
29 *                "in_len" PLUS ONE. This is to cater for a leading '\r' in the
30 *                buffer if certain conditions are met.
31 * in_len       - the length in bytes of the  buffer.
32 * prev_cr      - set to non-zero if this buffer fragment was immediately
33 *                preceeded by a '\r'.
34 * RETURNS
35 * The number of characters stored in the buffer, the buffer address, and
36 * if we ended on a '\r'.
37 */
38struct ascii_to_bin_ret
39{
40  unsigned int stored;
41  int last_was_cr;
42  char* p_buf;
43};
44struct ascii_to_bin_ret vsf_ascii_ascii_to_bin(
45  char* p_in, unsigned int in_len, int prev_cr);
46
47/* vsf_ascii_bin_to_ascii()
48 * PURPOSE
49 * This function converts an input buffer from binary format to ascii format.
50 * This entails replacing all occurences of '\n' with '\r\n'. The result is
51 * stored in "p_out".
52 * PARAMETERS
53 * p_in         - the input buffer, which is not modified
54 * p_out        - the output buffer, which MUST BE at least TWICE as big as
55 *                "in_len"
56 * in_len       - the length in bytes of the input buffer
57 * RETURNS
58 * The number of characters stored in the output buffer
59 */
60unsigned int vsf_ascii_bin_to_ascii(const char* p_in, char* p_out,
61                                    unsigned int in_len);
62
63#endif /* VSFTP_ASCII_H */
64
65