Rizin
unix-like reverse engineering framework and cli tools
main.c
Go to the documentation of this file.
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 
11 void mfp_register(const char *name) {
12  fprintf(stderr, "Registered plugin \"%s\"\n", name);
13 }
14 
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 }
int main(int argc, const char **argv)
Definition: main.c:340
void * malloc(size_t size)
Definition: malloc.c:123
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
Definition: z80asm.h:102
Definition: unix.h:218
void(* init_plugin_function)()
Definition: main.c:9
void mfp_register(const char *name)
Definition: main.c:11
UV_EXTERN int uv_dlopen(const char *filename, uv_lib_t *lib)
Definition: dl.c:33
UV_EXTERN int uv_dlsym(uv_lib_t *lib, const char *name, void **ptr)
Definition: dl.c:53
UV_EXTERN const char * uv_dlerror(const uv_lib_t *lib)
Definition: dl.c:60