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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
#ifndef MODULE_H
#define MODULE_H
#include <glib.h>
#include <audiofile.h>
#include <config.h>
#include "undo.h"
#include "shell.h"
#include "action.h"
#include "iterator.h"
typedef int module_id;
#define MODULE_API_VERSION 0x0200
#define MODULE_MAGIC 0x4242
/* Macro to fill in module struct. */
#define MODULE_INIT(module, n, a, c) \
do { (module)->magic = MODULE_MAGIC; \
(module)->version = MODULE_API_VERSION; \
(module)->error = NULL; \
(module)->name = (n); \
(module)->author = (a); \
(module)->copyright = (c); } while(0)
/*
* Module info. The module should return a pointer to this structure
* (initialized using the MODULE_INIT macro) from its module_new()
* function.
*/
typedef struct {
int magic;
int version;
char *name;
char *author;
char *copyright;
/* The module can use this field to store private data. */
void *privdata;
/* The module can use this field to signal initalization
errors. */
char *error;
/* These are filled in by GNUsound. */
char *fname;
void *handle;
} module;
extern module modules[];
/*
* Private functions.
*/
void
module_exit();
void
module_load(const char *path);
int
module_init();
/*
* Module API.
*/
/*
* Required. Called once to during module lifetime to initialize the
* module. Module should return a structure initialized using the
* MODULE_INIT() macro. If initalization fails, the module should
* specify the error in the module->error parameter or return NULL.
*/
module *
module_new();
/*
* Optional. Called once during module lifetime to destroy the module.
* It should free all the resources allocated during module_new().
*/
void
module_destroy(module *mod);
/*
* Optional. This function is called when the user performs the "open"
* action on the module. It should set up the structure in
* shl->module_state[id]. When this function is not defined, then
* the module's module_execute() function will be called instead. It
* is the responsibility of this function to display an interface
* and dispatch the MODULE_EXECUTE action when necessary.
*/
void
module_open(module_id id,
shell *shl,
int undo);
/*
* Required if module_open() exists. Should tear down the structure in
* shl->module_state[id].
*/
void
module_close(struct _module_state *module_state);
/*
* Required. Invoked when the module should do its job. If the module
* does not have a module_open() function, then this function is
* invoked automatically. If the module does have a module_open()
* function, then the module itself it responsible for invoking this
* function. The id of the module can be retrieved by using
* shl->active_module_id. This function should return an action_group
* that can be applied to reverse the effects of the action, or NULL
* if that is not possible.
*/
action_group *
module_execute(shell *shl,
int undo);
#endif /* ! MODULE_H */
|