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
16 /* Names of dependencies plugins may specify. */
17 #define nr_dependencies 6
18 extern const char *dependency_names
[nr_dependencies
];
20 /* A plugin hook consists of a name and a handler function. */
24 void (*handler
)(const char *);
27 /* Hooks that a plugin may define. */
29 extern const struct hook hooks
[nr_hooks
];
33 /* Struct representing a plugin instance. */
36 /* The name of the plugin. */
39 /* Array of dependencies. Each dependency is a (possibly empty) list of
40 * strings. The dependencies must be stored in the same order as the
41 * dependency names above. The strings a freed when the plugin is destroyed
42 * thus must be stored as copies. */
43 struct list
*dependencies
[nr_dependencies
];
45 /* Did one of the save hooks fail? */
48 /* The type of the plugin. */
49 struct plugin_type
*type
;
51 /* The call_hook and close functions may use this pointer. */
56 /* Struct representing the type of a plugin. */
59 /* Method that is called on plugin initialization. */
60 bool (*init
)(struct plugin
*p
);
61 /* Method that is called on plugin destruction. */
62 void (*destroy
)(struct plugin
*p
);
63 /* Method that is called when a hook should be executed. */
64 bool (*call_hook
)(struct plugin
*p
, const char *name
);
68 extern struct plugin_type
*module
;
70 extern struct plugin_type
*script
;
72 /* Open a new plugin struct of the given type. On error errno is set and NULL
74 struct plugin
*new_plugin(const char *name
, struct plugin_type
*type
);
76 /* Destroy the given plugin. This is the opposite of of __allocate_plugin.
77 * This function should not be called directly. */
78 void destroy_plugin(struct plugin
*p
);
80 /* Call the hook of a plugin. */
81 bool call_hook(struct plugin
*p
, const char *hook_name
);