From 335fb71873349127a830f37e5c71817bba801460 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 1 Aug 2010 16:42:13 -0700 Subject: [PATCH 1/1] Fix up test tool for web service library --- tools/web-test.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/web-test.c b/tools/web-test.c index cf85c71..1d8301f 100644 --- a/tools/web-test.c +++ b/tools/web-test.c @@ -44,6 +44,19 @@ static void sig_term(int sig) g_main_loop_quit(main_loop); } +static void web_result(uint16_t status, gpointer user_data) +{ + gdouble elapsed; + + elapsed = g_timer_elapsed(timer, NULL); + + g_print("elapse: %f seconds\n", elapsed); + + g_print("status: %03u\n", status); + + g_main_loop_quit(main_loop); +} + static gboolean option_debug = FALSE; static GOptionEntry options[] = { @@ -58,6 +71,7 @@ int main(int argc, char *argv[]) GError *error = NULL; struct sigaction sa; GWeb *web; + int index = 0; context = g_option_context_new(NULL); g_option_context_add_main_entries(context, options, NULL); @@ -78,7 +92,7 @@ int main(int argc, char *argv[]) return 1; } - web = g_web_new(); + web = g_web_new(index); if (web == NULL) { printf("failed to web service\n"); return 1; @@ -91,6 +105,12 @@ int main(int argc, char *argv[]) timer = g_timer_new(); + if (g_web_request(web, G_WEB_METHOD_GET, argv[1], + web_result, NULL) == 0) { + printf("failed to start request\n"); + return 1; + } + memset(&sa, 0, sizeof(sa)); sa.sa_handler = sig_term; sigaction(SIGINT, &sa, NULL); -- 2.7.4