X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fodhcpd.git;a=blobdiff_plain;f=src%2Fodhcpd.c;h=e83a7007c36b3701f4e2ce272c4b44710d7dcec4;hp=6f034bff4e8a99d383aed5c41a2c607d1d3c8521;hb=0b45fce0859e4726e27f408016ef2f7d210c847f;hpb=6292fcd5c2b73cdc3cbc8942672cf7a4173354b1 diff --git a/src/odhcpd.c b/src/odhcpd.c index 6f034bf..e83a700 100644 --- a/src/odhcpd.c +++ b/src/odhcpd.c @@ -54,11 +54,33 @@ static void sighandler(_unused int signal) uloop_end(); } +static void print_usage(const char *app) +{ + printf( + "== %s Usage ==\n\n" + " -h, --help Print this help\n" + " -l level Specify log level 0..7 (default %d)\n", + app, LOG_WARNING + ); +} -int main() +int main(int argc, char **argv) { openlog("odhcpd", LOG_PERROR | LOG_PID, LOG_DAEMON); - setlogmask(LOG_UPTO(LOG_WARNING)); + int opt; + int log_level = LOG_WARNING; + while ((opt = getopt(argc, argv, "hl:")) != -1) { + switch (opt) { + case 'h': + print_usage(argv[0]); + return 0; + case 'l': + log_level = atoi(optarg); + fprintf(stderr, "Log level set to %d\n", log_level); + break; + } + } + setlogmask(LOG_UPTO(log_level)); uloop_init(); if (getuid() != 0) {