-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin.c
52 lines (43 loc) · 1.2 KB
/
plugin.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
// plugin.c - load plugin module
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "btmha.h"
//===========================================================
void afc_bind(PLUG* plugin);
void agc_bind(PLUG* plugin);
void cfirfb_bind(PLUG* plugin);
void ciirfb_bind(PLUG* plugin);
void firfb_bind(PLUG* plugin);
void gha_bind(PLUG *plugin);
void icmp_bind(PLUG* plugin);
void iirfb_bind(PLUG* plugin);
typedef struct {void (*bind)(PLUG *); char *name; } plug_id;
static plug_id plug_ls[] = {
{afc_bind, "afc" },
{agc_bind, "agc" },
{cfirfb_bind, "cfirfb"},
{ciirfb_bind, "ciirfb"},
{firfb_bind, "firfb" },
{gha_bind, "gha" },
{icmp_bind, "icmp" },
{iirfb_bind, "iirfb" }
};
static int nplug = sizeof(plug_ls) / sizeof(plug_id);
//===========================================================
int
plugin_load(PLUG *plugin, int pn, char verbose)
{
int k;
void (*bind)(PLUG *plugin) = NULL;
for (k = 0; k < nplug; k++) {
if (strcmp(plugin[pn].name, plug_ls[k].name) == 0) {
bind = plug_ls[k].bind;
if (bind) {
bind(plugin + pn);
}
break;
}
}
return (!bind);
}