home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Carousel
/
CAROUSEL.cdr
/
mactosh
/
unix
/
unix_mac.hqx
(
.txt
)
< prev
next >
Wrap
LaTeX Document
|
1987-02-12
|
10KB
|
268 lines
12-Feb-87 02:12:24-MST,9995;000000000000
Return-Path: <INFO-MAC-REQUEST@SUMEX-AIM.STANFORD.EDU>
Received: from SUMEX-AIM.STANFORD.EDU by SIMTEL20.ARPA with TCP; Thu 12 Feb 87 02:11:57-MST
Return-Path: <weber%brand@usc-oberon.ARPA>
Received: from usc-oberon.ARPA by SUMEX-AIM.STANFORD.EDU with TCP; Mon 2 Feb 87 11:57:10-PST
Received: from brand by usc-oberon.ARPA (5.51/5.5) id AA08286;
Mon, 2 Feb 87 11:44:45 PST
Received: by brand (4.12/5.2) id AA04880;
Mon, 2 Feb 87 11:44:14 pst
Date: Mon, 2 Feb 87 11:44:14 pst
From: Allan G. Weber <weber%brand@usc-oberon.ARPA>
Message-Id: <8702021944.AA04880@brand>
Subject: Unix program for MacDraw->Imagen (3 of 3)
Newsgroups: mod.mac.sources
Distribution: na
To: info-mac@sumex-aim.arpa
ReSent-Date: Wed 11 Feb 87 23:39:18-PST
ReSent-From: Dwayne Virnau... <INFO-MAC-REQUEST@SUMEX-AIM.STANFORD.EDU>
ReSent-To: info-mac-redist: ;
ReSent-Message-ID: <12278384285.26.INFO-MAC-REQUEST@SUMEX-AIM.STANFORD.EDU>
This is part 1 of 3 of "drawimp", a program that runs on Unix to convert
MacDraw files into Impress commands for printing on Imagen laser printers.
Allan Weber
USC Signal and Image Processing Institute
(213) 743-5519
Arpa: Weber%Brand@USC-Oberon.ARPA
UUCP: ...sdcrdcf!usc-oberon!brand!weber
----------------------------------------------------------------------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# README.SPCL
# special.c
# PicMacros.tex
# This archive created: Mon Feb 2 11:06:56 1987
export PATH; PATH=/bin:$PATH
if test -f 'README.SPCL'
echo shar: will not over-write existing file "'README.SPCL'"
cat << \SHAR_EOF > 'README.SPCL'
Instruction for using putting MacDraw files in LaTeX documents
The following files are needed to use the TeX/LaTeX option of drawimp.
special.c - Handles the \special command for including files
with Impress commands in the output stream.
PicMacros.tex - TeX and LaTeX macros
You must be using the "imagen1" dvi-to-impress driver in order to make this
stuff work. This was the driver that came with the TeX distribution tape we
purchased. There may be others that could be made to work also. Imagen1
handles \special's with a routine that reads the data and ignores it.
Special.c has a new routine for handling the \special command and needs to
be linked in with the rest of imagen1.c First, go into your copy of
imagen1.c and find the routine "DoSpecial". Delete or comment out the
DoSpecial in imagen1.c so the one in special.c will be used instead.
Compile imagen1.c and special.c, link them together with whatever else is
needed, and move imagen1 to where it will be found by the shell scripts that
drive the Imagen printer.
The following assumes something like MacTerminal and macget have been used
to upload the MacDraw files to Unix. Normally this leaves three files on
Unix for each Mac file, with extensions .data, .info, and .rsrc. The .info
and .rsrc files can be deleted. Move all the .data files to one place and
% drawimp -t *.data
This will cause drawimp to process each MacDraw .data file into a separate
file containing Impress commands with the same name except ending in .imp.
If there are text objects in any of the pictures, it is important that all
the MacDraw files be processed together in this way. If a new picture is
added later, they should all be processed again or the fonts used in the
pictures will get mixed up.
In the LaTeX file, pictures are include with lines like
\DrawPicture{500}{200}{filename}
The first and second arguments are the width and height respectively of the
box area to reserve for the picture. They are specified in the current
units as set by \setlength{\unitlength}{0.01in} or something similar. The
picture can be larger or smaller than this, but LaTeX will reserve space
according to these parameters. The top-left corner of the active area of
the picture will be placed on the page at the top-left corner of the
reserved area. The picture does not have to be pushed to the top-left of
the MacDraw document page in order for drawimp to find it. The DrawPicture
macro will center the reserved picture area horizontally on the page. The
third parameter is the file name of the picture file as processed by
"drawimp -t". See the macro definition for more info.
Send any comments or bug reports to "Weber%Brand@USC-ECL.ARPA"
Allan Weber
USC Signal and Image Processing Inst.
PHE 306, MC-0272
L.A., CA 90089-0272
(213) 743-5519
SHAR_EOF
fi # end of overwriting check
if test -f 'special.c'
echo shar: will not over-write existing file "'special.c'"
cat << \SHAR_EOF > 'special.c'
Routines for handling \special commands. Currently only supports
inserting impress data from external files. Bitmap stuff is not
complete.
Allan Weber (Weber%Brand@USC-ECL.ARPA) - 9/12/86
/* #define DEBUG */
#include <stdio.h>
#include <ctype.h>
extern char *malloc();
extern int errno;
extern int ImHH, ImVV, hh, vv;
int S_bitmap();
int S_impress();
char *nb();
struct spec {
char *name;
int (*func)();
} spectbl[] = {
"bitmap", S_bitmap,
"impress", S_impress,
"", NULL
/* Perform a \special */
DoSpecial (len)
int len; /* length of the \special string */
struct spec *s;
char *p;
register char ch, *p1, *p2;
if (ImHH != hh || ImVV != vv) /* flush out any pending moves */
ImSetPosition (hh, vv);
p1 = p = malloc(len + 1);
while (len--) /* read the special string */
*p1++ = getc(stdin);
*p1 = '\0';
#ifdef DEBUG
fprintf(stderr,"special: '%s'\n",p);
#endif
p1 = nb(p); /* skip leading blanks */
if (*p1 == '\0') /* if nothing left, return */
return;
p2 = p1;
while ((ch = *p2) != '\0' && !isspace(ch)) /* find end of 1st word */
p2++;
if (ch != '\0') { /* more than one word? */
*p2++ = '\0'; /* mark end of first word */
p2 = nb(p2); /* point to start of rest of string */
s = spectbl;
while (s->func != NULL) {
if (strcmp(p1,s->name) == 0) {
(s->func)(p1,p2);
return;
else
s++;
free(p);
split - separate the words in string s, placing a '\0' after each one
and setting the elements of tok to point to the beginning of each word.
Only do this for up to max words. Return the number of words found.
static split(s,tok,max)
register char *s;
char *tok[];
int i, n;
register char ch;
n = 0;
for (i = 0; i < max; i++) {
s = nb(s); /* find word start */
if ((ch = *s) != '\0') { /* did we find one? */
tok[i] = s;
n++;
while ((ch = *s) != '\0' && !isspace(ch))
s++; /* find end of word */
if (ch != '\0') /* mark end of word */
*s++ = '\0';
else
tok[i] = NULL;
return(n);
char *nb(s)
char *s;
register char ch;
while ((ch = *s) != '\0' && isspace(ch))
s++;
return(s);
/* --------------------------------------------------------------------- */
static S_bitmap(s1, s2)
char *s1, *s2;
int i, n, fd;
int rows, cols, wrows, wcols, wroff, wcoff;
char *p, *word[7];
#ifdef DEBUG
fprintf(stderr,"in bitmap: s1='%s', s2='%s'\n",s1,s2);
#endif
p = malloc(strlen(s2) + 1);
strcpy(p,s2);
n = split(p,word,7);
#ifdef DEBUG
fprintf(stderr, "split into %d words\n",n);
for (i = 0; i < n; i++)
fprintf(stderr,"%d: '%s'\n",i,word[i]);
#endif
#ifndef DEBUG
if ((fd = open(word[0], 0)) == -1) {
error (1, errno, "can't open %s", s2);
if (n < 7) /* no window offset */
word[6] = word[5] = "0";
if (n < 5) { /* full window */
word[3] = word[1];
word[4] = word[2];
if (n < 3) { /* need at least the dimensions */
error(1, 0, "\"\\special bitmap\" not enough arguments");
free(p);
return;
rows = atoi(word[1]); cols = atoi(word[2]);
wrows = atoi(word[3]); wcols = atoi(word[4]);
wroff = atoi(word[5]); wcoff = atoi(word[6]);
close(fd);
#endif
free(p);
static S_impress(s1, s2)
char *s1, *s2;
FILE *fp;
int n, h, v, ch;
char *p, *word[3];
#ifdef DEBUG
fprintf(stderr,"in impress: s1='%s', s2='%s'\n",s1,s2);
#endif
#ifndef DEBUG
p = malloc(strlen(s2) + 1);
strcpy(p,s2);
n = split(p,word,3);
if ((fp = fopen(word[0], "r")) == NULL) {
error (1, errno, "can't open %s", word[0]);
putchar(211); /* push */
if (n == 3) { /* absolute move specified */
if (sscanf(word[1],"%d", &h) == 1) {
putchar(135);
putchar((h >> 8) & 255);
putchar(h & 255);
if (sscanf(word[2],"%d", &v) == 1) {
putchar(137);
putchar((v >> 8) & 255);
putchar(v & 255);
while ((ch = getc(fp)) != EOF || !feof(fp))
putchar(ch);
putchar(212); /* pop */
fclose(fp);
#endif
SHAR_EOF
fi # end of overwriting check
if test -f 'PicMacros.tex'
echo shar: will not over-write existing file "'PicMacros.tex'"
cat << \SHAR_EOF > 'PicMacros.tex'
\def\ifundefined#1{\expandafter\ifx\csname#1\endcsname\relax}
\ifundefined{newcommand}
% define DrawPicture for TeX
\long\gdef\DrawPicture#1#2#3
{\centerline
{\vbox to #1pt
{\hbox to #2pt
{\special{impress #3}}
\else
% define DrawPicture for LaTeX
% output some impress data at current location on page
\newcommand{\Impress}[1]
\makebox(0,0){\special{impress #1}}
% put a picture on page (use for multiple pictures across page)
\newcommand{\PutPicture}[3]
\begin{picture}(#1,#2)
\put(0,#2){\Impress{#3}}
\end{picture}
% put a centered picture on page (use for single picture across page)
\newcommand{\DrawPicture}[3]
\begin{center}
\PutPicture{#1}{#2}{#3}
\end{center}
SHAR_EOF
fi # end of overwriting check
# End of shell archive
exit 0