* \pre N/A
* \post N/A
* \see provider_fini
+ * \see provider_init_with_options
*/
extern int provider_init(void *disp, const char *name, struct event_handler *table, void *data);
/*!
+ * \brief Initialize the provider service
+ * \details Some provider doesn't want to access environment value.
+ * This API will get some configuration info via argument instead of environment value.
+ * \remarks N/A
+ * \param[in] disp XDisplay object, if you don't know what this is, set NULL
+ * \param[in] name Slave name which is given by the master provider.
+ * \param[in] table Event handler table
+ * \param[in] data callback data
+ * \return int
+ * \retval LB_STATUS_SUCCESS
+ * \retval LB_STATUS_ERROR_INVALID
+ * \retval LB_STATUS_ERROR_MEMORY
+ * \retval LB_STATUS_ERROR_ALREADY
+ * \retval LB_STATUS_ERROR_FAULT
+ * \pre N/A
+ * \post N/A
+ * \see provider_fini
+ * \see provider_init
+ */
+extern int provider_init_with_options(void *disp, const char *name, struct event_handler *table, void *data, int prevent_overwrite, int com_core_use_thread);
+
+/*!
* \brief Finalize the provider service
* \details N/A
* \remarks N/A
return 0;
}
-EAPI int provider_init(void *disp, const char *name, struct event_handler *table, void *data)
+static int initialize_provider(void *disp, const char *name, struct event_handler *table, void *data)
{
int ret;
- const char *option;
-
- option = getenv("PROVIDER_DISABLE_PREVENT_OVERWRITE");
- if (option && !strcasecmp(option, "true")) {
- s_info.prevent_overwrite = 1;
- }
-
- option = getenv("PROVIDER_COM_CORE_THREAD");
- if (option && !strcasecmp(option, "true")) {
- com_core_packet_use_thread(1);
- }
-
- if (!name || !table) {
- ErrPrint("Invalid argument\n");
- return LB_STATUS_ERROR_INVALID;
- }
-
- if (s_info.name) {
- ErrPrint("Provider is already initialized\n");
- return LB_STATUS_ERROR_ALREADY;
- }
s_info.name = strdup(name);
if (!s_info.name) {
return LB_STATUS_SUCCESS;
}
+EAPI int provider_init_with_options(void *disp, const char *name, struct event_handler *table, void *data, int prevent_overwrite, int com_core_use_thread)
+{
+ if (!name || !table) {
+ ErrPrint("Invalid argument\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (s_info.name) {
+ ErrPrint("Provider is already initialized\n");
+ return LB_STATUS_ERROR_ALREADY;
+ }
+
+ s_info.prevent_overwrite = prevent_overwrite;
+ com_core_packet_use_thread(com_core_use_thread);
+
+ return initialize_provider(disp, name, table, data);
+}
+
+EAPI int provider_init(void *disp, const char *name, struct event_handler *table, void *data)
+{
+ const char *option;
+
+ if (!name || !table) {
+ ErrPrint("Invalid argument\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (s_info.name) {
+ ErrPrint("Provider is already initialized\n");
+ return LB_STATUS_ERROR_ALREADY;
+ }
+
+ option = getenv("PROVIDER_DISABLE_PREVENT_OVERWRITE");
+ if (option && !strcasecmp(option, "true")) {
+ s_info.prevent_overwrite = 1;
+ }
+
+ option = getenv("PROVIDER_COM_CORE_THREAD");
+ if (option && !strcasecmp(option, "true")) {
+ com_core_packet_use_thread(1);
+ }
+
+ return initialize_provider(disp, name, table, data);
+}
+
EAPI void *provider_fini(void)
{
void *ret;