1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4
5 #include <uv.h>
6
7 #include "plugin.h"
8
9 typedef void (*init_plugin_function)();
10
mfp_register(const char * name)11 void mfp_register(const char *name) {
12 fprintf(stderr, "Registered plugin \"%s\"\n", name);
13 }
14
main(int argc,char ** argv)15 int main(int argc, char **argv) {
16 if (argc == 1) {
17 fprintf(stderr, "Usage: %s [plugin1] [plugin2] ...\n", argv[0]);
18 return 0;
19 }
20
21 uv_lib_t *lib = (uv_lib_t*) malloc(sizeof(uv_lib_t));
22 while (--argc) {
23 fprintf(stderr, "Loading %s\n", argv[argc]);
24 if (uv_dlopen(argv[argc], lib)) {
25 fprintf(stderr, "Error: %s\n", uv_dlerror(lib));
26 continue;
27 }
28
29 init_plugin_function init_plugin;
30 if (uv_dlsym(lib, "initialize", (void **) &init_plugin)) {
31 fprintf(stderr, "dlsym error: %s\n", uv_dlerror(lib));
32 continue;
33 }
34
35 init_plugin();
36 }
37
38 return 0;
39 }
40