Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Date: 2008-09-04 21:49:56-0400
Description:  This patch adds a new argument -wN or --wrap=N to
              fourmilab's base64, which can be found here:
               http://www.fourmilab.ch/webtools/base64/

License: This file is hereby released into the public domain.  
         Do with it what you like.  No Warranty of any sort.

--- base64-1.5/base64.w	2007-06-10 11:00:55.000000000 -0400
+++ base64-1.5.wraplen/base64.w	2008-09-04 21:34:15.000000000 -0400
@@ -48,7 +48,7 @@
 @** Program global context.
 @d TRUE  1
 @d FALSE 0
-@d LINELEN 72  /* Encoded line length (max 76) */
+@d LINELEN 72  /* Default encoded line length (max 76) */
 @d MAXINLINE 256  /* Maximum input line length */
 
 @c
@@ -117,6 +117,7 @@
 #endif
     ;
 static int errcheck = TRUE;           /* Check decode input for errors ? */
+static int linelen = LINELEN;           /* Check decode input for errors ? */
 
 @** Input/output functions.
 
@@ -192,7 +193,7 @@
 
 static void ochar(int c)
 {
-    if (linelength >= LINELEN) {
+    if (linelen && linelength >= linelen) {
         if (fputs(eol, fo) == EOF) {
             exit(1);
         }
@@ -407,6 +408,7 @@
     printf("           -d, --decode      Decode base64 encoded file\n");
     printf("           -e, --encode      Encode file into base64\n");
     printf("           -n, --noerrcheck  Ignore errors when decoding\n");
+    printf("           -w, --wide=N      Wrap at N characters (default: %d) \n", LINELEN);
     printf("           -u, --help        Print this message\n");
     printf("           --version         Print version number\n");
     printf("\n");
@@ -455,7 +457,7 @@
 permits aggregation of options without arguments and
 both \.{-d}{\it arg} and \.{-d} {\it arg} syntax.
 @<Process command-line options@>=
-    while ((opt = getopt(argc, argv, "denu-:")) != -1) {
+    while ((opt = getopt(argc, argv, "denuw:-:")) != -1) {
         switch (opt) {
             case 'd':             /* -d  Decode */
                 decoding = TRUE;
@@ -488,6 +490,10 @@
                         decoding = FALSE;
                         break;
 
+                    case 'w':     /* -wrap=NNN */
+                        linelen = atoi(optarg+5);
+                        break;
+
                     case 'h':     /* --help */
                         usage();
                         return 0;
--- base64-1.5/base64.1	2005-04-13 08:34:22.000000000 -0400
+++ base64-1.5.wraplen/base64.1	2008-09-04 21:38:26.000000000 -0400
@@ -12,6 +12,10 @@
 .B \-u
 ]
 [
+.B \-w 
+.B N
+]
+[
 .I infile
 [
 .I outfile
@@ -45,6 +49,10 @@
 Encodes the input into an output text file containing
 its base64 encoding.
 .TP
+.BR "\-w N" ", " \-\-wrap=N
+Wrap lines at N characters (72 characters is the default).  Set to 0
+to never wrap.
+.TP
 .BR \-n ", " \-\-noerrcheck
 Suppress error checking when decoding.  By default, upon encountering
 a non white space character which does not belong to the base64

