httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug MacEachern <do...@pobox.com>
Subject ap_uuencode()
Date Tue, 04 Aug 1998 19:01:12 GMT
We already have ap_uudecode() and the functionality for an ap_uuencode() in
util_digest.c:ap_md5contextTo64, about pulling that out?

-Doug

static char basis_64[] = 
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 
 
API_EXPORT(char *) ap_uuencode(pool *a, char *string) 
{ 
    int i, len = strlen(string); 
    char *p; 
    char *encoded = (char *) ap_pcalloc(a, (len+2) / 3 * 4); 
 
    p = encoded; 
    for (i = 0; i < len; i += 3) { 
        *p++ = basis_64[string[i] >> 2]; 
        *p++ = basis_64[((string[i] & 0x3) << 4) | ((int) (string[i + 1] &
0xF0) >> 4)]; 
        *p++ = basis_64[((string[i + 1] & 0xF) << 2) | ((int) (string[i +
2] & 0xC0) >> 6)]; 
        *p++ = basis_64[string[i + 2] & 0x3F]; 
    } 
    *p-- = '\0'; 
    *p-- = '='; 
    *p-- = '='; 
    return encoded; 
} 


Mime
View raw message