#!/bin/sh
# Find fvwm commands from function.c struct functions
# Written by Toshi Isogai

ff="FvwmCommand.sh";
fc="../../fvwm/functions.c";


echo "# $ff" > $ff;
echo "# Collection of fvwm2 builtin commands for FvwmCommand" >> $ff
echo "" >> $ff;

echo "alias FvwmCommand='$1/FvwmCommand'" >> $ff;
echo 'AM () { ' >> $ff
echo 'FvwmCommand "+ $*"' >> $ff
echo '}' >> $ff;


awk 'OFS="";
    /struct function/,/""/ {
 
	if( $0 ~ /\{ *"[a-zA-Z_]/ ) {
		sub(/^ *\{ *"/,"",$0); 
		sub(/".*/,"",$0);
		print  $0," () {"
		print  "FvwmCommand \"",$0," $*\""
        print  "}" ;
	}
}' $fc >> $ff;



