import.c
Go to the documentation of this file.00001 #include <dlfcn.h>
00002 static int cmd_import(int argc,char **argv)
00003 {
00004 void *handle;
00005 void (*initcmd)(void *);
00006 char *error;
00007
00008 handle = dlopen(argv[1], RTLD_NOW|RTLD_GLOBAL);
00009 if (!handle) {
00010 fprintf(stderr, "%s\n", dlerror());
00011 exit(EXIT_FAILURE);
00012 }
00013
00014 dlerror();
00015
00016
00017
00018
00019
00020
00021
00022
00023 initcmd = dlsym(handle, "initcmd");
00024
00025 if ((error = dlerror()) != NULL) {
00026 fprintf(stderr, "%s\n", error);
00027 exit(EXIT_FAILURE);
00028 }
00029
00030 initcmd(mysymbol_head);
00031
00032
00033 return 0;
00034 }
00035
00036 mycmd_init(import,cmd_import,"cmds","echo");