2018-03-14 11:27:27 +08:00
|
|
|
/* $%BEGINLICENSE%$
|
|
|
|
Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
published by the Free Software Foundation; version 2 of the
|
|
|
|
License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
|
|
02110-1301 USA
|
|
|
|
|
|
|
|
$%ENDLICENSE%$ */
|
|
|
|
|
2018-03-06 14:00:39 +08:00
|
|
|
#ifndef _CHASSIS_PLUGIN_H_
|
|
|
|
#define _CHASSIS_PLUGIN_H_
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <gmodule.h>
|
|
|
|
|
|
|
|
#include "chassis-mainloop.h"
|
|
|
|
#include "chassis-exports.h"
|
|
|
|
|
|
|
|
/* current magic is 0.8.0-1 */
|
|
|
|
#define CHASSIS_PLUGIN_MAGIC 0x00080001L
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The private stats structure of a plugin. This is opaque to the rest of the code,
|
|
|
|
* we can only get a copy of it in a hash.
|
|
|
|
* @see chassis_plugin_stats.get_stats()
|
|
|
|
*/
|
|
|
|
typedef struct chassis_plugin_stats chassis_plugin_stats_t;
|
|
|
|
typedef struct chassis_plugin_config chassis_plugin_config;
|
|
|
|
|
|
|
|
typedef struct chassis_plugin {
|
|
|
|
/**< a magic token to verify that the plugin API matches */
|
2018-03-20 14:19:44 +08:00
|
|
|
long magic;
|
2018-03-06 14:00:39 +08:00
|
|
|
|
|
|
|
/**< name of the option group (used in --help-<option-grp> */
|
2018-03-20 14:19:44 +08:00
|
|
|
gchar *option_grp_name;
|
2018-03-06 14:00:39 +08:00
|
|
|
|
|
|
|
/**< user visible name of this plugin */
|
2018-03-20 14:19:44 +08:00
|
|
|
gchar *name;
|
2018-03-06 14:00:39 +08:00
|
|
|
|
|
|
|
/**< the plugin's version number */
|
2018-03-20 14:19:44 +08:00
|
|
|
gchar *version;
|
2018-03-06 14:00:39 +08:00
|
|
|
|
|
|
|
/**< the plugin handle when loaded */
|
2018-03-20 14:19:44 +08:00
|
|
|
GModule *module;
|
2018-03-06 14:00:39 +08:00
|
|
|
|
|
|
|
/**< contains the plugin-specific statistics */
|
|
|
|
chassis_plugin_stats_t *stats;
|
|
|
|
|
|
|
|
/**< handler function to initialize the plugin-specific stats */
|
2018-03-20 14:19:44 +08:00
|
|
|
chassis_plugin_stats_t *(*new_stats) (void);
|
2018-03-06 14:00:39 +08:00
|
|
|
|
|
|
|
/**< handler function to dealloc the plugin-specific stats */
|
2018-03-20 14:19:44 +08:00
|
|
|
void (*free_stats) (chassis_plugin_stats_t *user_data);
|
2018-03-06 14:00:39 +08:00
|
|
|
|
|
|
|
/**< handler function to retrieve the plugin-specific stats */
|
2018-03-20 14:19:44 +08:00
|
|
|
GHashTable *(*get_stats) (chassis_plugin_stats_t *user_data);
|
2018-03-06 14:00:39 +08:00
|
|
|
|
|
|
|
/**< contains the plugin-specific config data */
|
|
|
|
chassis_plugin_config *config;
|
|
|
|
|
|
|
|
/**< handler function to allocate/initialize a chassis_plugin_config struct */
|
2018-03-20 14:19:44 +08:00
|
|
|
chassis_plugin_config *(*init) (void);
|
2018-03-06 14:00:39 +08:00
|
|
|
|
|
|
|
/**< handler function used to deallocate the chassis_plugin_config */
|
2018-03-20 14:19:44 +08:00
|
|
|
void (*destroy) (chassis *chas, chassis_plugin_config *user_data);
|
2018-03-06 14:00:39 +08:00
|
|
|
|
|
|
|
/**< handler function to obtain the command line argument information */
|
2018-03-20 14:19:44 +08:00
|
|
|
GList *(*get_options) (chassis_plugin_config *user_data);
|
2018-03-06 14:00:39 +08:00
|
|
|
|
|
|
|
/**< handler function to set the argument values in the plugin's config */
|
2018-03-20 14:19:44 +08:00
|
|
|
int (*apply_config) (chassis *chas, chassis_plugin_config *user_data);
|
2018-03-06 14:00:39 +08:00
|
|
|
|
2018-07-31 10:10:30 +08:00
|
|
|
void (*stop_listening) (chassis *chas, chassis_plugin_config *user_data);
|
|
|
|
|
2018-03-06 14:00:39 +08:00
|
|
|
/**< handler function to retrieve the plugin's global state */
|
2018-03-20 14:19:44 +08:00
|
|
|
void *(*get_global_state) (chassis_plugin_config *user_data, const char *member);
|
2018-03-06 14:00:39 +08:00
|
|
|
|
|
|
|
} chassis_plugin;
|
|
|
|
|
|
|
|
CHASSIS_API chassis_plugin *chassis_plugin_new(void);
|
|
|
|
CHASSIS_API chassis_plugin *chassis_plugin_load(const gchar *name);
|
|
|
|
CHASSIS_API void chassis_plugin_free(chassis_plugin *p);
|
|
|
|
CHASSIS_API GList *chassis_plugin_get_options(chassis_plugin *p);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve the chassis plugin for a particular name.
|
|
|
|
*
|
|
|
|
* @param chas a pointer to the chassis
|
|
|
|
* @param plugin_name The name of the plugin to look up.
|
|
|
|
* @return A pointer to a chassis_plugin structure
|
|
|
|
* @retval NULL if there is no loaded chassis with this name
|
|
|
|
*/
|
|
|
|
CHASSIS_API chassis_plugin *chassis_plugin_for_name(chassis *chas, gchar *plugin_name);
|
|
|
|
|
|
|
|
#endif
|