Mercurial > hg > vamp-plugin-pack
comparison get-version.cpp @ 66:85768d48e6ce
Add get-version utility
author | Chris Cannam |
---|---|
date | Wed, 12 Feb 2020 14:41:09 +0000 |
parents | |
children | 38cd115c91d4 |
comparison
equal
deleted
inserted
replaced
65:bf0fc15c3e21 | 66:85768d48e6ce |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 /* | |
3 Copyright (c) 2020 Queen Mary, University of London | |
4 | |
5 Permission is hereby granted, free of charge, to any person | |
6 obtaining a copy of this software and associated documentation | |
7 files (the "Software"), to deal in the Software without | |
8 restriction, including without limitation the rights to use, copy, | |
9 modify, merge, publish, distribute, sublicense, and/or sell copies | |
10 of the Software, and to permit persons to whom the Software is | |
11 furnished to do so, subject to the following conditions: | |
12 | |
13 The above copyright notice and this permission notice shall be | |
14 included in all copies or substantial portions of the Software. | |
15 | |
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
17 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | |
20 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |
21 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
22 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
23 | |
24 Except as contained in this notice, the names of the Centre for | |
25 Digital Music and Queen Mary, University of London shall not be | |
26 used in advertising or otherwise to promote the sale, use or other | |
27 dealings in this Software without prior written authorization. | |
28 */ | |
29 | |
30 #include <vamp-hostsdk/PluginHostAdapter.h> | |
31 | |
32 // Undocumented internal API | |
33 #include <vamp-hostsdk/../src/vamp-hostsdk/Files.h> | |
34 | |
35 #include <iostream> | |
36 #include <string> | |
37 | |
38 using namespace std; | |
39 | |
40 void usage(const char *me) | |
41 { | |
42 cerr << endl; | |
43 cerr << "Usage: " << me << " <soname>" << endl; | |
44 cerr << endl; | |
45 cerr << "Loads the Vamp plugin library found in <soname> and lists\n" | |
46 << "the plugin versions found therein. Plugins are listed one per\n" | |
47 << "line, with the plugin id and version number separated by a colon." | |
48 << endl; | |
49 cerr << endl; | |
50 cerr << "Note that <soname> must be the path to a plugin library, not\n" | |
51 << "merely the name of the library. That is, no search path is used.\n" | |
52 << "The file path should be UTF-8 encoded (on all platforms)." | |
53 << endl; | |
54 cerr << endl; | |
55 cerr << "The return code is 0 if the plugin library was successfully\n" | |
56 << "loaded, otherwise 1. An error message may be printed to stderr\n" | |
57 << "in the latter case." << endl; | |
58 cerr << endl; | |
59 exit(2); | |
60 } | |
61 | |
62 int main(int argc, char **argv) | |
63 { | |
64 char *scooter = argv[0]; | |
65 char *name = 0; | |
66 while (scooter && *scooter) { | |
67 if (*scooter == '/' || *scooter == '\\') name = ++scooter; | |
68 else ++scooter; | |
69 } | |
70 if (!name || !*name) name = argv[0]; | |
71 | |
72 if (argc != 2) usage(name); | |
73 if (string(argv[1]) == string("-?")) usage(name); | |
74 | |
75 string libraryPath(argv[1]); | |
76 | |
77 void *handle = Files::loadLibrary(libraryPath); | |
78 if (!handle) { | |
79 cerr << "Unable to load library " << libraryPath << endl; | |
80 return 1; | |
81 } | |
82 | |
83 VampGetPluginDescriptorFunction fn = | |
84 (VampGetPluginDescriptorFunction)Files::lookupInLibrary | |
85 (handle, "vampGetPluginDescriptor"); | |
86 | |
87 if (!fn) { | |
88 cerr << "No vampGetPluginDescriptor function found in library \"" | |
89 << libraryPath << "\"" << endl; | |
90 Files::unloadLibrary(handle); | |
91 return 1; | |
92 } | |
93 | |
94 int index = 0; | |
95 const VampPluginDescriptor *descriptor = 0; | |
96 | |
97 while ((descriptor = fn(VAMP_API_VERSION, index))) { | |
98 cout << descriptor->identifier << ":" | |
99 << descriptor->pluginVersion << endl; | |
100 ++index; | |
101 } | |
102 | |
103 Files::unloadLibrary(handle); | |
104 | |
105 return 0; | |
106 } |