summaryrefslogtreecommitdiff
path: root/cleopatre
diff options
context:
space:
mode:
authorThierry Carré2013-03-20 14:44:17 +0100
committerThierry Carré2013-04-26 17:03:12 +0200
commit644934bb0f2efc6f03596dc47398d7cc16db21fe (patch)
tree44f9dec166b617a1821d2be78c8e071bc214b721 /cleopatre
parent4451f7e30c2ea196989f17359ed761ec60a29762 (diff)
cleo/devkit/plcd: move hpav.conf read into plcd_files.c, refs #3789
Diffstat (limited to 'cleopatre')
-rw-r--r--cleopatre/devkit/plcd/inc/plcd_files.h25
-rw-r--r--cleopatre/devkit/plcd/src/plcd_daemon.c35
-rw-r--r--cleopatre/devkit/plcd/src/plcd_files.c58
3 files changed, 87 insertions, 31 deletions
diff --git a/cleopatre/devkit/plcd/inc/plcd_files.h b/cleopatre/devkit/plcd/inc/plcd_files.h
new file mode 100644
index 0000000000..a414a443f9
--- /dev/null
+++ b/cleopatre/devkit/plcd/inc/plcd_files.h
@@ -0,0 +1,25 @@
+#ifndef INC_PLCD_FILES_H
+#define INC_PLCD_FILES_H
+/* Cleopatre project {{{
+ *
+ * Copyright (C) 2013 MStar Semiconductor
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file devkit/plcd/inc/plcd_files.h
+ * \ingroup plcd
+ */
+#include "plcd_ctx.h"
+
+/**
+ * read HPAV.CONF file and save values in plcd context.
+ *
+ * \param ctx plcd context
+ * \return -1 on error, 0 otherwise
+ */
+int
+plcd_files_read_hpavconf (plcd_ctx_t *ctx);
+
+#endif /* INC_PLCD_FILES_H */
diff --git a/cleopatre/devkit/plcd/src/plcd_daemon.c b/cleopatre/devkit/plcd/src/plcd_daemon.c
index 8835022088..aa35ddf613 100644
--- a/cleopatre/devkit/plcd/src/plcd_daemon.c
+++ b/cleopatre/devkit/plcd/src/plcd_daemon.c
@@ -18,6 +18,7 @@
#include "plcd_daemon.h"
#include "plcd_stack.h"
#include "plcd_autoswitch.h"
+#include "plcd_files.h"
#include "plcd_ctx.h"
#include "libspid.h"
@@ -102,8 +103,6 @@ plcd_daemon_close (plcd_ctx_t *ctx)
static int
plcd_daemon_open (plcd_ctx_t *ctx)
{
- char is_cco_preferred_str[LIBSPID_BOOLEAN_STR_MAX_LEN] = {0};
- char was_cco_str[LIBSPID_BOOLEAN_STR_MAX_LEN] = {0};
struct plcdrv_setpid user_data;
struct ifreq ifr;
@@ -172,35 +171,6 @@ plcd_daemon_open (plcd_ctx_t *ctx)
syslog (LOG_WARNING, "libspid system get nvram failed");
return -1;
}
-
- /* read and save hpav.conf file contents */
- if ((LIBSPID_SUCCESS != libspid_config_read_item (ctx->hpav_conf_path,
- LIBSPID_HPAV_CONF_LABEL_CCO_PREFERRED, is_cco_preferred_str,
- LIBSPID_BOOLEAN_STR_MAX_LEN))
- || (LIBSPID_SUCCESS != libspid_config_read_item (ctx->hpav_conf_path,
- LIBSPID_HPAV_CONF_LABEL_WAS_CCO, was_cco_str, LIBSPID_BOOLEAN_STR_MAX_LEN))
- || (LIBSPID_SUCCESS != libspid_config_read_item (ctx->hpav_conf_path,
- LIBSPID_HPAV_CONF_LABEL_NMK, ctx->hpav_conf.nmk_str,
- LIBSPID_HPAV_CONF_NMK_STR_LEN))
- || (LIBSPID_SUCCESS != libspid_config_read_item (ctx->hpav_conf_path,
- LIBSPID_HPAV_CONF_LABEL_NID, ctx->hpav_conf.nid_str,
- LIBSPID_HPAV_CONF_NID_STR_LEN))
- || (LIBSPID_SUCCESS != libspid_config_read_item (ctx->hpav_conf_path,
- LIBSPID_HPAV_CONF_LABEL_SL, ctx->hpav_conf.sl_str,
- LIBSPID_HPAV_CONF_SL_STR_MAX_LEN))
- || (LIBSPID_SUCCESS != libspid_config_read_item (ctx->hpav_conf_path,
- LIBSPID_HPAV_CONF_LABEL_USER_HFID, ctx->hpav_conf.user_hfid,
- LIBSPID_HPAV_CONF_HFID_MAX_LEN))
- || (LIBSPID_SUCCESS != libspid_config_read_item (ctx->hpav_conf_path,
- LIBSPID_HPAV_CONF_LABEL_AVLN_HFID, ctx->hpav_conf.avln_hfid,
- LIBSPID_HPAV_CONF_HFID_MAX_LEN)))
- {
- syslog (LOG_WARNING, "libspid config read item failed");
- return -1;
- }
- ctx->hpav_conf.is_cco_preferred = LIBSPID_GET_BOOLEAN (is_cco_preferred_str);
- ctx->hpav_conf.was_cco = LIBSPID_GET_BOOLEAN (was_cco_str);
-
return 0;
}
@@ -209,6 +179,9 @@ plcd_daemon_main (plcd_ctx_t *ctx)
{
PLCD_ASSERT (ctx);
+ if (0 > plcd_files_read_hpavconf (ctx))
+ return;
+
int init_nb, init_ret = -1;
if (0 <= plcd_daemon_open (ctx))
diff --git a/cleopatre/devkit/plcd/src/plcd_files.c b/cleopatre/devkit/plcd/src/plcd_files.c
new file mode 100644
index 0000000000..edda391659
--- /dev/null
+++ b/cleopatre/devkit/plcd/src/plcd_files.c
@@ -0,0 +1,58 @@
+/* Cleopatre project {{{
+ *
+ * Copyright (C) 2013 MStar Semiconductor
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file devkit/plcd/src/plcd_files.c
+ * \ingroup plcd
+ *
+ * Manage read and write operation for :
+ * - HPAV.CONF
+ * - HPAV.INFO
+ */
+#include "plcd_files.h"
+#include "plcd_ctx.h"
+
+#include "libspid.h"
+
+int
+plcd_files_read_hpavconf (plcd_ctx_t *ctx)
+{
+ char is_cco_preferred_str[LIBSPID_BOOLEAN_STR_MAX_LEN] = {0};
+ char was_cco_str[LIBSPID_BOOLEAN_STR_MAX_LEN] = {0};
+
+ PLCD_ASSERT (ctx);
+
+ /* read and save hpav.conf file contents */
+ if ((LIBSPID_SUCCESS != libspid_config_read_item (ctx->hpav_conf_path,
+ LIBSPID_HPAV_CONF_LABEL_CCO_PREFERRED, is_cco_preferred_str,
+ LIBSPID_BOOLEAN_STR_MAX_LEN))
+ || (LIBSPID_SUCCESS != libspid_config_read_item (ctx->hpav_conf_path,
+ LIBSPID_HPAV_CONF_LABEL_WAS_CCO, was_cco_str, LIBSPID_BOOLEAN_STR_MAX_LEN))
+ || (LIBSPID_SUCCESS != libspid_config_read_item (ctx->hpav_conf_path,
+ LIBSPID_HPAV_CONF_LABEL_NMK, ctx->hpav_conf.nmk_str,
+ LIBSPID_HPAV_CONF_NMK_STR_LEN))
+ || (LIBSPID_SUCCESS != libspid_config_read_item (ctx->hpav_conf_path,
+ LIBSPID_HPAV_CONF_LABEL_NID, ctx->hpav_conf.nid_str,
+ LIBSPID_HPAV_CONF_NID_STR_LEN))
+ || (LIBSPID_SUCCESS != libspid_config_read_item (ctx->hpav_conf_path,
+ LIBSPID_HPAV_CONF_LABEL_SL, ctx->hpav_conf.sl_str,
+ LIBSPID_HPAV_CONF_SL_STR_MAX_LEN))
+ || (LIBSPID_SUCCESS != libspid_config_read_item (ctx->hpav_conf_path,
+ LIBSPID_HPAV_CONF_LABEL_USER_HFID, ctx->hpav_conf.user_hfid,
+ LIBSPID_HPAV_CONF_HFID_MAX_LEN))
+ || (LIBSPID_SUCCESS != libspid_config_read_item (ctx->hpav_conf_path,
+ LIBSPID_HPAV_CONF_LABEL_AVLN_HFID, ctx->hpav_conf.avln_hfid,
+ LIBSPID_HPAV_CONF_HFID_MAX_LEN)))
+ {
+ syslog (LOG_WARNING, "libspid config read item failed");
+ return -1;
+ }
+
+ ctx->hpav_conf.is_cco_preferred = LIBSPID_GET_BOOLEAN (is_cco_preferred_str);
+ ctx->hpav_conf.was_cco = LIBSPID_GET_BOOLEAN (was_cco_str);
+ return 0;
+}