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