FreeBSD/sys/dev/pci/pci.c
/*
 * Assuming (ptr) points to the beginning of a line in the database,
 * return the vendor or device and description of the next entry.
 * The value of (vendor) or (device) inappropriate for the entry type
 * is set to -1.  Returns nonzero at the end of the database.
 *
 * Note that this is slightly unrobust in the face of corrupt data;
 * we attempt to safeguard against this by spamming the end of the
 * database with a newline when we initialise.
 */
Assuming (ptr) points to the beginning of a line in the database,
return the vendor or device and description of the next entry.
The value of (vendor) or (device) inappropriate for the entry type
is set to -1.  Returns nonzero at the end of the database.

Note that this is slightly unrobust in the face of corrupt data;
we attempt to safeguard against this by spamming the end of the
database with a newline when we initialise.
Assuming ( ptr ) points to the beginning of a line in the database return the vendor or device and description of the next entry . The value of ( vendor ) or ( device ) inappropriate for the entry type is set to - 1 . Returns nonzero at the end of the database . Note that this is slightly unrobust in the face of corrupt data ; we attempt to safeguard against this by spamming the end of the database with a newline when we initialise .
static int
pci_describe_parse_line(char **ptr, int *vendor, int *device, char **desc)
{
	char	*cp = *ptr;
	int	left;
	*device = -1;
	*vendor = -1;
	**desc = '\0';
	for (;;) {
		left = pci_vendordata_size - (cp - pci_vendordata);
		if (left <= 0) {
			*ptr = cp;
			return(1);
		}
		if (*cp != '\t' &&
		    sscanf(cp, "%x\t%80[^\n]", vendor, *desc) == 2)
			break;
		if (*cp == '\t' &&
		    sscanf(cp, "%x\t%80[^\n]", device, *desc) == 2)
			break;
		while (*cp != '\n' && left > 0) {
			cp++;
			left--;
		}
		if (*cp == '\n') {
			cp++;
			left--;
		}
	}
	while (*cp != '\n' && left > 0) {
		cp++;
		left--;
	}
	if (*cp == '\n' && left > 0)
		cp++;
	*ptr = cp;
	return(0);
}
static int pci_describe_parse_line ( char * * ptr , int * vendor , int * device , char * * desc ) { char * cp = * ptr ; int left ; * device = -1 ; * vendor = -1 ; * * desc = ' \0 ' ; for ( ; ; ) { left = pci_vendordata_size - ( cp - pci_vendordata ) ; if ( left <= 0 ) { * ptr = cp ; return ( 1 ) ; } if ( * cp != ' \t ' && sscanf ( cp , " \t \n " , vendor , * desc ) == 2 ) break ; if ( * cp == ' \t ' && sscanf ( cp , " \t \n " , device , * desc ) == 2 ) break ; while ( * cp != ' \n ' && left > 0 ) { cp ++ ; left -- ; } if ( * cp == ' \n ' ) { cp ++ ; left -- ; } } while ( * cp != ' \n ' && left > 0 ) { cp ++ ; left -- ; } if ( * cp == ' \n ' && left > 0 ) cp ++ ; * ptr = cp ; return ( 0 ) ; }
Assuming (ptr) points to the beginning of a line in the database,
 return the vendor or device and description of the next entry.
Assuming ( ptr ) points to the beginning of a line in the database return the vendor or device and description of the next entry .
/* vendor entry? */ /* device entry? */ /* skip to next line */ /* skip to next line */