#include <verto-module.h>
#ifdef WIN32
-#define pdlmsuffix ".dll"
#define pdlmtype HMODULE
#define pdlopenl(filename) LoadLibraryEx(filename, NULL, \
DONT_RESOLVE_DLL_REFERENCES)
return true;
}
#else
-#define pdlmsuffix ".so"
#define pdlmtype void *
#define pdlopenl(filename) dlopen(filename, RTLD_LAZY | RTLD_LOCAL)
#define pdlclose(module) dlclose((pdlmtype) module)
const verto_module *defmodule;
static int
-_vasprintf(char **strp, const char *fmt, va_list ap) {
+int_vasprintf(char **strp, const char *fmt, va_list ap) {
va_list apc;
int size = 0;
}
static int
-_asprintf(char **strp, const char *fmt, ...) {
+int_asprintf(char **strp, const char *fmt, ...) {
va_list ap;
int size = 0;
va_start(ap, fmt);
- size = _vasprintf(strp, fmt, ap);
+ size = int_vasprintf(strp, fmt, ap);
va_end(ap);
return size;
}
if (flen < slen || strcmp(ent->d_name + flen - slen, suffix))
continue;
- if (_asprintf(&tmp, "%s/%s", dirname, ent->d_name) < 0)
+ if (int_asprintf(&tmp, "%s/%s", dirname, ent->d_name) < 0)
continue;
success = do_load_file(tmp, reqsym, reqtypes, dll, module);
* impl == glib
* suffix == .so.0
* Put them all together: /usr/lib/libverto-glib.so.0 */
- suffix = strstr(prefix, pdlmsuffix);
+ tmp = strdup(prefix);
+ if (!tmp) {
+ free(prefix);
+ return 0;
+ }
+
+ suffix = basename(tmp);
+ suffix = strchr(suffix, '.');
if (!suffix || strlen(suffix) < 1 || !(suffix = strdup(suffix))) {
free(prefix);
+ free(tmp);
return 0;
}
strcpy(prefix + strlen(prefix) - strlen(suffix), "-");
+ free(tmp);
if (impl) {
/* Try to do a load by the path */
if (!success) {
/* Try to do a load by the name */
tmp = NULL;
- if (_asprintf(&tmp, "%s%s%s", prefix, impl, suffix) > 0) {
+ if (int_asprintf(&tmp, "%s%s%s", prefix, impl, suffix) > 0) {
success = do_load_file(tmp, 0, reqtypes, dll, module);
free(tmp);
}