From: "Luis R. Rodriguez" <mcgrof@xxxxxxxxxxxxxxxx> We'll later move this to reglib but first we have to clean up the print utility to make it more general. Signed-off-by: Luis R. Rodriguez <mcgrof at do-not-panic.com> --- regdbdump.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/regdbdump.c b/regdbdump.c index ea14730..edf3e7c 100644 --- a/regdbdump.c +++ b/regdbdump.c @@ -2,26 +2,35 @@ #include <errno.h> #include "reglib.h" -int main(int argc, char **argv) +static int reglib_regdbdump(char *regdb_file) { const struct ieee80211_regdomain *rd = NULL; unsigned int idx = 0; - if (argc != 2) { - fprintf(stderr, "Usage: %s <filename>\n", argv[0]); - return 2; - } - - reglib_for_each_country(rd, idx, argv[1]) { + reglib_for_each_country(rd, idx, regdb_file) { reglib_print_regdom(rd); free((struct ieee80211_regdomain *) rd); } if (!idx) { - printf("Invalid or empty regulatory file, note: " + fprintf(stderr, "Invalid or empty regulatory file, note: " "a binary regulatory file should be used.\n"); return -EINVAL; } return 0; } + +int main(int argc, char **argv) +{ + int r; + + if (argc != 2) { + fprintf(stderr, "Usage: %s <regulatory-binary-file>\n", argv[0]); + return 2; + } + + r = reglib_regdbdump(argv[1]); + + return r; +} -- 1.7.10.4