From d0dc3f5c30ca0b8350b48ba032a65681bfa20bdb Mon Sep 17 00:00:00 2001
From: Lorry
Date: Wed, 15 Aug 2012 09:31:11 +0100
Subject: Tarball conversion
---
autoconf/scripts/index.sh | 171 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 171 insertions(+)
create mode 100755 autoconf/scripts/index.sh
(limited to 'autoconf/scripts/index.sh')
diff --git a/autoconf/scripts/index.sh b/autoconf/scripts/index.sh
new file mode 100755
index 0000000..e0a0c07
--- /dev/null
+++ b/autoconf/scripts/index.sh
@@ -0,0 +1,171 @@
+#!/bin/ash
+#
+# Script to generate an HTML index of all C code from the current directory
+# downwards (skipping directories ending in ~). The header comment in each
+# file is listed, and each function's prototype and comment are given. A
+# list of "TODO:" comments is also generated.
+#
+# Outputs the HTML on standard output.
+#
+# If a parameter is given, it is the prefix to put before any "view file"
+# links, eg ".." to link to "../dir/file.c" instead of "dir/file.c".
+#
+# Skips any files containing the string !NOINDEX.
+#
+# Requires ctags and cproto.
+#
+
+OFFS=$1
+
+
+# Convert the given string to HTML-escaped values (<, >, & escaped) on
+# stdout.
+#
+html_safe () {
+ echo "$*" \
+ | sed -e 's|&|\&|g;s|<|\<|g;s|>|\>|g'
+}
+
+
+# Convert the given string to HTML-escaped values (<, >, & escaped) on
+# stdout, also adding a
to the end of each line.
+#
+html_safebr () {
+ echo "$*" \
+ | sed -e 's|&|\&|g;s|<|\<|g;s|>|\>|g;s/$/
/'
+}
+
+ALLFILES=`find . -name '*~' -prune -o -type f -name '*.c' \
+ -exec grep -FL '!NOINDEX' /dev/null '{}' ';'`
+
+CTAGDATA=`echo "$ALLFILES" \
+ | ctags -nRf- -L- --c-types=f \
+ | sed 's/ .\// /;s/;" .*$//'`
+
+FILELIST=`echo "$CTAGDATA" | cut -d ' ' -f 2 | sort | uniq`
+
+echo ''
+echo 'Source Code Index'
+echo ''
+echo ''
+echo '
'
+
+echo ''
+echo ''
+echo "$FILELIST" \
+| sed -e \
+ 's|^.*$|\0
|'
+echo '
'
+
+for FILE in $FILELIST; do
+
+ DIR=`dirname $FILE`
+ FUNCDEFS=`cproto -f1 -I. -Isrc/include -I$DIR $FILE 2>/dev/null \
+ | sed -n 's/^.*[ *]\([^ *(]*\)(.*$/\1/p'`
+ FILEHEAD="`sed -n -e \
+ '1,/\*\//{/\/\*/,/\*\//{s/^[\/ *]//;s/^\*[\/]*//;p;};}' \
+ < $FILE`"
+ FILESHORTDESC=`echo "$FILEHEAD" | sed -n '1,/^ *$/{/^ *[^ ]*/p;}'`
+ FILELONGDESC=`echo "$FILEHEAD" | sed '1,/^ *$/d'`
+
+ echo '
'
+ echo ''
+ echo ''
+ echo ''"$FILE"' | '
+ echo ' - | '
+ echo ''`html_safe "$FILESHORTDESC"`' | '
+ echo '
'
+ echo '[View File]
'
+ echo ''
+ echo "`html_safebr "$FILELONGDESC"`"
+ echo '
'
+
+ if [ -n "$FUNCDEFS" ]; then
+ echo 'Functions defined:
'
+ echo ''
+ echo "$FUNCDEFS" \
+ | sed 's|^.*$|\0|' \
+ | sed 's/^//;s|$|
|'
+ echo '
'
+ fi
+
+ echo '['
+ echo 'Top |'
+ echo 'To Do |'
+ echo 'Functions ]
'
+done
+
+echo ''
+echo ''
+echo "$CTAGDATA" | while read FUNC FILE LINENUM REST; do
+ echo -n ''
+ echo -n ''"$FUNC"'
'
+ echo '['"$FILE"'
] '
+done
+echo '
'
+
+echo "$CTAGDATA" | while read FUNC FILE LINENUM REST; do
+
+ FUNCDEF=`sed -n "$LINENUM,/{/p" < $FILE \
+ | tr '\n' ' ' \
+ | tr -d '{'`
+
+ LASTCOMLINE=`sed -n '1,'"$LINENUM"'{/\/\*/=;}' < $FILE | sed -n '$p'`
+ [ -z "$LASTCOMLINE" ] && LASTCOMLINE=1
+ LASTENDFUNCLINE=`sed -n '1,'"$LINENUM"'{/}/=;}' < $FILE | sed -n '$p'`
+ [ -z "$LASTENDFUNCLINE" ] && LASTENDFUNCLINE=1
+ FUNCHEAD="`sed -n -e \
+ "$LASTCOMLINE,"'/\*\//{h;s/^[\/ *]//;s/^\*[\/]*//;p;x;/\*\//q;}' \
+ < $FILE`"
+ [ "$LASTCOMLINE" -le "$LASTENDFUNCLINE" ] && FUNCHEAD=""
+
+ echo '
'
+ echo ''
+ echo -n ''
+ echo -n "$FUNC"'
'
+ echo -n '['
+ echo "$FILE"'
]'
+ echo '
'
+
+ echo ''"`html_safe "$FUNCDEF"`"'
'
+
+ echo ''
+ echo "`html_safebr "$FUNCHEAD"`"
+ echo '
'
+
+ echo '['
+ echo 'Top |'
+ echo 'To Do |'
+ echo 'Files ]
'
+done
+
+echo ''
+echo ''
+for FILE in $FILELIST; do
+
+ TODOLINES=`sed -n \
+ -e '/\/\*.*\*\//!{/\/\*/,/\*\//{/TODO:/{=;};};}' \
+ -e '/\/\*.*\*\//{/TODO:/{=;};}' \
+ < $FILE`
+
+ [ -z "$TODOLINES" ] && continue
+
+ echo -n ''
+ echo ''"$FILE"'
'
+ echo ''
+
+ for NUM in $TODOLINES; do
+ TODO=`sed -n "$NUM"'{s/^.*TODO://;s/\*\/.*$//;p;}' < $FILE`
+ echo "- [$NUM] `html_safe "$TODO"`
"
+ done
+
+ echo '
'
+done
+
+echo ''
+
+# EOF
--
cgit v1.2.1