OSDN Git Service

記録パス設定 記録CH設定 ファイル書込タイミング
[scilog/scilog.git] / conf.c
diff --git a/conf.c b/conf.c
index c26f16e..ce7fc5e 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -6,6 +6,7 @@
 
 #include "conf.h"
 #include "debug_print.h"
+#include "ad_ring.h"
 
 // ミューテックス
 static pthread_mutex_t mutex_conf = PTHREAD_MUTEX_INITIALIZER;
@@ -67,6 +68,28 @@ int conf_linux_time_set_get(void)
        return linux_time_set;
 }
 
+// 記録パス
+static char    recpath[CONF_RECPATH_MAX];
+void conf_recpath_set(char *s)
+{
+       strncpy(recpath, s, sizeof(recpath));
+}
+char* conf_recpath_getp(void)
+{
+       return recpath;
+}
+
+// 記録CH
+static int     recchnum;
+void conf_recchn_set(int chn)
+{
+       recchnum = chn;
+}
+int conf_recchn_get(void)
+{
+       return recchnum;
+}
+
 //
 /**** 設定ファイル *******************************************
 */
@@ -159,9 +182,10 @@ int conf_read(void)
        FILE    *fp;
        char    buf[256];
 //     char    buf2[256];
+       char    buf2[CONF_RECPATH_MAX];
        int     f;
        int     val;
-       
+
        fp = fopen(CONF_FILE, "rt");
        if (fp == NULL) {
                syslog(LOG_ERR, "conf_read(): conf file not found. %s", CONF_FILE);
@@ -190,6 +214,17 @@ int conf_read(void)
                        conf_linux_time_set_set(val);
                        syslog(LOG_INFO, "linux_time_set=%d", conf_linux_time_set_get());
                } 
+               // 記録パス
+               if (sscanf(buf, "rec_path = %s", buf2) == 1) {
+                       trim_space(buf2);
+                       conf_recpath_set(buf2);
+                       syslog(LOG_INFO, "rec_path=%s", conf_recpath_getp());
+               } 
+               // 記録CH
+               if (sscanf(buf, "rec_chn = %d", &f) == 1) {
+                       if (f < 1 || f > AD_CHNUM) f = AD_CHNUM;
+                       conf_recchn_set(f);
+               }
        }
        fclose(fp);
        return 0;