#! /bin/dash # # update project file # # this script is invoked via chroot+setuidgid # # cwd is $top/$sub # # R. Perry, Aug. 2003 # # ZZ marks local customization sections PATH="/usr/bin"; export PATH RMCMTS="/vecr/bin/rmcmts" INDENT="/usr/bin/indent" mode="$1" user="$2" sub="$3" file="$4" args="$5" case "$color" in "blue") color="green";; "green") color="blue";; *) color="blue";; esac ### # function to check for test option/script # check_tester() { tester="" # case "$file" in p1.c|p1.h|p1.cc|p1.hh|p1.java|p1.sh|scan.l|parse.y) tester="test1" ;; p2.c|p2.h|p2.cc|p2.hh|p2.java|p2.sh) tester="test2" ;; p3.c|p3.h|p3.cc|p3.hh|p3.java|p3.sh) tester="test3" ;; p4.c|p4.h|p4.cc|p4.hh|p4.java|p4.sh) tester="test4" ;; esac # tester_link="" # if [ -n "$tester" -a -x "$tester" ]; then tester_link="- test" fi } ### # function to display subdir, home menu # menu1() { echo "${sub} - Home $tester_link - preproc - asm - asmopt - disasm - cerr - clean - reload - rmcmts - indent - +frames - -frames
" } ### # function to display compile/run menu # menu2() { echo "
Compile args:
" } ### # function to display Update menu # menu3() { echo " <-save changes args: " } # # case "$mode" in update) # # make backup, copy file # rm -f "$file.OLD" mv "$file" "$file.OLD" case "$file" in Makefile) tr -d '\r' | sed -e 's/^ / /' -e '/^$/d' > "$file" ;; *) tr -d '\r' | sed -e '/^$/d' > "$file" ;; esac ;; upload) # # make backup, upload file # read boundary while read header do if [ -z "$header" ]; then break fi done tmpfile="upload.$$" rm -f "$tmpfile" sed -e '/^$/d' -e "/^$boundary/,\$d" > "$tmpfile" # if [ -s "$tmpfile" ]; then rm -f "$file.OLD" mv "$file" "$file.OLD" mv "$tmpfile" "$file" else rm -f "$tmpfile" fi ;; copy) # # make backup, copy file # read fname rest fpath="/vecr/copy/$fname" # if [ -n "$fname" -a -r "$fpath" ]; then rm -f "$file.OLD" mv "$file" "$file.OLD" cp "$fpath" "$file" fi exit 0 ;; edit|rmcmts|indent) # # create links as needed, display edit page # for p in ../../../proto/${sub}/* do f=`basename "$p"` if [ ! -r "$f" ]; then ln -s "$p" "$f" fi done # # dynamically create additional files here... # if [ ! -r "$file" ]; then touch "$file" fi #-- # #-- if [ ! -r "$file" ]; then #-- case "$COURSE" in # ZZ #-- # #-- osp) #-- case "$sub" in #-- a5) case "$file" in #-- p1.c) /vecr/osp/a5/make.sh "$user" > p1.c ;; #-- *) touch "$file" ;; #-- esac #-- ;; #-- *) touch "$file" #-- ;; #-- esac #-- ;; #-- # #-- *) touch "$file" #-- ;; #-- # #-- esac #-- fi # echo "Content-type: text/html\n" echo "${user} - ${COURSE} - ${sub}/${file}

${user} - ${COURSE} - ${sub}/${file}" # if [ "$sub" = "HTML" ]; then case "$file" in *.sh|*.c|*.h|*.cc|*.hh|*.java) echo " (run output Content-Type will be HTML)" ;; esac # ZZ: #-- elif [ "$COURSE/$sub/$file" = "osp/a9/scan.l" ]; then #-- echo " (run output Content-Type will be HTML)" fi # case "$file" in Makefile) echo " (leading blank will be converted to tab)" ;; esac # echo "

" # # ZZ # case "${COURSE}/${sub}" in fc/a10) echo "*** ${sub} was collected Sun May 1 07:01 EDT 2022 ***

" ;; esac # check_tester menu1 menu2 echo "

" menu3 # # echo "

" echo "
" echo "<-save changes
" echo "
" # case "$COURSE" in # ZZ osp) case "$file" in *.c) echo "
" ;; *.txt) echo "
" ;; *.ss) echo "
" ;; # *.sh) # echo "
" # ;; *.l) echo "
" ;; *.y) echo "
" ;; esac ;; os) case "$file" in *.c) echo "
" ;; esac ;; fc) case "$file" in *.c) echo "
" ;; *.txt) echo "
" ;; *.ss) echo "
" ;; esac ;; cpp) case "$file" in *.cc) echo "
" ;; *.txt) echo "
" ;; *.ss) echo "
" ;; *.l) echo "
" ;; *.y) echo "
" ;; esac ;; esac # echo "" ;; *) echo "Content-type: text/plain\n" echo "Bad mode" exit 1 ;; esac