-
Notifications
You must be signed in to change notification settings - Fork 1
/
Example.c
69 lines (54 loc) · 1.48 KB
/
Example.c
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
/* Search and replace "Example" with new module name. */
#include <stdio.h> /* fprintf */
#include <stdlib.h> /* calloc */
#include <string.h> /* memcpy */
#include "CTI.h"
#include "Example.h"
static void Config_handler(Instance *pi, void *msg);
enum { INPUT_CONFIG };
static Input Example_inputs[] = {
[ INPUT_CONFIG ] = { .type_label = "Config_msg", .handler = Config_handler },
};
//enum { /* OUTPUT_... */ };
static Output Example_outputs[] = {
//[ OUTPUT_... ] = { .type_label = "", .destination = 0L },
};
typedef struct {
Instance i;
// int ...;
} Example_private;
static Config config_table[] = {
// { "...", set_..., get_..., get_..._range },
};
static void Config_handler(Instance *pi, void *data)
{
Generic_config_handler(pi, data, config_table, table_size(config_table));
}
static void Example_tick(Instance *pi)
{
Handler_message *hm;
hm = GetData(pi, 1);
if (hm) {
hm->handler(pi, hm->data);
ReleaseMessage(&hm,pi);
}
pi->counter++;
}
static void Example_instance_init(Instance *pi)
{
Example_private *priv = (Example_private *)pi;
}
static Template Example_template = {
.label = "Example",
.priv_size = sizeof(Example_private),
.inputs = Example_inputs,
.num_inputs = table_size(Example_inputs),
.outputs = Example_outputs,
.num_outputs = table_size(Example_outputs),
.tick = Example_tick,
.instance_init = Example_instance_init,
};
void Example_init(void)
{
Template_register(&Example_template);
}