home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-386-Vol-2of3.iso
/
b
/
bootp.zip
/
NVAL.C
< prev
next >
Wrap
Text File
|
1992-04-13
|
2KB
|
120 lines
extern unsigned long rdvct();
extern unsigned long peekl();
unsigned long default_nval_mul = 10l;
char *nval( s, np )
char *s;
unsigned long *np;
{
unsigned long l;
int hex;
unsigned long mul;
int first;
int dptr;
int i;
unsigned char *s1;
l = 0l;
hex = 0;
mul = default_nval_mul;
first = 1;
dptr = 0;
if( mul == 16 ) hex = 1;
while(*s)
{
if( (*s) == '&' )
dptr = 1;
else if( (toupper(*s)&0x0FF) == 'X' )
{
hex = 1;
mul = 16;
}
else if( isdigit( *s ) )
l = l*mul + *s - '0';
else if( hex && ((toupper(*s)&0x0FF) >= 'A') && ((toupper(*s)&0x0FF) <= 'F') )
l = l*mul + (toupper(*s)&0x0FF) - 'A' + 10;
else
{
if( first ) return(0l);
s++;
break;
}
first = 0;
s++;
}
if( dptr )
{
*np = peekl( rdvct(0x049) + l );
for( i=0; i<4; i++ )
{
s1 = peekl( rdvct(0x049) + 17 + i ); /* serial number */
if( (!isspace( s1 )) && (!isdigit( s1 )) )
{
pmsg( "ROM bad or not found\r\n" );
*np = 0l;
break;
}
}
}
else
*np = l;
return( s );
}
extern char *strstr();
do_one_arg( cmd, cmds, lptr, len )
char *cmd;
char *cmds;
unsigned long *lptr;
int len;
{
char *s;
unsigned long n;
unsigned char *cptr;
unsigned int *iptr;
int j;
iptr = cptr = lptr;
if( s = strstr( cmd, cmds ) )
{
s += strlen( cmds );
if( s = nval( s, &n ) )
{
if( len == 1 )
*cptr = n;
else if( len == 2 )
*iptr = n;
else if( len == 3 )
{
*iptr = (n & 0x0FFFFl);
cptr += 2;
*cptr = (n & 0x00FF0000l) >> 16;
}
else if( len == 4 )
{
*lptr = n;
if( s && *s )
{
for( j=1; (j<4) && s; j++ )
{
if( !(s = nval( s, &n ) ) ) break;
*lptr = *lptr | (n << (j*8));
}
}
}
else
return(0);
return(1);
}
}
return(0);
}