5 * Copyright (C) 2007-2010 Marcel Holtmann <marcel@holtmann.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
40 static GMainLoop *event_loop = NULL;
42 static char *option_debug = NULL;
43 static gboolean option_stderr = FALSE;
45 static gboolean parse_debug(const char *key, const char *value,
46 gpointer user_data, GError **error)
49 option_debug = g_strdup(value);
51 option_debug = g_strdup("*");
56 static GOptionEntry options[] = {
57 { "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG,
58 G_OPTION_ARG_CALLBACK, parse_debug,
59 "Enable debug information output", "DEBUG" },
60 { "stderr", 's', 0, G_OPTION_ARG_NONE, &option_stderr,
61 "Write log information to stderr" },
65 static void sig_term(int sig)
67 g_main_loop_quit(event_loop);
70 int main(int argc, char *argv[])
72 GOptionContext *context;
76 context = g_option_context_new(NULL);
77 g_option_context_add_main_entries(context, options, NULL);
79 g_option_context_parse(context, &argc, &argv, &gerr);
81 g_printerr("%s\n", gerr->message);
86 g_option_context_free(context);
88 event_loop = g_main_loop_new(NULL, FALSE);
90 __obex_log_init("obex-client", option_debug, !option_stderr);
92 if (manager_init() < 0)
95 DBG("Entering main loop");
97 memset(&sa, 0, sizeof(sa));
98 sa.sa_handler = sig_term;
99 sigaction(SIGINT, &sa, NULL);
100 sigaction(SIGTERM, &sa, NULL);
102 g_main_loop_run(event_loop);
106 g_main_loop_unref(event_loop);
108 __obex_log_cleanup();