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