Search:

Return to previous page

Contents of file 'dvlabel.tex':



\input cwebmac
% File:        dvlabel.w [CWEB source code]
% Created:     December 5, 2003
% Last change: August 10, 2005
% Author:      Fredrik Jonsson
% Description: CWEB source code for the DVLABEL program, which generates
%              TeX source code for typesetting of labels for digital video
%              tapes (DV format, typically used for hand-held video camera
%              recorders). The program is primarily designed to run in
%              interactive mode, but via command-line parameters it also
%              supports batch-mode operation.
%                 A feature of the program is also that it is able to compile
%              the generated TeX source code into PostScript, using the DVIPS
%              program. (The DVIPS program is copyrighted by Radical Eye
%              Software, but is typically included in most TeX distributions
%              under UNIX, Linux, and Microsoft Windows; see the site
%              http://www.radicaleye.com for further information).
%                 For information on the CWEB programming language, see
%              http://www.literateprogramming.com.
% Compilation: Compile this program by using the enclosed Makefile, or use
%              the blocks of the Makefile as listed in section five of the
%              documentation (file dvlabel.ps or dvlabel.pdf). The C source
%              code (as generated from this CWEB code) conforms to the ANSI
%              standard for the C programming language (which is equivalent
%              to the ISO C89 standard for C).
%
% Copyright (C) 2003-2004, Fredrik Jonsson
%
\input epsf
\def\version{1.6}
\def\lastrevdate{August 10, 2005}
\font\eightcmr=cmr8
\font\tensc=cmcsc10
\font\eightcmssq=cmssq8
\font\eightcmssqi=cmssqi8
\font\twentycmcsc=cmcsc10 at 20 truept
\def\dvlabel{{\eightcmr DVLABEL\spacefactor1000}}
\def\poincare{{\eightcmr POINCARE\spacefactor1000}}
\def\magbragg{{\eightcmr MAGBRAGG\spacefactor1000}}
\def\CEE{{\eightcmr C\spacefactor1000}}     % The C programming language
\def\CWEB{{\eightcmr CWEB\spacefactor1000}} % The CWEB programming language
\def\DVIPS{{\eightcmr DVIPS\spacefactor1000}} % The DVIPS program
%
% Define a handy macro for the list of program revisions.
%
\newdimen\citemindent \citemindent=80pt
\newdimen\citemleftskip \citemleftskip=90pt
\def\citem[#1]{\smallbreak\noindent\hbox to 10pt{}%
  \hbox to\citemindent{\bf #1\hfill}%
  \hangindent\citemleftskip\ignorespaces}

\datethis


\N{1}{1}Introduction.
\vskip 120pt
\centerline{\twentycmcsc Dvlabel}
\vskip 20pt
\centerline{Creates TeX source code for typesetting labels for digital
video tapes}
\vskip 2pt
\centerline{(Version \version\ of \lastrevdate)}
\vskip 10pt
\centerline{Written by Fredrik Jonsson}
\vskip 80pt
\noindent
This \CWEB\footnote{${}ˆ\dagger$}{For information on the \CWEB\ programming
language by Donald E.˜Knuth, as well as samples of \CWEB\ programs, see
{\tt http://www-cs-faculty.stanford.edu/\˜\ \kern -5pt knuth/cweb.html}.
For general information on literate programming, see
{\tt http://www.literateprogramming.com}.}
program generates \TeX\ source code for typesetting of labels for digital
video tapes (DV format, typically used for hand-held video camera recorders).

Most people have not heard of the \TeX\ system for typesetting mathematical
text, and if they have, they will most probably not use the system for
creating things like labels for video tapes.
However, the output generated by \TeX\ is in many cases absolutely superior
in balance and visual clarity, and in order to benefit from the compactness
and beauty of text processed by \TeX\ even for such basic things as labels
for video tapes, this program generates the necessary \TeX\ code and even
compiles it into printable PostScript.

The program is primarily designed to run in interactive mode, but via
command-line parameters it also supports batch-mode operation.
A feature of the program is also that it is able to compile
the generated TeX source code into PostScript, using the
\DVIPS\ program.\footnote{$\ddagger$}{The \DVIPS\ program is copyrighted
by Radical Eye Software, but is typically included in most \TeX\ distributions
under UNIX, Linux, and Microsoft Windows; see the site
{\tt http://www.radicaleye.com} for further information.}
\bigskip
\noindent Copyright \copyright\ Fredrik Jonsson, 2003--2005.
All rights reserved.
\vfill

\fi

\N{1}{2}Revision history of the program.
\medskip

\citem[2003-12-28]{[v.1.0]} {\tt <jonsson@uni-wuppertal.de>}\hfill\break
First properly working version of the \dvlabel\ program.
I got the idea of creating this program from the {\tt audio-tape.ps} PostScript
code by Jamie Zawinski. That code is a splendid example of how one can
write a simple PostScript program with the help of a regular ASCII editor,
and by sending the PostScript program to the printer, one gets a neat
printout to be used for tape cassette labels, DAT, or video tapes.
However, whenever one has a new cassette to be labeled, one has to edit
the PostScript source, and for a rookie on PostScript programming this
task is somewhat inconvenient.
Therefore, I decided to create something similar, but with a standalone program
that could be operated either in interactive mode, with the program asking
for the specific information to be entered in the label, or in batch mode.
However, instead of directly generating PostScript, I decided to go for a
language that I know somewhat more in detail, namely plain \TeX, which also
has the benefit of being a language which the author, Donald E.˜Knuth, has
decided to keep fixed in order to ensure future compatibility.

\citem[2003-12-29]{[v.1.1]} {\tt <jonsson@uni-wuppertal.de>}\hfill\break
Revised the leading blocks (definitions) of the generator of the \TeX-code,
in order to have a more clearly structure of the labels. Included the
{\tt {\char'134}boxit} example from the \TeX-book to have the face, flap, and
spine
of the labels neatly structured.
Also finished the parsing engine for the address and table of contents
fields.

\citem[2004-11-26]{[v.1.2]} {\tt <fredrik.jonsson@nmrc.ie>}\hfill\break
Added support for supplying \DVIPS\ options via the command line when
invoking \dvlabel. In order to parse for an arbitrary number of \DVIPS\ options
at the command line, it is important to enclose the list of \DVIPS\ options
by quotes, hence forcing the \dvlabel\ program to parse the set of options as
one single string of characters. (The quotes are only necessary if the number
of \DVIPS\ options are two or more.)
Hence, for example, to force \DVIPS\ to generate output pages of US letter
format and at a resolution of 720 dpi one could invoke \dvlabel\ with
{\tt dvlabel --dvipsopts "-tletter -D720" ...}
Also slightly changed the way the input filename is used; now one can specify
only the basic filename, to which the \dvlabel\ program now automatically
appends the suffix {\tt .dvl}, if necessary.
Finally restructured the blocks related to scanning and saving code for
individual DV labels, in order to have the structure ready for making
the program generally capable of scanning one single file containing
an arbitrary number of labels, as for instance if one would keep all
records in one single text file.

\citem[2004-11-27]{[v.1.3]} {\tt <fredrik.jonsson@nmrc.ie>}\hfill\break
The \dvlabel\ program now parses multiple label records from the same input
file. Also added the useful feature of crop marks in the generated \TeX\ output
of the program. In its current state, the program only generates labels in one
single horizontal column; this is something that I in the future versions will
change into a $[3\times3]$ array of labels, as soon as I get the {\tt\\vbox}
and {\tt\\hbox} statements of the {\tt\\boxit} definition right.

\citem[2004-12-28]{[v.1.4]} {\tt <fredrik.jonsson@nmrc.ie>}\hfill\break
Added the {\tt --headline} and {\tt --linethick} options. Fixed a bug in
the page output, which previously caused \TeX\ to complain about vertical
underfill of the generated pages.

\citem[2005-01-01]{[v.1.5]} {\tt <fredrik.jonsson@nmrc.ie>}\hfill\break
Added the {\tt --cropmark} and {\tt --edgeseparation} options. Also fixed a
bug in the vertical label dimensions.

\citem[2005-08-10]{[v.1.6]} {\tt <fj@phys.soton.ac.uk>}\hfill\break
Back in Southampton with my family after a hot summer. Wrote the code for
the \PB{\\{strip\_away\_path}(\,)} routine originally for the \poincare\
program and
immediately decided to adopt the code also into the \dvlabel\ and \magbragg\
programs in order to finally solve the problem with long path strings that
appear in the program name string whenever poincare is called with an explicit
path specified at the command line. The call to the \PB{\\{strip\_away\_path}(%
\,)} routine
is located in the beginning of the block for command line parsing.

\fi

\N{1}{3}Compiling the source code. The program is written in \CWEB, generating
ANSI-C conforming source code and documentation as \TeX-source, and is to
be compiled using the enclosed Makefile, leaving an executable
file {\tt dvlabel}\footnote{$\dagger$}{On platforms running Windows NT,
Windows 2000, or any other operating system by Microsoft, the executable
file will instead automatically be called {\tt dvlabel.exe}.} and a
PostScript file {\tt dvlabel.ps} (the document you currently are reading),
which contains the full documentation of the program:
\bigskip
{\obeyspaces\obeylines\tt
˜   \#
˜   \# Makefile designed for use with ctangle, cweave, gcc, and plain TeX.
˜   \#
˜   \# Copyright (C) 2003, Fredrik Jonsson <jonsson@uni-wuppertal.de>
˜   \#
˜   CTANGLE  = ctangle
˜   CC       = gcc
˜   CCOPTS   = -O2 -Wall -ansi -pedantic \# follow ISO C89 (ANSI) strictly
˜   LNOPTS   = -lm
˜   CWEAVE   = cweave
˜   TEX      = tex
˜   DVIPS    = dvips
˜   DVIPSOPT = -ta4 -D1200
˜   ˜
˜   all: dvlabel.exe dvlabel.ps
˜   ˜
˜   dvlabel.exe: dvlabel.o \# generate the executable file
˜           \$(CC) \$(CCOPTS) -o dvlabel dvlabel.o \$(LNOPTS)
˜   ˜
˜   dvlabel.o: dvlabel.c \# generate the object file
˜           \$(CC) \$(CCOPTS) -c dvlabel.c
˜   ˜
˜   dvlabel.c: dvlabel.w \# generate C code from the CWEB source
˜           \$(CTANGLE) dvlabel
˜   ˜
˜   dvlabel.ps: dvlabel.dvi \# generate the PostScript documentation
˜           \$(DVIPS) \$(DVIPSOPT) dvlabel.dvi -o dvlabel.ps
˜   ˜
˜   dvlabel.dvi: dvlabel.tex \# generate the device-independent documentation
˜           \$(TEX) dvlabel.tex
˜   ˜
˜   dvlabel.tex: dvlabel.w \# generate plain TeX code from the CWEB source
˜           \$(CWEAVE) dvlabel
˜   ˜
˜   clean:
˜   ˜       -rm -Rf *.c *.o *.exe
˜   ˜       -rm -Rf *.tex *.aux *.log *.toc *.idx *.scn *.dvi}
\bigskip

\fi

\N{1}{4}Running the program. The program is entirely controlled by the command
line options supplied when invoking the program.
To start the program in interactive mode, simply run {\tt dvlabel} from
the command line, without any command line options.
\medskip
\noindent{\bf Example I:} In the following excerpt
from an interactive terminal session, where a leading asterisk ({\tt *})
in a line indicates the user-supplied input to the program, a DV label is
generated as Encapsulated PostScript, stored in a file named {\tt fig.eps}.
\bigskip
{\obeyspaces\obeylines\tt
˜   ˜[dvlabel> dvlabel -c -e -o fig
˜   ˜This is dvlabel, Version 1.4
˜   ˜Specify table of contents of the DV tape
˜   ˜[Enter text and finish with single dot on blank line]:
˜   ˜* Table of contents
˜   ˜* This is line number one
˜   ˜* This is line number two
˜   ˜* This is line number three
˜   ˜* .
˜   ˜Specify time stamp of DV tape. This is typically
˜   ˜the last date that appears as time stamp in the
˜   ˜recorded tape. [Press enter to use the current date]
˜   ˜* Monday 29/12/2003
˜   ˜Specify title of the DV tape [Press enter to leave blank title]:
˜   ˜* Beavis and Butthead
˜   ˜Specify author of the DV tape [Press enter to leave blank]:
˜   ˜* Fredrik Jonsson
˜   ˜Specify address of author of the DV tape
˜   ˜[Enter text and finish with single dot on blank line]:
˜   ˜* Storgatan 77
˜   ˜* SE-47111 Sunne, Sweden
˜   ˜* .
˜   ˜Specify email of author of the DV tape [Press enter to leave blank]:
˜   ˜* hakkasberra@hotmail.com
}
\bigskip
The generated DV label {\tt fig.eps} looks like this:
\bigskip
\centerline{\epsfxsize=62.56mm\epsfbox{fig.eps}}
\vfill\eject
\noindent
In this example, the {\tt -c} command line option specifies that the program
should compile the generated \TeX\ code, {\tt -e} that it also should attempt
to generate the output as Encapsulated PostScript, and {\tt -o fig}
that the generated files all should have the base name ``{\tt fig}'',
that is to say, the program will use {\tt fig.tex} for the
generated \TeX-code, {\tt fig.dvi}
for the generated device-independent (DVI) output, and {\tt fig.eps} for
the generated Encapsulated PostScript (EPS) image of the DV label.
The command for invoking the \dvlabel\ program can equivalently be written in
a more extensive form as {\tt dvlabel --compile --eps --outputfile fig}.

The \TeX-code that the program generates (from which the Encapsulated
PostScript subsequently is generated) is stored in the file {\tt fig.tex},
which contains
\bigskip
{\obeylines\obeyspaces\tt
˜   ˜\% File: fig.tex
˜   ˜\% TeX code automatically generated by dvlabel, v.1.4,
˜   ˜\% Mon Dec 29 15:46:36 2003
˜   ˜\% Copyright (C) Fredrik Jonsson, 2003
˜   ˜\%
˜   ˜{\char'134}font{\char'134}eightcmssqeight=cmssq8
˜   ˜{\char'134}font{\char'134}tencmssqten=cmssq8 at 10 truept
˜   ˜{\char'134}font{\char'134}defaultfacefont=cmtt8
˜   ˜{\char'134}font{\char'134}defaultflapfont=cmtt8
˜   ˜{\char'134}def{\char'134}monthname{{\char'134}ifcase{\char'134}month\%
˜   ˜ {\char'134}or Jan{\char'134}or Feb{\char'134}or Mar{\char'134}or
Apr{\char'134}or May{\char'134}or Jun\%
˜   ˜ {\char'134}or Jul{\char'134}or Aug{\char'134}or Sep{\char'134}or
Oct{\char'134}or Nov{\char'134}or Dec\%
˜   ˜ {\char'134}fi}
˜   ˜{\char'134}def{\char'134}fullmonthname{{\char'134}ifcase{\char'134}month\%
˜   ˜ {\char'134}or January{\char'134}or February{\char'134}or
March{\char'134}or April\%
˜   ˜ {\char'134}or May{\char'134}or June{\char'134}or July{\char'134}or
August{\char'134}or September
˜   ˜ {\char'134}or October{\char'134}or November{\char'134}or
December{\char'134}fi}
˜   ˜{\char'134}def{\char'134}today{{\char'134}fullmonthname{\char'134}space%
{\char'134}number{\char'134}day,\%
˜   ˜  {\char'134}space{\char'134}number{\char'134}year}
˜   ˜{\char'134}def{\char'134}timestamp{Monday 29/12/2003}
˜   ˜{\char'134}def{\char'134}title{Beavis and Butthead}
˜   ˜{\char'134}def{\char'134}author{Fredrik Jonsson}
˜   ˜{\char'134}def{\char'134}email{hakkasberra@hotmail.com}
˜   ˜{\char'134}nopagenumbers
˜   ˜{\char'134}newdimen{\char'134}facewidth
˜   ˜{\char'134}newdimen{\char'134}faceheight
˜   ˜{\char'134}newdimen{\char'134}spineheight
˜   ˜{\char'134}newdimen{\char'134}flapheight
˜   ˜{\char'134}newdimen{\char'134}edgeseparation
˜   ˜{\char'134}facewidth=60mm
˜   ˜{\char'134}faceheight=40mm
˜   ˜{\char'134}spineheight=12mm
˜   ˜{\char'134}flapheight=20mm
˜   ˜{\char'134}edgeseparation=1pt
˜   ˜{\char'134}def{\char'134}boxit\#1{{\char'134}vbox{{\char'134}hrule%
{\char'134}hbox{\%
˜   ˜  {\char'134}vrule{\char'134}kern1pt{\char'134}vbox{{\char'134}kern1pt\#1%
{\char'134}kern1pt}\%
˜   ˜{\char'134}kern1pt{\char'134}vrule}{\char'134}hrule}}
˜   ˜{\char'134}parindent 0pt
}
\vfill\eject
{\obeylines\obeyspaces\tt
˜   ˜
˜   ˜\% Define the outline of the face of the label
˜   ˜{\char'134}setbox1={\char'134}hbox to {\char'134}facewidth{{\%
˜   ˜  {\char'134}vbox to {\char'134}faceheight{\%
˜   ˜    {\char'134}hbox{{\char'134}defaultfacefont{\char'134}timestamp%
{\char'134}hfil}\%
˜   ˜    {\char'134}vskip -3pt{\char'134}hbox{{\char'134}defaultfacefont
Table of contents{\char'134}hfil}\%
˜   ˜    {\char'134}vskip -3pt{\char'134}hbox{{\char'134}defaultfacefont
This is line number one{\char'134}hfil}\%
˜   ˜    {\char'134}vskip -3pt{\char'134}hbox{{\char'134}defaultfacefont
This is line number two{\char'134}hfil}\%
˜   ˜    {\char'134}vskip -3pt{\char'134}hbox{{\char'134}defaultfacefont
This is line number three{\char'134}hfil}\%
˜   ˜  {\char'134}vfil}}{\char'134}hfil}
˜   ˜
˜   ˜\% Define the outline of the spine of the label
˜   ˜{\char'134}setbox2={\char'134}hbox to {\char'134}facewidth{{\%
˜   ˜  {\char'134}vbox to {\char'134}spineheight{\%
˜   ˜    {\char'134}hbox{{\char'134}bf{\char'134}timestamp{\char'134}hfil}\%
˜   ˜    {\char'134}hbox{{\char'134}bf{\char'134}title{\char'134}hfil}\%
˜   ˜  {\char'134}vfil}}{\char'134}hfil}
˜   ˜
˜   ˜\% Define the outline of the flap of the label
˜   ˜{\char'134}setbox3={\char'134}hbox to {\char'134}facewidth{{\%
˜   ˜  {\char'134}vbox to {\char'134}flapheight{\%
˜   ˜    {\char'134}hbox{{\char'134}defaultflapfont Digital Video by
{\char'134}author{\char'134}hfil}\%
˜   ˜    {\char'134}vskip -3pt{\char'134}hbox{{\char'134}defaultflapfont
Storgatan 77{\char'134}hfil}\%
˜   ˜    {\char'134}vskip -3pt{\char'134}hbox{{\char'134}defaultflapfont
SE-47111 Sunne, Sweden{\char'134}hfil}\%
˜   ˜    {\char'134}vskip -3pt{\char'134}hbox{{\char'134}defaultflapfont \%
˜   ˜      <{\char'134}email>{\char'134}hfil}\%
˜   ˜  {\char'134}vfil}}{\char'134}hfil}
˜   ˜
˜   ˜{\char'134}def{\char'134}dvlabel{{\char'134}boxit{{\char'134}boxit%
{{\char'134}box1}\%
˜   ˜  {\char'134}vskip{\char'134}edgeseparation{\char'134}boxit%
{{\char'134}box2}\%
˜   ˜  {\char'134}vskip{\char'134}edgeseparation{\char'134}%
boxit{{\char'134}box3}}}
˜   ˜
˜   ˜{\char'134}dvlabel
˜   ˜
˜   ˜{\char'134}bye
}
\vfill\eject
\noindent{\bf Example II:}
Another way of using the program is in batch mode, where the input instead
is read from a text file.
In the following example, the file named {\tt fig.asc} contains the
following text (compare with the interactive session on the previous pages):
\bigskip
{\obeyspaces\obeylines\tt
˜   ˜Table of contents
˜   ˜This is line number one
˜   ˜This is line number two
˜   ˜This is line number three
˜   ˜.
˜   ˜Monday 29/12/2003
˜   ˜Beavis and Butthead
˜   ˜Fredrik Jonsson
˜   ˜Storgatan 77
˜   ˜SE-47111 Sunne, Sweden
˜   ˜.
˜   ˜hakkasberra@hotmail.com
}
\bigskip
\noindent
When the \dvlabel\ program is launched with the above file specified as
the input to read, via the command\footnote{$\dagger$}{In similar to
the previous example, this command for invoking the \dvlabel\ program
can similarly written in a more extensive form as {\tt dvlabel --compile
--eps --inputfile fig.asc --outputfile fig}.}
\bigskip
{\obeyspaces\obeylines\tt
˜   ˜[dvlabel> dvlabel -c -e -i fig.asc -o fig
}
\bigskip
\noindent
the same output as in the previous example will be generated.

\fi

\N{1}{5}The main program. Here follows the general outline of the main program.

\Y\B\8\#\&{include} \.{<time.h>}\6
\8\#\&{include} \.{<stdio.h>}\6
\8\#\&{include} \.{<stddef.h>}\6
\8\#\&{include} \.{<stdlib.h>}\6
\8\#\&{include} \.{<string.h>}\6
\8\#\&{define} \.{VERSION} \5\.{"1.5"}\C{ Program revision }\6
\8\#\&{define} \.{DEFAULT\_DVIPSOPTS} \5\.{"-ta4\ -D1200"}\C{ Default DVIPS
options }\6
\8\#\&{define} \.{DEFAULT\_LINETHICKNESS} \5(\T{0.5})\C{ Default line thickness
in pt }\6
\8\#\&{define} \.{DEFAULT\_CROPLINETHICKNESS} \5(\T{0.15})\C{ Crop line
thickness in pt }\6
\8\#\&{define} \.{DEFAULT\_EDGESEPARATION} \5(\T{1.0})\6
\8\#\&{define} \.{MAXCHAR} \5(\T{128})\C{ Maximum allowed number of characters
on each line }\6
\8\#\&{define} \.{SUCCESS} \5(\T{0})\C{ Return code for successful program
termination }\6
\8\#\&{define} \.{FAILURE} \5(\T{1})\C{ Return code for unsuccessful program
termination }\6
\8\#\&{define} \.{INSTREAM} \5${}(\\{infile\_specified}\?\\{infile}:%
\\{stdin}){}$\6
\8\#\&{define} \.{OUTSTREAM} \5${}(\\{outfile\_specified}\?\\{outfile}:%
\\{stdout}){}$\6
\X6:Global variables\X\6
\X7:Subroutines\X\7
\&{int} \\{main}(\&{int} \\{argc}${},\39{}$\&{char} ${}{*}\\{argv}[\,]){}$\1\1%
\2\2\6
${}\{{}$\1\6
\X17:Local variables\X\6
\X18:Parse command line\X\6
\X19:Display banner\X\6
\X21:Open files for reading\X\6
\X22:Open files for writing\X\6
\X32:Save preamble source code\X\6
${}\\{num\_labels}\K\T{0};{}$\6
\&{while} (\\{newlabel}(\.{INSTREAM}))\5
${}\{{}$\1\6
${}\\{num\_labels}\PP;{}$\6
\X25:Scan text lines of one label from input stream\X\6
\&{if} ${}(\\{num\_labels}\E\T{1}){}$\5
${}\{{}$\1\6
\&{if} (\\{generate\_crop\_marks})\5
${}\{{}$\1\6
\X35:Write vertical crop marks with width measure\X\6
\X36:Write horizontal crop marks with height measure\X\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\X33:Save label source code\X\6
\&{if} ${}(\\{num\_labels}\E\T{2}){}$\5
${}\{{}$\1\6
\&{if} (\\{generate\_crop\_marks})\5
${}\{{}$\1\6
\X36:Write horizontal crop marks with height measure\X\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\&{if} ${}(\\{num\_labels}\E\\{num\_labels\_per\_page}){}$\5
${}\{{}$\1\6
\&{if} (\\{generate\_crop\_marks})\5
${}\{{}$\1\6
\X36:Write horizontal crop marks with height measure\X\6
\X35:Write vertical crop marks with width measure\X\6
\4${}\}{}$\2\6
\X34:Close output page\X\6
${}\\{num\_labels}\K\T{0};{}$\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\X37:Save closing source code\X\6
\X23:Close files\X\6
\X38:Compile source code\X\6
\&{return} (\.{SUCCESS});\6
\4${}\}{}$\2\par
\fi

\M{6}Declaration of global variables. The only global variables allowed in
my programs are \PB{\\{optarg}}, which is the string of characters that
specified
the call from the command line, and \PB{\\{progname}}, which simply is the
string
containing the name of the program, as it was invoked from the command line.

\Y\B\4\X6:Global variables\X${}\E{}$\6
\&{extern} \&{char} ${}{*}\\{optarg};{}$\6
\&{char} ${}{*}\\{progname}{}$;\par
\U5.\fi

\M{7}Declarations of subroutines used by the program.

\Y\B\4\X7:Subroutines\X${}\E{}$\6
\X8:Routines for displaying help message\X\6
\X12:Scan for beginning of new label\X\6
\X13:Routines for removing preceding path of filenames\X\par
\U5.\fi

\M{8}Routines for displaying help message.

\Y\B\4\X8:Routines for displaying help message\X${}\E{}$\6
\X9:Display split help line\X\6
\X10:Display full help line\X\6
\X11:Display help message\X\par
\U7.\fi

\M{9}Routine for proper display of split help lines. This is a very simple
routine just to keep the \PB{$\\{fprintf}(\\{stdout},\.{"..."},\.{"..."})$}
statements to a
minimum.

\Y\B\4\X9:Display split help line\X${}\E{}$\6
\&{void} \\{hl}(\&{char} \\{firststring}[\,]${},\39{}$\&{char} %
\\{secondstring}[\,])\1\1\2\2\6
${}\{{}$\1\6
${}\\{fprintf}(\\{stderr},\39\.{"\%-25.25s\%1.65s\\n"},\39\\{firststring},\39%
\\{secondstring});{}$\6
\4${}\}{}$\2\par
\U8.\fi

\M{10}Routine for proper display of full help lines. This is similar to the %
\PB{\\{hl}(\,)}
routine, with the only difference being that a full line of text is flushed
instead of a line split into two parts.

\Y\B\4\X10:Display full help line\X${}\E{}$\6
\&{void} \\{fhl}(\&{char} \\{linestring}[\,])\1\1\2\2\6
${}\{{}$\1\6
${}\\{fprintf}(\\{stderr},\39\.{"\%s\\n"},\39\\{linestring});{}$\6
\4${}\}{}$\2\par
\U8.\fi

\M{11}Routine for displaying a help message at the screen.

\Y\B\4\X11:Display help message\X${}\E{}$\6
\&{void} \\{showsomehelp}(\&{void})\1\1\2\2\6
${}\{{}$\1\6
\&{char} \\{tmpstr}[\T{80}];\7
${}\\{sprintf}(\\{tmpstr},\39\.{"Usage:\ \%s\ [options]}\)\.{"},\39%
\\{progname});{}$\6
\\{fhl}(\\{tmpstr});\6
\\{fhl}(\.{"When\ invoked\ withou}\)\.{t\ any\ command\ line\ o}\)\.{ptions,\
this\ program}\)\.{\ enters"});\6
\\{fhl}(\.{"interactive\ mode."});\6
\\{fhl}(\.{"Options:"});\6
${}\\{hl}(\.{"\ \ -i,\ --inputfile\ <}\)\.{str>"},\39\.{"Specifies\ the\ file\
}\)\.{where\ to\ read\ the\ la}\)\.{bel\ text"});{}$\6
${}\\{hl}(\.{""},\39\.{"strings,\ entered\ in}\)\.{\ a\ format\ correspond}\)%
\.{ing\ to\ the"});{}$\6
${}\\{hl}(\.{""},\39\.{"input\ order\ as\ woul}\)\.{d\ have\ been\ entered\ }\)%
\.{in\ inter-"});{}$\6
${}\\{hl}(\.{""},\39\.{"active\ mode."});{}$\6
${}\\{hl}(\.{"\ \ -o,\ --outputfile\ }\)\.{<str>"},\39\.{"Specifies\ the\ file\
}\)\.{where\ to\ save\ the\ ge}\)\.{nerated"});{}$\6
${}\\{hl}(\.{""},\39\.{"TeX\ source\ code\ for}\)\.{\ the\ label.\ whenever}\)%
\.{\ this"});{}$\6
${}\\{hl}(\.{""},\39\.{"option\ is\ omitted,\ }\)\.{the\ generated\ source}\)%
\.{\ code"});{}$\6
${}\\{hl}(\.{""},\39\.{"will\ be\ written\ to\ }\)\.{standard\ terminal\ ou}\)%
\.{tput"});{}$\6
${}\\{hl}(\.{""},\39\.{"instead."});{}$\6
${}\\{hl}(\.{""},\39\.{"\ \ \ Notice\ that\ the\ }\)\.{name\ specified\ using}%
\)\.{\ this"});{}$\6
${}\\{hl}(\.{""},\39\.{"option\ is\ used\ as\ t}\)\.{he\ *base\ name*\ for\ t}%
\)\.{he"});{}$\6
${}\\{hl}(\.{""},\39\.{"generated\ output;\ t}\)\.{his\ means\ that\ the\ T}\)%
\.{eX\ file"});{}$\6
${}\\{hl}(\.{""},\39\.{"automatically\ will\ }\)\.{get\ .tex\ as\ suffix,\ }\)%
\.{the\ DVI"});{}$\6
${}\\{hl}(\.{""},\39\.{"file\ .dvi,\ etc.\ For}\)\.{\ example,\ if\ you\ wan}\)%
\.{t\ to"});{}$\6
${}\\{hl}(\.{""},\39\.{"have\ the\ TeX\ output}\)\.{\ stored\ into\ a\ file\ }%
\)\.{named,"});{}$\6
${}\\{hl}(\.{""},\39\.{"say,\ 'foo.tex',\ jus}\)\.{t\ specify\ '-o\
foo'."});{}$\6
${}\\{hl}(\.{""},\39\.{"Toggle\ display\ of\ g}\)\.{eneration\ time\ and\ i}\)%
\.{nput"});{}$\6
${}\\{hl}(\.{""},\39\.{"source\ in\ page\ head}\)\.{er\ of\ the\ generated\ }\)%
\.{TeX"});{}$\6
${}\\{hl}(\.{""},\39\.{"code.\ Default:\ off"});{}$\6
${}\\{hl}(\.{""},\39\.{"Toggle\ display\ of\ c}\)\.{rop\ marks\ (alignment}\)%
\.{\ marks)"});{}$\6
${}\\{hl}(\.{""},\39\.{"in\ the\ generated\ Te}\)\.{X\ code.\ Default:\ off}\)%
\.{"});{}$\6
${}\\{hl}(\.{"\ \ -t,\ --linethick\ <}\)\.{f>"},\39\.{"Use\ linethickness\ o}\)%
\.{f\ <f>\ typographic\ po}\)\.{ints\ in"});{}$\6
${}\\{hl}(\.{""},\39\.{"generating\ the\ boxe}\)\.{s\ of\ the\ label.\ (One}\)%
\.{\ point,"});{}$\6
${}\\{hl}(\.{""},\39\.{"or\ pt,\ equals\ to\ 1/}\)\.{72.27\ inch,\ or\ 0.351}\)%
\.{\ mm.)"});{}$\6
${}\\{hl}(\.{"\ \ -s,\ --edgeseparat}\)\.{ion\ <f>"},\39\.{"Insert\ extra\
space\ }\)\.{of\ <f>\ typographic\ p}\)\.{oints"});{}$\6
${}\\{hl}(\.{""},\39\.{"between\ the\ text\ bo}\)\.{xes\ at\ the\ folded\ ed}\)%
\.{ges\ of"});{}$\6
${}\\{hl}(\.{""},\39\.{"the\ label.\ This\ is\ }\)\.{useful\ when,\ for\ exa}\)%
\.{mple,"});{}$\6
${}\\{hl}(\.{""},\39\.{"thick\ paper\ is\ used}\)\.{."});{}$\6
${}\\{hl}(\.{""},\39\.{"By\ changing\ the\ lin}\)\.{e\ thickness,\ the\ int}\)%
\.{ernal"});{}$\6
${}\\{hl}(\.{""},\39\.{"margins\ of\ the\ labe}\)\.{l\ are\ also\ changed,\ }\)%
\.{since"});{}$\6
${}\\{hl}(\.{""},\39\.{"the\ inner\ edge-to-e}\)\.{dge\ distance\ between}\)\.{%
\ the"});{}$\6
${}\\{hl}(\.{""},\39\.{"lines\ of\ the\ inner\ }\)\.{and\ outer\ boxes\ are\ }%
\)\.{linked"});{}$\6
${}\\{hl}(\.{""},\39\.{"to\ be\ twice\ the\ val}\)\.{ue\ of\ the\ line\ thick}%
\)\.{ness."});{}$\6
${}\\{hl}(\.{""},\39\.{"The\ correction\ of\ i}\)\.{nner\ bounding\ boxes\ }\)%
\.{of\ the"});{}$\6
${}\\{hl}(\.{""},\39\.{"label\ text\ is\ autom}\)\.{atically\ adjusted\ so}\)%
\.{\ as\ to"});{}$\6
${}\\{hl}(\.{""},\39\.{"ensure\ that\ the\ ove}\)\.{rall\ outer\ dimension}\)%
\.{s\ of\ the"});{}$\6
${}\\{hl}(\.{""},\39\.{"label\ are\ unchanged}\)\.{."});{}$\6
${}\\{hl}(\.{"\ \ -c,\ --compile"},\39\.{"Try\ to\ compile\ the\ }\)%
\.{generated\ TeX\ code.\ }\)\.{This"});{}$\6
${}\\{hl}(\.{""},\39\.{"requires\ DVIPS\ to\ b}\)\.{e\ installed\ on\ your\ }\)%
\.{system,"});{}$\6
${}\\{hl}(\.{""},\39\.{"see\ www.radicaleye.}\)\.{com\ for\ further\ info}\)%
\.{."});{}$\6
${}\\{hl}(\.{"\ \ -e,\ --eps"},\39\.{"When\ compiling\ the\ }\)\.{generated\
TeX\ code,\ }\)\.{generate"});{}$\6
${}\\{hl}(\.{""},\39\.{"Encapsulated\ PostSc}\)\.{ript\ (EPS)\ instead\ o}\)%
\.{f\ the"});{}$\6
${}\\{hl}(\.{""},\39\.{"regular\ PostScript.}\)\.{"});{}$\6
${}\\{hl}(\.{"\ \ -d,\ --dvipsopts\ <}\)\.{str>"},\39\.{"When\ compiling\ the\
}\)\.{generated\ TeX\ code,\ }\)\.{use"});{}$\6
${}\\{hl}(\.{""},\39\.{"<str>\ as\ options\ to}\)\.{\ be\ supplied\ to\ DVIP}\)%
\.{S."});{}$\6
${}\\{hl}(\.{""},\39\.{"In\ order\ to\ parse\ f}\)\.{or\ an\ arbitrary\ numb}\)%
\.{er\ of"});{}$\6
${}\\{hl}(\.{""},\39\.{"DVIPS\ options\ at\ th}\)\.{e\ command\ line,\ it\ i}\)%
\.{s"});{}$\6
${}\\{hl}(\.{""},\39\.{"important\ to\ enclos}\)\.{e\ the\ list\ of\ DVIPS\ }\)%
\.{options"});{}$\6
${}\\{hl}(\.{""},\39\.{"by\ quotes.\ Hence,\ f}\)\.{or\ example,\ to\ force}\)%
\.{\ DVIPS"});{}$\6
${}\\{hl}(\.{""},\39\.{"to\ generate\ output\ }\)\.{pages\ of\ US\ letter\ f}\)%
\.{ormat"});{}$\6
${}\\{hl}(\.{""},\39\.{"and\ at\ a\ resolution}\)\.{\ of\ 720\ dpi\ one\ coul}%
\)\.{d\ invoke"});{}$\6
${}\\{hl}(\.{""},\39\.{"DVLABEL\ with"});{}$\6
${}\\{hl}(\.{""},\39\.{"\ \ dvlabel\ --dvipsop}\)\.{ts\ \\"-tletter\ -D720\\}\)%
\.{""});{}$\6
${}\\{hl}(\.{""},\39\.{"The\ quotes\ are\ only}\)\.{\ necessary\ if\ the\ nu}\)%
\.{mber\ of"});{}$\6
${}\\{hl}(\.{""},\39\.{"DVIPS\ options\ are\ t}\)\.{wo\ or\ more."});{}$\6
${}\\{hl}(\.{""},\39\.{"Default:\ -D1200\ -ta}\)\.{4\ (1200\ DPI\ on\ A4\ pa}\)%
\.{per)."});{}$\6
${}\\{hl}(\.{"\ \ -v,\ --verbose"},\39\.{"Toggle\ verbose\ mode}\)\.{.\
Default:\ off"});{}$\6
${}\\{hl}(\.{"\ \ -h,\ --help"},\39\.{"Display\ this\ help\ m}\)\.{essage\ and\
exit\ clea}\)\.{n."});{}$\6
\\{fhl}(\.{"\\nCopyright\ (C)\ 200}\)\.{3-2005\ Fredrik\ Jonss}\)\.{on\
<fj@phys.soton.ac}\)\.{.uk>"});\6
\4${}\}{}$\2\par
\U8.\fi

\M{12}Scan the input stream for a statement on what to do next, that is to say,
either to start generating a new label (if the character `n' is present, in
which case the \PB{\\{newlabel}} routine returns 1) or quit the program (if the
character `q' is present, in which case the \PB{\\{newlabel}} routine returns
0).
The \PB{\\{newlabel}} routine also takes care of scanning away any trailing
blanks
or other characters from the input stream until a carriage return character
is found, also removing this before return.

\Y\B\4\X12:Scan for beginning of new label\X${}\E{}$\6
\&{short} \\{newlabel}(\&{FILE} ${}{*}\\{instream}){}$\1\1\2\2\6
${}\{{}$\1\6
\&{char} \\{ch};\7
${}\\{fprintf}(\\{stdout},\39\.{"Create\ new\ label\ re}\)\.{cord\ or\ quit?%
\\n"});{}$\6
${}\\{fprintf}(\\{stdout},\39\.{"['n'=new\ label\ /\ 'q}\)\.{'=quit]:\\n"});{}$%
\6
${}\\{fprintf}(\\{stdout},\39\.{"**"});{}$\6
\&{while} ${}((\\{ch}\K\\{fgetc}(\\{instream}))\E\.{'\ '}){}$\1\5
;\C{ get rid of leading blanks }\2\6
\&{if} ${}(\\{ch}\E\.{'n'}){}$\5
${}\{{}$\1\6
\&{while} ${}((\\{ch}\K\\{fgetc}(\\{instream}))\I\.{'\\n'}){}$\1\5
;\C{ get rid of trailing characters }\2\6
\&{return} (\T{1});\6
\4${}\}{}$\2\6
\&{else} \&{if} ${}(\\{ch}\E\.{'q'}){}$\5
${}\{{}$\1\6
\&{while} ${}((\\{ch}\K\\{fgetc}(\\{instream}))\I\.{'\\n'}){}$\1\5
;\C{ get rid of trailing characters }\2\6
\&{return} (\T{0});\6
\4${}\}{}$\2\6
\&{else}\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stderr},\39\.{"\%s:\ Unrecognized\ in}\)\.{put\ stream\
control\ c}\)\.{haracter\ '\%c'.\\n"},\39\\{progname},\39\\{ch});{}$\6
\\{exit}(\.{FAILURE});\6
\4${}\}{}$\2\6
\4${}\}{}$\2\par
\U7.\fi

\M{13}Routines for removing preceding path of filenames.
In this block all routines related to removing preceding path strings go.
Not really fancy programming, and no contribution to any increase of numerical
efficiency or precision; just for the sake of keeping a tidy terminal output
of the program. The \PB{\\{strip\_away\_path}(\,)} routine is typically called
when
initializing the program name string \PB{\\{progname}} from the command line
string
\PB{\\{argv}[\T{0}]}, and is typically located in the blocks related to parsing
of the
command line options.

\Y\B\4\X13:Routines for removing preceding path of filenames\X${}\E{}$\6
\X14:Routine for checking for alphanumerical characters\X\6
\X15:Routine for checking for valid characters of path names\X\6
\X16:Routine for stripping away path string\X\par
\U7.\fi

\M{14}Routine for checking for alphanumerical characters.
The \PB{\\{alphanumeric}(\,)} routine takes one character \PB{\\{ch}} as
argument, and
returns 1 (``true'') if the character is a sign, numeric, or alphabetic
character, otherwise 0 (``false'') is returned.

\Y\B\4\X14:Routine for checking for alphanumerical characters\X${}\E{}$\6
\&{short} \\{alphanumeric}(\&{char} \\{ch})\1\1\2\2\6
${}\{{}$\1\6
\&{if} ${}((\\{ch}\E\.{'0'})\V(\\{ch}\E\.{'1'})\V(\\{ch}\E\.{'2'})\V(\\{ch}\E%
\.{'3'})\V(\\{ch}\E\.{'4'})\V(\\{ch}\E\.{'5'})\V(\\{ch}\E\.{'6'})\V(\\{ch}\E%
\.{'7'})\V(\\{ch}\E\.{'8'})\V(\\{ch}\E\.{'9'})\V(\\{ch}\E\.{'+'})\V(\\{ch}\E%
\.{'-'})\V(\\{ch}\E\.{'a'})\V(\\{ch}\E\.{'b'})\V(\\{ch}\E\.{'c'})\V(\\{ch}\E%
\.{'d'})\V(\\{ch}\E\.{'e'})\V(\\{ch}\E\.{'f'})\V(\\{ch}\E\.{'g'})\V(\\{ch}\E%
\.{'h'})\V(\\{ch}\E\.{'i'})\V(\\{ch}\E\.{'j'})\V(\\{ch}\E\.{'k'})\V(\\{ch}\E%
\.{'l'})\V(\\{ch}\E\.{'m'})\V(\\{ch}\E\.{'n'})\V(\\{ch}\E\.{'o'})\V(\\{ch}\E%
\.{'p'})\V(\\{ch}\E\.{'q'})\V(\\{ch}\E\.{'r'})\V(\\{ch}\E\.{'s'})\V(\\{ch}\E%
\.{'t'})\V(\\{ch}\E\.{'u'})\V(\\{ch}\E\.{'v'})\V(\\{ch}\E\.{'w'})\V(\\{ch}\E%
\.{'x'})\V(\\{ch}\E\.{'y'})\V(\\{ch}\E\.{'z'})){}$\5
${}\{{}$\1\6
\&{return} (\T{1});\C{ yes, this is a sign, a letter, or numeric character }\6
\4${}\}{}$\2\6
\&{else}\5
${}\{{}$\1\6
\&{return} (\T{0});\C{ no, this is not a sign, a letter, or numeric character }%
\6
\4${}\}{}$\2\6
\4${}\}{}$\2\par
\U13.\fi

\M{15}Routine for checking for valid characters of path names.
The \PB{\\{pathcharacter}(\,)} routine takes one character \PB{\\{ch}} as
argument,
and returns 1 (``true'') if the character is valid character of a path
string, otherwise 0 (``false'') is returned.

\Y\B\4\X15:Routine for checking for valid characters of path names\X${}\E{}$\6
\&{short} \\{pathcharacter}(\&{char} \\{ch})\1\1\2\2\6
${}\{{}$\1\6
\&{if} ${}(\\{alphanumeric}(\\{ch})\V(\\{ch}\E\.{'.'})\V(\\{ch}\E\.{'/'})\V(%
\\{ch}\E\.{'\\\\'})\V(\\{ch}\E\.{'\_'})\V(\\{ch}\E\.{'-'})\V(\\{ch}\E%
\.{'+'})){}$\5
${}\{{}$\1\6
\&{return} (\T{1});\C{ yes, this is a valid character of a path string }\6
\4${}\}{}$\2\6
\&{else}\5
${}\{{}$\1\6
\&{return} (\T{0});\C{ no, this is not a valid character of a path string }\6
\4${}\}{}$\2\6
\4${}\}{}$\2\par
\U13.\fi

\M{16}Routine for stripping away path string.
The \PB{\\{strip\_away\_path}(\,)} routine takes a character string \PB{%
\\{filename}} as
argument, and returns a pointer to the same string but without any
preceding path segments. This routine is, for example, useful for
removing paths from program names parsed from the command line.

\Y\B\4\X16:Routine for stripping away path string\X${}\E{}$\6
\&{char} ${}{*}{}$\\{strip\_away\_path}(\&{char} \\{filename}[\,])\1\1\2\2\6
${}\{{}$\1\6
\&{int} \|j${},{}$ \|k${}\K\T{0};{}$\6
\&{char} ${}{*}\\{stripped\_filename}[\T{80}];{}$\7
\&{while} (\\{pathcharacter}(\\{filename}[\|k]))\1\5
${}\|k\PP;{}$\2\6
${}\|k\MM;{}$\6
${}\|j\K\|k{}$;\C{ this is the uppermost index of the full path+file string }\6
\&{while} (\\{alphanumeric}(\\{filename}[\|j]))\1\5
${}\|j\MM;{}$\2\6
${}\|j\PP{}$;\C{ this is the lowermost index of the stripped file name }\6
${}{*}\\{stripped\_filename}\K{\AND}\\{filename}[\|j];{}$\6
\&{return} ${}({*}\\{stripped\_filename});{}$\6
\4${}\}{}$\2\par
\U13.\fi

\N{1}{17}Declaration of local variables of the main program.
Here \PB{\\{num\_labels}} is a counter that is used for determining whenever a
page
brake in the generated \TeX\ code is to appear, in order to give a nice output
with a $[3\times1]$ array of labels.

\Y\B\4\X17:Local variables\X${}\E{}$\6
\&{time\_t} \\{now}${}\K\\{time}(\NULL);{}$\6
\&{long} \|j${},{}$ \|k${},{}$ \|n${},{}$ \\{num\_address\_lines}${},{}$ \\{num%
\_toc\_lines}${},{}$ \\{num\_labels}${},{}$ \\{num\_labels\_per\_page}${}\K%
\T{4};{}$\6
\&{int} \\{no\_arg}${},{}$ \\{tmpch};\6
\&{FILE} ${}{*}\\{infile}\K\NULL,{}$ ${}{*}\\{outfile}\K\NULL;{}$\6
\&{char} \\{inputfilename}[\.{MAXCHAR}]${}\K\.{""},{}$ \\{outputfilename}[%
\.{MAXCHAR}]${}\K\.{""},{}$ \\{tmpstr}[\.{MAXCHAR}];\6
\&{char} \\{dvipsopts}[\.{MAXCHAR}]${}\K\.{DEFAULT\_DVIPSOPTS};{}$\6
\&{char} \\{timestamp}[\.{MAXCHAR}]${}\K\.{"\\today"},{}$ \\{title}[%
\.{MAXCHAR}]${}\K\.{""};{}$\6
\&{char} \\{author}[\.{MAXCHAR}]${}\K\.{""},{}$ \\{email}[\.{MAXCHAR}]${}\K%
\.{""};{}$\6
\&{char} ${}\\{address}[\T{10}*\.{MAXCHAR}]\K\.{""},{}$ ${}\\{toc}[\T{50}*%
\.{MAXCHAR}]\K\.{""};{}$\6
\&{short} \\{done}${},{}$ \\{verbose}${}\K\T{0},{}$ \\{compile}${}\K\T{0},{}$ %
\\{eps\_output}${}\K\T{0};{}$\6
\&{short} \\{headline}${}\K\T{1},{}$ \\{generate\_crop\_marks}${}\K\T{1};{}$\6
\&{short} \\{infile\_specified}${}\K\T{0},{}$ \\{outfile\_specified}${}\K%
\T{0},{}$ \\{dvipsopts\_specified}${}\K\T{0};{}$\6
\&{float} \\{linethickness}${}\K\.{DEFAULT\_LINETHICKNESS};{}$\6
\&{float} \\{clthick}${}\K\.{DEFAULT\_CROPLINETHICKNESS};{}$\6
\&{float} \\{edgeseparation}${}\K\.{DEFAULT\_EDGESEPARATION};{}$\6
\&{float} \\{facewidth}${},{}$ \\{faceheight}${},{}$ \\{spineheight}${},{}$ %
\\{flapheight};\6
\&{float} \\{ifacewidth}${},{}$ \\{ifaceheight}${},{}$ \\{ispineheight}${},{}$ %
\\{iflapheight};\par
\U5.\fi

\N{1}{18}Parsing command line options. All input parameters are passed to the
program through command line options and arguments to the program.
The syntax of command line options is listed whenever the program is invoked
with the {\tt --help} option at startup, or whenever an error occurs in the
input.

\Y\B\4\X18:Parse command line\X${}\E{}$\6
${}\{{}$\1\6
${}\\{progname}\K\\{strip\_away\_path}(\\{argv}[\T{0}]);{}$\6
${}\\{no\_arg}\K\\{argc};{}$\6
\&{while} ${}(\MM\\{argc}){}$\5
${}\{{}$\1\6
\&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-o"})\V\R%
\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--outputfile"})){}$\5
${}\{{}$\1\6
${}\MM\\{argc};{}$\6
${}\\{strcpy}(\\{outputfilename},\39\\{argv}[\\{no\_arg}-\\{argc}]);{}$\6
${}\\{outfile\_specified}\K\T{1};{}$\6
\4${}\}{}$\2\6
\&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-i"})\V%
\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--inputfile"})){}$\5
${}\{{}$\1\6
${}\MM\\{argc};{}$\6
${}\\{strcpy}(\\{inputfilename},\39\\{argv}[\\{no\_arg}-\\{argc}]);{}$\6
${}\\{infile\_specified}\K\T{1};{}$\6
\4${}\}{}$\2\6
\&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-v"})\V%
\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--verbose"})){}$\5
${}\{{}$\1\6
${}\\{verbose}\K(\\{verbose}\?\T{0}:\T{1});{}$\6
\4${}\}{}$\2\6
\&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-h"})\V%
\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--help"})){}$\5
${}\{{}$\1\6
\\{showsomehelp}(\,);\6
\\{exit}(\.{SUCCESS});\6
\4${}\}{}$\2\6
\&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-H"})\V%
\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--headline"})){}$\5
${}\{{}$\1\6
${}\\{headline}\K(\\{headline}\?\T{0}:\T{1});{}$\6
\4${}\}{}$\2\6
\&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-C"})\V%
\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--cropmarks"})){}$\5
${}\{{}$\1\6
${}\\{generate\_crop\_marks}\K(\\{generate\_crop\_marks}\?\T{0}:\T{1});{}$\6
\4${}\}{}$\2\6
\&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-t"})\V%
\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--linethick"})){}$\5
${}\{{}$\1\6
${}\MM\\{argc};{}$\6
\&{if} ${}(\R\\{sscanf}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"\%f"},\39{\AND}%
\\{linethickness})){}$\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stderr},\39\.{"\%s:\ Error\ in\ lineth}\)\.{ickness\
argument.\\n"},\39\\{progname});{}$\6
\\{exit}(\T{1});\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-s"})\V%
\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--edgeseparation"})){}$\5
${}\{{}$\1\6
${}\MM\\{argc};{}$\6
\&{if} ${}(\R\\{sscanf}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"\%f"},\39{\AND}%
\\{edgeseparation})){}$\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stderr},\39\.{"\%s:\ Error\ in\ edgese}\)\.{paration\
argument.\\n}\)\.{"},\39\\{progname});{}$\6
\\{exit}(\T{1});\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-c"})\V%
\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--compile"})){}$\5
${}\{{}$\1\6
${}\\{compile}\K(\\{compile}\?\T{0}:\T{1});{}$\6
\4${}\}{}$\2\6
\&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-e"})\V%
\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--eps"})){}$\5
${}\{{}$\1\6
${}\\{eps\_output}\K(\\{eps\_output}\?\T{0}:\T{1});{}$\6
\4${}\}{}$\2\6
\&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-d"})\V%
\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--dvipsopts"})){}$\5
${}\{{}$\1\6
${}\MM\\{argc};{}$\6
${}\\{strcpy}(\\{dvipsopts},\39\\{argv}[\\{no\_arg}-\\{argc}]);{}$\6
${}\\{dvipsopts\_specified}\K\T{1};{}$\6
\4${}\}{}$\2\6
\&{else}\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stderr},\39\.{"\%s:\ Unknown\ option\ }\)\.{'\%s'.\\n"},\39%
\\{progname},\39\\{argv}[\\{no\_arg}-\\{argc}]);{}$\6
\\{showsomehelp}(\,);\6
\\{exit}(\.{FAILURE});\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\&{if} ${}(\\{verbose}\W\R\\{outfile\_specified}){}$\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"You\ have\ specified\ }\)\.{verbose\ mode\
without}\)\.{\ any\ specification\ o}\)\.{f\\n"}\.{"a\ file\ where\ to\ sav}\)%
\.{e\ the\ generated\ TeX\ }\)\.{source\ code.\ This\ me}\)\.{ans\\n"}\.{"that\
any\ program\ co}\)\.{mments\ that\ appear,\ }\)\.{due\ to\ the\ verbose\ m}\)%
\.{ode,\\n"}\.{"will\ be\ mixed\ with\ }\)\.{the\ source\ code.\ It\ }\)\.{is\
highly\ recommende}\)\.{d\ that\\n"}\.{"you\ either\ turn\ off}\)\.{\ verbose\
mode\ or\ spe}\)\.{cify\ a\ file\ where\ to}\)\.{\ save\\n"}\.{"the\ generated\
outpu}\)\.{t\ (using\ the\ -o\ or\ -}\)\.{-outputfile\ option).}\)\.{\\n"});{}$%
\6
${}\\{fprintf}(\\{stdout},\39\.{"In\ order\ to\ make\ a\ }\)\.{clean\ output,\
the\ Te}\)\.{X\ code\ is\ separately}\)\.{\\n"}\.{"enclosed\ in\ the\ blo}\)%
\.{cks\ below.\\n"});{}$\6
\4${}\}{}$\2\6
\&{if} ${}(\\{verbose}\W\\{dvipsopts\_specified}){}$\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"Specified\ options\ f}\)\.{or\ later\ use\
with\ DV}\)\.{IPS:\ "});{}$\6
${}\\{fprintf}(\\{stdout},\39\.{"\%s\\n"},\39\\{dvipsopts});{}$\6
\4${}\}{}$\2\6
\4${}\}{}$\2\par
\U5.\fi

\M{19}Display a banner at start-up of the program.

\Y\B\4\X19:Display banner\X${}\E{}$\6
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"This\ is\ \%s,\ Version}\)\.{\ \%s\\n"},\39%
\\{progname},\39\.{VERSION});{}$\6
\4${}\}{}$\2\par
\U5.\fi

\N{1}{20}Opening and closing files for data output.

\fi

\M{21}Open files for reading. In order to read the text to typeset from an
external
file rather than the default standard input stream {\tt stdin}, the name of the
input file is specified with the {\tt -i} or {\tt --inputfile} command line
options.
If the filename as specified on the command line does not exist, then the
program will instead try to open a file with the suffix {\tt .dvl} concatenated
to the name. This way, the program will accept short-hand filenames as well, in
a way analogous to the input syntax rules of, for example, the \TeX\ program.
If no input file can be opened, an error message is displayed and the program
will exit with return value \PB{\.{FAILURE}}.

\Y\B\4\X21:Open files for reading\X${}\E{}$\6
${}\{{}$\1\6
\&{if} (\\{infile\_specified})\5
${}\{{}$\1\6
\&{if} ${}((\\{infile}\K\\{fopen}(\\{inputfilename},\39\.{"r"}))\E\NULL){}$\5
${}\{{}$\1\6
\&{if} ${}((\\{infile}\K\\{fopen}(\\{strcat}(\\{inputfilename},\39\.{".dvl"}),%
\39\.{"r"}))\E\NULL){}$\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stderr},\39\.{"\%s:\ Could\ not\ open\ }\)\.{file\ \%s\ for\
reading!}\)\.{\\n"},\39\\{progname},\39\\{inputfilename});{}$\6
\\{exit}(\.{FAILURE});\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
${}\\{fseek}(\\{infile},\39\T{0\$L},\39\.{SEEK\_SET});{}$\6
\&{if} (\\{verbose})\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stderr},\39\.{"\%s:\ Opened\ input\ fi}\)\.{le\ \%s\ for\
reading.\\n}\)\.{"},\39\\{progname},\39\\{inputfilename});{}$\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\&{else}\5
${}\{{}$\1\6
\&{if} (\\{verbose})\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stderr},\39\.{"\%s:\ No\ input\ filena}\)\.{me\ specified.%
\\n"},\39\\{progname});{}$\6
${}\\{fprintf}(\\{stderr},\39\.{"\%s:\ Entering\ intera}\)\.{ctive\ mode.\\n"},%
\39\\{progname});{}$\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\4${}\}{}$\2\par
\U5.\fi

\M{22}Open files for writing.

\Y\B\4\X22:Open files for writing\X${}\E{}$\6
${}\{{}$\1\6
\&{if} (\\{outfile\_specified})\5
${}\{{}$\1\6
${}\\{sprintf}(\\{tmpstr},\39\.{"\%s.tex"},\39\\{outputfilename});{}$\6
\&{if} ${}((\\{outfile}\K\\{fopen}(\\{tmpstr},\39\.{"w"}))\E\NULL){}$\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stderr},\39\.{"\%s:\ Could\ not\ open\ }\)\.{file\ \%s\ for\
writing!}\)\.{\\n"},\39\\{progname},\39\\{tmpstr});{}$\6
\\{exit}(\.{FAILURE});\6
\4${}\}{}$\2\6
${}\\{fseek}(\\{outfile},\39\T{0\$L},\39\.{SEEK\_SET});{}$\6
\&{if} (\\{verbose})\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stderr},\39\.{"\%s:\ Opened\ output\ f}\)\.{ile\ \%s\ for\
writing.\\}\)\.{n"},\39\\{progname},\39\\{outputfilename});{}$\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\&{else}\5
${}\{{}$\1\6
\&{if} (\\{verbose})\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stderr},\39\.{"\%s:\ No\ output\ filen}\)\.{ame\ specified.%
\\n"},\39\\{progname});{}$\6
${}\\{fprintf}(\\{stderr},\39\.{"\%s:\ Will\ write\ gene}\)\.{rated\ TeX\
output\ to\ }\)\.{standard\ terminal\ ou}\)\.{tput\\n"},\39\\{progname});{}$\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\4${}\}{}$\2\par
\U5.\fi

\M{23}Close all open files.

\Y\B\4\X23:Close files\X${}\E{}$\6
${}\{{}$\1\6
\&{if} (\\{infile\_specified})\1\5
\\{fclose}(\\{infile});\2\6
\&{if} (\\{outfile\_specified})\1\5
\\{fclose}(\\{outfile});\2\6
\4${}\}{}$\2\par
\U5.\fi

\N{1}{24}Reading input as supplied by the user.

\fi

\M{25}Parsing the input as supplied by the user. When reading the input, the
\dvlabel\ program makes use of either the \PB{\\{stdin}} stream (in the case of
interactive mode), or the file pointed out by the \PB{\\{infile}} pointer (in
the
case of processing of an input text file).
In the latter case, the syntax of the supplied file is identical to the
syntax as if operating the program in interactive mode, with every newline
character ({\tt /n}) interpreted as an end-of-line of a corresponding
interactive input.

Example: [TO BE INSERTED]

As the individual lines of text generally contain different number of
characters, the feedline character {\tt /n} of standard \CEE\ is throughout
the program used to keep track of the end of line. (This is more convenient
than keeping track of the indvidual line widths in, for example, and array
of integers.)

\Y\B\4\X25:Scan text lines of one label from input stream\X${}\E{}$\6
${}\{{}$\1\6
\X26:Read table of contents\X\6
\X27:Read time stamp\X\6
\X28:Read title\X\6
\X29:Read author name\X\6
\X30:Read address\X\6
\X31:Read email address\X\6
\4${}\}{}$\2\par
\U5.\fi

\M{26}Parse for the table of contents of the tape.
The syntax for specifying the table of contents is similar to that of the
address, with arbitrary number of lines of text. The input is ended by
a single dot on a new line, in similar to the way of entering, for example,
email messages in terminal mode using the basic engine of {\tt sendmail} on
regular UNIX and Linux systems.

\Y\B\4\X26:Read table of contents\X${}\E{}$\6
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"Specify\ table\ of\ co}\)\.{ntents\ of\ the\
DV\ tap}\)\.{e\\n"});{}$\6
${}\\{fprintf}(\\{stdout},\39\.{"[Enter\ text\ and\ fin}\)\.{ish\ with\ single\
dot\ }\)\.{on\ blank\ line]:\\n"});{}$\6
${}\\{done}\K\T{0};{}$\6
${}\|n\K\T{0};{}$\6
${}\\{num\_toc\_lines}\K\T{0};{}$\6
\&{while} ${}(\R\\{done}){}$\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"**"});{}$\6
\&{while} ${}((\\{tmpch}\K\\{fgetc}(\.{INSTREAM}))\E\.{'\ '}){}$\1\5
;\C{ Get rid of leading blanks }\2\6
${}\\{ungetc}(\\{tmpch},\39\.{INSTREAM});{}$\6
${}\|k\K\T{0};{}$\6
\&{while} ${}((\\{tmpstr}[\|k\PP]\K\\{fgetc}(\.{INSTREAM}))\I\.{'\\n'}){}$\1\5
;\C{ Read line }\2\6
\&{if} ${}(\|k>\T{1}){}$\5
${}\{{}$\C{ If more text than just spaces and a linefeed character }\1\6
\&{if} ${}((\\{tmpstr}[\T{0}]\E\.{'.'})\W(\\{tmpstr}[\T{1}]\E\.{'\\n'})){}$\5
${}\{{}$\1\6
${}\\{done}\K\T{1};{}$\6
\4${}\}{}$\2\6
\&{else}\5
${}\{{}$\1\6
\&{for} ${}(\|j\K\T{0};{}$ ${}\|j<\|k;{}$ ${}\|j\PP){}$\1\5
${}\\{toc}[\|n+\|j]\K\\{tmpstr}[\|j];{}$\2\6
\&{if} ${}(\T{1}\E\T{0}){}$\1\5
${}\\{toc}[\|n+\|j]\K\.{'\\n'};{}$\2\6
${}\|n\K\|n+\|j{}$;\C{ Keep track of last index of the \PB{\\{toc}} array }\6
${}\\{num\_toc\_lines}\PP;{}$\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\&{else}\5
${}\{{}$\C{ If just spaces and a linefeed character }\1\6
${}\\{toc}[\|n]\K\.{'\\n'}{}$;\C{ Blank line of table-of-contents field }\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\&{if} (\\{verbose})\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"\%s:\ Counted\ \%ld\ num}\)\.{ber\ of\
table-of-cont}\)\.{ents\ lines.\\n"},\39\\{progname},\39\\{num\_toc%
\_lines});{}$\6
${}\\{fprintf}(\\{stdout},\39\.{"Table\ of\ contents:\\}\)\.{n"});{}$\6
${}\|n\K\T{0};{}$\6
\&{for} ${}(\|k\K\T{1};{}$ ${}\|k\Z\\{num\_toc\_lines};{}$ ${}\|k\PP){}$\5
${}\{{}$\1\6
\&{for} ${}(\|j\K\|n;{}$ ${}\\{toc}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
${}\\{fprintf}(\\{stdout},\39\.{"\%c"},\39\\{toc}[\|j]);{}$\2\6
${}\\{fprintf}(\\{stdout},\39\.{"\\n"});{}$\6
${}\|n\K\|j+\T{1};{}$\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\4${}\}{}$\2\par
\U25.\fi

\M{27}Parse for the time stamp to be used.

\Y\B\4\X27:Read time stamp\X${}\E{}$\6
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"Specify\ time\ stamp\ }\)\.{of\ DV\ tape.\
This\ is\ }\)\.{typically\\n"});{}$\6
${}\\{fprintf}(\\{stdout},\39\.{"the\ last\ date\ that\ }\)\.{appears\ as\ time%
\ stam}\)\.{p\ in\ the\\n"});{}$\6
${}\\{fprintf}(\\{stdout},\39\.{"recorded\ tape.\ [Pre}\)\.{ss\ enter\ to\ use\
the\ }\)\.{current\ date]\\n"});{}$\6
${}\\{fprintf}(\\{stdout},\39\.{"**"});{}$\6
\&{while} ${}((\\{tmpch}\K\\{fgetc}(\.{INSTREAM}))\E\.{'\ '}){}$\1\5
;\C{ Get rid of leading blank spaces }\2\6
${}\\{ungetc}(\\{tmpch},\39\.{INSTREAM});{}$\6
${}\|k\K\T{0};{}$\6
\&{while} ${}((\\{tmpstr}[\|k\PP]\K\\{fgetc}(\.{INSTREAM}))\I\.{'\\n'}){}$\1\5
;\C{ Read line }\2\6
\&{if} ${}(\|k>\T{1}{}$)\C{ If more text than just spaces and a linefeed
character }\1\6
\&{for} ${}(\|j\K\T{0};{}$ ${}\|j<\|k;{}$ ${}\|j\PP){}$\1\5
${}\\{timestamp}[\|j]\K\\{tmpstr}[\|j];{}$\2\2\6
\&{else}\C{ If just spaces and a linefeed character }\1\6
\&{for} ${}(\|j\K\T{0};{}$ ${}\|j<\T{7};{}$ ${}\|j\PP){}$\1\5
${}\\{timestamp}[\|j]\K\.{"\\\\today\\n"}[\|j];{}$\2\2\6
\&{if} (\\{verbose})\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"Time\ stamp:\ "});{}$\6
\&{for} ${}(\|j\K\T{0};{}$ ${}\\{timestamp}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1%
\5
${}\\{fprintf}(\\{stdout},\39\.{"\%c"},\39\\{timestamp}[\|j]);{}$\2\6
${}\\{fprintf}(\\{stdout},\39\.{"\\n"});{}$\6
\4${}\}{}$\2\6
\4${}\}{}$\2\par
\U25.\fi

\M{28}Parse for the title to be used.

\Y\B\4\X28:Read title\X${}\E{}$\6
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"Specify\ title\ of\ th}\)\.{e\ DV\ tape\
[Press\ ent}\)\.{er\ to\ leave\ blank\ ti}\)\.{tle]:\\n"});{}$\6
${}\\{fprintf}(\\{stdout},\39\.{"**"});{}$\6
\&{while} ${}((\\{tmpch}\K\\{fgetc}(\.{INSTREAM}))\E\.{'\ '}){}$\1\5
;\C{ Get rid of leading blank spaces }\2\6
${}\\{ungetc}(\\{tmpch},\39\.{INSTREAM});{}$\6
${}\|k\K\T{0};{}$\6
\&{while} ${}((\\{tmpstr}[\|k\PP]\K\\{fgetc}(\.{INSTREAM}))\I\.{'\\n'}){}$\1\5
;\C{ Read line }\2\6
\&{if} ${}(\|k>\T{1}{}$)\C{ If more text than just spaces and a linefeed
character }\1\6
\&{for} ${}(\|j\K\T{0};{}$ ${}\|j<\|k;{}$ ${}\|j\PP){}$\1\5
${}\\{title}[\|j]\K\\{tmpstr}[\|j];{}$\2\2\6
\&{else}\C{ If just spaces and a linefeed character }\1\6
${}\\{title}[\T{0}]\K\.{'\\n'}{}$;\C{ Blank title }\2\6
\&{if} (\\{verbose})\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"Title:\ "});{}$\6
\&{for} ${}(\|j\K\T{0};{}$ ${}\\{title}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
${}\\{fprintf}(\\{stdout},\39\.{"\%c"},\39\\{title}[\|j]);{}$\2\6
${}\\{fprintf}(\\{stdout},\39\.{"\\n"});{}$\6
\4${}\}{}$\2\6
\4${}\}{}$\2\par
\U25.\fi

\M{29}Parse for the author name to be used.

\Y\B\4\X29:Read author name\X${}\E{}$\6
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"Specify\ author\ of\ t}\)\.{he\ DV\ tape\
[Press\ en}\)\.{ter\ to\ leave\ blank]:}\)\.{\\n"});{}$\6
${}\\{fprintf}(\\{stdout},\39\.{"**"});{}$\6
\&{while} ${}((\\{tmpch}\K\\{fgetc}(\.{INSTREAM}))\E\.{'\ '}){}$\1\5
;\C{ Get rid of leading blank spaces }\2\6
${}\\{ungetc}(\\{tmpch},\39\.{INSTREAM});{}$\6
${}\|k\K\T{0};{}$\6
\&{while} ${}((\\{tmpstr}[\|k\PP]\K\\{fgetc}(\.{INSTREAM}))\I\.{'\\n'}){}$\1\5
;\C{ Read line }\2\6
\&{if} ${}(\|k>\T{1}{}$)\C{ If more text than just spaces and a linefeed
character }\1\6
\&{for} ${}(\|j\K\T{0};{}$ ${}\|j<\|k;{}$ ${}\|j\PP){}$\1\5
${}\\{author}[\|j]\K\\{tmpstr}[\|j];{}$\2\2\6
\&{else}\C{ If just spaces and a linefeed character }\1\6
${}\\{author}[\T{0}]\K\.{'\\n'}{}$;\C{ Blank author field }\2\6
\&{if} (\\{verbose})\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"Author:\ "});{}$\6
\&{for} ${}(\|j\K\T{0};{}$ ${}\\{author}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
${}\\{fprintf}(\\{stdout},\39\.{"\%c"},\39\\{author}[\|j]);{}$\2\6
${}\\{fprintf}(\\{stdout},\39\.{"\\n"});{}$\6
\4${}\}{}$\2\6
\4${}\}{}$\2\par
\U25.\fi

\M{30}Parse for the address to be used.
The syntax for specifying the address is similar to that of the table of
contents, with arbitrary number of lines of text. The input is ended by
a single dot on a new line, in similar to the way of entering, for example,
email messages in terminal mode using the basic engine of {\tt sendmail} on
regular UNIX and Linux systems.

\Y\B\4\X30:Read address\X${}\E{}$\6
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"Specify\ address\ of\ }\)\.{author\ of\ the\
DV\ tap}\)\.{e\\n"});{}$\6
${}\\{fprintf}(\\{stdout},\39\.{"[Enter\ text\ and\ fin}\)\.{ish\ with\ single\
dot\ }\)\.{on\ blank\ line]:\\n"});{}$\6
${}\\{fprintf}(\\{stdout},\39\.{"**"});{}$\6
${}\\{done}\K\T{0};{}$\6
${}\|n\K\T{0};{}$\6
${}\\{num\_address\_lines}\K\T{0};{}$\6
\&{while} ${}(\R\\{done}){}$\5
${}\{{}$\1\6
\&{while} ${}((\\{tmpch}\K\\{fgetc}(\.{INSTREAM}))\E\.{'\ '}){}$\1\5
;\C{ Get rid of leading spaces }\2\6
${}\\{ungetc}(\\{tmpch},\39\.{INSTREAM});{}$\6
${}\|k\K\T{0};{}$\6
\&{while} ${}((\\{tmpstr}[\|k\PP]\K\\{fgetc}(\.{INSTREAM}))\I\.{'\\n'}){}$\1\5
;\C{ Read line }\2\6
\&{if} ${}(\|k>\T{1}){}$\5
${}\{{}$\C{ If more text than just spaces and a linefeed character }\1\6
\&{if} ${}((\\{tmpstr}[\T{0}]\E\.{'.'})\W(\\{tmpstr}[\T{1}]\E\.{'\\n'})){}$\5
${}\{{}$\1\6
${}\\{done}\K\T{1};{}$\6
\4${}\}{}$\2\6
\&{else}\5
${}\{{}$\1\6
\&{for} ${}(\|j\K\T{0};{}$ ${}\|j<\|k;{}$ ${}\|j\PP){}$\1\5
${}\\{address}[\|n+\|j]\K\\{tmpstr}[\|j];{}$\2\6
\&{if} ${}(\T{1}\E\T{0}){}$\1\5
${}\\{address}[\|n+\|j]\K\.{'\\n'};{}$\2\6
${}\|n\K\|n+\|j{}$;\C{ Keep track of last index of the \PB{\\{address}} array }%
\6
${}\\{num\_address\_lines}\PP;{}$\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\&{else}\5
${}\{{}$\C{ If just spaces and a linefeed character }\1\6
${}\\{address}[\|n]\K\.{'\\n'}{}$;\C{ Blank line of address field }\6
\4${}\}{}$\2\6
${}\\{fprintf}(\\{stdout},\39\.{"**"});{}$\6
\4${}\}{}$\2\6
\&{if} (\\{verbose})\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"\%s:\ Counted\ \%ld\ add}\)\.{ress\ lines.%
\\n"},\39\\{progname},\39\\{num\_address\_lines});{}$\6
${}\\{fprintf}(\\{stdout},\39\.{"Address:\\n"});{}$\6
${}\|n\K\T{0};{}$\6
\&{for} ${}(\|k\K\T{1};{}$ ${}\|k\Z\\{num\_address\_lines};{}$ ${}\|k\PP){}$\5
${}\{{}$\1\6
\&{for} ${}(\|j\K\|n;{}$ ${}\\{address}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
${}\\{fprintf}(\\{stdout},\39\.{"\%c"},\39\\{address}[\|j]);{}$\2\6
${}\\{fprintf}(\\{stdout},\39\.{"\\n"});{}$\6
${}\|n\K\|j+\T{1};{}$\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\4${}\}{}$\2\par
\U25.\fi

\M{31}Parse for the email address to be used.

\Y\B\4\X31:Read email address\X${}\E{}$\6
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"Specify\ email\ of\ au}\)\.{thor\ of\ the\ DV\
tape\ }\)\.{[Press\ enter\ to\ leav}\)\.{e\ blank]:\\n"});{}$\6
${}\\{fprintf}(\\{stdout},\39\.{"**"});{}$\6
\&{while} ${}((\\{tmpch}\K\\{fgetc}(\.{INSTREAM}))\E\.{'\ '}){}$\1\5
;\C{ Get rid of leading blank spaces }\2\6
${}\\{ungetc}(\\{tmpch},\39\.{INSTREAM});{}$\6
${}\|k\K\T{0};{}$\6
\&{while} ${}((\\{tmpstr}[\|k\PP]\K\\{fgetc}(\.{INSTREAM}))\I\.{'\\n'}){}$\1\5
;\C{ Read line }\2\6
\&{if} ${}(\|k>\T{1}{}$)\C{ If more text than just spaces and a linefeed
character }\1\6
\&{for} ${}(\|j\K\T{0};{}$ ${}\|j<\|k;{}$ ${}\|j\PP){}$\1\5
${}\\{email}[\|j]\K\\{tmpstr}[\|j];{}$\2\2\6
\&{else}\C{ If just spaces and a linefeed character }\1\6
${}\\{email}[\T{0}]\K\.{'\\n'}{}$;\C{ Blank email field }\2\6
\&{if} (\\{verbose})\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"Email:\ "});{}$\6
\&{for} ${}(\|j\K\T{0};{}$ ${}\\{email}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
${}\\{fprintf}(\\{stdout},\39\.{"\%c"},\39\\{email}[\|j]);{}$\2\6
${}\\{fprintf}(\\{stdout},\39\.{"\\n"});{}$\6
\4${}\}{}$\2\6
\4${}\}{}$\2\par
\U25.\fi

\M{32}Generating the preamble of output \TeX\ source code for the labels.
The physical outer of the Mini Digital Label dimensions are based on the inset
of TDK cassettes, with \PB{\\{flapheight}} of 14.5˜mm (41.3˜pt), spineheight of
12.5˜mm (35.6˜pt), \PB{\\{faceheight}} of 47˜mm (133.7˜pt), and \PB{%
\\{facewidth}} of
67˜mm (190.6˜pt), hence summing up to overall outer dimensions of
$190.6\times210.6$˜pt of the label.

\Y\B\4\X32:Save preamble source code\X${}\E{}$\6
${}\{{}$\1\6
${}\\{facewidth}\K\T{190.6}+\T{3.0}*\T{72.27}/\T{25.4};{}$\6
${}\\{faceheight}\K\T{133.7};{}$\6
${}\\{spineheight}\K\T{35.6};{}$\6
${}\\{flapheight}\K\T{41.3};{}$\6
${}\\{ifacewidth}\K\\{facewidth}-\T{14.0}*\\{linethickness};{}$\6
${}\\{ifaceheight}\K\\{faceheight}-\T{11.0}*\\{linethickness}-\T{0.5}*%
\\{edgeseparation};{}$\6
${}\\{ispineheight}\K\\{spineheight}-\T{8.0}*\\{linethickness}-%
\\{edgeseparation};{}$\6
${}\\{iflapheight}\K\\{flapheight}-\T{11.0}*\\{linethickness}-\T{0.5}*%
\\{edgeseparation};{}$\6
\&{if} ${}(\R\\{outfile\_specified}){}$\1\5
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%\%--------\ TEX\ CODE}\)\.{\ BEGINS\ HERE%
\ -------}\)\.{----------\\n"});{}$\2\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%\%\ File:\ \%s.tex\\n"},\39%
\\{outputfilename});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%\%\ TeX\ code\ generat}\)\.{ed\ by\ \%s,\
v.\%s,\ \%s"},\39\\{progname},\39\.{VERSION},\39\\{ctime}({\AND}\\{now}));{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%\%\ Copyright\ (C)\ Fr}\)\.{edrik\
Jonsson,\ 2003-}\)\.{2005\\n\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hoffset=-35pt\\\\vo}\)\.{ffset=-25pt%
\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hsize=175mm\\\\vsiz}\)\.{e=254mm%
\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\font\\\\eightcmssqe}\)\.{ight=cmssq8%
\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\font\\\\sevencmtt=c}\)\.{mtt7\\n"});{}$%
\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\font\\\\tencmssqten}\)\.{=cmssq8\ at\
10\ truept}\)\.{\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\font\\\\deffacefont}\)\.{=cmr7%
\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\font\\\\deftimestam}\)\.{pfont=cmtt8\
at\ 7\ tru}\)\.{ept\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\font\\\\defspinefon}\)\.{t=cmr9%
\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\font\\\\defflapfont}\)\.{=cmr7%
\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\monthname\{\\\\}\)\.{ifcase%
\\\\month\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \\\\or\ Jan\\\\or\ Feb\\\\}\)\.{or\ Mar%
\\\\or\ Apr\\\\or\ M}\)\.{ay\\\\or\ Jun\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \\\\or\ Jul\\\\or\ Aug\\\\}\)\.{or\ Sep%
\\\\or\ Oct\\\\or\ N}\)\.{ov\\\\or\ Dec\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \\\\fi\}\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\fullmonthnam}\)\.{e\{\\\\ifcase%
\\\\month\%\%\\}\)\.{n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \\\\or\ January\\\\or\ F}\)\.{ebruary%
\\\\or\ March\\\\o}\)\.{r\ April\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \\\\or\ May\\\\or\ June\\}\)\.{\\or\ July%
\\\\or\ August\\}\)\.{\\or\ September\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \\\\or\ October\\\\or\ N}\)\.{ovember%
\\\\or\ December}\)\.{\\\\fi\}\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\today\{\\\\full}\)\.{monthname%
\\\\space\\\\nu}\)\.{mber\\\\day,\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\space\\\\number\\\\}\)\.{year\}%
\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\dvby\{Digital}\)\.{\ Video\ by%
\\\\\ \}\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\parindent\ 0pt\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\newdimen\\\\facewid}\)\.{th\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\newdimen\\\\facehei}\)\.{ght\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\newdimen\\\\spinehe}\)\.{ight\\n"});{}$%
\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\newdimen\\\\flaphei}\)\.{ght\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\newdimen\\\\linethi}\)\.{ck\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\newdimen\\\\spaceth}\)\.{ick\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\newdimen\\\\edgesep}\)\.{aration%
\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\newdimen\\\\cropthi}\)\.{ck\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\facewidth=\%1.3fpt}\)\.{\\n"},\39%
\\{facewidth});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\faceheight=\%1.3fp}\)\.{t\\n"},\39%
\\{faceheight});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\spineheight=\%1.3f}\)\.{pt\\n"},\39%
\\{spineheight});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\flapheight=\%1.3fp}\)\.{t\\n"},\39%
\\{flapheight});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\linethick=\%1.3fpt}\)\.{\\n"},\39%
\\{linethickness});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\spacethick=\%1.3fp}\)\.{t\\n"},\39%
\T{2.0}*\\{linethickness});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\edgeseparation=\%1}\)\.{.3fpt\\n"},\39%
\\{edgeseparation});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\cropthick=\%1.3fpt}\)\.{\\n"},\39%
\\{clthick});{}$\6
\&{if} (\\{headline})\5
${}\{{}$\1\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\headline=\{\\\\hfill}\)\.{\{\\\\tt\
dvlabel\ output}\)\.{"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \%s"},\39\\{ctime}({\AND}\\{now}));{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ [\%s]\}\}\\n"},\39(\\{infile\_specified}%
\?\\{inputfilename}:\.{"stdin"}));{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\footline=\{\\\\hfill}\)\.{\\\\folio%
\\\\hfill\}\\n"});{}$\6
\4${}\}{}$\2\6
\&{else}\5
${}\{{}$\1\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\headline=\{\\\\hfil\}}\)\.{\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\nopagenumbers\\n"});{}$\6
\4${}\}{}$\2\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\boxit\#1\{\\\\vb}\)\.{ox\{%
\\\\hrule\ height\\\\l}\)\.{inethick\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\hbox\{\\\\vrule\ wi}\)\.{dth%
\\\\linethick\\\\kern}\)\.{\\\\spacethick\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\vbox\{\\\\kern\\\\sp}\)\.{acethick%
\#1\\\\kern\\\\sp}\)\.{acethick\}\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\kern\\\\spacethic}\)\.{k\\\\vrule\
width\\\\line}\)\.{thick\}\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\hrule\ height\\\\l}\)\.{inethick\}%
\}\%\%\\n"});{}$\6
\4${}\}{}$\2\par
\U5.\fi

\M{33}Generating the output \TeX\ source code for the labels.

\Y\B\4\X33:Save label source code\X${}\E{}$\6
${}\{{}$\1\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\timestamp\{"});{}$\6
\&{for} ${}(\|j\K\T{0};{}$ ${}\\{timestamp}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1%
\5
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%c"},\39\\{timestamp}[\|j]);{}$\2\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\}\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\title\{"});{}$\6
\&{for} ${}(\|j\K\T{0};{}$ ${}\\{title}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%c"},\39\\{title}[\|j]);{}$\2\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\}\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\author\{"});{}$\6
\&{for} ${}(\|j\K\T{0};{}$ ${}\\{author}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%c"},\39\\{author}[\|j]);{}$\2\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\}\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\email\{"});{}$\6
\&{for} ${}(\|j\K\T{0};{}$ ${}\\{email}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%c"},\39\\{email}[\|j]);{}$\2\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\}\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%\%\ Define\ the\ outli}\)\.{ne\ of\ the\
face\ of\ th}\)\.{e\ label\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\setbox1=\\\\hbox\ to}\)\.{\ \%1.3fpt\{%
\{\%\%\\n"},\39\\{ifacewidth});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\vbox\ to\ \\\\faceh}\)\.{eight\{\%%
\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \ \ \\\\hbox\{\\\\deffac}\)\.{efont%
\\\\timestamp\\\\hf}\)\.{il\}\%\%\\n"});{}$\6
${}\|n\K\T{0};{}$\6
\&{for} ${}(\|k\K\T{1};{}$ ${}\|k\Z\\{num\_toc\_lines};{}$ ${}\|k\PP){}$\5
${}\{{}$\1\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \ \ \\\\vskip\ -3pt\\\\h}\)\.{box\{%
\\\\deffacefont\ "});{}$\6
\&{for} ${}(\|j\K\|n;{}$ ${}\\{toc}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%c"},\39\\{toc}[\|j]);{}$\2\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hfil\}\%\%\\n"});{}$\6
${}\|n\K\|j+\T{1};{}$\6
\4${}\}{}$\2\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\vfil\}\}\\\\hfil\}\%\%}\)\.{%
\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%\%\ Define\ the\ outli}\)\.{ne\ of\ the\
spine\ of\ t}\)\.{he\ label\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\setbox2=\\\\hbox\ to}\)\.{\ \%1.3fpt\{%
\{\%\%\\n"},\39\\{ifacewidth});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\vbox\ to\ \%1.3fpt}\)\.{\{\%\%%
\\n"},\39\\{ispineheight});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \ \ \\\\hbox\{\\\\deftim}\)%
\.{estampfont\\\\timestam}\)\.{p\\\\hfil\}\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \ \ \\\\hbox\{\\\\defspi}\)\.{nefont%
\\\\title\\\\hfil\}}\)\.{\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\vfil\}\}\\\\hfil\}\%\%}\)\.{%
\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%\%\ Define\ the\ outli}\)\.{ne\ of\ the\
flap\ of\ th}\)\.{e\ label\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\setbox3=\\\\hbox\ to}\)\.{\ \%1.3fpt\{%
\{\%\%\\n"},\39\\{ifacewidth});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\vbox\ to\ \%1.3fpt}\)\.{\{\%\%%
\\n"},\39\\{iflapheight});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \ \ \\\\hbox\{\\\\deffla}\)\.{pfont%
\\\\dvby\\\\author\\}\)\.{\\hfil\}\%\%\\n"});{}$\6
${}\|n\K\T{0};{}$\6
\&{for} ${}(\|k\K\T{1};{}$ ${}\|k\Z\\{num\_address\_lines};{}$ ${}\|k\PP){}$\5
${}\{{}$\1\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \ \ \\\\vskip\ -3pt\\\\h}\)\.{box\{%
\\\\defflapfont\ "});{}$\6
\&{for} ${}(\|j\K\|n;{}$ ${}\\{address}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%c"},\39\\{address}[\|j]);{}$\2\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hfil\}\\n"});{}$\6
${}\|n\K\|j+\T{1};{}$\6
\4${}\}{}$\2\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \ \ \\\\vskip\ -3pt\\\\h}\)\.{box\{%
\\\\defflapfont\\\\e}\)\.{mail\\\\hfil\}\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\vfil\}\}\\\\hfil\}\%\%}\)\.{%
\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\dvlabel\{\\\\hs}\)\.{kip%
\\\\linethick\\\\boxi}\)\.{t\{\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\boxit\{\\\\box1\}\\\\}\)\.{vskip%
\\\\edgeseparatio}\)\.{n\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\boxit\{\\\\box2\}\\\\}\)\.{vskip%
\\\\edgeseparatio}\)\.{n\%\%\\n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\boxit\{\\\\box3\}\}\\}\)\.{\\hskip%
\\\\linethick\}\%\%}\)\.{\\n"});{}$\6
\&{if} ${}((\\{num\_labels}\E\T{1})\V(\\{num\_labels}\E\T{3})){}$\1\5
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hskip\ \%1.3fpt"},\39(\T{20.0}));{}$\2\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\dvlabel\\n"});{}$\6
\&{if} ${}((\\{num\_labels}\E\T{2})\V(\\{num\_labels}\E\T{4})\V(\\{num\_labels}%
\E\T{6})){}$\5
${}\{{}$\1\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\par\\\\nointerlines}\)\.{kip\\n"});{}$\6
\4${}\}{}$\2\6
\4${}\}{}$\2\par
\U5.\fi

\M{34}Close one page of output, with each page containing \PB{\\{num\_labels%
\_per\_page}}
labels, and write any preamble for initialization of a new page to the output
stream.

\Y\B\4\X34:Close output page\X${}\E{}$\6
${}\{{}$\1\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\vfill\\\\eject\\n"});{}$\6
\4${}\}{}$\2\par
\Us5\ET37.\fi

\M{35}Before writing the first row of labels to the page output, save the
vertical
crop marks to be used as alignment marks in vertical cutting of the final
pages.

\Y\B\4\X35:Write vertical crop marks with width measure\X${}\E{}$\6
${}\{{}$\1\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hskip\ \%1.3fpt\\\\vr}\)\.{ule\
height20pt\ width}\)\.{\%1.3fpt\%\%\\n"},\39\T{20.0}-\\{clthick}/\T{2.0},\39%
\\{clthick});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hbox\ to\%1.3fpt\{\\\\}\)\.{hfil"},\39%
\\{facewidth}-\\{clthick});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\$\\\\matrix\{\{\%1.3f\{\\\\}\)\.{rm\\\\\
pt\}/\%1.3f\{\\\\rm\\}\)\.{\\\ mm\}\}"}\.{"\\\\cr\{\}\\\\cr\}\$\\\\hfil\}}\)\.{%
\%\%\\n"},\39\\{facewidth},\39\\{facewidth}*(\T{25.4}/\T{72.27}));{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\vrule\ height20pt\ }\)\.{width\%1.3fpt%
\%\%\\n"},\39\\{clthick});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hbox\ to\ \%1.3fpt\{\\}\)\.{\\hfil"},%
\39\\{facewidth}-\\{clthick});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\$\\\\matrix\{\{\%1.3f\{\\\\}\)\.{rm\\\\\
pt\}/\%1.3f\{\\\\rm\\}\)\.{\\\ mm\}\}"}\.{"\\\\cr\{\}\\\\cr\}\$\\\\hfil\}}\)\.{%
\%\%\\n"},\39\\{facewidth},\39\\{facewidth}*(\T{25.4}/\T{72.27}));{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\vrule\ height20pt\ }\)\.{width\%1.3fpt%
\\\\par\\\\n}\)\.{ointerlineskip\\n"},\39\\{clthick});{}$\6
\4${}\}{}$\2\par
\Us5\ET37.\fi

\M{36}The following block is analogous to the previous one, but now instead
considering horizontal crop marks, to be used as alignment marks in
horizontal cutting of the final pages.

\Y\B\4\X36:Write horizontal crop marks with height measure\X${}\E{}$\6
${}\{{}$\1\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\vskip\\\\linethick\\}\)\.{n"});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\vrule\ height\%1.3f}\)\.{pt\
width20pt"},\39\\{clthick});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hskip\ \%1.3fpt"},\39\T{2.0}*%
\\{facewidth});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\vrule\ height\%1.3f}\)\.{pt\ width20pt%
\\\\par\\\\n}\)\.{ointerlineskip\\n"},\39\\{clthick});{}$\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\vskip\\\\linethick\\}\)\.{n"});{}$\6
\4${}\}{}$\2\par
\Us5\ET37.\fi

