X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fpb-discover.c;h=fd370685653f979419943ee03db5c3b64f311f5f;hp=713d99d3cee1cdcd1061164a017447df5bc5962e;hb=b5f9e34d85075afe7aa87b5ce4a1a2d911468e36;hpb=edcfca78ac49793e295ac97328942321f39e3996 diff --git a/discover/pb-discover.c b/discover/pb-discover.c index 713d99d..fd37068 100644 --- a/discover/pb-discover.c +++ b/discover/pb-discover.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "discover-server.h" #include "device-handler.h" @@ -29,7 +30,7 @@ static void print_usage(void) print_version(); printf( "Usage: pb-discover [-a, --no-autoboot] [-h, --help] [-l, --log log-file]\n" -" [-n, --dry-run] [-V, --version]\n"); +" [-n, --dry-run] [-v, --verbose] [-V, --version]\n"); } /** @@ -48,6 +49,7 @@ struct opts { const char *log_file; enum opt_value dry_run; enum opt_value show_version; + enum opt_value verbose; }; /** @@ -61,14 +63,16 @@ static int opts_parse(struct opts *opts, int argc, char *argv[]) {"help", no_argument, NULL, 'h'}, {"log", required_argument, NULL, 'l'}, {"dry-run", no_argument, NULL, 'n'}, + {"verbose", no_argument, NULL, 'v'}, {"version", no_argument, NULL, 'V'}, { NULL, 0, NULL, 0}, }; - static const char short_options[] = "ahl:nV"; + static const char short_options[] = "ahl:nvV"; static const struct opts default_values = { .no_autoboot = opt_no, .log_file = "/var/log/petitboot/pb-discover.log", .dry_run = opt_no, + .verbose = opt_no, }; *opts = default_values; @@ -93,6 +97,9 @@ static int opts_parse(struct opts *opts, int argc, char *argv[]) case 'n': opts->dry_run = opt_yes; break; + case 'v': + opts->verbose = opt_yes; + break; case 'V': opts->show_version = opt_yes; break; @@ -121,6 +128,10 @@ int main(int argc, char *argv[]) struct opts opts; FILE *log; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + if (opts_parse(&opts, argc, argv)) { print_usage(); return EXIT_FAILURE; @@ -147,6 +158,9 @@ int main(int argc, char *argv[]) } pb_log_init(log); + if (opts.verbose == opt_yes) + pb_log_set_debug(true); + pb_log("--- pb-discover ---\n"); /* we look for closed sockets when we write, so ignore SIGPIPE */ @@ -168,6 +182,12 @@ int main(int argc, char *argv[]) if (opts.no_autoboot == opt_yes) config_set_autoboot(false); + if (config_get()->lang) + setlocale(LC_ALL, config_get()->lang); + + if (config_get()->debug) + pb_log_set_debug(true); + system_info_init(server); handler = device_handler_init(server, waitset, opts.dry_run == opt_yes);