usr.bin/dsynth/pkglist.c
/*
 * Parse packages from the list installed on the system.
 */
Parse packages from the list installed on the system.
Parse packages from the list installed on the system .
pkg_t *
GetLocalPackageList(void)
{
	pkg_t *list;
	FILE *fp;
	char *base;
	char *l1;
	char *l2;
	char *l3;
	int total;
	size_t len;
	initbulk(childGetPackageInfo, MaxBulk);
	total = 0;
	fp = popen("pkg info -a -o", "r");
	queuebulk("ports-mgmt", "pkg", NULL, "x");
	while ((base = fgetln(fp, &len)) != NULL) {
		if (len == 0 || base[len-1] != '\n')
			continue;
		base[--len] = 0;
		if (strtok(base, " \t") == NULL) {
			printf("Badly formatted pkg info line: %s\n", base);
			continue;
		}
		l1 = strtok(NULL, " \t");
		if (l1 == NULL) {
			printf("Badly formatted pkg info line: %s\n", base);
			continue;
		}
		l2 = strchr(l1, '/');
		if (l2 == NULL) {
			printf("Badly formatted specification: %s\n", l1);
			continue;
		}
		*l2++ = 0;
		l3 = strchr(l2, '@');
		if (l3)
			*l3++ = 0;
		queuebulk(l1, l2, l3, NULL);
		++total;
	}
	pclose(fp);
	printf("Processing %d ports\n", total);
	list = processPackageListBulk(total);
	return list;
}
pkg_t * GetLocalPackageList ( void ) { pkg_t * list ; FILE * fp ; char * base ; char * l1 ; char * l2 ; char * l3 ; int total ; size_t len ; initbulk ( childGetPackageInfo , MaxBulk ) ; total = 0 ; fp = popen ( " " , " " ) ; queuebulk ( " " , " " , NULL , " " ) ; while ( ( base = fgetln ( fp , & len ) ) != NULL ) { if ( len == 0 || base [ len - 1 ] != ' \n ' ) continue ; base [ -- len ] = 0 ; if ( strtok ( base , " \t " ) == NULL ) { printf ( " \n " , base ) ; continue ; } l1 = strtok ( NULL , " \t " ) ; if ( l1 == NULL ) { printf ( " \n " , base ) ; continue ; } l2 = strchr ( l1 , ' ' ) ; if ( l2 == NULL ) { printf ( " \n " , l1 ) ; continue ; } * l2 ++ = 0 ; l3 = strchr ( l2 , ' ' ) ; if ( l3 ) * l3 ++ = 0 ; queuebulk ( l1 , l2 , l3 , NULL ) ; ++ total ; } pclose ( fp ) ; printf ( " \n " , total ) ; list = processPackageListBulk ( total ) ; return list ; }
Parse packages from the list installed on the system.
Parse packages from the list installed on the system .
/*
	 * Always include ports-mgmt/pkg.  s4 is "x" meaning not a manual
	 * selection, "d" meaning DEBUGSTOP mode, or NULL.
	 */