
!if $edtype=file
 fcheck=!exec ftype $wims_home/$wims_sesdir/user-deposit
 fcheck=!word 1 of $fcheck
 !if $fcheck=$empty
  error=deposit_fail
  job=edit
  !exit
 !endif
 !if $fcheck notwordof text html latex
  error=deposit_binary
  job=edit
  !exit
 !endif
 !if $fcheck=latex
  srclen=!mexec scripts/flen.sh $wims_home/$wims_sesdir/user-deposit
  !if $srclen>$max_texlen
   error=file_too_long
   !exit
  !endif
  l2htest=!sh which latex2html
  !if $l2htest=$empty or not found isin $l2htest
   error=no_latex2html
   !exit
  !endif
  # The definition of TMPDIR will make latex2html fail!
  !sh cd $wims_home/$wims_sesdir\
	unset TMPDIR\
	cp user-deposit test.tex\
	latex2html -tmp /tmp -split 0 -nonavigation -noimages -noinfo -noaddress test.tex >latex2html.out 2>latex2html.err\
	sed 's/\&#233\;/\&eacute\;/g;s/\&#232\;/\&egrave\;/g;s/\&#224\;/\&agrave\;/g;' <test/test.html >user-deposit\
	rm -r test
  fcheck=html
 !endif
 !if $fcheck=html
  !exec html2msg $wims_home/$wims_sesdir/user-deposit
 !endif
 edtype=
!else
 addtype=replace
!endif

!if $addtype=append
 src=$wims_home/$Docdir/$doc/src/$block
 dest=$wims_home/$wims_sesdir/doc.src
 !mexec scripts/copy.sh
 method=append
!else
 method=copy
!endif

src=$wims_home/$wims_sesdir/user-deposit
dest=$wims_home/$wims_sesdir/doc.src
srclen=!mexec scripts/$method.sh

!if $addtype=prepend
 src=$wims_home/$Docdir/$doc/src/$block
 dest=$wims_home/$wims_sesdir/doc.src
 srclen=!mexec scripts/append.sh
!endif

!if $srclen>$max_blocklen
 error=src_too_long
 job=edit
 !exit
!endif

!writefile wimshome/$wims_sesdir/doc.def
!sh $wims_home/bin/msg2wims $wims_home/$wims_sesdir/doc.src $wims_home/$wims_sesdir/doc.def

