diff --git a/src/driver.c b/src/driver.c index 9e3a2eb1dc..71569e6eaa 100644 --- a/src/driver.c +++ b/src/driver.c @@ -23,6 +23,7 @@ #include #include +#include #include "driver.h" #include "viralloc.h" @@ -45,7 +46,8 @@ VIR_LOG_INIT("driver"); 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); @@ -72,7 +74,18 @@ virDriverLoadModule(const char *name) 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; } @@ -89,11 +102,13 @@ virDriverLoadModule(const char *name) 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;