\M{37}Generating the closing \TeX\ source code for the labels.

\Y\B\4\X37:Save closing source code\X${}\E{}$\6
${}\{{}$\1\6
\&{if} ${}((\\{num\_labels}\I\T{2})\W(\\{num\_labels}\I\T{4})){}$\5
${}\{{}$\1\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\par\\\\nointerlines}\)\.{kip\\n"});{}$\6
\4${}\}{}$\2\6
\&{if} ${}(\\{num\_labels}\I\\{num\_labels\_per\_page}){}$\5
${}\{{}$\1\6
\&{if} ${}(\\{num\_labels}\I\T{0}){}$\5
${}\{{}$\1\6
\&{if} (\\{generate\_crop\_marks})\5
${}\{{}$\1\6
\X36:Write horizontal crop marks with height measure\X\6
\X35:Write vertical crop marks with width measure\X\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\X34:Close output page\X\6
\4${}\}{}$\2\6
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\bye\\n"});{}$\6
\&{if} ${}(\R\\{outfile\_specified}){}$\1\5
${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%\%--------\ TEX\ CODE}\)\.{\ ENDS\ HERE\
---------}\)\.{--------\\n"});{}$\2\6
\4${}\}{}$\2\par
\U5.\fi

\M{38}Compiling the output \TeX\ source code. If the {\tt -c} or {\tt
--compile}
option was present at the command line during startup of \dvlabel, then
the program will make use of \DVIPS\ to compile the previously generated
\TeX\ source code into PostScript.
If the {\tt -c} or {\tt --compile} option is used together with a specified
output file (specified using the {\tt-o} or {\tt --outputfile} options),
then this output file will be compiled.
On the other hand, if the {\tt -c} or {\tt --compile} option is used while
the program should send the generated source to \PB{\\{stdout}}, then the
internally
stored lines of output will be compiled instead (hence eliminating the need
for a temporary file for the compilation).

