-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin_manager.h
52 lines (41 loc) · 1.35 KB
/
plugin_manager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// plugin_manager.h: Plugin manager interface. It's used both by plugins
// and the main application.
// The main application will create a PluginManager and pass a pointer to
// plugins, which use the PluginManager_register_* functions to register
// hooks on the PluginManager.
//
// Eli Bendersky ([email protected])
// This code is in the public domain
//
#ifndef PLUGIN_MANAGER_H
#define PLUGIN_MANAGER_H
#include "sds.h"
//
// Types of hook callbacks registered by plugins
//
// String Manipulate hook. Will be called with: the input String
//
typedef sds (*PluginStrManipulateHook)(sds);
typedef struct PluginManager_t PluginManager;
// Create a new plugin manager.
//
PluginManager* PluginManager_new();
// Free the memory of a plugin manager.
//
void PluginManager_free(PluginManager* pm);
// Register a hook for input String.
//
void PluginManager_register_strmanipulatehook(PluginManager* pm,
PluginStrManipulateHook hook);
// Apply the registered str manipulate hooks to the given input string, returning
// the transformed string.
// All registered hooks are composed:
//
// while (has_plugins)
// inputstr = apply_next_plugin(inputstr)
//
// If no str manipulate plugin exists, NULL is returned.
//
sds PluginManager_apply_strmanipulatehooks(PluginManager* pm, sds inputstr);
#endif /* PLUGIN_MANAGER_H */