Mercurial > pidgin
comparison src/plugins.c @ 391:be408b41c172
[gaim-migrate @ 401]
Plugins got updated.
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Mon, 12 Jun 2000 11:30:05 +0000 |
| parents | fd3cc0a28d5d |
| children | df5127560034 |
comparison
equal
deleted
inserted
replaced
| 390:0890c6250e7e | 391:be408b41c172 |
|---|---|
| 136 plugin_dialog = NULL; | 136 plugin_dialog = NULL; |
| 137 } | 137 } |
| 138 | 138 |
| 139 void load_plugin(char *filename) { | 139 void load_plugin(char *filename) { |
| 140 struct gaim_plugin *plug; | 140 struct gaim_plugin *plug; |
| 141 void (*gaim_plugin_init)(); | 141 int (*gaim_plugin_init)(); |
| 142 char *(*gaim_plugin_error)(int); | |
| 142 char *(*cfunc)(); | 143 char *(*cfunc)(); |
| 143 char *error; | 144 char *error; |
| 145 int retval; | |
| 146 char *plugin_error; | |
| 144 | 147 |
| 145 if (filename == NULL) return; | 148 if (filename == NULL) return; |
| 146 plug = g_malloc(sizeof *plug); | 149 plug = g_malloc(sizeof *plug); |
| 147 if (filename[0] != '/') { | 150 if (filename[0] != '/') { |
| 148 char *buf = g_malloc(BUF_LEN); | 151 char *buf = g_malloc(BUF_LEN); |
| 170 dlclose(plug->handle); | 173 dlclose(plug->handle); |
| 171 g_free(plug); | 174 g_free(plug); |
| 172 return; | 175 return; |
| 173 } | 176 } |
| 174 | 177 |
| 178 retval = (*gaim_plugin_init)(plug->handle); | |
| 179 sprintf(debug_buff, "loaded plugin returned %d\n", retval); | |
| 180 debug_print(debug_buff); | |
| 181 if (retval) { | |
| 182 GList *c = callbacks; | |
| 183 struct gaim_callback *g; | |
| 184 while (c) { | |
| 185 g = (struct gaim_callback *)c->data; | |
| 186 if (g->handle == plug->handle) { | |
| 187 callbacks = g_list_remove(callbacks, c->data); | |
| 188 sprintf(debug_buff, "Removing callback, %d remain\n", | |
| 189 g_list_length(callbacks)); | |
| 190 debug_print(debug_buff); | |
| 191 c = callbacks; | |
| 192 if (c == NULL) { | |
| 193 break; | |
| 194 } | |
| 195 } else { | |
| 196 c = c->next; | |
| 197 } | |
| 198 } | |
| 199 gaim_plugin_error = dlsym(plug->handle, "gaim_plugin_error"); | |
| 200 if ((error = (char *)dlerror()) == NULL) { | |
| 201 plugin_error = (*gaim_plugin_error)(retval); | |
| 202 if (plugin_error) | |
| 203 do_error_dialog(plugin_error, _("Plugin Error")); | |
| 204 } | |
| 205 dlclose(plug->handle); | |
| 206 g_free(plug); | |
| 207 return; | |
| 208 } | |
| 209 | |
| 175 plugins = g_list_append(plugins, plug); | 210 plugins = g_list_append(plugins, plug); |
| 176 (*gaim_plugin_init)(plug->handle); | |
| 177 | 211 |
| 178 cfunc = dlsym(plug->handle, "name"); | 212 cfunc = dlsym(plug->handle, "name"); |
| 179 if ((error = (char *)dlerror()) == NULL) | 213 if ((error = (char *)dlerror()) == NULL) |
| 180 plug->name = (*cfunc)(); | 214 plug->name = (*cfunc)(); |
| 181 else | 215 else |
