Changeset 7486853
- Timestamp:
- 2016-12-26T00:20:09Z (8 years ago)
- Branches:
- master
- Children:
- 6d212f4
- Parents:
- 6908ab7
- git-author:
- dequis <dx@…> (25-12-16 23:10:58)
- git-committer:
- dequis <dx@…> (26-12-16 00:20:09)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
r6908ab7 r7486853 50 50 } 51 51 52 /* semi-private */ 53 gboolean plugin_info_validate(struct plugin_info *info, const char *path) 54 { 55 GList *l; 56 gboolean loaded = FALSE; 57 58 if (!path) { 59 path = "(null)"; 60 } 61 62 if (info->abiver != BITLBEE_ABI_VERSION_CODE) { 63 log_message(LOGLVL_ERROR, 64 "`%s' uses ABI %u but %u is required\n", 65 path, info->abiver, 66 BITLBEE_ABI_VERSION_CODE); 67 return FALSE; 68 } 69 70 if (!info->name || !info->version) { 71 log_message(LOGLVL_ERROR, 72 "Name or version missing from the " 73 "plugin info in `%s'\n", path); 74 return FALSE; 75 } 76 77 for (l = plugins; l; l = l->next) { 78 struct plugin_info *i = l->data; 79 80 if (g_strcasecmp(i->name, info->name) == 0) { 81 loaded = TRUE; 82 break; 83 } 84 } 85 86 if (loaded) { 87 log_message(LOGLVL_WARNING, 88 "%s plugin already loaded\n", 89 info->name); 90 return FALSE; 91 } 92 93 return TRUE; 94 } 95 96 /* semi-private */ 97 gboolean plugin_info_add(struct plugin_info *info) 98 { 99 plugins = g_list_insert_sorted_with_data(plugins, info, pluginscmp, NULL); 100 return TRUE; 101 } 102 52 103 gboolean load_plugin(char *path) 53 104 { 54 GList *l;55 struct plugin_info *i;56 105 struct plugin_info *info = NULL; 57 106 struct plugin_info * (*info_function) (void) = NULL; … … 59 108 60 109 GModule *mod = g_module_open(path, G_MODULE_BIND_LAZY); 61 gboolean loaded = FALSE;62 110 63 111 if (!mod) { … … 69 117 info = info_function(); 70 118 71 if (info->abiver != BITLBEE_ABI_VERSION_CODE) { 72 log_message(LOGLVL_ERROR, 73 "`%s' uses ABI %u but %u is required\n", 74 path, info->abiver, 75 BITLBEE_ABI_VERSION_CODE); 76 g_module_close(mod); 77 return FALSE; 78 } 79 80 if (!info->name || !info->version) { 81 log_message(LOGLVL_ERROR, 82 "Name or version missing from the " 83 "plugin info in `%s'\n", path); 84 g_module_close(mod); 85 return FALSE; 86 } 87 88 for (l = plugins; l; l = l->next) { 89 i = l->data; 90 91 if (g_strcasecmp(i->name, info->name) == 0) { 92 loaded = TRUE; 93 break; 94 } 95 } 96 97 if (loaded) { 98 log_message(LOGLVL_WARNING, 99 "%s plugin already loaded\n", 100 info->name); 119 if (!plugin_info_validate(info, path)) { 101 120 g_module_close(mod); 102 121 return FALSE; … … 113 132 114 133 if (info_function) { 115 plugins = g_list_insert_sorted_with_data(plugins, info, 116 pluginscmp, NULL); 134 plugin_info_add(info); 117 135 } 118 136
Note: See TracChangeset
for help on using the changeset viewer.