diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-01-14 00:04:48 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2007-01-14 00:04:48 +0000 |
commit | 70fcd297bce634b8a1b117c3b27784995a8c652a (patch) | |
tree | bcc002898cacfba6fcc9163a4ad583bcfc8f7148 | |
parent | 54b33571eb8833f86d17957ff5a3309512aab57b (diff) |
Make debug information optional
-rw-r--r-- | hcid/main.c | 21 | ||||
-rw-r--r-- | sdpd/main.c | 21 |
2 files changed, 37 insertions, 5 deletions
diff --git a/hcid/main.c b/hcid/main.c index 91348f9d..9f29e8f9 100644 --- a/hcid/main.c +++ b/hcid/main.c @@ -543,6 +543,11 @@ static void sig_hup(int sig) init_all_devices(hcid.sock); } +static void sig_debug(int sig) +{ + toggle_debug(); +} + static inline void device_event(GIOChannel *chan, evt_stack_internal *si) { evt_si_device *sd = (void *) &si->data; @@ -622,7 +627,7 @@ int main(int argc, char *argv[]) struct hci_filter flt; struct sigaction sa; GIOChannel *ctl_io; - int opt, daemonize = 1, sdp = 0, experimental = 0; + int opt, daemonize = 1, debug = 0, sdp = 0, experimental = 0; /* Default HCId settings */ memset(&hcid, 0, sizeof(hcid)); @@ -640,12 +645,16 @@ int main(int argc, char *argv[]) init_defaults(); - while ((opt = getopt(argc, argv, "nsxf:")) != EOF) { + while ((opt = getopt(argc, argv, "ndsxf:")) != EOF) { switch (opt) { case 'n': daemonize = 0; break; + case 'd': + debug = 1; + break; + case 's': sdp = 1; break; @@ -681,11 +690,17 @@ int main(int argc, char *argv[]) sa.sa_handler = sig_hup; sigaction(SIGHUP, &sa, NULL); + sa.sa_handler = sig_debug; + sigaction(SIGUSR2, &sa, NULL); + sa.sa_handler = SIG_IGN; sigaction(SIGCHLD, &sa, NULL); sigaction(SIGPIPE, &sa, NULL); - enable_debug(); + if (debug) { + info("Enabling debug information"); + enable_debug(); + } /* Create and bind HCI socket */ if ((hcid.sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) { diff --git a/sdpd/main.c b/sdpd/main.c index 7e97d3f9..1154547b 100644 --- a/sdpd/main.c +++ b/sdpd/main.c @@ -51,6 +51,11 @@ static void sig_hup(int sig) { } +static void sig_debug(int sig) +{ + toggle_debug(); +} + static void usage(void) { printf("sdpd - SDP daemon ver %s\n", VERSION); @@ -72,14 +77,18 @@ int main(int argc, char *argv[]) struct sigaction sa; uint16_t mtu = 0; uint32_t flags = SDP_SERVER_COMPAT; - int opt, daemonize = 1; + int opt, daemonize = 1, debug = 0; - while ((opt = getopt_long(argc, argv, "nm:pM", main_options, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, "ndm:pM", main_options, NULL)) != -1) { switch (opt) { case 'n': daemonize = 0; break; + case 'd': + debug = 1; + break; + case 'm': mtu = atoi(optarg); break; @@ -115,10 +124,18 @@ int main(int argc, char *argv[]) sa.sa_handler = sig_hup; sigaction(SIGHUP, &sa, NULL); + sa.sa_handler = sig_debug; + sigaction(SIGUSR2, &sa, NULL); + sa.sa_handler = SIG_IGN; sigaction(SIGCHLD, &sa, NULL); sigaction(SIGPIPE, &sa, NULL); + if (debug) { + info("Enabling debug information"); + enable_debug(); + } + event_loop = g_main_loop_new(NULL, FALSE); if (start_sdp_server(mtu, flags) < 0) { |