2 * Part of Very Secure FTPd
7 * Routines to handle ASCII mode tranfers. Yuk.
12 struct ascii_to_bin_ret
13 vsf_ascii_ascii_to_bin(char* p_buf
, unsigned int in_len
, int prev_cr
)
15 /* Task: translate all \r\n into plain \n. A plain \r not followed by \n must
18 struct ascii_to_bin_ret ret
;
19 unsigned int indexx
= 0;
20 unsigned int written
= 0;
21 char* p_out
= p_buf
+ 1;
23 if (prev_cr
&& (!in_len
|| p_out
[0] != '\n'))
33 while (indexx
< in_len
)
35 char the_char
= p_buf
[indexx
+ 1];
41 else if (indexx
== in_len
- 1)
45 else if (p_buf
[indexx
+ 2] != '\n')
56 struct bin_to_ascii_ret
57 vsf_ascii_bin_to_ascii(const char* p_in
,
62 /* Task: translate all \n not preceeded by \r into \r\n.
63 * Note that \r\n stays as \r\n. We used to map it to \r\r\n like wu-ftpd
64 * but have switched to leaving it, like the more popular proftpd.
66 struct bin_to_ascii_ret ret
= { 0, 0 };
67 unsigned int indexx
= 0;
68 unsigned int written
= 0;
75 while (indexx
< in_len
)
77 char the_char
= p_in
[indexx
];
78 if (the_char
== '\n' && last_char
!= '\r')