xmlbusErrorPtr registerOutboundTransports(xmlbusdServerOutboundTransportConfig* outboundTransports) { xmlbusErrorPtr xbErr = XMLBUS_OK; xmlbusdServerOutboundTransportConfig* thisConf = outboundTransports; while(thisConf != NULL) { thisConf->modOutboundTransportImpl = xmlModuleOpen(thisConf->outboundTransportImpl,0); if (thisConf->modOutboundTransportImpl == NULL) { xbErr = xmlbusErrorAdd(xbErr, XMLBUS_ERRORS_LOCATION, -1, BAD_CAST "Could not open module implementation %s", thisConf->outboundTransportImpl); goto onError; } xbErr = xmlbusTransportResolverRegistryAddModule(thisConf->modOutboundTransportImpl,thisConf->outboundTransportConfiguration); if (xbErr != XMLBUS_OK) { xbErr = xmlbusErrorAdd(xbErr, XMLBUS_ERRORS_LOCATION, -1, BAD_CAST "Could not register sender module implementation %s", thisConf->outboundTransportImpl); goto onError; } thisConf = thisConf->next; } return xbErr; onError: if (thisConf != outboundTransports) { xmlbusTransportResolverRegistryFree(); } return xbErr; }
xmlbusErrorPtr xmlbusdRunnerInitialize(xmlNodePtr config,xmlbusdServiceConfig** serviceConf) { xmlbusErrorPtr xbErr = XMLBUS_OK; if (serviceConf == NULL || *serviceConf == NULL) { xbErr = xmlbusErrorAdd(xbErr, XMLBUS_ERRORS_LOCATION, -1, BAD_CAST "passed xmlbusdServiceConfig is not a valid memory address"); return xbErr; } xmlbusdServiceConfig* thisConf = *serviceConf; (*serviceConf)->modImpl = (xmlModulePtr)xmlModuleOpen((char*)thisConf->implementation,0); if (thisConf->modImpl == NULL) { xbErr = xmlbusErrorAdd(xbErr, XMLBUS_ERRORS_LOCATION, -1, BAD_CAST "Could not open service implementation %s", thisConf->implementation); } xmlbusServiceCustomDataPtr newCustomData = malloc(sizeof(struct xmlbus_servicecustomdata_struct)); if (newCustomData == NULL) { xbErr = xmlbusErrorAdd(xbErr, XMLBUS_ERRORS_LOCATION, -1, BAD_CAST "Could not allocate the memory for the custom data"); goto onError; } newCustomData->modServiceImpl = (*serviceConf)->modImpl; xmlbusServiceSetCustomData(&((*serviceConf)->service),&newCustomData); return xbErr; onError: return xbErr; }
#endif typedef int (*hello_world_t)(void); int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { xmlChar filename[PATH_MAX]; xmlModulePtr module = NULL; hello_world_t hello_world = NULL; /* build the module filename, and confirm the module exists */ xmlStrPrintf(filename, sizeof(filename), (const xmlChar*) "%s/testdso%s", (const xmlChar*)MODULE_PATH, (const xmlChar*)LIBXML_MODULE_EXTENSION); module = xmlModuleOpen((const char*)filename, 0); if (module) { if (xmlModuleSymbol(module, "hello_world", (void **) &hello_world)) { fprintf(stderr, "Failure to lookup\n"); return(1); } if (hello_world == NULL) { fprintf(stderr, "Lookup returned NULL\n"); return(1); } (*hello_world)(); xmlModuleClose(module); }