lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | #include <fcntl.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <stdio.h> |
| 4 | #include <dlfcn.h> |
| 5 | #include <stdint.h> |
| 6 | #include <unistd.h> |
| 7 | #include <errno.h> |
| 8 | #include <string.h> |
| 9 | |
| 10 | #define LIBNAME "libafk.so" |
| 11 | |
| 12 | #define LIBAFK "libafk-temp.so" |
| 13 | #define LIBAFK_BAK ".libafk-temp.so.temp" |
| 14 | |
| 15 | int main(int argc, char **argv) |
| 16 | { |
| 17 | void *handle; |
| 18 | |
| 19 | if (rename(LIBAFK, LIBAFK_BAK)) { |
| 20 | fprintf(stderr, "Unable to rename %s: %s\n", LIBAFK, strerror(errno)); |
| 21 | return EXIT_FAILURE; |
| 22 | } |
| 23 | |
| 24 | handle = dlopen(LIBNAME, RTLD_NOW); |
| 25 | if (!handle) { |
| 26 | fprintf(stderr, "Could not open ./%s: %s\n", LIBNAME, dlerror()); |
| 27 | return EXIT_FAILURE; |
| 28 | } |
| 29 | |
| 30 | if (rename(LIBAFK_BAK, LIBAFK)) { |
| 31 | fprintf(stderr, "Unable to rename %s: %s\n", LIBAFK_BAK, strerror(errno)); |
| 32 | return EXIT_FAILURE; |
| 33 | } |
| 34 | |
| 35 | return EXIT_SUCCESS; |
| 36 | } |