dlcall.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <errno.h>
00003 #include <unistd.h>
00004 #include <dlfcn.h>
00005 
00006 typedef int (*MAIN_ENTRY)(int argc, char** argv);
00007 
00008 int main(int argc, char** argv){
00009         void* dl;
00010         MAIN_ENTRY f;
00011     dl=dlopen(argv[1], RTLD_NOW);
00012     if (!dl) {
00013         fprintf(stderr, "%s: %s\n", argv[1], dlerror());
00014         return -1;
00015     }
00016     f = dlsym(dl, argv[2]);
00017     if (!f) {
00018         fprintf(stderr, "%s:%s: %s\n", argv[1], argv[2], dlerror());
00019         return -1;
00020     }
00021     argv[2] = argv[0];
00022     return f(argc-2, argv+2);
00023 }


dji_ronin
Author(s):
autogenerated on Sat Jun 8 2019 20:15:31