From: kazama@square.ntt.jp (Kazuhiro Kazama)
Newsgroups: fj.comp.texhax
Subject: Re: including EPSF figure into Tex File
Date: 7 Apr 92 14:40:09 GMT
	<278936@nttlab.ntt.JP> <KURI.92Apr3140053@news3.pontneuf.tis.co.jp>
	<TAKEBA.92Apr6122902@rondo.otsl.oki.co.jp>
Distribution: fj
Organization: NTT Software Laboratories, Tokyo, Japan.
In-reply-to: takeba@otsl.oki.co.jp's message of 6 Apr 1992 12:29:02 JST

$@Iw4V!w#N#T#T%=%U%H8&(J$@$G$9!#(J

In article <TAKEBA.92Apr6122902@rondo.otsl.oki.co.jp> takeba@otsl.oki.co.jp (Takahiro Takebayashi) writes:
 > $@$D$^$j!"(J
 > 	   $@3($N0LCV$,@hF,$@$HBg>fIW(J
 > 		   $@"-(J
 > 	   $@3($N=PNO$,%Z!<%8$N;O$a$J$i(J$@Bg>fIW(J
 > 		   $@"-(J
 > 	   jdvi2kps$@$G$O(J@beginspecialspecial$@$+$i$N;XDj$NCf$K3($N:BI8$OF~$C$F$$$k(J
 > 		   $@"-(J
 > 	   $@%]%9%H%9%/%j%W%H$N=PNO=g=x$rJQ$($F$b=PNO$5$l$k?^$OF1$8$O$:(J
 > $@$H$$$&?dO@$r9T$J$$!#(J
 > @beginspecial $@$+$i(J @endspecial $@$^$G$r(J @bop $@$ND>8e$K0\$9$H$$$&(Jawk$@%9%/%j(J
 > $@%W%H$r=q$$$F$_$^$7$?!#(J

$@!!$&!<$s(J$@!"BgC@$G$9$P$i$7$$H/A[$@$H;W$$$^$9!#46F0$7$^$7$?!#$3$l$@$H$&$^(J
$@$/2sHr$G$-$k$+$b$7$l$^$;$s!#(J

$@!!;d$b(Jdvi2ps-j$@MQ$K:G=i8E$$(Jawk$@$G=q$3$&$H$7$F=q$1$J$$$N$K5$$,$D$$$F!"(J
SunOS 4.1.1$@$N(Jnawk$@$r;H$C$?(Jshell script$@$K$7(J$@$?$i!"(Jnawk$@$H(Jgawk$@$HF0:n$,0[$J(J
$@$k$N$K5$$,$D$$$F!":#EY$O(Jperl$@$G=q$$$?$iCY$$$N$G!"7k6I(JC$@8@8l$G=q$-$^$7$?!#(J
$@E73$$5$s$N%"%I%P%$%9DL$j!":G=i$+$i(JC$@$G=q$1$P$h$+$C$?(J;-(

$@!!$H$$$&$o$1$G!"(Jdvi2ps-j$@MQ$N(JC$@8@8l$G=q$$$?%W%m(J$@%0%i%`$rEj9F$7$^$9!#(J
dvi2ps-j$@$N%f!<%6$O$3$l$G%P%0$r$&$^$/2sHr$G$-$k$+$I$&$+$r;n$7$F$_$F$/$@(J
$@$5$$!#$3$l(J$@$GLdBj$r2sHr$G$-$k$+$I$&$+CN$j$?$$$N$G!"$<$R7k2L$r%a!<%k$^$?(J
$@$O%K%e!<%9$G65$($F2<$5$$!#(J

$@!!%W%m%0%i%`(J$@$O5^$$$G:n$C$?$N$G$+$J$j$$$$2C8:$G$9$,!"$H$j$"$($:$,$^$s$7(J
$@$F$/$@$5$$!#0-$$=j$O8@$C$F$b$i$($PD>$7$^$9(J$@!#<B$O0l2sEj9F$7$?8e$K!"E73$(J
$@$5$s$,$5$C$=$/(JANSI-C$@%3%s%Q%$%i$G$O$&$^$/F0$+$J$$%P%0$r;XE&$7$F$/$l$?$N(J
$@$G(J$@!"%-%c%s%;%k$7$F=$@5$7$^$7$?!#(J

$@!!;H$$J}$O!"(J
	dvi2ps foo.dvi | texfix | lpr
$@$_$?$$$K!"I8=`F~NO$+$iFI$s(J$@$GI8=`=PNO$K=P$7$^$9!#$J$*!"(JJDVI2KPS$@$rDj5A$9(J
$@$k$H(Jjdvi2kps$@$G$b;H$($k$+$b$7$l$^$;$s!J$?$@$7L$3NG'$G$9!K(J$@!#(J
--- cut here --- cut here --- cut here --- cut here --- cut here ---
/*
 *	texfix.c
 *
 *	version 1.0 (April 7, 1992)
 *	written by Kazuhiro Kazama (kazama@square.ntt.jp)
 *
 *	This original program is retexps made by takeba@otsl.oki.co.jp.
 */
#include	<stdio.h>
#include	<string.h>
#include	<signal.h>
char *mktemp();

#define	PAGECOM	"%%Page:"
#define	BSP	"@beginspecial"
#define	ESP	"@endspecial"
#ifdef JDVI2KPS
#define	BOP	"@bop"
#define	EOP	"@eop"
#else
#define	BOP	"BP"
#define	EOP	"EP"
#endif

char	line[BUFSIZ];
char	tmpstr[] = "/tmp/tfXXXXXX";
char	*tmpfn;
int	cleanup();

main()
{
    if ((tmpfn = mktemp(tmpstr)) == NULL) {
        perror("mktemp failed.");
        exit(1);
    }
    signal(SIGHUP, cleanup);
    signal(SIGINT, cleanup);
    signal(SIGQUIT, cleanup);
    signal(SIGPIPE, cleanup);
    signal(SIGTERM, cleanup);
    while (gets(line) != NULL) {
	if (strncmp(line, PAGECOM, strlen(PAGECOM)) == 0) {
	    printf("%s\n", line);
	    if (pageout())
		break;
	} else
	    printf("%s\n", line);
    }
    unlink(tmpfn);
    exit(0);
}

pageout()
{
    char	*p;
    int	c;
    FILE	*tmpfp;

    while (gets(line) != NULL) {
	if (strcmp(line, BOP) == 0) {
	    printf("%s\n", line);
	    if ((tmpfp = fopen(tmpfn, "w")) == NULL) {
		perror("fopen failed.");
		exit(1);
	    }
	} else if (strcmp(line, EOP) == 0) {
	    fclose(tmpfp);
	    if ((tmpfp = fopen(tmpfn, "r")) == NULL) {
		perror("fopen failed.");
		exit(1);
	    }
	    while ((c = getc(tmpfp)) != EOF)
		putchar(c);
	    fclose(tmpfp);
	    printf("%s\n", line);
	    return 0;
	} else if ((p = strstr(line, BSP)) != NULL && strcmp(p, BSP) == 0) {
	    printf("%s\n", line);
	    if (specialout())
		return 1;
	} else
	    fprintf(tmpfp, "%s\n", line);
    }
    return 1;
}

specialout()
{
    char	*p;
    int	inspecial = 1;

    while (gets(line) != NULL) {
	if ((p = strstr(line, BSP)) != NULL && strcmp(p, BSP) == 0) {
	    printf("%s\n", line);
	    inspecial++;
	} else if (strcmp(line, ESP) == 0) {
	    printf("%s\n", line);
	    if (--inspecial == 0)
		return 0;
	} else
	    printf("%s\n", line);
    }
    return 1;
}

cleanup()
{
    unlink(tmpfn);
    exit(0);
}
--
	$@Iw4V0lMN(J (kazama@square.ntt.jp)
	NTT$@%=%U%H%&%'%"8&5f=j(J $@%=%U%H%&%'%"4pAC5;=Q8&5fIt(J
	$@J,;67?%=%U%H%&%'%"8&5f%0%k!<%W(J