Mercurial > hg > vamp-plugin-load-checker
comparison helper.cpp @ 4:6f891a9c6434
Make checker with hard-coded knowledge about various plugin types and paths; fix some process management problems
author | Chris Cannam |
---|---|
date | Wed, 13 Apr 2016 12:00:07 +0100 |
parents | 2288c1d05c28 |
children | 74064d6f5e07 |
comparison
equal
deleted
inserted
replaced
3:3bae396cf8e0 | 4:6f891a9c6434 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ |
2 | 2 |
3 /** | 3 /** |
4 * Plugin Load Checker Helper | 4 * Plugin Load Checker Helper |
5 * | 5 * |
6 * This program accepts the name of a descriptor function as its only | 6 * This program accepts the name of a descriptor symbol as its only |
7 * command-line argument. It then reads a list of plugin library paths | 7 * command-line argument. It then reads a list of plugin library paths |
8 * from stdin, one per line. For each path read, it attempts to load | 8 * from stdin, one per line. For each path read, it attempts to load |
9 * that library and retrieve the named descriptor function, printing a | 9 * that library and retrieve the named descriptor symbol, printing a |
10 * line to stdout reporting whether this was successful or not and | 10 * line to stdout reporting whether this was successful or not and |
11 * then flushing stdout. The output line format is described | 11 * then flushing stdout. The output line format is described |
12 * below. The program exits with code 0 if all libraries were loaded | 12 * below. The program exits with code 0 if all libraries were loaded |
13 * successfully and non-zero otherwise. | 13 * successfully and non-zero otherwise. |
14 * | 14 * |
55 else return e; | 55 else return e; |
56 } | 56 } |
57 | 57 |
58 string check(string soname, string descriptor) | 58 string check(string soname, string descriptor) |
59 { | 59 { |
60 // cerr << "helper: trying: " << soname << endl; | |
61 | |
60 void *handle = DLOPEN(soname, RTLD_NOW | RTLD_LOCAL); | 62 void *handle = DLOPEN(soname, RTLD_NOW | RTLD_LOCAL); |
61 if (!handle) { | 63 if (!handle) { |
64 // cerr << "helper: failed to open" << endl; | |
62 return "Unable to open plugin library: " + error(); | 65 return "Unable to open plugin library: " + error(); |
63 } | 66 } |
64 | 67 |
65 void *fn = DLSYM(handle, descriptor); | 68 void *fn = DLSYM(handle, descriptor); |
66 if (!fn) { | 69 if (!fn) { |
70 // cerr << "helper: failed to find descriptor" << endl; | |
67 return "Failed to find plugin descriptor " + descriptor + | 71 return "Failed to find plugin descriptor " + descriptor + |
68 " in library: " + error(); | 72 " in library: " + error(); |
69 } | 73 } |
70 | 74 |
75 // cerr << "helper: succeeded" << endl; | |
76 | |
71 return ""; | 77 return ""; |
72 } | 78 } |
73 | 79 |
74 int main(int argc, char **argv) | 80 int main(int argc, char **argv) |
75 { | 81 { |
76 bool allGood = true; | 82 bool allGood = true; |
77 string soname; | 83 string soname; |
78 | 84 |
79 if (argc != 2) { | 85 if (argc != 2) { |
80 cerr << "\nUsage:\n " << argv[0] << " descriptorname\n" | 86 cerr << "\nUsage:\n " << argv[0] << " descriptorname\n" |
81 "\nwhere descriptorname is the name of a plugin descriptor function to be sought\n" | 87 "\nwhere descriptorname is the name of a plugin descriptor symbol to be sought\n" |
82 "in each library (e.g. vampGetPluginDescriptor for Vamp plugins). The list of\n" | 88 "in each library (e.g. vampGetPluginDescriptor for Vamp plugins). The list of\n" |
83 "candidate plugin library filenames is read from stdin.\n" << endl; | 89 "candidate plugin library filenames is read from stdin.\n" << endl; |
84 return 2; | 90 return 2; |
85 } | 91 } |
86 | 92 |