本文整理汇总了C++中PluginInfo::get_options_list方法的典型用法代码示例。如果您正苦于以下问题:C++ PluginInfo::get_options_list方法的具体用法?C++ PluginInfo::get_options_list怎么用?C++ PluginInfo::get_options_list使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PluginInfo
的用法示例。
在下文中一共展示了PluginInfo::get_options_list方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ERROR
/* return value means the number of successfully loaded plugins */
static int
enumerate_plugins(const gchar *plugin_path, GPtrArray *plugin_array, GOptionContext *ctx)
{
GDir *dir;
const gchar *fname;
dir = g_dir_open(plugin_path, 0, NULL);
if (!dir)
{
ERROR("unable to open plugin directory %s (err=%s)\n", plugin_path, strerror(errno));
return 0;
}
DEBUG("search for plugins in directory %s\n", plugin_path);
/* add common options to help context: */
g_option_context_add_main_entries(ctx, loggen_options, 0);
GModule *module = NULL;
while ((fname = g_dir_read_name(dir)))
{
if (!g_str_has_suffix(fname,G_MODULE_SUFFIX))
continue;
gchar *full_lib_path = g_build_filename(plugin_path,fname,NULL);
module = g_module_open(full_lib_path, G_MODULE_BIND_LAZY);
if (!module)
{
ERROR("error opening plugin module %s (%s)\n", fname, g_module_error());
continue;
}
/* get plugin info from lib file */
PluginInfo *plugin;
if (!g_module_symbol(module, LOGGEN_PLUGIN_INFO, (gpointer *) &plugin))
{
DEBUG("%s isn't a plugin for loggen. skip it. (%s)\n", fname, g_module_error());
g_module_close(module);
continue;
}
if (is_plugin_already_loaded(plugin_array, plugin->name))
{
DEBUG("plugin %s was already loaded. skip it\n", plugin->name);
continue;
}
if (plugin->set_generate_message)
plugin->set_generate_message(generate_message);
else
ERROR("plugin (%s) doesn't have set_generate_message function\n",plugin->name);
g_ptr_array_add(plugin_array, (gpointer) plugin);
/* create sub group for plugin specific parameters: */
GOptionGroup *group = g_option_group_new(plugin->name, plugin->name, "Show options", NULL, NULL);
g_option_group_add_entries(group, plugin->get_options_list());
g_option_context_add_group(ctx, group);
DEBUG("%s in %s is a loggen plugin\n", plugin->name, fname);
}
if (plugin_array->len == 0)
{
ERROR("no loggen plugin found in %s\n", plugin_path);
}
return plugin_array->len;
}