misc.c revision a734c64bff58bda2fa48c2795453e092167b0ff7
/**************************************************************************
MISC Support Routines
**************************************************************************/
#include <stdlib.h>
#include <ctype.h>
#include <byteswap.h>
/**************************************************************************
INET_ATON - Convert an ascii x.x.x.x to binary form
**************************************************************************/
const char *p = cp;
const char *digits_start;
unsigned long ip = 0;
unsigned long val;
int j;
for(j = 0; j <= 3; j++) {
digits_start = p;
if ( ( j < 3 ) && ( *(p++) != '.' ) ) return 0;
}
if ( *p == '\0' ) {
return 1;
}
return 0;
}
unsigned long ret = 0;
int negative = 0;
unsigned int charval;
while ( isspace ( *p ) )
p++;
if ( *p == '-' ) {
negative = 1;
p++;
}
while ( 1 ) {
charval = strtoul_charval ( *p );
break;
p++;
}
if ( negative )
if ( endp )
*endp = ( char * ) p;
return ( ret );
}
/*
* Local variables:
* c-basic-offset: 8
* End:
*/