#!/bin/bash

# for each *.h file in /usr/include and /usr/include/sys
# run it through the C preprocessor
# then find function tags.

for file in /usr/include/*.h /usr/include/sys/*.h
do
    #~ echo ${file:5}
    cpp -std=c99 $file ${file:5}
done

# function prototypes from processed headers
ctags -f - --c-kinds=+px  --excmd=number include/sys/*.h include/*.h | grep -E "^[^~_]" | uniq -w12  > tags 

# non-processed headens usually have other stuff OK
ctags -f - --c-kinds=+px  --excmd=number /usr/include/sys/*.h /usr/include/*.h | grep -E "^[^~_]" | uniq -w12  >> tags 

# create api file from tags
python ~/.SciTE/tags2api.py  tags > c99.api

# EOF

