P8000/WEGA/contrib/lcc/lib/libc/port/gen/a64l.c

25 lines
387 B
C

/*
* convert base 64 ascii to long int
* char set is [./0-9A-Za-z]
*
*/
#define BITSPERCHAR 6 /* to hold entire character set */
long
a64l(s)
register char *s;
{
register int i, c;
long lg = 0;
for (i = 0; (c = *s++) != '\0'; i += BITSPERCHAR) {
if (c > 'Z')
c -= 'a' - 'Z' - 1;
if (c > '9')
c -= 'A' - '9' - 1;
lg |= (long)(c - ('0' - 2)) << i;
}
return (lg);
}