/[baselayout]/trunk/src/rc-plugin.c
Gentoo

Diff of /trunk/src/rc-plugin.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2703 Revision 2704
26 int (*hook) (rc_hook_t, const char *); 26 int (*hook) (rc_hook_t, const char *);
27 struct plugin *next; 27 struct plugin *next;
28} plugin_t; 28} plugin_t;
29 29
30static plugin_t *plugins = NULL; 30static plugin_t *plugins = NULL;
31
32#ifndef __FreeBSD__
33dlfunc_t dlfunc (void * __restrict handle, const char * __restrict symbol)
34{
35 union {
36 void *d;
37 dlfunc_t f;
38 } rv;
39
40 rv.d = dlsym (handle, symbol);
41 return (rv.f);
42}
43#endif
31 44
32void rc_plugin_load (void) 45void rc_plugin_load (void)
33{ 46{
34 char **files; 47 char **files;
35 char *file; 48 char *file;
60 file = strsep (&func, "."); 73 file = strsep (&func, ".");
61 len = strlen (file) + 7; 74 len = strlen (file) + 7;
62 func = rc_xmalloc (sizeof (char *) * len); 75 func = rc_xmalloc (sizeof (char *) * len);
63 snprintf (func, len, "_%s_hook", file); 76 snprintf (func, len, "_%s_hook", file);
64 77
65#ifdef __FreeBSD__
66 fptr = (int (*)(rc_hook_t, const char*)) dlfunc (h, func); 78 fptr = (int (*)(rc_hook_t, const char*)) dlfunc (h, func);
67#else
68 fptr = (int (*)(rc_hook_t, const char*)) dlsym (h, func);
69#endif
70 if (! fptr) { 79 if (! fptr) {
71 eerror ("`%s' does not expose the symbol `%s'", p, func); 80 eerror ("`%s' does not expose the symbol `%s'", p, func);
72 dlclose (h); 81 dlclose (h);
73 } else { 82 } else {
74 if (plugin) { 83 if (plugin) {

Legend:
Removed from v.2703  
changed lines
  Added in v.2704

  ViewVC Help
Powered by ViewVC 1.1.20