aboutsummaryrefslogtreecommitdiff
path: root/mailutils/mail.c
diff options
context:
space:
mode:
Diffstat (limited to 'mailutils/mail.c')
-rw-r--r--mailutils/mail.c67
1 files changed, 0 insertions, 67 deletions
diff --git a/mailutils/mail.c b/mailutils/mail.c
index 8e52a3efc..89db66166 100644
--- a/mailutils/mail.c
+++ b/mailutils/mail.c
@@ -161,73 +161,6 @@ void FAST_FUNC encode_base64(char *fname, const char *text, const char *eol)
161#undef src_buf 161#undef src_buf
162} 162}
163 163
164void FAST_FUNC decode_base64(FILE *src_stream, FILE *dst_stream)
165{
166 int term_count = 1;
167
168 while (1) {
169 char translated[4];
170 int count = 0;
171
172 while (count < 4) {
173 char *table_ptr;
174 int ch;
175
176 /* Get next _valid_ character.
177 * global vector bb_uuenc_tbl_base64[] contains this string:
178 * "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n"
179 */
180 do {
181 ch = fgetc(src_stream);
182 if (ch == EOF) {
183 bb_error_msg_and_die(bb_msg_read_error);
184 }
185 // - means end of MIME section
186 if ('-' == ch) {
187 // push it back
188 ungetc(ch, src_stream);
189 return;
190 }
191 table_ptr = strchr(bb_uuenc_tbl_base64, ch);
192 } while (table_ptr == NULL);
193
194 /* Convert encoded character to decimal */
195 ch = table_ptr - bb_uuenc_tbl_base64;
196
197 if (*table_ptr == '=') {
198 if (term_count == 0) {
199 translated[count] = '\0';
200 break;
201 }
202 term_count++;
203 } else if (*table_ptr == '\n') {
204 /* Check for terminating line */
205 if (term_count == 5) {
206 return;
207 }
208 term_count = 1;
209 continue;
210 } else {
211 translated[count] = ch;
212 count++;
213 term_count = 0;
214 }
215 }
216
217 /* Merge 6 bit chars to 8 bit */
218 if (count > 1) {
219 fputc(translated[0] << 2 | translated[1] >> 4, dst_stream);
220 }
221 if (count > 2) {
222 fputc(translated[1] << 4 | translated[2] >> 2, dst_stream);
223 }
224 if (count > 3) {
225 fputc(translated[2] << 6 | translated[3], dst_stream);
226 }
227 }
228}
229
230
231/* 164/*
232 * get username and password from a file descriptor 165 * get username and password from a file descriptor
233 */ 166 */