diff src/checksignal.c @ 164:7d8a5bb874ad

EXPERIMENTAL: Change phisical channel by mq_recv(). KNOWN ISSUE: Cannnot split BS-TBS(BS1_1). enable compile recpt1ctl. SID can specified by recpt1ctl.
author Naoya OYAMA <naoya.oyama@gmail.com>
date Mon, 01 Oct 2012 21:52:05 +0900
parents 4e39ce051c57
children 061ef2cd98f0
line wrap: on
line diff
--- a/src/checksignal.c	Mon Sep 24 20:49:17 2012 +0900
+++ b/src/checksignal.c	Mon Oct 01 21:52:05 2012 +0900
@@ -36,9 +36,6 @@
 
 #define MAX_RETRY (2)
 
-/* type definitions */
-typedef int boolean;
-
 /* globals */
 boolean f_exit = FALSE;
 boolean use_bell = FALSE;
@@ -48,18 +45,17 @@
 int close_tuner(thread_data *tdata);
 
 void
-cleanup(thread_data *tdata)
+cleanup(void)
 {
     f_exit = TRUE;
 }
 
 /* will be signal handler thread */
 void *
-process_signals(void *data)
+process_signals(void *p)
 {
     sigset_t waitset;
     int sig;
-    thread_data *tdata = (thread_data *)data;
 
     sigemptyset(&waitset);
     sigaddset(&waitset, SIGINT);
@@ -71,14 +67,14 @@
     switch(sig) {
     case SIGINT:
         fprintf(stderr, "\nSIGINT received. cleaning up...\n");
-        cleanup(tdata);
+        cleanup();
         break;
     case SIGTERM:
         fprintf(stderr, "\nSIGTERM received. cleaning up...\n");
-        cleanup(tdata);
+        cleanup();
         break;
     case SIGUSR1: /* normal exit*/
-        cleanup(tdata);
+        cleanup();
         break;
     }
 
@@ -86,7 +82,7 @@
 }
 
 void
-init_signal_handlers(pthread_t *signal_thread, thread_data *tdata)
+init_signal_handlers(pthread_t *signal_thread)
 {
     sigset_t blockset;
 
@@ -98,7 +94,7 @@
     if(pthread_sigmask(SIG_BLOCK, &blockset, NULL))
         fprintf(stderr, "pthread_sigmask() failed.\n");
 
-    pthread_create(signal_thread, NULL, process_signals, tdata);
+    pthread_create(signal_thread, NULL, process_signals, NULL);
 }
 
 /* lookup frequency conversion table*/
@@ -309,7 +305,7 @@
         }
 
         fprintf(stderr, "device = %s\n", device);
-        tdata->ch = atoi(channel);
+        strncpy(tdata->ch, channel, sizeof(tdata->ch));
     }
     else {
         /* case 2: loop around available devices */
@@ -362,7 +358,7 @@
             return 1;
         }
         else {
-            tdata->ch = atoi(channel);
+            strncpy(tdata->ch, channel, sizeof(tdata->ch));
         }
     }
 
@@ -464,7 +460,7 @@
     }
 
     /* spawn signal handler thread */
-    init_signal_handlers(&signal_thread, &tdata);
+    init_signal_handlers(&signal_thread);
 
     /* tune */
     if(tune(argv[optind], &tdata, device) != 0)