/* base85.c : encode numbers using two different techniques for Base-85 * PUBLIC DOMAIN - Jon Mayo - September 10, 2008 */ #include #include #include /* define this to use PDF/adobe Ascii85 encoding * default is to use an encoding derived from RFC1924, except 32-bits at a time instead of 128-bits * yes, I realize that RFC1924 is a joke RFC */ // #define USE_ASCII85 #define NR(x) (sizeof(x)/sizeof*(x)) #define BASE85_DIGITS 5 /* log85 (2^32) is 4.9926740807112 */ #ifndef USE_ASCII85 /* rfc1924 :) */ static const unsigned char base85[85] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"; #else /* ascii85 (adobe) */ static const unsigned char base85[85] = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu"; #endif static signed char decode_table[UCHAR_MAX]; /* create a look up table suitable for convering characters to base85 digits */ static void base85_init(void) { unsigned char ch; assert((sizeof base85 == 85) && (base85[84] != 0)); /* make sure the array is exactly the right size */ for(ch=0;ch0 && i