3 # Create a file named identifiers containing identifiers from internal header
4 # files or all header files, based on --internal flag.
5 # Outputs the line count of the file to stdout.
7 # Usage: list-identifiers.sh [ -i | --internal ]
11 if [ -d include/mbedtls ]; then :; else
12 echo "$0: must be run from root" >&2
26 echo "Unknown argument: '$1'"
35 HEADERS=$( ls include/mbedtls/*_internal.h | egrep -v 'compat-1\.3\.h|bn_mul' )
37 HEADERS=$( ls include/mbedtls/*.h | egrep -v 'compat-1\.3\.h|bn_mul' )
42 grep '^[^ /#{]' $HEADERS | \
43 sed -e 's/^[^:]*://' | \
44 egrep -v '^(extern "C"|(typedef )?(struct|enum)( {)?$|};?$)' \
48 sed -n -e 's/.* \**\([a-zA-Z_][a-zA-Z0-9_]*\)(.*/\1/p' \
49 -e 's/.*(\*\(.*\))(.*/\1/p' _decls
50 grep -v '(' _decls | sed -e 's/\([a-zA-Z0-9_]*\)[;[].*/\1/' -e 's/.* \**//'
53 if [ $( wc -l < _identifiers ) -eq $( wc -l < _decls ) ]; then
55 egrep -v '^(u?int(16|32|64)_t)$' _identifiers | sort > identifiers
58 echo "$0: oops, lost some identifiers" 2>&1