#include <config.h>
#include <unistd.h>
+#include <c-ctype.h>
#include "driver.h"
#include "viralloc.h"
void *
virDriverLoadModule(const char *name)
{
- char *modfile = NULL, *regfunc = NULL;
+ char *modfile = NULL, *regfunc = NULL, *fixedname = NULL;
+ char *tmp;
void *handle = NULL;
int (*regsym)(void);
goto cleanup;
}
- if (virAsprintfQuiet(®func, "%sRegister", name) < 0) {
+ if (VIR_STRDUP_QUIET(fixedname, name) < 0) {
+ VIR_ERROR(_("out of memory"));
+ goto cleanup;
+ }
+
+ /* convert something_like_this into somethingLikeThis */
+ while ((tmp = strchr(fixedname, '_'))) {
+ memmove(tmp, tmp + 1, strlen(tmp));
+ *tmp = c_toupper(*tmp);
+ }
+
+ if (virAsprintfQuiet(®func, "%sRegister", fixedname) < 0) {
goto cleanup;
}
VIR_FREE(modfile);
VIR_FREE(regfunc);
+ VIR_FREE(fixedname);
return handle;
cleanup:
VIR_FREE(modfile);
VIR_FREE(regfunc);
+ VIR_FREE(fixedname);
if (handle)
dlclose(handle);
return NULL;