Mercurial
comparison third_party/libuv/docs/code/plugin/main.c @ 160:948de3f54cea
[ThirdParty] Added libuv
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Wed, 14 Jan 2026 19:39:52 -0800 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 159:05cf9467a1c3 | 160:948de3f54cea |
|---|---|
| 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; | |
| 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 return 0; | |
| 38 } |