extern int livebox_init(void *disp);
/*!
+ * \brief Initialize the livebox system with some options
+ * \details livebox_init function uses environment value to initiate some configurable values
+ * But some application doesn't want to use the env value.
+ * For them, this API will give a chance to set default options using given arguments
+ * \remarks N/A
+ * \param[in] disp
+ * \param[in] prevent_overwrite
+ * \param[in] event_filter
+ * \return int
+ * \retval LB_STATUS_SUCCESS if success
+ * \pre N/A
+ * \post N/A
+ * \see livebox_init
+ * \see livebox_fini
+ */
+extern int livebox_init_with_options(void *disp, int prevent_overwrite, double event_filter);
+
+/*!
* \brief Finalize the livebox system
* \details N/A
* \remarks N/A
return master_rpc_request_only(handler, packet);
}
+static void initialize_livebox(void *disp)
+{
+#if defined(FLOG)
+ char filename[BUFSIZ];
+ snprintf(filename, sizeof(filename), "/tmp/%d.box.log", getpid());
+ __file_log_fp = fopen(filename, "w+t");
+ if (!__file_log_fp) {
+ __file_log_fp = fdopen(1, "w+t");
+ }
+#endif
+ critical_log_init("viewer");
+ livebox_service_init();
+ fb_init(disp);
+
+ client_init();
+
+ s_info.init_count++;
+}
+
+EAPI int livebox_init_with_options(void *disp, int prevent_overwrite, double event_filter)
+{
+ if (s_info.init_count > 0) {
+ s_info.init_count++;
+ return LB_STATUS_SUCCESS;
+ }
+
+ /*!
+ * \note
+ * Some application doesn't want to use the environment value.
+ * So set them using arguments.
+ */
+ s_info.prevent_overwrite = prevent_overwrite;
+ MINIMUM_EVENT = event_filter;
+
+ initialize_livebox(disp);
+ return LB_STATUS_SUCCESS;
+}
+
EAPI int livebox_init(void *disp)
{
const char *env;
s_info.init_count++;
return LB_STATUS_SUCCESS;
}
+
env = getenv("PROVIDER_DISABLE_PREVENT_OVERWRITE");
if (env && !strcasecmp(env, "true")) {
s_info.prevent_overwrite = 1;
sscanf(env, "%lf", &MINIMUM_EVENT);
}
-#if defined(FLOG)
- char filename[BUFSIZ];
- snprintf(filename, sizeof(filename), "/tmp/%d.box.log", getpid());
- __file_log_fp = fopen(filename, "w+t");
- if (!__file_log_fp) {
- __file_log_fp = fdopen(1, "w+t");
- }
-#endif
- critical_log_init("viewer");
- livebox_service_init();
- fb_init(disp);
-
- client_init();
-
- s_info.init_count++;
+ initialize_livebox(disp);
return LB_STATUS_SUCCESS;
}