5 * Copyright (C) 2007-2010 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 #include <gweb/gweb.h>
35 static GMainLoop *main_loop;
37 static void web_debug(const char *str, void *data)
39 g_print("%s: %s\n", (const char *) data, str);
42 static void sig_term(int sig)
44 g_main_loop_quit(main_loop);
47 static gboolean option_debug = FALSE;
49 static GOptionEntry options[] = {
50 { "debug", 'd', 0, G_OPTION_ARG_NONE, &option_debug,
51 "Enable debug output" },
55 int main(int argc, char *argv[])
57 GOptionContext *context;
62 context = g_option_context_new(NULL);
63 g_option_context_add_main_entries(context, options, NULL);
65 if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) {
67 g_printerr("%s\n", error->message);
70 g_printerr("An unknown error occurred\n");
74 g_option_context_free(context);
77 printf("missing argument\n");
83 printf("failed to web service\n");
87 if (option_debug == TRUE)
88 g_web_set_debug(web, web_debug, "WEB");
90 main_loop = g_main_loop_new(NULL, FALSE);
92 timer = g_timer_new();
94 memset(&sa, 0, sizeof(sa));
95 sa.sa_handler = sig_term;
96 sigaction(SIGINT, &sa, NULL);
97 sigaction(SIGTERM, &sa, NULL);
99 g_main_loop_run(main_loop);
101 g_timer_destroy(timer);
105 g_main_loop_unref(main_loop);