summaryrefslogtreecommitdiff
path: root/mk.sh
blob: 80b5ae1d0acc41e1c405f253d0871b7dfa5648d9 (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
#!/bin/sh

classify_source () {
	NAME=$(basename $1 .c)

	if grep -q "^REFERENCE(" $1; then
		echo REFERENCE
	elif grep -q "^#define ${NAME}[ (]" $1; then
		echo MACRO
	elif grep -q "#undef ${NAME}" $1; then
		echo MACRO
	elif grep -q "^typedef.* ${NAME}.*;" $1; then
		echo TYPE
	elif grep -q "^typedef.*{$" $1; then
		echo TYPE_LONG
	elif grep -q "^struct.*{" $1; then
		echo STRUCT
	elif grep -q "^union.*{" $1; then
		echo UNION
	elif grep -q "^[A-Za-z_].* ${NAME};" $1; then
		echo EXTERN
	elif grep -q 'TGFN' $1; then
		echo TGFN
	else
		echo FUNCTION
	fi
}