Skip to content

Commit

Permalink
pdbt and pdb_server: add version output to help and as a dedicated sw…
Browse files Browse the repository at this point in the history
…itch
  • Loading branch information
henningw committed Jun 20, 2018
1 parent f42e542 commit 04fffc7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 9 additions & 3 deletions utils/pdbt/pdb_server.c
Expand Up @@ -40,8 +40,8 @@

void print_usage(char *program) {
set_log_level(LOG_INFO);
LINFO("Listens on a UDP port for queries and sends answer UDP\n");
LINFO("packets back.\n");
LINFO("version: pdb_server %d\n", PDB_VERSION);
LINFO("Listens on a UDP port for queries and sends answer UDP packets back.\n");
LINFO("\n");
LINFO("Usage: %s [<option>...]\n", program);
LINFO(" %s -m <data file> [-i <bind addr>] [-p <port>] [-d <log level>]\n", program);
Expand All @@ -62,6 +62,7 @@ void print_usage(char *program) {
LINFO(" %ld for emergency level.\n", LOG_EMERG);
LINFO(" %ld to disable all messages.\n", LOG_EMERG-1);
LINFO(" Default is warning level.\n");
LINFO(" -v: Print the version\n");
LINFO(" -h: Print this help.\n");
}

Expand Down Expand Up @@ -212,7 +213,7 @@ int main(int argc, char *argv[]) {
int so;
struct sockaddr_in sa;

while ((opt = getopt(argc, argv, "m:i:p:hdl:")) != -1) {
while ((opt = getopt(argc, argv, "m:i:p:vhdl:")) != -1) {
switch (opt) {
case 'm':
backend_data_filename = optarg;
Expand All @@ -229,6 +230,11 @@ int main(int argc, char *argv[]) {
}
bind_port=ret;
break;
case 'v':
set_log_level(LOG_INFO);
LINFO("version: pdb_server %d\n", PDB_VERSION);
return 0;
break;
case 'h':
init_log("pdb_server", use_syslog);
print_usage(argv[0]);
Expand Down
9 changes: 8 additions & 1 deletion utils/pdbt/pdbt.c
Expand Up @@ -50,6 +50,7 @@ typedef int (*query_func_t)(char *number, char *comment, void *data);

void print_usage(char *program) {
set_log_level(LOG_INFO);
LINFO("version: pdbt %d\n", PDB_VERSION);
LINFO("Usage: %s [<option>...] <command> [<param>...]\n", program);
LINFO(" %s -s <csv file> -m <mmap file> [-k <ids>] [-o] [-u <tree file>] [-l <log level>] build\n", program);
LINFO(" %s (-m <mmap file>|-r <host>:<port>) [-q <timeout>] [-f <query file>] [-t <carrier text file>] [-l <log level>] query <number>...\n", program);
Expand Down Expand Up @@ -93,6 +94,7 @@ void print_usage(char *program) {
LINFO(" %ld for emergency level.\n", LOG_EMERG);
LINFO(" %ld to disable all messages.\n", LOG_EMERG-1);
LINFO(" Default is info level.\n");
LINFO(" -v: Print the version\n");
LINFO(" -h: Print this help.\n");
}

Expand Down Expand Up @@ -678,7 +680,7 @@ int main(int argc, char *argv[]) {

init_log("pdbt", 0);

while ((opt = getopt(argc, argv, "s:m:f:u:t:r:q:k:ol:h")) != -1) {
while ((opt = getopt(argc, argv, "s:m:f:u:t:r:q:k:ol:vh")) != -1) {
switch (opt) {
case 's':
csv_file = optarg;
Expand Down Expand Up @@ -752,6 +754,11 @@ int main(int argc, char *argv[]) {
}
log_level=ret;
break;
case 'v':
set_log_level(LOG_INFO);
LINFO("version: pdbt %d\n", PDB_VERSION);
return 0;
break;
case 'h':
print_usage(argv[0]);
return 0;
Expand Down

0 comments on commit 04fffc7

Please sign in to comment.