print_rule(&pr.rule, opts & PF_OPT_VERBOSE2);
print_rule(&pr.rule, rule_numbers);
pfctl_show_rules(int dev, int opts, int format){	struct pfioc_rule pr;	u_int32_t nr, mnr;	if (*anchorname && !*rulesetname) {		struct pfioc_ruleset pr;		int r;		memset(&pr, 0, sizeof(pr));		memcpy(pr.anchor, anchorname, sizeof(pr.anchor));		if (ioctl(dev, DIOCGETRULESETS, &pr)) {			if (errno == EINVAL)				fprintf(stderr, "No rulesets in anchor '%s'.\n",				    anchorname);			else				warn("DIOCGETRULESETS");			return (-1);		}		mnr = pr.nr;		for (nr = 0; nr < mnr; ++nr) {			pr.nr = nr;			if (ioctl(dev, DIOCGETRULESET, &pr)) {				warn("DIOCGETRULESET");				return (-1);			}			memcpy(rulesetname, pr.name, sizeof(rulesetname));			r = pfctl_show_rules(dev, opts, format);			memset(rulesetname, 0, sizeof(rulesetname));			if (r)				return (r);		}		return (0);	}	memset(&pr, 0, sizeof(pr));	memcpy(pr.anchor, anchorname, sizeof(pr.anchor));	memcpy(pr.ruleset, rulesetname, sizeof(pr.ruleset));	pr.rule.action = PF_SCRUB;	if (ioctl(dev, DIOCGETRULES, &pr)) {		warn("DIOCGETRULES");		return (-1);	}	mnr = pr.nr;	for (nr = 0; nr < mnr; ++nr) {		pr.nr = nr;		if (ioctl(dev, DIOCGETRULE, &pr)) {			warn("DIOCGETRULE");			return (-1);		}		if (pfctl_get_pool(dev, &pr.rule.rpool,		    nr, pr.ticket, PF_SCRUB) != 0)			return (-1);		switch (format) {		case 1:			if (pr.rule.label[0]) {				if (opts & PF_OPT_VERBOSE)					print_rule(&pr.rule,					    opts & PF_OPT_VERBOSE2);				else					printf("%s ", pr.rule.label);				printf("%llu %llu %llu\n",				    pr.rule.evaluations, pr.rule.packets,				    pr.rule.bytes);			}			break;		default:			print_rule(&pr.rule, opts & PF_OPT_VERBOSE2);			pfctl_print_rule_counters(&pr.rule, opts);		}		pfctl_clear_pool(&pr.rule.rpool);	}	pr.rule.action = PF_PASS;	if (ioctl(dev, DIOCGETRULES, &pr)) {		warn("DIOCGETRULES");		return (-1);	}	mnr = pr.nr;	for (nr = 0; nr < mnr; ++nr) {		pr.nr = nr;		if (ioctl(dev, DIOCGETRULE, &pr)) {			warn("DIOCGETRULE");			return (-1);		}		if (pfctl_get_pool(dev, &pr.rule.rpool,		    nr, pr.ticket, PF_PASS) != 0)			return (-1);		switch (format) {		case 1:			if (pr.rule.label[0]) {				if (opts & PF_OPT_VERBOSE)					print_rule(&pr.rule,					    opts & PF_OPT_VERBOSE2);				else					printf("%s ", pr.rule.label);				printf("%llu %llu %llu\n",				    pr.rule.evaluations, pr.rule.packets,				    pr.rule.bytes);			}			break;		default:			print_rule(&pr.rule, opts & PF_OPT_VERBOSE2);			pfctl_print_rule_counters(&pr.rule, opts);		}		pfctl_clear_pool(&pr.rule.rpool);	}	return (0);}