static char *IGNORES[] = { "127.", // localhost "0:0:0:0:0:0:0:1", // localhost "ff02:0:0:0:0:1:", // (char*)0 }; // Return the size of the IGN table static int IGN_count() { int i = 0; while ( IGNORES[ i ] != 0 ) { i++; } return i; } /** * Compare an IP against an ignore entry of width w. * return 0 if ip starts with ign, <0 if ip < ign, and >0 if ip > ign */ static int IGN_cmp(const void *ipx, const void *ignx) { char *ip = (char *) ipx; char *ign = *(char**) ignx; while ( *ign ) { if ( *ip == 0 ) { return -1; } int c = *(ip++) - *(ign++); if ( c ) { return c; } } return 0; } static int ignored(char *ip) { static int IGN_size = -1; if ( IGN_size == -1 ) { IGN_size = IGN_count(); } return bsearch( ip, IGNORES, IGN_size, sizeof( char* ), IGN_cmp )? 1 : 0; }