#include <dlfcn.h>
Go to the source code of this file.
Functions | |
| static int | cmd_import (int argc, char **argv) |
| mycmd_init (import, cmd_import,"cmds","echo") | |
| static int cmd_import | ( | int | argc, | |
| char ** | argv | |||
| ) | [static] |
Definition at line 2 of file import.c.
References initcmd(), and mysymbol_head.
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(); /* Clear any existing error */ 00015 00016 /* Writing: cosine = (double (*)(double)) dlsym(handle, "cos"); 00017 would seem more natural, but the C99 standard leaves 00018 casting from "void *" to a function pointer undefined. 00019 The assignment used below is the POSIX.1-2003 (Technical 00020 Corrigendum 1) workaround; see the Rationale for the 00021 POSIX specification of dlsym(). */ 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 // dlclose(handle); 00033 return 0; 00034 }
| mycmd_init | ( | import | , | |
| cmd_import | , | |||
| "cmds" | , | |||
| "echo" | ||||
| ) |
1.5.6