8 #include "debug_print.h"
12 static pthread_mutex_t mutex_conf = PTHREAD_MUTEX_INITIALIZER;
15 /**** 記録周波数 ***************************************************
20 void conf_freq_set(int f)
22 pthread_mutex_lock(&mutex_conf);
24 pthread_mutex_unlock(&mutex_conf);
26 int conf_freq_get(void)
29 pthread_mutex_lock(&mutex_conf);
31 pthread_mutex_unlock(&mutex_conf);
35 /**** Gain ***************************************************
38 0=1/8, 1=1/4, 2=1/2, 3=1, 4=2, 5=4
39 6=8, 7=16, 8=32, 9=64, 10=128
43 void conf_gain_set(int f)
45 pthread_mutex_lock(&mutex_conf);
47 pthread_mutex_unlock(&mutex_conf);
49 int conf_gain_get(void)
52 pthread_mutex_lock(&mutex_conf);
54 pthread_mutex_unlock(&mutex_conf);
58 /**** Linux時刻セット ***************************************************
61 static int linux_time_set;
62 void conf_linux_time_set_set(int val)
66 int conf_linux_time_set_get(void)
68 return linux_time_set;
72 static char recpath[CONF_RECPATH_MAX];
73 void conf_recpath_set(char *s)
75 strncpy(recpath, s, sizeof(recpath));
77 char* conf_recpath_getp(void)
84 void conf_recchn_set(int chn)
88 int conf_recchn_get(void)
94 /**** 設定ファイル *******************************************
99 static void trims_space(char *name)
117 if (name0 != name) memmove(name0, name, len);
124 static void trime_space(char *name)
133 for(i = len - 1; i >= 0; i--) {
144 static void trim_space(char *name)
146 if (name == NULL) return;
153 static void trim_crlf(char *name)
159 if (name == NULL) return;
163 for(i = 0; i < len; i++) {
164 if (*src != 0x0d && *src != 0x0a) {
185 char buf2[CONF_RECPATH_MAX];
189 fp = fopen(CONF_FILE, "rt");
191 syslog(LOG_ERR, "conf_read(): conf file not found. %s", CONF_FILE);
195 syslog(LOG_INFO, "conf_read():");
196 while(fgets(buf, sizeof(buf), fp)) {
203 if (sscanf(buf, "freq = %d", &f) == 1) {
205 syslog(LOG_INFO, "freq=%d", conf_freq_get());
208 if (sscanf(buf, "gain = %d", &f) == 1) {
210 syslog(LOG_INFO, "gain=%d", conf_gain_get());
213 if (sscanf(buf, "linux_time_set = %d", &val) == 1) {
214 conf_linux_time_set_set(val);
215 syslog(LOG_INFO, "linux_time_set=%d", conf_linux_time_set_get());
218 if (sscanf(buf, "rec_path = %s", buf2) == 1) {
220 conf_recpath_set(buf2);
221 syslog(LOG_INFO, "rec_path=%s", conf_recpath_getp());
224 if (sscanf(buf, "rec_chn = %d", &f) == 1) {
225 if (f < 1 || f > AD_CHNUM) f = AD_CHNUM;