aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugin.c
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2019-11-07 18:44:19 +0100
committercbdev <cb@cbcdn.com>2019-11-07 18:44:19 +0100
commit350f0d2d2eaff5f0d57b09857102e2df1e96d733 (patch)
treefe81a48535d700195034e9173018c9a9a63d02d0 /plugin.c
parent6c75f07260639fd2bc6d328d5f00c72ab4382fa8 (diff)
downloadmidimonster-350f0d2d2eaff5f0d57b09857102e2df1e96d733.tar.gz
midimonster-350f0d2d2eaff5f0d57b09857102e2df1e96d733.tar.bz2
midimonster-350f0d2d2eaff5f0d57b09857102e2df1e96d733.zip
Makefile install target and packaging instructions (Fixes #28)
Diffstat (limited to 'plugin.c')
-rw-r--r--plugin.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/plugin.c b/plugin.c
index dd99041..a14baff 100644
--- a/plugin.c
+++ b/plugin.c
@@ -24,13 +24,21 @@ static int plugin_attach(char* path, char* file){
plugin_init init = NULL;
void* handle = NULL;
char* lib = NULL;
+ #ifdef _WIN32
+ char* path_separator = "\\";
+ #else
+ char* path_separator = "/";
+ #endif
- lib = calloc(strlen(path) + strlen(file) + 1, sizeof(char));
+ lib = calloc(strlen(path) + strlen(file) + 2, sizeof(char));
if(!lib){
fprintf(stderr, "Failed to allocate memory\n");
return 1;
}
- snprintf(lib, strlen(path) + strlen(file) + 1, "%s%s", path, file);
+ snprintf(lib, strlen(path) + strlen(file) + 2, "%s%s%s",
+ path,
+ (path[strlen(path)] == path_separator[0]) ? "" : path_separator,
+ file);
handle = dlopen(lib, RTLD_NOW);
if(!handle){