#/bin/sh

rm -f gsac_help.h

cat > jj  << EOF
HELP
ABS
ADD
ADDF
AGC
BACKGROUND
BANDPASS
BANDREJECT
BEGINGRAPHICS
BOXCAR
CD
CHNHDR
COLOR
CONVOLVE
CORRELATE
CUT
CUTERR
DECIMATE
DELETE
DIF
DIV
DIVF
ECHO
ENVELOPE
EXP
EXP10
FFT
FILEID
FILTER
FUNCGEN
GRID
HIGHPASS
HILBERT
HISTORY
HOLD
INT
INTERPOLATE
LINLIN
LINLOG
LISTHEADER
LOG
LOG10
LOWPASS
MAP
MAP5
MARKTIMES
MERGE
MOMENTTENSOR
MUL
MULF
OUTCSV
PAUSE
PCTL
PLOT1
PLOTPK
PLOTSP
PLOTSPPK
PRS
QDP
READ
READHDR
REFRACTION
REVERSE
RICKER
RMEAN
ROTATE
ROTATE3
RTREND
SGN
SHIFT
SMOOTH
SORT
SQR
SQRT
STACK
SUB
SUBF
SYNCHRONIZE
TAPER
TITLE
TRANSFER
TRAPEZOID
TRIANGLE
VERSION
WHITEN
WRITE
WRITEHEADER
WRITESPEC
XGRID
XLIM
XLIN
XLOG
YGRID
YLIM
YLIN
YLOG
EOF

for j in `cat jj`
do
case $j in
	HELP) TOP="char *help_default [] = {" ; BOT=HELP 
