File: optimize.c

package info (click to toggle)
crda 4.14%2Bgit20191112.9856751-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 568 kB
  • sloc: ansic: 2,599; makefile: 195; python: 130; sh: 6
file content (40 lines) | stat: -rw-r--r-- 727 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <arpa/inet.h> /* ntohl */
#include <string.h>

#include "nl80211.h"
#include "reglib.h"

int main(int argc, char **argv)
{
	struct ieee80211_regdomain *rd = NULL, *rd_opt = NULL;
	FILE *fp;

	if (argc != 1) {
		fprintf(stderr, "Usage: cat db.txt | %s\n", argv[0]);
		return -EINVAL;
	}

	fp = reglib_create_parse_stream(stdin);
	if (!fp)
		return -EINVAL;

	reglib_for_each_country_stream(fp, rd) {
		rd_opt = reglib_optimize_regdom(rd);
		if (!rd_opt){
			fprintf(stderr, "Unable to optimize %c%c\n",
				rd->alpha2[0],
				rd->alpha2[1]);
			free(rd);
			continue;
		}
		reglib_print_regdom(rd_opt);
		free(rd);
		free(rd_opt);
	}

	fclose(fp);
	return 0;
}