summaryrefslogtreecommitdiffstats
path: root/tests/generate-symbols-list
blob: 33a2e239f059a0391ca49a8a35d3961cbe9e50ad (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
30
31
32
33
34
35
#!/bin/bash

function fail()
{
	[ -n "$1" ] && echo "$1"
	exit 2
}

function generate() {
	local ver=

	while IFS= read -r line; do
		local len=${#line}


		if [ "${line:0:11}" = "CRYPTSETUP_" ]; then
			local i=12
			while [ $i -lt $len ]; do
				if [ "${line:$i:1}" = "{" ]; then
					ver=${line:0:$i}
					break
				fi
				i=$((i+1))
			done
		elif [ "${line:0:6}" = "crypt_" -a -n "$ver" ]; then
			printf 'CHECK_SYMBOL(%s, %s)\n' $line $ver
		fi
	done < <(tr -d '[:blank:];' < $1)
}

test $# -ge 1 || fail "usage: $0 <symbol_file>"

test -f $1 || fail "$1 is not a file."

generate $1