src/util.c: shut up gcc warnings
[vlock.git] / src / plugin.h
blobff69dfab7dc3aacbda16a84025b4b702046ee45b
1 /* plugin.h -- header file for the generic plugin routines for vlock,
2 * the VT locking program for linux
4 * This program is copyright (C) 2007 Frank Benkstein, and is free
5 * software which is freely distributable under the terms of the
6 * GNU General Public License version 2, included as the file COPYING in this
7 * distribution. It is NOT public domain software, and any
8 * redistribution not permitted by the GNU General Public License is
9 * expressly forbidden without prior written permission from
10 * the author.
14 #pragma once
16 #include <stdbool.h>
17 #include <glib.h>
18 #include <glib-object.h>
20 /* Names of dependencies plugins may specify. */
21 #define nr_dependencies 6
22 extern const char *dependency_names[nr_dependencies];
24 /* A plugin hook consists of a name and a handler function. */
25 struct hook
27 const char *name;
28 void (*handler)(const char *);
31 /* Hooks that a plugin may define. */
32 #define nr_hooks 4
33 extern const struct hook hooks[nr_hooks];
35 /* Errors */
36 #define VLOCK_PLUGIN_ERROR vlock_plugin_error_quark()
37 GQuark vlock_plugin_error_quark(void);
39 enum {
40 VLOCK_PLUGIN_ERROR_FAILED,
41 VLOCK_PLUGIN_ERROR_DEPENDENCY,
42 VLOCK_PLUGIN_ERROR_NOT_FOUND
46 * Plugin type macros.
48 #define TYPE_VLOCK_PLUGIN (vlock_plugin_get_type())
49 #define VLOCK_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_VLOCK_PLUGIN,\
50 VlockPlugin))
51 #define VLOCK_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\
52 TYPE_VLOCK_PLUGIN,\
53 VlockPluginClass))
54 #define IS_VLOCK_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\
55 TYPE_VLOCK_PLUGIN))
56 #define IS_VLOCK_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\
57 TYPE_VLOCK_PLUGIN))
58 #define VLOCK_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),\
59 TYPE_VLOCK_PLUGIN,\
60 VlockPluginClass))
62 typedef struct _VlockPlugin VlockPlugin;
63 typedef struct _VlockPluginClass VlockPluginClass;
65 struct _VlockPlugin
67 GObject parent_instance;
69 gchar *name;
71 GList *dependencies[nr_dependencies];
73 bool save_disabled;
76 struct _VlockPluginClass
78 GObjectClass parent_class;
80 bool (*open)(VlockPlugin *self, GError **error);
81 bool (*call_hook)(VlockPlugin *self, const gchar *hook_name);
84 GType vlock_plugin_get_type(void);
86 /* Open the plugin. */
87 bool vlock_plugin_open(VlockPlugin *self, GError **error);
89 GList *vlock_plugin_get_dependencies(VlockPlugin *self,
90 const gchar *dependency_name);
91 bool vlock_plugin_call_hook(VlockPlugin *self, const gchar *hook_name);