NetBSD/sys/isofs/isofs_util.c

136 lines
1.8 KiB
C
Raw Normal View History

1993-05-20 07:30:41 +04:00
/*
* $Id: isofs_util.c,v 1.2 1993/05/20 03:30:52 cgd Exp $
*/
1993-03-21 12:45:37 +03:00
int
isonum_711 (p)
char *p;
{
return (*p & 0xff);
}
int
isonum_712 (p)
char *p;
{
int val;
val = *p;
if (val & 0x80)
val |= 0xffffff00;
return (val);
}
int
isonum_721 (p)
char *p;
{
return ((p[0] & 0xff) | ((p[1] & 0xff) << 8));
}
int
isonum_722 (p)
char *p;
{
return (((p[0] & 0xff) << 8) | (p[1] & 0xff));
}
int
isonum_723 (p)
char *p;
{
#if 0
if (p[0] != p[3] || p[1] != p[2]) {
fprintf (stderr, "invalid format 7.2.3 number\n");
exit (1);
}
#endif
return (isonum_721 (p));
}
int
isonum_731 (p)
char *p;
{
return ((p[0] & 0xff)
| ((p[1] & 0xff) << 8)
| ((p[2] & 0xff) << 16)
| ((p[3] & 0xff) << 24));
}
int
isonum_732 (p)
char *p;
{
return (((p[0] & 0xff) << 24)
| ((p[1] & 0xff) << 16)
| ((p[2] & 0xff) << 8)
| (p[3] & 0xff));
}
int
isonum_733 (p)
char *p;
{
int i;
#if 0
for (i = 0; i < 4; i++) {
if (p[i] != p[7-i]) {
fprintf (stderr, "bad format 7.3.3 number\n");
exit (1);
}
}
#endif
return (isonum_731 (p));
}
/*
* translate and compare a filename
*/
isofncmp(char *fn, int fnlen, char *isofn, int isolen) {
int fnidx;
fnidx = 0;
for (fnidx = 0; fnidx < isolen; fnidx++, fn++) {
char c = *isofn++;
if (fnidx > fnlen)
return (0);
if (c >= 'A' && c <= 'Z') {
if (c + ('a' - 'A') != *fn)
return(0);
else
continue;
}
if (c == ';')
return ((fnidx == fnlen));
if (c != *fn)
return (0);
}
return (1);
}
/*
* translate a filename
*/
void
isofntrans(char *infn, int infnlen, char *outfn, short *outfnlen) {
int fnidx;
fnidx = 0;
for (fnidx = 0; fnidx < infnlen; fnidx++) {
char c = *infn++;
if (c >= 'A' && c <= 'Z')
*outfn++ = c + ('a' - 'A');
else if (c == ';') {
*outfnlen = fnidx;
return;
} else
*outfn++ = c;
}
*outfnlen = infnlen;
}