Mercurial > hg > xemacs-beta
comparison src/fns.c @ 396:6719134a07c2 r21-2-13
Import from CVS: tag r21-2-13
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:12:05 +0200 |
parents | bbff43aa5eb7 |
children | 74fd4e045ea6 |
comparison
equal
deleted
inserted
replaced
395:de2c2a7459d2 | 396:6719134a07c2 |
---|---|
3560 | 3560 |
3561 *e++ = base64_value_to_char[value | (0x03 & c >> 6)]; | 3561 *e++ = base64_value_to_char[value | (0x03 & c >> 6)]; |
3562 *e++ = base64_value_to_char[0x3f & c]; | 3562 *e++ = base64_value_to_char[0x3f & c]; |
3563 } | 3563 } |
3564 | 3564 |
3565 /* Complete last partial line. */ | |
3566 if (line_break) | |
3567 if (counter > 0) | |
3568 *e++ = '\n'; | |
3569 | |
3570 return e - to; | 3565 return e - to; |
3571 } | 3566 } |
3572 #undef ADVANCE_INPUT | 3567 #undef ADVANCE_INPUT |
3573 | 3568 |
3574 #define ADVANCE_INPUT(c, stream) \ | 3569 #define ADVANCE_INPUT(c, stream) \ |
3753 | 3748 |
3754 /* We return the length of the encoded text. */ | 3749 /* We return the length of the encoded text. */ |
3755 return make_int (encoded_length); | 3750 return make_int (encoded_length); |
3756 } | 3751 } |
3757 | 3752 |
3758 DEFUN ("base64-encode-string", Fbase64_encode_string, 1, 1, 0, /* | 3753 DEFUN ("base64-encode-string", Fbase64_encode_string, 1, 2, 0, /* |
3759 Base64 encode STRING and return the result. | 3754 Base64 encode STRING and return the result. |
3760 */ | 3755 */ |
3761 (string)) | 3756 (string, no_line_break)) |
3762 { | 3757 { |
3763 Charcount allength, length; | 3758 Charcount allength, length; |
3764 Bytind encoded_length; | 3759 Bytind encoded_length; |
3765 Bufbyte *encoded; | 3760 Bufbyte *encoded; |
3766 Lisp_Object input, result; | 3761 Lisp_Object input, result; |
3767 int speccount = specpdl_depth(); | 3762 int speccount = specpdl_depth(); |
3768 | 3763 |
3769 CHECK_STRING (string); | 3764 CHECK_STRING (string); |
3770 | 3765 |
3771 length = XSTRING_CHAR_LENGTH (string); | 3766 length = XSTRING_CHAR_LENGTH (string); |
3772 allength = length + length/3 + 1 + 6; | 3767 allength = length + length/3 + 1; |
3768 allength += allength / MIME_LINE_LENGTH + 1 + 6; | |
3773 | 3769 |
3774 input = make_lisp_string_input_stream (string, 0, -1); | 3770 input = make_lisp_string_input_stream (string, 0, -1); |
3775 XMALLOC_OR_ALLOCA (encoded, allength, Bufbyte); | 3771 XMALLOC_OR_ALLOCA (encoded, allength, Bufbyte); |
3776 encoded_length = base64_encode_1 (XLSTREAM (input), encoded, 0); | 3772 encoded_length = base64_encode_1 (XLSTREAM (input), encoded, |
3773 NILP (no_line_break)); | |
3777 if (encoded_length > allength) | 3774 if (encoded_length > allength) |
3778 abort (); | 3775 abort (); |
3779 Lstream_delete (XLSTREAM (input)); | 3776 Lstream_delete (XLSTREAM (input)); |
3780 result = make_string (encoded, encoded_length); | 3777 result = make_string (encoded, encoded_length); |
3781 XMALLOC_UNBIND (encoded, allength, speccount); | 3778 XMALLOC_UNBIND (encoded, allength, speccount); |