aboutsummaryrefslogtreecommitdiffstats
path: root/utils/gen-modules.sh
blob: ec8191c66f0f3ccfc0e415f726dff13225559f3f (plain)
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
#!/bin/sh
#
# This script generate modules.c and modules.h for rspamd
# Used by build system

echo "#ifndef MODULES_H" > modules.h
echo "#include \"config.h\"" >> modules.h
echo "#include \"modules.h\"" > modules.c
echo "module_t modules[] = {" >> modules.c;

for arg in $@ ; do
	IFS=/
	for comp in ${arg} ; do
		echo $comp | egrep '^[^/]+.c$' > /dev/null 2>&1
		if [ $? -eq 0 ] ; then
			mod=`echo $comp | sed -e 's/.c$//'`
		fi
	done
	if [ "F${mod}" != "F" ] ; then
		echo "{\"${mod}\", ${mod}_module_init, ${mod}_module_config, ${mod}_module_reconfig}," >> modules.c
		echo "int ${mod}_module_init(struct config_file *cfg, struct module_ctx **ctx);" >> modules.h
		echo "int ${mod}_module_config(struct config_file *cfg);" >> modules.h
		echo "int ${mod}_module_reconfig(struct config_file *cfg);" >> modules.h
	fi
	IFS=" "
done

echo "};" >> modules.c
echo "#endif" >> modules.h