#pragma prototyped
#include "pax.h"
void
convert(Archive_t* ap, int section, int from, int to)
{
if (ap->convert[section].on = (ap->convert[section].f2t = ccmap(from, to)) != 0)
{
ap->convert[section].t2f = ccmap(to, from);
ap->convert[section].f2a = ccmap(from, CC_ASCII);
ap->convert[section].t2a = ccmap(to, CC_ASCII);
}
}
char*
strlower(register char* s)
{
register int c;
register char* t;
for (t = s; c = *t; t++)
if (isupper(c))
*t = tolower(c);
return s;
}
char*
strupper(register char* s)
{
register int c;
register char* t;
for (t = s; c = *t; t++)
if (islower(c))
*t = toupper(c);
return s;
}
int
portable(Archive_t* ap, const char* s)
{
register unsigned char* u = (unsigned char*)s;
register unsigned char* m;
register int c;
if (!ap->convert[SECTION_CONTROL].on)
{
while (c = *u++)
if (c > 0177)
return 0;
}
else
{
m = ap->convert[SECTION_CONTROL].f2t;
while (c = m[*u++])
if (c > 0177)
return 0;
}
return 1;
}
#undef OHASHPART
#define OHASHPART(b,h,c,l,r) (h = ((h = ((unsigned)h << (l)) ^ (h >> (r)) ^ (c)) & ((unsigned)1 << (b)) ? ~h : h) & (((((unsigned)1 << ((b) - 1)) - 1) << 2) | 3))
#undef OHASHLPART
#define OHASHLPART(h,c) OHASHPART(31, h, c, 3, 2)
unsigned long
omemsum(const void* b, int n, register unsigned long c)
{
register unsigned char* p;
register unsigned char* e;
p = (unsigned char*)b;
e = p + n;
while (p < e) OHASHLPART(c, *p++ + 1);
return c;
}