~lattis/muon

ref: 85283983c022b571ca80d040d866215509ad0afe muon/src/functions/modules.c -rw-r--r-- 985 bytes
85283983Stone Tickle implement very basic pc file generation 8 months ago
                                                                                
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
#include "posix.h"

#include <string.h>

#include "functions/common.h"
#include "functions/modules.h"
#include "functions/modules/fs.h"
#include "functions/modules/pkgconfig.h"
#include "functions/modules/python.h"
#include "log.h"

const char *module_names[module_count] = {
	[module_fs] = "fs",
	[module_python] = "python",
	[module_python3] = "python3",
	[module_pkgconfig] = "pkgconfig",
};

bool
module_lookup(const char *name, enum module *res)
{
	enum module i;
	for (i = 0; i < module_count; ++i) {
		if (strcmp(name, module_names[i]) == 0) {
			*res = i;
			return true;
		}
	}

	return false;
}

static const struct func_impl_name *module_func_tbl[module_count] = {
	[module_fs] = impl_tbl_module_fs,
	[module_python] = impl_tbl_module_python,
	[module_python3] = impl_tbl_module_python3,
	[module_pkgconfig] = impl_tbl_module_pkgconfig,
};

bool
module_lookup_func(const char *name, enum module mod, func_impl *res)
{
	return func_lookup(module_func_tbl[mod], name, res);
}