Add vcs-load-dirs project to thirdparty directory.
[Melange.git] / thirdparty / vcs-load-dirs / docs / sgml-common / ps2epsi
blobf7216d629afebcc46aea5651c9b31b41e25e78f3
1 #!/bin/sh
2 # $RCSfile: ps2epsi,v $ $Revision: 1.4.2.2 $
3 # arch-tag: ps2epsi customized for sgml-common
5 tmpfile=/tmp/ps2epsi$$
7 export outfile
9 if [ $# -lt 1 -o $# -gt 2 ]; then
10 echo "Usage: `basename $0` file.ps [file.epsi]" 1>&2
11 exit 1
14 infile=$1;
16 if [ $# -eq 1 ]
17 then
18 case "${infile}" in
19 *.ps) base=`basename ${infile} .ps` ;;
20 *.cps) base=`basename ${infile} .cps` ;;
21 *.eps) base=`basename ${infile} .eps` ;;
22 *.epsf) base=`basename ${infile} .epsf` ;;
23 *) base=`basename ${infile}` ;;
24 esac
25 outfile=${base}.epsi
26 else
27 outfile=$2
30 ls -l ${infile} |
31 awk 'F==1 {
32 cd="%%CreationDate: " $6 " " $7 " " $8;
33 t="%%Title: " $9;
34 f="%%For:" U " " $3;
35 c="%%Creator: Ghostscript ps2epsi from " $9;
36 next;
38 /^%!/ {next;}
39 /^%%Title:/ {t=$0; next;}
40 /^%%Creator:/ {c=$0; next;}
41 /^%%CreationDate:/ {cd=$0; next;}
42 /^%%For:/ {f=$0; next;}
43 !/^%/ {
44 print "/ps2edict 30 dict def";
45 print "ps2edict begin";
46 print "/epsititle (" t "\\n) def";
47 print "/epsicreator (" c "\\n) def";
48 print "/epsicrdt (" cd "\\n) def";
49 print "/epsifor (" f "\\n) def";
50 print "end";
51 exit(0);
53 ' U="$USERNAME$LOGNAME" F=1 - F=2 ${infile} >$tmpfile
55 gs -q -dNOPAUSE -dSAFER -dDELAYSAFER -r72 -sDEVICE=bit -sOutputFile=/dev/null $tmpfile ps2epsi.ps $tmpfile <${infile} 1>&2
56 rm -f $tmpfile
59 cat << BEGINEPS
60 save countdictstack mark newpath /showpage {} def /setpagedevice {pop} def
61 %%EndProlog
62 %%Page 1 1
63 BEGINEPS
65 cat ${infile} |
66 sed -e '/^%%BeginPreview:/,/^%%EndPreview[^!-~]*$/d' -e '/^%!PS-Adobe/d'\
67 -e '/^%%[A-Za-z][A-Za-z]*[^!-~]*$/d' -e '/^%%[A-Za-z][A-Za-z]*: /d'
69 cat << ENDEPS
70 %%Trailer
71 cleartomark countdictstack exch sub { end } repeat restore
72 %%EOF
73 ENDEPS
75 ) >> ${outfile}
77 exit 0