#!/usr/bin/awk -f
# Disclaimer and Terms: You may use these scripts for commercial or
# non-commercial use at your own risk, as long as you retain the
# copyright statements in the source code. These scripts are provided
# "AS IS" with no warranty whatsoever and are FREE for as long as you
# want to use them. You can edit and adapt them to your requirements
# without seeking permission from me. I only ask that you retain the
# credits where they are due. 
#
# Author: Vishal Goenka <vgoenka@hotmail.com>
#
# Fold MIME Content at the given line length 
# Version 1.0
#
# Usage: fold.awk [width=<length to fold at>] <ldif file>
#              or
#        cat <ldif file> | fold.awk [width=<length to fold at>]
# and if /usr/bin/awk is not available,
#        awk [width=<length to fold at>] -f fold.awk <ldif file>
#
# This AWK script implements line delimiting and folding as described in
# "5.8.1 Line delimiting and folding" RFC2425.
#
# The parameter "width" can be used to change the length of the resulting
# lines. Folding defaults to 75 characters per line.
#
# On Solaris and other Unix environments, try nawk/gawk if you get an
# error with awk.
{
   if (!width) width=75;
   line = $0;
   do {
        print substr(line, 0, width);
        line = " " substr(line, width+1);
   }
   while (length(line) > 1);
}

Make your own free website on Tripod.com