comparison helper.cpp @ 6:61dbb18f2369

Logging, timeouts
author Chris Cannam
date Wed, 13 Apr 2016 18:41:49 +0100
parents 74064d6f5e07
children
comparison
equal deleted inserted replaced
5:74064d6f5e07 6:61dbb18f2369
72 #endif 72 #endif
73 73
74 #include <string> 74 #include <string>
75 #include <iostream> 75 #include <iostream>
76 76
77 #include <unistd.h>
78
77 using namespace std; 79 using namespace std;
78 80
79 string error() 81 string error()
80 { 82 {
81 string e = dlerror(); 83 string e = dlerror();
83 else return e; 85 else return e;
84 } 86 }
85 87
86 string check(string soname, string descriptor) 88 string check(string soname, string descriptor)
87 { 89 {
88 // cerr << "helper: trying: " << soname << endl;
89
90 void *handle = DLOPEN(soname, RTLD_NOW | RTLD_LOCAL); 90 void *handle = DLOPEN(soname, RTLD_NOW | RTLD_LOCAL);
91 if (!handle) { 91 if (!handle) {
92 // cerr << "helper: failed to open" << endl;
93 return "Unable to open plugin library: " + error(); 92 return "Unable to open plugin library: " + error();
94 } 93 }
95 94
96 void *fn = DLSYM(handle, descriptor); 95 void *fn = DLSYM(handle, descriptor);
97 if (!fn) { 96 if (!fn) {
98 // cerr << "helper: failed to find descriptor" << endl;
99 return "Failed to find plugin descriptor " + descriptor + 97 return "Failed to find plugin descriptor " + descriptor +
100 " in library: " + error(); 98 " in library: " + error();
101 } 99 }
102 100
103 // cerr << "helper: succeeded" << endl;
104
105 return ""; 101 return "";
106 } 102 }
107 103
108 int main(int argc, char **argv) 104 int main(int argc, char **argv)
109 { 105 {