#include <assert.h>
#include <string.h>
#include <errno.h>
-
+#include <sys/param.h>
class OutputPlugin : public cms::ExceptionListener {
extern "C"
int
-plugin_init(const char *config)
+plugin_init(char *config)
{
+ char *s, *p;
+ char key[MAXPATHLEN], val[MAXPATHLEN];
+ int ret;
std::string brokerURI;
+ s = strstr(config, "[msg]");
+ if(s == NULL) {
+ set_error(IL_DL, ENOENT, "plugin_init: missing required configuration section [msg]\n");
+ return -1;
+ }
+ s = strchr(s, '\n');
+ if(s) s++;
+ while(s) {
+ if(*s == 0 || *s == '[')
+ break;
+ p = strchr(s, '\n');
+ if(p) *p = 0;
+ ret = sscanf(s, " %s =%s", key, val);
+ if(p) *p = '\n';
+ if(ret == 2) {
+ if(strcmp(key, "broker") == 0) {
+ brokerURI.assign(val);
+ }
+ }
+ s = p;
+ }
+ if(brokerURI.length() == 0) {
+ set_error(IL_DL, ENOENT, "plugin_init: broker uri not configured\n");
+ return -1;
+ }
+
try {
activemq::library::ActiveMQCPP::initializeLibrary();
OutputPlugin::connectionFactory = NULL;
}
} catch(cms::CMSException &e) {
-
}
+ set_error(IL_DL, 0, (char*)e.what());
return -1;
}
if(p) *p = '\n';
if(ret > 0) {
glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, " loading plugin %s\n", name);
- if(plugin_init(name, config) < 0) {
+ if(plugin_mgr_init(name, config) < 0) {
glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "Failed to load plugin %s: %s\n", name, error_get_msg());
}
}
int (*event_queue_connect)(struct event_queue *);
int (*event_queue_send)(struct event_queue *);
int (*event_queue_close)(struct event_queue *);
- int (*plugin_init)(const char *);
+ int (*plugin_init)(char *);
int (*plugin_supports_scheme)(const char *);
};
#endif
/* plugin functions */
-int plugin_init(const char *, const char *);
+int plugin_mgr_init(const char *, char *);
struct il_output_plugin *plugin_get(const char *);
/* master main loop */