\Y\B\4\X38:Compile source code\X${}\E{}$\6
${}\{{}$\1\6
\&{if} (\\{compile})\5
${}\{{}$\1\6
\&{if} (\\{verbose})\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"\%s:\ Compiling\ the\ T}\)\.{eX\ source\ code\
into\ }\)\.{PostScript.\\n"},\39\\{progname});{}$\6
\4${}\}{}$\2\6
\&{if} (\\{outfile\_specified})\5
${}\{{}$\1\6
\&{if} (\\{eps\_output})\5
${}\{{}$\1\6
${}\\{sprintf}(\\{tmpstr},\39\.{"tex\ \%s;\ dvips\ \%s\ \%s}\)\.{\ -E\ -o\ %
\%s.eps"},\39\\{outputfilename},\39\\{dvipsopts},\39\\{outputfilename},\39%
\\{outputfilename});{}$\6
\4${}\}{}$\2\6
\&{else}\5
${}\{{}$\1\6
${}\\{sprintf}(\\{tmpstr},\39\.{"tex\ \%s;\ dvips\ \%s\ \%s}\)\.{\ -o\ %
\%s.ps"},\39\\{outputfilename},\39\\{dvipsopts},\39\\{outputfilename},\39%
\\{outputfilename});{}$\6
\4${}\}{}$\2\6
\\{system}(\\{tmpstr});\C{ System call to execute \PB{\\{tmpstr}} }\6
\4${}\}{}$\2\6
\&{else}\5
${}\{{}$\1\6
${}\\{fprintf}(\\{stdout},\39\.{"Compiling\ terminal\ }\)\.{output:\ Not\
implemen}\)\.{ted\ yet.\\n"});{}$\6
\\{exit}(\.{FAILURE});\6
\4${}\}{}$\2\6
\4${}\}{}$\2\6
\4${}\}{}$\2\par
\U5.\fi

\N{1}{39}Index.
\fi

\inx
\fin
\con


Return to previous page

Last modified 15 Dec 2009