Skip to content

Commit

Permalink
Omit line breaks by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher J. Brody committed Dec 27, 2016
1 parent 2185b07 commit cb8f361
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Chris Venter [email protected] http://rocketpod.blogspot.com
Major changes:
--------------

- Line breaks disabled by default
- Include fixed for iOS build

Other versions:
Expand Down
6 changes: 6 additions & 0 deletions cencode.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ For details, see http://sourceforge.net/projects/libb64

#include "cencode.h"

#ifdef B64_ENCODE_LINE_BREAKS
const int CHARS_PER_LINE = 72;
#endif

void base64_init_encodestate(base64_encodestate* state_in)
{
Expand Down Expand Up @@ -73,11 +75,13 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
*codechar++ = base64_encode_value(result);

++(state_in->stepcount);
#ifdef B64_ENCODE_LINE_BREAKS
if (state_in->stepcount == CHARS_PER_LINE/4)
{
*codechar++ = '\n';
state_in->stepcount = 0;
}
#endif
}
}
/* control should not reach here */
Expand All @@ -102,7 +106,9 @@ int base64_encode_blockend(char* code_out, base64_encodestate* state_in)
case step_A:
break;
}
#ifdef B64_ENCODE_LINE_BREAKS
*codechar++ = '\n';
#endif

return codechar - code_out;
}

0 comments on commit cb8f361

Please sign in to comment.