2
Copyright (C) 2003-2004 Douglas Thain and the University of Wisconsin
3
Copyright (C) 2005- The University of Notre Dame
4
This software is distributed under the GNU General Public License.
5
See the file COPYING for details.
9
This product includes software developed by and/or derived
10
from the Globus Project (http://www.globus.org/)
11
to which the U.S. Government retains certain rights.
15
This file in particular was adapted from the Globus toolkit.
16
These functions encode binary data in base 64 ascii. They
17
were adapted from similarly-named functions in globus_ftp_control_client.c
25
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
27
static char pad = '=';
29
int ftp_lite_radix_encode( const unsigned char * inbuf, unsigned char * outbuf, int * length )
35
for (i=0,j=0; i < *length; i++)
40
outbuf[j++] = radixN[inbuf[i]>>2];
44
outbuf[j++] = radixN[c|inbuf[i]>>4];
48
outbuf[j++] = radixN[c|inbuf[i]>>6];
49
outbuf[j++] = radixN[inbuf[i]&63];
56
outbuf[j++] = radixN[c];
67
outbuf[*length = j] = '\0';
72
int ftp_lite_radix_decode( const unsigned char *inbuf, unsigned char *outbuf, int * length )
79
for (i=0,j=0; inbuf[i] && inbuf[i] != pad; i++)
82
if ((p = strchr(radixN, inbuf[i])) == NULL)
95
outbuf[j] = (D&15)<<4;
114
if (strcmp((char *)&inbuf[i], "=="))
124
if (strcmp((char *)&inbuf[i], "="))