summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-07-27 18:29:32 -0700
committerMarcel Holtmann <marcel@holtmann.org>2010-07-27 18:29:32 -0700
commit53fd2c3bf958859f6b518681ff65f5dff9e23f70 (patch)
treeced16c233f4e5b0b52289752fc1936d4ead7a9cf /tools
parent36d2e299ce90b620ca9a64e19b778b4c8c949a47 (diff)
downloadconnman-53fd2c3bf958859f6b518681ff65f5dff9e23f70.tar.gz
connman-53fd2c3bf958859f6b518681ff65f5dff9e23f70.tar.bz2
connman-53fd2c3bf958859f6b518681ff65f5dff9e23f70.zip
Add debug option to resolver test tool
Diffstat (limited to 'tools')
-rw-r--r--tools/resolv-test.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/tools/resolv-test.c b/tools/resolv-test.c
index e8dba36f..637c9e36 100644
--- a/tools/resolv-test.c
+++ b/tools/resolv-test.c
@@ -24,6 +24,7 @@
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <signal.h>
@@ -56,12 +57,36 @@ static void resolv_result(GResolvResultStatus status,
g_main_loop_quit(main_loop);
}
+static gboolean option_debug = FALSE;
+
+static GOptionEntry options[] = {
+ { "debug", 'd', 0, G_OPTION_ARG_NONE, &option_debug,
+ "Enable debug output" },
+ { NULL },
+};
+
int main(int argc, char *argv[])
{
+ GOptionContext *context;
+ GError *error = NULL;
struct sigaction sa;
GResolv *resolv;
int index = 0;
+ context = g_option_context_new(NULL);
+ g_option_context_add_main_entries(context, options, NULL);
+
+ if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) {
+ if (error != NULL) {
+ g_printerr("%s\n", error->message);
+ g_error_free(error);
+ } else
+ g_printerr("An unknown error occurred\n");
+ exit(1);
+ }
+
+ g_option_context_free(context);
+
if (argc < 2) {
printf("missing argument\n");
return 1;
@@ -73,7 +98,8 @@ int main(int argc, char *argv[])
return 1;
}
- g_resolv_set_debug(resolv, resolv_debug, "RESOLV");
+ if (option_debug == TRUE)
+ g_resolv_set_debug(resolv, resolv_debug, "RESOLV");
main_loop = g_main_loop_new(NULL, FALSE);