regdbdump.c 900 Bytes
Newer Older
1
#include <stdio.h>
2
#include <errno.h>
3
#include "reglib.h"
4

5
static void reglib_regdbdump(const struct reglib_regdb_ctx *ctx)
6
{
7
	const struct ieee80211_regdomain *rd = NULL;
8
	unsigned int idx = 0;
9

10
	reglib_for_each_country(rd, idx, ctx) {
11 12 13 14 15
		if (!reglib_is_valid_rd(rd)) {
			fprintf(stderr, "country %.2s: invalid\n", rd->alpha2);
			free((struct ieee80211_regdomain *) rd);
			continue;
		}
16
		reglib_print_regdom(rd);
17
		free((struct ieee80211_regdomain *) rd);
18
	}
19
}
20 21 22

int main(int argc, char **argv)
{
23
	const struct reglib_regdb_ctx *ctx;
24 25 26

	if (argc != 2) {
		fprintf(stderr, "Usage: %s <regulatory-binary-file>\n", argv[0]);
27 28 29 30 31 32 33 34
		return -EINVAL;
	}

	ctx = reglib_malloc_regdb_ctx(argv[1]);
	if (!ctx) {
		fprintf(stderr, "Invalid or empty regulatory file, note: "
			"a binary regulatory file should be used.\n");
		return -EINVAL;
35 36
	}

37 38
	reglib_regdbdump(ctx);
	reglib_free_regdb_ctx(ctx);
39

40
	return 0;
41
}