-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.h
44 lines (36 loc) · 1.25 KB
/
module.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
/*
* ----------------------------------------------------------------------------
* "THE COFFEE-WARE LICENSE" (Revision 23):
* <[email protected]> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can bring me a coffee in return.
* ----------------------------------------------------------------------------
*/
#ifndef _MODULE_H_
#define _MODULE_H_
#include <string.h>
#include <stdio.h>
#ifndef MAX_MODULES
#define MAX_MODULES 10
#endif
typedef char module_name_t[50];
typedef char module_ident_t[10];
// Module
typedef struct {
module_name_t name;
module_ident_t ident;
void * func; // The module executable
} module_t;
// Modules registry
typedef struct {
module_name_t name;
module_t modules[MAX_MODULES];
unsigned char max_id;
signed char default_id;
} module_registry_t;
void init_registry(module_registry_t * registry);
int register_module(module_registry_t * registry, module_t * module);
void usage_modules(module_registry_t * registry);
module_t * search_module(module_registry_t * registry, module_ident_t * ident);
module_t * get_default_module(module_registry_t * registry);
#endif