ed HELP.help << POX
/^$/d
w
q
POX
	;;
	READ) TOP="char *help_read[] = {" ; BOT=READ ;;
	WRITE) TOP="char *help_write[] = {" ; BOT=WRITE ;;
	PWS) TOP="char *help_pws[] = {" ;BOT=PWS ;;
	PLOTSPPK) TOP="char *help_psppk[] = {" ;BOT=PLOTSPPK ;;
	RICKER) TOP="char *help_ricker[] = {" ;BOT=RICKER ;;
	SHIFT) TOP="char *help_shift[] = {" ;BOT=SHIFT ;;
	MOMENTTENSOR) TOP="char *help_mt[] = {" ;BOT=MOMENTTENSOR ;;
	TITLE) TOP="char *help_title[] = {" ;BOT=TITLE ;;
	READHDR) TOP="char *help_rh[] = {" ;BOT=READHDR ;;
	OUTCSV) TOP="char *help_outcsv[] = {" ;BOT=OUTCSV ;;
	BACKGROUND) TOP="char *help_back[] = {" ;BOT=BACKGROUND ;;
	GRID) TOP="char *help_grid[] = {" ;BOT=GRID ;;
	YGRID) TOP="char *help_ygrid[] = {" ;BOT=YGRID ;;
	XGRID) TOP="char *help_xgrid[] = {" ;BOT=XGRID ;;
	VERSION) TOP="char *help_v[] = {" ;BOT=VERSION ;;
	TRAPEZOID) TOP="char *help_trapezoid[] = {" ;BOT=TRAPEZOID ;;
	BOXCAR) TOP="char *help_boxcar[] = {" ;BOT=BOXCAR ;;
	TRIANGLE) TOP="char *help_triangle[] = {" ;BOT=TRIANGLE ;;
	MAP) TOP="char *help_map[] = {" ;BOT=MAP ;;
	MAP5) TOP="char *help_map5[] = {" ;BOT=MAP5 ;;
	DECIMATE) TOP="char *help_dec[] = {" ;BOT=DECIMATE ;;
	WRITESPEC) TOP="char *help_writesp[] = {" ;BOT=WRITESPEC ;;
	SUBF) TOP="char *help_subf[] = {" ;BOT=SUBF ;;
	ADDF) TOP="char *help_addf[] = {" ;BOT=ADDF ;;
	DIVF) TOP="char *help_divf[] = {" ;BOT=DIVF ;;
	MULF) TOP="char *help_mulf[] = {" ;BOT=MULF ;;
	REFRACTION) TOP="char *help_refr[] = {" ;BOT=REFRACTION ;;
	FILEID) TOP="char *help_fileid[] = {" ;BOT=FILEID ;;
	WHITEN) TOP="char *help_whit[] = {" ;BOT=WHITEN ;;
	HISTORY) TOP="char *help_hist[] = {" ;BOT=HISTORY ;;
	TAPER) TOP="char *help_taper[] = {" ;BOT=TAPER ;;
	MARKTIMES) TOP="char *help_markt[] = {" ;BOT=MARKTIMES ;;
	REVERSE) TOP="char *help_rev[] = {" ;BOT=REVERSE ;;
	STACK) TOP="char *help_stack[] = {" ;BOT=STACK ;;
	CORRELATE) TOP="char *help_corr[] = {" ;BOT=CORRELATE ;;
	CONVOLVE) TOP="char *help_conv[] = {" ;BOT=CONVOLVE ;;
	SGN) TOP="char *help_sgn[] = {" ;BOT=SGN ;;
	ROTATE3) TOP="char *help_rot3[] = {" ;BOT=ROTATE3 ;;
	SMOOTH) TOP="char *help_smth[] = {" ;BOT=SMOOTH ;;
	XLIM) TOP="char *help_xlim[] = {" ;BOT=XLIM ;;
	ECHO) TOP="char *help_echo[] = {" ;BOT=ECHO ;;
	PAUSE) TOP="char *help_pause[] = {" ;BOT=PAUSE ;;
	HOLD) TOP="char *help_hold[] = {" ;BOT=HOLD ;;
	PCTL) TOP="char *help_pctl[] = {" ;BOT=PCTL ;;
	AGC) TOP="char *help_dagc[] = {" ;BOT=AGC ;;
	YLIM) TOP="char *help_ylim[] = {" ; BOT=YLIM ;;
	MERGE) TOP="char *help_merge[] = {" ; BOT=MERGE ;;
	LOWPASS) TOP="char *help_lp[] = {" ; BOT=LOWPASS ;;
	HIGHPASS) TOP="char *help_hp[] = {" ; BOT=HIGHPASS ;;
	BANDPASS) TOP="char *help_bp[] = {" ; BOT=BANDPASS ;;
	BANDREJECT) TOP="char *help_br[] = {" ; BOT=BANDREJECT ;;
	LISTHEADER) TOP="char *help_lh[] = {" ; BOT=LISTHEADER ;;
	BEGINGRAPHICS) TOP="char *help_bg[] = {" ; BOT=BEGINGRAPHICS ;;
	RTREND) TOP="char *help_rtr[] = {" ; BOT=RTREND ;;
	RMEAN) TOP="char *help_rmean[] = {" ; BOT=RMEAN ;;
	ADD) TOP="char *help_add[] = {" ; BOT=ADD ;;
	SUB) TOP="char *help_sub[] = {" ; BOT=SUB ;;
	DIV) TOP="char *help_div[] = {" ; BOT=DIV ;;
	MUL) TOP="char *help_mul[] = {" ; BOT=MUL ;;
	INT) TOP="char *help_int[] = {" ; BOT=INT ;;
	DIF) TOP="char *help_dif[] = {" ; BOT=DIF ;;
	FFT) TOP="char *help_fft[] = {" ; BOT=FFT ;;
	PLOT1) TOP="char *help_plot[] = {" ; BOT=PLOT1 ;;
	PLOTPK) TOP="char *help_plotpk[] = {" ; BOT=PLOTPK ;;
	PLOTSP) TOP="char *help_plotsp[] = {" ; BOT=PLOTSP ;;
	CHNHDR) TOP="char *help_ch [] = {" ; BOT=CHNHDR ;;
	SORT) TOP="char *help_sort [] = {" ; BOT=SORT ;;
	DELETE) TOP="char *help_del [] = {" ; BOT=DELETE ;;
	SYNCHRONIZE) TOP="char *help_sync [] = {" ; BOT=SYNCHRONIZE ;;
	WRITEHEADER) TOP="char *help_wh [] = {" ; BOT=WRITEHEADER ;;
	COLOR) TOP="char *help_color [] = {" ; BOT=COLOR ;;
	FUNCGEN) TOP="char *help_fg [] = {" ; BOT=FUNCGEN ;;
	CUTERR) TOP="char *help_cuterr [] = {" ; BOT=CUTERR ;;
	ROTATE) TOP="char *help_rot [] = {" ; BOT=ROTATE ;;
	CUT) TOP="char *help_cut [] = {" ; BOT=CUT ;;
	INTERPOLATE) TOP="char *help_in [] = {" ; BOT=INTERPOLATE ;;
	TRANSFER) TOP="char *help_trans [] = {" ; BOT=TRANSFER ;;
	CD) TOP="char *help_cd [] = {" ; BOT=CD ;;
	FILTER) TOP="char *help_filter [] = {" ; BOT=FILTER ;;
	HILBERT) TOP="char *help_hilb [] = {" ; BOT=HILBERT ;;
	ENVELOPE) TOP="char *help_env [] = {" ; BOT=ENVELOPE ;;
	ABS) TOP="char *help_abs [] = {" ; BOT=ABS ;;
	SQR) TOP="char *help_sqr [] = {" ; BOT=SQR ;;
	SQRT) TOP="char *help_sqrt [] = {" ; BOT=SQRT ;;
	EXP) TOP="char *help_exp [] = {" ; BOT=EXP ;;
	EXP10) TOP="char *help_exp10 [] = {" ; BOT=EXP10 ;;
	LOG) TOP="char *help_log [] = {" ; BOT=LOG ;;
	QDP) TOP="char *help_qdp [] = {" ; BOT=QDP ;;
	LOG10) TOP="char *help_log10 [] = {" ; BOT=LOG10 ;;
	XLOG) TOP="char *help_xlog [] = {" ; BOT=XLOG ;;
	XLIN) TOP="char *help_xlin [] = {" ; BOT=XLIN ;;
	YLOG) TOP="char *help_ylog [] = {" ; BOT=YLOG ;;
	YLIN) TOP="char *help_ylin [] = {" ; BOT=YLIN ;;
	LINLIN) TOP="char *help_linlin [] = {" ; BOT=LINLIN ;;
	LINLOG) TOP="char *help_linlog [] = {" ; BOT=LINLOG ;;
	LOGLOG) TOP="char *help_loglog [] = {" ; BOT=LOGLOG ;;
	LOGLIN) TOP="char *help_loglin [] = {" ; BOT=LOGLIN ;;
	PRS) TOP="char *help_prs [] = {" ; BOT=PRS ;;
esac
groff -t -Tascii inc.tmac ${BOT}.trf > ${BOT}.help
ed ${BOT}.help << EOF
?[A-Za-z]?
.p
.+1,\$d
w
q
EOF

echo $TOP >> gsac_help.h
rm -f lunk
ed ${BOT}.help << EFO
1,\$s/^/"/
1,\$s/\$/\\\n",/p
w lunk
EFO
cat lunk >> gsac_help.h
echo  \"\" >> gsac_help.h
echo "};" >> gsac_help.h
echo  >> gsac_help.h
done

#####
#	clean up
#####
rm -f j
rm -f lunk
rm -f *.help
rm -f jj
