/[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 2568 Revision 2569
48 char *func; 48 char *func;
49 void *f; 49 void *f;
50 int len; 50 int len;
51 51
52 if (! h) 52 if (! h)
53 { 53 {
54 eerror ("dlopen `%s': %s", p, dlerror ()); 54 eerror ("dlopen `%s': %s", p, dlerror ());
55 free (p); 55 free (p);
56 continue; 56 continue;
57 } 57 }
58 58
59 func = file; 59 func = file;
60 file = strsep (&func, "."); 60 file = strsep (&func, ".");
61 len = strlen (file) + 7; 61 len = strlen (file) + 7;
62 func = rc_xmalloc (sizeof (char *) * len); 62 func = rc_xmalloc (sizeof (char *) * len);
63 snprintf (func, len, "_%s_hook", file); 63 snprintf (func, len, "_%s_hook", file);
64 64
65 f = dlsym (h, func); 65 f = dlsym (h, func);
66 if (! f) 66 if (! f)
67 { 67 {
68 eerror ("`%s' does not expose the symbol `%s'", p, func); 68 eerror ("`%s' does not expose the symbol `%s'", p, func);
69 dlclose (h); 69 dlclose (h);
70 } 70 }
71 else 71 else
72 { 72 {
73 if (plugin) 73 if (plugin)
74 { 74 {
75 plugin->next = rc_xmalloc (sizeof (plugin_t)); 75 plugin->next = rc_xmalloc (sizeof (plugin_t));
76 plugin = plugin->next; 76 plugin = plugin->next;
77 } 77 }
78 else 78 else
79 plugin = plugins = rc_xmalloc (sizeof (plugin_t)); 79 plugin = plugins = rc_xmalloc (sizeof (plugin_t));
80 80
81 memset (plugin, 0, sizeof (plugin_t)); 81 memset (plugin, 0, sizeof (plugin_t));
82 plugin->name = strdup (file); 82 plugin->name = strdup (file);
83 plugin->handle = h; 83 plugin->handle = h;
84 plugin->hook = f; 84 plugin->hook = f;
85 } 85 }
86 86
87 free (func); 87 free (func);
88 free (p); 88 free (p);
89 } 89 }
90 90
96 plugin_t *plugin = plugins; 96 plugin_t *plugin = plugins;
97 97
98 while (plugin) 98 while (plugin)
99 { 99 {
100 if (plugin->hook) 100 if (plugin->hook)
101 plugin->hook (hook, value); 101 plugin->hook (hook, value);
102 102
103 plugin = plugin->next; 103 plugin = plugin->next;
104 } 104 }
105} 105}
106 106

Legend:
Removed from v.2568  
changed lines
  Added in v.2569

  ViewVC Help
Powered by ViewVC 1.1.20