Contents of file 'dvlabel/dvlabel.tex':
1 \input cwebmac
2 % File: dvlabel.w [CWEB source code]
3 % Created: December 5, 2003
4 % Last change: August 10, 2005
5 % Author: Fredrik Jonsson
6 % Description: CWEB source code for the DVLABEL program, which generates
7 % TeX source code for typesetting of labels for digital video
8 % tapes (DV format, typically used for hand-held video camera
9 % recorders). The program is primarily designed to run in
10 % interactive mode, but via command-line parameters it also
11 % supports batch-mode operation.
12 % A feature of the program is also that it is able to compile
13 % the generated TeX source code into PostScript, using the DVIPS
14 % program. (The DVIPS program is copyrighted by Radical Eye
15 % Software, but is typically included in most TeX distributions
16 % under UNIX, Linux, and Microsoft Windows; see the site
17 % http://www.radicaleye.com for further information).
18 % For information on the CWEB programming language, see
19 % http://www.literateprogramming.com.
20 % Compilation: Compile this program by using the enclosed Makefile, or use
21 % the blocks of the Makefile as listed in section five of the
22 % documentation (file dvlabel.ps or dvlabel.pdf). The C source
23 % code (as generated from this CWEB code) conforms to the ANSI
24 % standard for the C programming language (which is equivalent
25 % to the ISO C89 standard for C).
26 %
27 % Copyright (C) 2003-2004, Fredrik Jonsson
28 %
29 \input epsf
30 \def\version{1.6}
31 \def\lastrevdate{August 10, 2005}
32 \font\eightcmr=cmr8
33 \font\tensc=cmcsc10
34 \font\eightcmssq=cmssq8
35 \font\eightcmssqi=cmssqi8
36 \font\twentycmcsc=cmcsc10 at 20 truept
37 \def\dvlabel{{\eightcmr DVLABEL\spacefactor1000}}
38 \def\poincare{{\eightcmr POINCARE\spacefactor1000}}
39 \def\magbragg{{\eightcmr MAGBRAGG\spacefactor1000}}
40 \def\CEE{{\eightcmr C\spacefactor1000}} % The C programming language
41 \def\CWEB{{\eightcmr CWEB\spacefactor1000}} % The CWEB programming language
42 \def\DVIPS{{\eightcmr DVIPS\spacefactor1000}} % The DVIPS program
43 %
44 % Define a handy macro for the list of program revisions.
45 %
46 \newdimen\citemindent \citemindent=80pt
47 \newdimen\citemleftskip \citemleftskip=90pt
48 \def\citem[#1]{\smallbreak\noindent\hbox to 10pt{}%
49 \hbox to\citemindent{\bf #1\hfill}%
50 \hangindent\citemleftskip\ignorespaces}
51
52 \datethis
53
54
55 \N{1}{1}Introduction.
56 \vskip 120pt
57 \centerline{\twentycmcsc Dvlabel}
58 \vskip 20pt
59 \centerline{Creates TeX source code for typesetting labels for digital
60 video tapes}
61 \vskip 2pt
62 \centerline{(Version \version\ of \lastrevdate)}
63 \vskip 10pt
64 \centerline{Written by Fredrik Jonsson}
65 \vskip 80pt
66 \noindent
67 This \CWEB\footnote{${}^\dagger$}{For information on the \CWEB\ programming
68 language by Donald E.~Knuth, as well as samples of \CWEB\ programs, see
69 {\tt http://www-cs-faculty.stanford.edu/\~\ \kern -5pt knuth/cweb.html}.
70 For general information on literate programming, see
71 {\tt http://www.literateprogramming.com}.}
72 program generates \TeX\ source code for typesetting of labels for digital
73 video tapes (DV format, typically used for hand-held video camera recorders).
74
75 Most people have not heard of the \TeX\ system for typesetting mathematical
76 text, and if they have, they will most probably not use the system for
77 creating things like labels for video tapes.
78 However, the output generated by \TeX\ is in many cases absolutely superior
79 in balance and visual clarity, and in order to benefit from the compactness
80 and beauty of text processed by \TeX\ even for such basic things as labels
81 for video tapes, this program generates the necessary \TeX\ code and even
82 compiles it into printable PostScript.
83
84 The program is primarily designed to run in interactive mode, but via
85 command-line parameters it also supports batch-mode operation.
86 A feature of the program is also that it is able to compile
87 the generated TeX source code into PostScript, using the
88 \DVIPS\ program.\footnote{$\ddagger$}{The \DVIPS\ program is copyrighted
89 by Radical Eye Software, but is typically included in most \TeX\ distributions
90 under UNIX, Linux, and Microsoft Windows; see the site
91 {\tt http://www.radicaleye.com} for further information.}
92 \bigskip
93 \noindent Copyright \copyright\ Fredrik Jonsson, 2003--2005.
94 All rights reserved.
95 \vfill
96
97 \fi
98
99 \N{1}{2}Revision history of the program.
100 \medskip
101
102 \citem[2003-12-28]{[v.1.0]} {\tt <jonsson@uni-wuppertal.de>}\hfill\break
103 First properly working version of the \dvlabel\ program.
104 I got the idea of creating this program from the {\tt audio-tape.ps} PostScript
105 code by Jamie Zawinski. This code is a splendid example of how one can
106 write a simple PostScript program with the help of a regular ASCII editor,
107 and by sending the PostScript program to the printer, one gets a neat
108 printout to be used for tape cassette labels, DAT, or video tapes.
109 However, whenever one has a new cassette to be labeled, one has to edit
110 the PostScript source, and for a rookie on PostScript programming this
111 task is somewhat inconvenient.
112 Therefore, I decided to create something similar, but with a standalone program
113 that could be operated either in interactive mode, with the program asking
114 for the specific information to be entered in the label, or in batch mode.
115 However, instead of directly generating PostScript, I decided to go for a
116 language that I know somewhat more in detail, namely plain \TeX, which also
117 has the benefit of being a language which the author, Donald E.~Knuth, has
118 decided to keep fixed in order to ensure future compatibility.
119
120 \citem[2003-12-29]{[v.1.1]} {\tt <jonsson@uni-wuppertal.de>}\hfill\break
121 Revised the leading blocks (definitions) of the generator of the \TeX-code,
122 in order to have a more clearly structure of the labels. Included the
123 {\tt {\char'134}boxit} example from the \TeX-book to have the face, flap, and
124 spine
125 of the labels neatly structured.
126 Also finished the parsing engine for the address and table of contents
127 fields.
128
129 \citem[2004-11-26]{[v.1.2]} {\tt <fredrik.jonsson@nmrc.ie>}\hfill\break
130 Added support for supplying \DVIPS\ options via the command line when
131 invoking \dvlabel. In order to parse for an arbitrary number of \DVIPS\ options
132 at the command line, it is important to enclose the list of \DVIPS\ options
133 by quotes, hence forcing the \dvlabel\ program to parse the set of options as
134 one single string of characters. (The quotes are only necessary if the number
135 of \DVIPS\ options are two or more.)
136 Hence, for example, to force \DVIPS\ to generate output pages of US letter
137 format and at a resolution of 720 dpi one could invoke \dvlabel\ with
138 {\tt dvlabel --dvipsopts "-tletter -D720" ...}
139 Also slightly changed the way the input filename is used; now one can specify
140 only the basic filename, to which the \dvlabel\ program now automatically
141 appends the suffix {\tt .dvl}, if necessary.
142 Finally restructured the blocks related to scanning and saving code for
143 individual DV labels, in order to have the structure ready for making
144 the program generally capable of scanning one single file containing
145 an arbitrary number of labels, as for instance if one would keep all
146 records in one single text file.
147
148 \citem[2004-11-27]{[v.1.3]} {\tt <fredrik.jonsson@nmrc.ie>}\hfill\break
149 The \dvlabel\ program now parses multiple label records from the same input
150 file. Also added the useful feature of crop marks in the generated \TeX\ output
151 of the program. In its current state, the program only generates labels in one
152 single horizontal column; this is something that I in the future versions will
153 change into a $[3\times3]$ array of labels, as soon as I get the {\tt\\vbox}
154 and {\tt\\hbox} statements of the {\tt\\boxit} definition right.
155
156 \citem[2004-12-28]{[v.1.4]} {\tt <fredrik.jonsson@nmrc.ie>}\hfill\break
157 Added the {\tt --headline} and {\tt --linethick} options. Fixed a bug in
158 the page output, which previously caused \TeX\ to complain about vertical
159 underfill of the generated pages.
160
161 \citem[2005-01-01]{[v.1.5]} {\tt <fredrik.jonsson@nmrc.ie>}\hfill\break
162 Added the {\tt --cropmark} and {\tt --edgeseparation} options. Also fixed a bug
163 in the vertical label dimensions. Added the \PB{\\{log}(\,)} way of displaying
164 log and
165 error messages.
166
167 \citem[2005-08-10]{[v.1.6]} {\tt <fj@phys.soton.ac.uk>}\hfill\break
168 Back in Southampton with my family after a hot summer. Wrote the code for
169 the \PB{\\{strip\_away\_path}(\,)} routine originally for the \poincare\
170 program and
171 immediately decided to adopt the code also into the \dvlabel\ and \magbragg\
172 programs in order to finally solve the problem with long path strings that
173 appear in the program name string whenever poincare is called with an explicit
174 path specified at the command line. The call to the \PB{\\{strip\_away\_path}(%
175 \,)} routine
176 is located in the beginning of the block for command line parsing.
177
178 \fi
179
180 \N{1}{3}Compiling the source code. The program is written in \CWEB, generating
181 ANSI-C conforming source code and documentation as \TeX-source, and is to
182 be compiled using the enclosed Makefile, leaving an executable
183 file {\tt dvlabel}\footnote{$\dagger$}{On platforms running Windows NT,
184 Windows 2000, or any other operating system by Microsoft, the executable
185 file will instead automatically be called {\tt dvlabel.exe}.} and a
186 PostScript file {\tt dvlabel.ps} (the document you currently are reading),
187 which contains the full documentation of the program:
188 \bigskip
189 {\obeyspaces\obeylines\tt
190 ~ \#
191 ~ \# Makefile designed for use with ctangle, cweave, gcc, and plain TeX.
192 ~ \#
193 ~ \# Copyright (C) 2003, Fredrik Jonsson <jonsson@uni-wuppertal.de>
194 ~ \#
195 ~ CTANGLE = ctangle
196 ~ CC = gcc
197 ~ CCOPTS = -O2 -Wall -ansi -pedantic \# follow ISO C89 (ANSI) strictly
198 ~ LNOPTS = -lm
199 ~ CWEAVE = cweave
200 ~ TEX = tex
201 ~ DVIPS = dvips
202 ~ DVIPSOPT = -ta4 -D1200
203 ~ ~
204 ~ all: dvlabel.exe dvlabel.ps
205 ~ ~
206 ~ dvlabel.exe: dvlabel.o \# generate the executable file
207 ~ \$(CC) \$(CCOPTS) -o dvlabel dvlabel.o \$(LNOPTS)
208 ~ ~
209 ~ dvlabel.o: dvlabel.c \# generate the object file
210 ~ \$(CC) \$(CCOPTS) -c dvlabel.c
211 ~ ~
212 ~ dvlabel.c: dvlabel.w \# generate C code from the CWEB source
213 ~ \$(CTANGLE) dvlabel
214 ~ ~
215 ~ dvlabel.ps: dvlabel.dvi \# generate the PostScript documentation
216 ~ \$(DVIPS) \$(DVIPSOPT) dvlabel.dvi -o dvlabel.ps
217 ~ ~
218 ~ dvlabel.dvi: dvlabel.tex \# generate the device-independent documentation
219 ~ \$(TEX) dvlabel.tex
220 ~ ~
221 ~ dvlabel.tex: dvlabel.w \# generate plain TeX code from the CWEB source
222 ~ \$(CWEAVE) dvlabel
223 ~ ~
224 ~ clean:
225 ~ ~ -rm -Rf *.c *.o *.exe
226 ~ ~ -rm -Rf *.tex *.aux *.log *.toc *.idx *.scn *.dvi}
227 \bigskip
228
229 \fi
230
231 \N{1}{4}Running the program. The program is entirely controlled by the command
232 line options supplied when invoking the program.
233 To start the program in interactive mode, simply run {\tt dvlabel} from
234 the command line, without any command line options.
235 \medskip
236 \noindent{\bf Example I:} In the following excerpt
237 from an interactive terminal session, where a leading asterisk ({\tt *})
238 in a line indicates the user-supplied input to the program, a DV label is
239 generated as Encapsulated PostScript, stored in a file named {\tt fig.eps}.
240 \bigskip
241 {\obeyspaces\obeylines\tt
242 ~ ~[dvlabel> dvlabel -c -e -o fig
243 ~ ~This is dvlabel, Version 1.4
244 ~ ~Specify table of contents of the DV tape
245 ~ ~[Enter text and finish with single dot on blank line]:
246 ~ ~* Table of contents
247 ~ ~* This is line number one
248 ~ ~* This is line number two
249 ~ ~* This is line number three
250 ~ ~* .
251 ~ ~Specify time stamp of DV tape. This is typically
252 ~ ~the last date that appears as time stamp in the
253 ~ ~recorded tape. [Press enter to use the current date]
254 ~ ~* Monday 29/12/2003
255 ~ ~Specify title of the DV tape [Press enter to leave blank title]:
256 ~ ~* Beavis and Butthead
257 ~ ~Specify author of the DV tape [Press enter to leave blank]:
258 ~ ~* Fredrik Jonsson
259 ~ ~Specify address of author of the DV tape
260 ~ ~[Enter text and finish with single dot on blank line]:
261 ~ ~* Storgatan 77
262 ~ ~* SE-47111 Sunne, Sweden
263 ~ ~* .
264 ~ ~Specify email of author of the DV tape [Press enter to leave blank]:
265 ~ ~* hmv@hotmail.com
266 }
267 \bigskip
268 The generated DV label {\tt fig.eps} looks like this:
269 \bigskip
270 \centerline{\epsfxsize=62.56mm\epsfbox{fig.eps}}
271 \vfill\eject
272 \noindent
273 In this example, the {\tt -c} command line option specifies that the program
274 should compile the generated \TeX\ code, {\tt -e} that it also should attempt
275 to generate the output as Encapsulated PostScript, and {\tt -o fig}
276 that the generated files all should have the base name ``{\tt fig}'',
277 that is to say, the program will use {\tt fig.tex} for the
278 generated \TeX-code, {\tt fig.dvi}
279 for the generated device-independent (DVI) output, and {\tt fig.eps} for
280 the generated Encapsulated PostScript (EPS) image of the DV label.
281 The command for invoking the \dvlabel\ program can equivalently be written in
282 a more extensive form as {\tt dvlabel --compile --eps --outputfile fig}.
283
284 The \TeX-code that the program generates (from which the Encapsulated
285 PostScript subsequently is generated) is stored in the file {\tt fig.tex},
286 which contains
287 \bigskip
288 {\obeylines\obeyspaces\tt
289 ~ ~\% File: fig.tex
290 ~ ~\% TeX code automatically generated by dvlabel, v.1.4,
291 ~ ~\% Mon Dec 29 15:46:36 2003
292 ~ ~\% Copyright (C) Fredrik Jonsson, 2003
293 ~ ~\%
294 ~ ~{\char'134}font{\char'134}eightcmssqeight=cmssq8
295 ~ ~{\char'134}font{\char'134}tencmssqten=cmssq8 at 10 truept
296 ~ ~{\char'134}font{\char'134}defaultfacefont=cmtt8
297 ~ ~{\char'134}font{\char'134}defaultflapfont=cmtt8
298 ~ ~{\char'134}def{\char'134}monthname{{\char'134}ifcase{\char'134}month\%
299 ~ ~ {\char'134}or Jan{\char'134}or Feb{\char'134}or Mar{\char'134}or
300 Apr{\char'134}or May{\char'134}or Jun\%
301 ~ ~ {\char'134}or Jul{\char'134}or Aug{\char'134}or Sep{\char'134}or
302 Oct{\char'134}or Nov{\char'134}or Dec\%
303 ~ ~ {\char'134}fi}
304 ~ ~{\char'134}def{\char'134}fullmonthname{{\char'134}ifcase{\char'134}month\%
305 ~ ~ {\char'134}or January{\char'134}or February{\char'134}or
306 March{\char'134}or April\%
307 ~ ~ {\char'134}or May{\char'134}or June{\char'134}or July{\char'134}or
308 August{\char'134}or September
309 ~ ~ {\char'134}or October{\char'134}or November{\char'134}or
310 December{\char'134}fi}
311 ~ ~{\char'134}def{\char'134}today{{\char'134}fullmonthname{\char'134}space%
312 {\char'134}number{\char'134}day,\%
313 ~ ~ {\char'134}space{\char'134}number{\char'134}year}
314 ~ ~{\char'134}def{\char'134}timestamp{Monday 29/12/2003}
315 ~ ~{\char'134}def{\char'134}title{Beavis and Butthead}
316 ~ ~{\char'134}def{\char'134}author{Fredrik Jonsson}
317 ~ ~{\char'134}def{\char'134}email{hmv@hotmail.com}
318 ~ ~{\char'134}nopagenumbers
319 ~ ~{\char'134}newdimen{\char'134}facewidth
320 ~ ~{\char'134}newdimen{\char'134}faceheight
321 ~ ~{\char'134}newdimen{\char'134}spineheight
322 ~ ~{\char'134}newdimen{\char'134}flapheight
323 ~ ~{\char'134}newdimen{\char'134}edgeseparation
324 ~ ~{\char'134}facewidth=60mm
325 ~ ~{\char'134}faceheight=40mm
326 ~ ~{\char'134}spineheight=12mm
327 ~ ~{\char'134}flapheight=20mm
328 ~ ~{\char'134}edgeseparation=1pt
329 ~ ~{\char'134}def{\char'134}boxit\#1{{\char'134}vbox{{\char'134}hrule%
330 {\char'134}hbox{\%
331 ~ ~ {\char'134}vrule{\char'134}kern1pt{\char'134}vbox{{\char'134}kern1pt\#1%
332 {\char'134}kern1pt}\%
333 ~ ~{\char'134}kern1pt{\char'134}vrule}{\char'134}hrule}}
334 ~ ~{\char'134}parindent 0pt
335 }
336 \vfill\eject
337 {\obeylines\obeyspaces\tt
338 ~ ~
339 ~ ~\% Define the outline of the face of the label
340 ~ ~{\char'134}setbox1={\char'134}hbox to {\char'134}facewidth{{\%
341 ~ ~ {\char'134}vbox to {\char'134}faceheight{\%
342 ~ ~ {\char'134}hbox{{\char'134}defaultfacefont{\char'134}timestamp%
343 {\char'134}hfil}\%
344 ~ ~ {\char'134}vskip -3pt{\char'134}hbox{{\char'134}defaultfacefont
345 Table of contents{\char'134}hfil}\%
346 ~ ~ {\char'134}vskip -3pt{\char'134}hbox{{\char'134}defaultfacefont
347 This is line number one{\char'134}hfil}\%
348 ~ ~ {\char'134}vskip -3pt{\char'134}hbox{{\char'134}defaultfacefont
349 This is line number two{\char'134}hfil}\%
350 ~ ~ {\char'134}vskip -3pt{\char'134}hbox{{\char'134}defaultfacefont
351 This is line number three{\char'134}hfil}\%
352 ~ ~ {\char'134}vfil}}{\char'134}hfil}
353 ~ ~
354 ~ ~\% Define the outline of the spine of the label
355 ~ ~{\char'134}setbox2={\char'134}hbox to {\char'134}facewidth{{\%
356 ~ ~ {\char'134}vbox to {\char'134}spineheight{\%
357 ~ ~ {\char'134}hbox{{\char'134}bf{\char'134}timestamp{\char'134}hfil}\%
358 ~ ~ {\char'134}hbox{{\char'134}bf{\char'134}title{\char'134}hfil}\%
359 ~ ~ {\char'134}vfil}}{\char'134}hfil}
360 ~ ~
361 ~ ~\% Define the outline of the flap of the label
362 ~ ~{\char'134}setbox3={\char'134}hbox to {\char'134}facewidth{{\%
363 ~ ~ {\char'134}vbox to {\char'134}flapheight{\%
364 ~ ~ {\char'134}hbox{{\char'134}defaultflapfont Digital Video by
365 {\char'134}author{\char'134}hfil}\%
366 ~ ~ {\char'134}vskip -3pt{\char'134}hbox{{\char'134}defaultflapfont
367 Storgatan 77{\char'134}hfil}\%
368 ~ ~ {\char'134}vskip -3pt{\char'134}hbox{{\char'134}defaultflapfont
369 SE-47111 Sunne, Sweden{\char'134}hfil}\%
370 ~ ~ {\char'134}vskip -3pt{\char'134}hbox{{\char'134}defaultflapfont \%
371 ~ ~ <{\char'134}email>{\char'134}hfil}\%
372 ~ ~ {\char'134}vfil}}{\char'134}hfil}
373 ~ ~
374 ~ ~{\char'134}def{\char'134}dvlabel{{\char'134}boxit{{\char'134}boxit%
375 {{\char'134}box1}\%
376 ~ ~ {\char'134}vskip{\char'134}edgeseparation{\char'134}boxit%
377 {{\char'134}box2}\%
378 ~ ~ {\char'134}vskip{\char'134}edgeseparation{\char'134}%
379 boxit{{\char'134}box3}}}
380 ~ ~
381 ~ ~{\char'134}dvlabel
382 ~ ~
383 ~ ~{\char'134}bye
384 }
385 \vfill\eject
386 \noindent{\bf Example II:}
387 Another way of using the program is in batch mode, where the input instead
388 is read from a text file.
389 In the following example, the file named {\tt fig.asc} contains the
390 following text (compare with the interactive session on the previous pages):
391 \bigskip
392 {\obeyspaces\obeylines\tt
393 ~ ~Table of contents
394 ~ ~This is line number one
395 ~ ~This is line number two
396 ~ ~This is line number three
397 ~ ~.
398 ~ ~Monday 29/12/2003
399 ~ ~Beavis and Butthead
400 ~ ~Fredrik Jonsson
401 ~ ~Storgatan 77
402 ~ ~SE-47111 Sunne, Sweden
403 ~ ~.
404 ~ ~hmv@hotmail.com
405 }
406 \bigskip
407 \noindent
408 When the \dvlabel\ program is launched with the above file specified as
409 the input to read, via the command\footnote{$\dagger$}{In similar to
410 the previous example, this command for invoking the \dvlabel\ program
411 can similarly written in a more extensive form as {\tt dvlabel --compile
412 --eps --inputfile fig.asc --outputfile fig}.}
413 \bigskip
414 {\obeyspaces\obeylines\tt
415 ~ ~[dvlabel> dvlabel -c -e -i fig.asc -o fig
416 }
417 \bigskip
418 \noindent
419 the same output as in the previous example will be generated.
420
421 \fi
422
423 \N{1}{5}The main program. Here follows the general outline of the main program.
424
425 \Y\B\8\#\&{include} \.{<time.h>}\6
426 \8\#\&{include} \.{<sys/time.h>}\6
427 \8\#\&{include} \.{<stdio.h>}\6
428 \8\#\&{include} \.{<stdarg.h>}\6
429 \8\#\&{include} \.{<stdlib.h>}\6
430 \8\#\&{include} \.{<string.h>}\6
431 \8\#\&{include} \.{<ctype.h>}\6
432 \8\#\&{define} \.{VERSION} \5\.{"1.6"}\C{ Program revision }\6
433 \8\#\&{define} \.{DEFAULT\_DVIPSOPTS} \5\.{"-ta4\ -D1200"}\C{ Default DVIPS
434 options }\6
435 \8\#\&{define} \.{DEFAULT\_LINETHICKNESS} \5(\T{0.5})\C{ Default line thickness
436 in pt }\6
437 \8\#\&{define} \.{DEFAULT\_CROPLINETHICKNESS} \5(\T{0.15})\C{ Crop line
438 thickness in pt }\6
439 \8\#\&{define} \.{DEFAULT\_EDGESEPARATION} \5(\T{1.0})\6
440 \8\#\&{define} \.{MAXCHAR} \5(\T{128})\C{ Maximum allowed number of characters
441 on each line }\6
442 \8\#\&{define} \.{SUCCESS} \5(\T{0})\C{ Return code for successful program
443 termination }\6
444 \8\#\&{define} \.{FAILURE} \5(\T{1})\C{ Return code for unsuccessful program
445 termination }\6
446 \8\#\&{define} \.{INSTREAM} \5${}(\\{infile\_specified}\?\\{infile}:%
447 \\{stdin}){}$\6
448 \8\#\&{define} \.{OUTSTREAM} \5${}(\\{outfile\_specified}\?\\{outfile}:%
449 \\{stdout}){}$\6
450 \8\#\&{define} ${}\\{log}(\,\ldots\,)\\{log\_printf} \5(\\{\_\_func\_\_},\39\.{%
451 \_\_VA\_ARGS\_\_}){}$\6
452 \X6:Global variables\X\6
453 \X7:Subroutines\X\7
454 \&{int} \\{main}(\&{int} \\{argc}${},\39{}$\&{char} ${}{*}\\{argv}[\,]){}$\1\1%
455 \2\2\6
456 ${}\{{}$\1\6
457 \X14:Local variables\X\6
458 \X15:Parse command line\X\6
459 \X16:Display banner\X\6
460 \X18:Open files for reading\X\6
461 \X19:Open files for writing\X\6
462 \X29:Save preamble source code\X\6
463 ${}\\{num\_labels}\K\T{0};{}$\6
464 \&{while} (\\{newlabel}(\.{INSTREAM}))\5
465 ${}\{{}$\1\6
466 ${}\\{num\_labels}\PP;{}$\6
467 \X22:Scan text lines of one label from input stream\X\6
468 \&{if} ${}(\\{num\_labels}\E\T{1}){}$\5
469 ${}\{{}$\1\6
470 \&{if} (\\{generate\_crop\_marks})\5
471 ${}\{{}$\1\6
472 \X32:Write vertical crop marks with width measure\X\6
473 \X33:Write horizontal crop marks with height measure\X\6
474 \4${}\}{}$\2\6
475 \4${}\}{}$\2\6
476 \X30:Save label source code\X\6
477 \&{if} ${}(\\{num\_labels}\E\T{2}){}$\5
478 ${}\{{}$\1\6
479 \&{if} (\\{generate\_crop\_marks})\5
480 ${}\{{}$\1\6
481 \X33:Write horizontal crop marks with height measure\X\6
482 \4${}\}{}$\2\6
483 \4${}\}{}$\2\6
484 \&{if} ${}(\\{num\_labels}\E\\{num\_labels\_per\_page}){}$\5
485 ${}\{{}$\1\6
486 \&{if} (\\{generate\_crop\_marks})\5
487 ${}\{{}$\1\6
488 \X33:Write horizontal crop marks with height measure\X\6
489 \X32:Write vertical crop marks with width measure\X\6
490 \4${}\}{}$\2\6
491 \X31:Close output page\X\6
492 ${}\\{num\_labels}\K\T{0};{}$\6
493 \4${}\}{}$\2\6
494 \4${}\}{}$\2\6
495 \X34:Save closing source code\X\6
496 \X20:Close files\X\6
497 \X35:Compile source code\X\6
498 \&{return} (\.{SUCCESS});\6
499 \4${}\}{}$\2\par
500 \fi
501
502 \M{6}Declaration of global variables. The only global variables allowed in
503 my programs are \PB{\\{optarg}}, which is the string of characters that
504 specified
505 the call from the command line, and \PB{\\{progname}}, which simply is the
506 string
507 containing the name of the program, as it was invoked from the command line.
508
509 \Y\B\4\X6:Global variables\X${}\E{}$\6
510 \&{extern} \&{char} ${}{*}\\{optarg};{}$\6
511 \&{char} ${}{*}\\{progname}{}$;\par
512 \U5.\fi
513
514 \M{7}Declarations of subroutines used by the program.
515
516 \Y\B\4\X7:Subroutines\X${}\E{}$\6
517 \X8:Routine for logging and error messaging\X\6
518 \X9:Routine for displaying help message\X\6
519 \X11:Scan for beginning of new label\X\6
520 \X12:Routine for removing preceding path of filenames\X\par
521 \U5.\fi
522
523 \M{8}The \PB{\&{void} \\{log\_printf}(\&{const} \&{char} ${}{*}\\{function%
524 \_name},{}$\&{const} \&{char} ${}{*}\\{format},\,\ldots\,)$}
525 routine writes formatted entries to standard output, displaying time and
526 calling routine in a coherent manner. Notice that although the \PB{\\{log%
527 \_printf}(\,)}
528 routine is the one which performs the actual messaging, the \PB{\\{log}(\,)}
529 macro
530 (defined in the header file) is the preferred way of accessing this routine,
531 as it provides a more compact notation and automatically takes care of
532 supplying
533 the reference to the name of the calling function.
534
535 Also notice that the \PB{\&{const} \&{char}} type of the last two input pointer
536 arguments
537 here is absolutely essential in order to pass strict pedantic compilation with
538 GCC.
539
540 The routine accepts two input parameters. First, \PB{\\{function\_name}} which
541 should
542 be the name of the calling function. This is to ensure that any displayed
543 error messages are properly matched to the issuing routines. Notice, however,
544 that the \PB{\\{log}(\,)} macro (which is the preferred way of displaying error
545 messages)
546 automatically takes care of supplying the proper function name.
547 Second, \PB{\\{format}}, which simply is the format and message string to be
548 displayed, formatted in the \CEE-standard \PB{\\{printf}(\,)} or \PB{%
549 \\{fprintf}(\,)} syntax.
550
551 \Y\B\4\X8:Routine for logging and error messaging\X${}\E{}$\6
552 \&{void} \\{log\_printf}(\&{const} \&{char} ${}{*}\\{function\_name},\39{}$%
553 \&{const} \&{char} ${}{*}\\{format},\39\,\ldots\,){}$\1\1\2\2\6
554 ${}\{{}$\1\6
555 \&{va\_list} \\{args};\6
556 \&{time\_t} \\{time0};\6
557 \&{struct} \\{tm} \\{lt};\6
558 \&{struct} \\{timeval} \\{tv};\6
559 \&{char} \\{logentry}[\T{1024}];\7
560 ${}\\{gettimeofday}({\AND}\\{tv},\39\NULL);{}$\6
561 ${}\\{time}({\AND}\\{time0});{}$\6
562 ${}\\{lt}\K{*}\\{localtime}({\AND}\\{time0});{}$\6
563 ${}\\{sprintf}(\\{logentry},\39\.{"\%02u\%02u\%02u\ \%02u:\%}\)\.{02u:\%02u.%
564 \%03d\ "},\39\\{lt}.\\{tm\_year}-\T{100},\39\\{lt}.\\{tm\_mon}+\T{1},\39\\{lt}.%
565 \\{tm\_mday},\39\\{lt}.\\{tm\_hour},\39\\{lt}.\\{tm\_min},\39\\{lt}.\\{tm%
566 \_sec},\39\\{tv}.\\{tv\_usec}/\T{1000});{}$\6
567 ${}\\{sprintf}(\\{logentry}+\\{strlen}(\\{logentry}),\39\.{"(\%s)\ "},\39%
568 \\{function\_name});{}$\6
569 ${}\\{va\_start}(\\{args},\39\\{format}){}$;\C{ Initialize args by the \PB{%
570 \\{va\_start}(\,)} macro }\6
571 ${}\\{vsprintf}(\\{logentry}+\\{strlen}(\\{logentry}),\39\\{format},\39%
572 \\{args});{}$\6
573 \\{va\_end}(\\{args});\C{ Terminate the use of args by the \PB{\\{va\_end}(\,)}
574 macro }\6
575 ${}\\{sprintf}(\\{logentry}+\\{strlen}(\\{logentry}),\39\.{"\\n"}){}$;\C{
576 Always append newline }\6
577 ${}\\{fprintf}(\\{stdout},\39\.{"\%s"},\39\\{logentry});{}$\6
578 \&{return};\6
579 \4${}\}{}$\2\par
580 \U7.\fi
581
582 \M{9}Routines for displaying help message.
583
584 \Y\B\4\X9:Routine for displaying help message\X${}\E{}$\6
585 \X10:Routine for displaying a single line of the help message\X\7
586 \&{void} \\{showsomehelp}(\&{void})\1\1\2\2\6
587 ${}\{{}$\1\6
588 ${}\\{hl}(\.{"Usage:\ \%s\ [options]}\)\.{"},\39\\{progname});{}$\6
589 \\{hl}(\.{"When\ invoked\ withou}\)\.{t\ any\ command\ line\ o}\)\.{ptions,\
590 this\ program}\)\.{\ enters"});\6
591 \\{hl}(\.{"interactive\ mode."});\6
592 \\{hl}(\.{"Options:"});\6
593 \\{hl}(\.{"\ -i,\ --inputfile\ <s}\)\.{tr>"});\6
594 \\{hl}(\.{"\ \ \ \ Specifies\ the\ f}\)\.{ile\ where\ to\ read\ th}\)\.{e\
595 label\ text\ strings}\)\.{,\ entered\ in"});\6
596 \\{hl}(\.{"\ \ \ \ a\ format\ corres}\)\.{ponding\ to\ the\ input}\)\.{\ order\
597 as\ would\ have}\)\.{\ been"});\6
598 \\{hl}(\.{"\ \ \ \ entered\ in\ inte}\)\.{ractive\ mode."});\6
599 \\{hl}(\.{"\ -o,\ --outputfile\ <}\)\.{str>"});\6
600 \\{hl}(\.{"\ \ \ \ Specifies\ the\ f}\)\.{ile\ where\ to\ save\ th}\)\.{e\
601 generated\ TeX\ sour}\)\.{ce\ code\ for"});\6
602 \\{hl}(\.{"\ \ \ \ the\ label.\ when}\)\.{ever\ this\ option\ is\ }\)%
603 \.{omitted,\ the\ generat}\)\.{ed\ source"});\6
604 \\{hl}(\.{"\ \ \ \ code\ will\ be\ wr}\)\.{itten\ to\ standard\ te}\)\.{rminal\
605 output\ instea}\)\.{d.\ Notice"});\6
606 \\{hl}(\.{"\ \ \ \ that\ the\ name\ s}\)\.{pecified\ using\ this\ }\)\.{option\
607 is\ used\ as\ th}\)\.{e\ *base"});\6
608 \\{hl}(\.{"\ \ \ \ name*\ for\ the\ g}\)\.{enerated\ output;\ thi}\)\.{s\ means%
609 \ that\ the\ TeX}\)\.{\ file"});\6
610 \\{hl}(\.{"\ \ \ \ automatically\ w}\)\.{ill\ get\ .tex\ as\ suff}\)\.{ix,\ the%
611 \ DVIfile\ .dvi}\)\.{,\ etc."});\6
612 \\{hl}(\.{"\ \ \ \ For\ example,\ if}\)\.{\ you\ want\ to\ have\ yo}\)\.{ur\
613 TeX\ output\ stored}\)\.{\ into\ a\ file"});\6
614 \\{hl}(\.{"\ \ \ \ named,\ say,\ 'fo}\)\.{o.tex',\ just\ specify}\)\.{\ '-o\
615 foo'."});\6
616 \\{hl}(\.{"\ -H,\ --headline"});\6
617 \\{hl}(\.{"\ \ \ \ Toggle\ display\ }\)\.{of\ generation\ time\ a}\)\.{nd\
618 input\ source\ in\ p}\)\.{age\ header"});\6
619 \\{hl}(\.{"\ \ \ \ of\ the\ generate}\)\.{d\ TeX\ code.\ Default:}\)\.{\
620 off"});\6
621 \\{hl}(\.{"\ -C,\ --cropmarks"});\6
622 \\{hl}(\.{"\ \ \ \ Toggle\ display\ }\)\.{of\ crop\ marks\ (align}\)\.{ment\
623 marks)\ in\ the\ g}\)\.{enerated\ TeX"});\6
624 \\{hl}(\.{"\ \ \ \ code.\ Default:\ }\)\.{off"});\6
625 \\{hl}(\.{"\ -t,\ --linethick\ <f}\)\.{>"});\6
626 \\{hl}(\.{"\ \ \ \ Use\ linethickne}\)\.{ss\ of\ <f>\ typographi}\)\.{c\ points%
627 \ in\ generati}\)\.{ng\ the\ boxes"});\6
628 \\{hl}(\.{"\ \ \ \ of\ the\ label.\ (}\)\.{One\ point,\ or\ pt,\ eq}\)\.{uals\
629 to\ 1/72.27\ inch}\)\.{.)"});\6
630 \\{hl}(\.{"\ -s,\ --edgeseparati}\)\.{on\ <f>"});\6
631 \\{hl}(\.{"\ \ \ \ Insert\ extra\ sp}\)\.{ace\ of\ <f>\ typograph}\)\.{ic\
632 points\ between\ th}\)\.{e\ text\ boxes"});\6
633 \\{hl}(\.{"\ \ \ \ at\ the\ folded\ e}\)\.{dges\ of\ the\ label.\ T}\)\.{his\
634 is\ useful\ when,\ }\)\.{for\ example,"});\6
635 \\{hl}(\.{"\ \ \ \ thick\ paper\ is\ }\)\.{used.\ By\ changing\ th}\)\.{e\ line%
636 \ thickness,\ th}\)\.{e\ internal"});\6
637 \\{hl}(\.{"\ \ \ \ margins\ of\ the\ }\)\.{label\ are\ also\ chang}\)\.{ed,\
638 since\ the\ inner\ }\)\.{edge-to-edge"});\6
639 \\{hl}(\.{"\ \ \ \ distance\ betwee}\)\.{n\ the\ lines\ of\ the\ i}\)\.{nner\
640 and\ outer\ boxes}\)\.{\ are\ linked"});\6
641 \\{hl}(\.{"\ \ \ \ to\ be\ twice\ the}\)\.{\ value\ of\ the\ line\ t}\)%
642 \.{hickness.\ The\ correc}\)\.{tion\ of"});\6
643 \\{hl}(\.{"\ \ \ \ inner\ bounding\ }\)\.{boxes\ of\ the\ label\ t}\)\.{ext\ is%
644 \ automatically}\)\.{\ adjusted\ so"});\6
645 \\{hl}(\.{"\ \ \ \ as\ to\ ensure\ th}\)\.{at\ the\ overall\ outer}\)\.{\
646 dimensions\ of\ the\ l}\)\.{abel\ are"});\6
647 \\{hl}(\.{"\ \ \ \ unchanged."});\6
648 \\{hl}(\.{"\ -c,\ --compile"});\6
649 \\{hl}(\.{"\ \ \ \ Try\ to\ compile\ }\)\.{the\ generated\ TeX\ co}\)\.{de.\
650 This\ requires\ DV}\)\.{IPS\ to\ be"});\6
651 \\{hl}(\.{"\ \ \ \ installed\ on\ yo}\)\.{ur\ system,\ see\ www.r}\)%
652 \.{adicaleye.com\ for\ fu}\)\.{rther\ info."});\6
653 \\{hl}(\.{"\ -e,\ --eps"});\6
654 \\{hl}(\.{"\ \ \ \ When\ compiling\ }\)\.{the\ generated\ TeX\ co}\)\.{de,\
655 generate\ Encapsu}\)\.{lated"});\6
656 \\{hl}(\.{"\ \ \ \ PostScript\ (EPS}\)\.{)\ instead\ of\ the\ def}\)\.{ault\
657 regular\ PostScr}\)\.{ipt."});\6
658 \\{hl}(\.{"\ -d,\ --dvipsopts\ <s}\)\.{tr>"});\6
659 \\{hl}(\.{"\ \ \ \ When\ compiling\ }\)\.{the\ generated\ TeX\ co}\)\.{de,\ use%
660 \ <str>\ as\ opt}\)\.{ions\ to\ be"});\6
661 \\{hl}(\.{"\ \ \ \ supplied\ to\ DVI}\)\.{PS.\ In\ order\ to\ pars}\)\.{e\ for\
662 an\ arbitrary\ n}\)\.{umber\ of"});\6
663 \\{hl}(\.{"\ \ \ \ DVIPS\ options\ a}\)\.{t\ the\ command\ line,\ }\)\.{it\ is\
664 important\ to\ e}\)\.{nclose\ the"});\6
665 \\{hl}(\.{"\ \ \ \ list\ of\ DVIPS\ o}\)\.{ptions\ by\ quotes.\ He}\)\.{nce,\
666 for\ example,\ to}\)\.{\ force\ DVIPS"});\6
667 \\{hl}(\.{"\ \ \ \ to\ generate\ out}\)\.{put\ pages\ of\ US\ lett}\)\.{er\
668 format\ and\ at\ a\ r}\)\.{esolution\ of"});\6
669 \\{hl}(\.{"\ \ \ \ 720\ dpi\ one\ cou}\)\.{ld\ invoke\ DVLABEL\ wi}\)\.{th"});\6
670 \\{hl}(\.{"\ \ \ \ \ \ \ \ \ \ dvlabel\ -}\)\.{-dvipsopts\ \\"-tlette}\)\.{r\
671 -D720\\""});\6
672 \\{hl}(\.{"\ \ \ \ The\ quotes\ are\ }\)\.{only\ necessary\ if\ th}\)\.{e\
673 number\ of\ DVIPS\ op}\)\.{tions\ are"});\6
674 \\{hl}(\.{"\ \ \ \ two\ or\ more.\ De}\)\.{fault:\ -D1200\ -ta4\ (}\)\.{1200\
675 DPI\ on\ A4\ paper}\)\.{)."});\6
676 \\{hl}(\.{"\ -v,\ --verbose"});\6
677 \\{hl}(\.{"\ \ \ \ Toggle\ verbose\ }\)\.{mode.\ Default:\ off"});\6
678 \\{hl}(\.{"\ -h,\ --help"});\6
679 \\{hl}(\.{"\ \ \ \ Display\ this\ he}\)\.{lp\ message\ and\ exit\ }\)%
680 \.{clean."});\6
681 \\{hl}(\.{"\\nCopyright\ (C)\ 200}\)\.{3-2011\ Fredrik\ Jonss}\)\.{on\
682 <http://jonsson.e}\)\.{u>"});\6
683 \4${}\}{}$\2\par
684 \U7.\fi
685
686 \M{10}In order to simplify the messaging, the \PB{\\{hl}(\&{const} \&{char}
687 ${}{*}\\{format},\,\ldots\,)$} routine
688 acts as a simple front-end merely for compactifying the code by successive
689 calls to \PB{$\\{hl}(\,\ldots\,)$} rather than the full \PB{$\\{fprintf}(%
690 \\{stderr},\,\ldots\,)$}, still
691 maintaining all the functionality of string formatting in the regular
692 \PB{\\{printf}(\,)} or \PB{\\{fprintf}(\,)} syntax.
693
694 \Y\B\4\X10:Routine for displaying a single line of the help message\X${}\E{}$\6
695 \&{void} \\{hl}(\&{const} \&{char} ${}{*}\\{format},\39\,\ldots\,){}$\1\1 $\{$ %
696 \&{va\_list} \\{args}; \&{char} \6
697 \&{line} [\T{1024}]\1\5
698 ;\2\6
699 ${}\\{va\_start}(\\{args},\39\\{format}){}$;\C{ Initialize args by the \PB{%
700 \\{va\_start}(\,)} macro }\6
701 \\{vsprintf} ( \&{line} $,$ $\\{format},\39\\{args}$ ) ;\6
702 \\{va\_end}(\\{args});\C{ Terminate the use of args by the \PB{\\{va\_end}(\,)}
703 macro }\6
704 \\{sprintf} ( \&{line} ${}{+}\\{strlen}$ ( \&{line} ) $,$ \.{"\\n"} ) ;\C{
705 Always append newline }\6
706 \\{fprintf} $(\\{stdout},\39\.{"\%s"},\39$ \&{line} ) ;\6
707 \&{return}; $\}{}$\par
708 \U9.\fi
709
710 \M{11}Scan the input stream for a statement on what to do next, that is to say,
711 either to start generating a new label (if the character `n' is present, in
712 which case the \PB{\\{newlabel}} routine returns 1) or quit the program (if the
713 character `q' is present, in which case the \PB{\\{newlabel}} routine returns
714 0).
715 The \PB{\\{newlabel}} routine also takes care of scanning away any trailing
716 blanks
717 or other characters from the input stream until a carriage return character
718 is found, also removing this before return.
719
720 \Y\B\4\X11:Scan for beginning of new label\X${}\E{}$\6
721 \&{short} \\{newlabel}(\&{FILE} ${}{*}\\{instream}){}$\1\1\2\2\6
722 ${}\{{}$\1\6
723 \&{char} \\{ch};\7
724 ${}\\{fprintf}(\\{stdout},\39\.{"Create\ new\ label\ re}\)\.{cord\ or\ quit?%
725 \\n"});{}$\6
726 ${}\\{fprintf}(\\{stdout},\39\.{"['n'=new\ label\ /\ 'q}\)\.{'=quit]:\\n"});{}$%
727 \6
728 ${}\\{fprintf}(\\{stdout},\39\.{"**"});{}$\6
729 \&{while} ${}((\\{ch}\K\\{fgetc}(\\{instream}))\E\.{'\ '}){}$\1\5
730 ;\C{ get rid of leading blanks }\2\6
731 \&{if} ${}(\\{ch}\E\.{'n'}){}$\5
732 ${}\{{}$\1\6
733 \&{while} ${}((\\{ch}\K\\{fgetc}(\\{instream}))\I\.{'\\n'}){}$\1\5
734 ;\C{ get rid of trailing characters }\2\6
735 \&{return} (\T{1});\6
736 \4${}\}{}$\2\6
737 \&{else} \&{if} ${}(\\{ch}\E\.{'q'}){}$\5
738 ${}\{{}$\1\6
739 \&{while} ${}((\\{ch}\K\\{fgetc}(\\{instream}))\I\.{'\\n'}){}$\1\5
740 ;\C{ get rid of trailing characters }\2\6
741 \&{return} (\T{0});\6
742 \4${}\}{}$\2\6
743 \&{else}\5
744 ${}\{{}$\1\6
745 ${}\\{log}(\.{"\%s:\ Error:\ Unrecogn}\)\.{ized\ input\ stream\ co}\)\.{ntrol\
746 character\ '\%c'}\)\.{.\\n"},\39\\{progname},\39\\{ch});{}$\6
747 \\{exit}(\.{FAILURE});\6
748 \4${}\}{}$\2\6
749 \4${}\}{}$\2\par
750 \U7.\fi
751
752 \M{12}Routines for removing preceding path of filenames.
753 In this block all routines related to removing preceding path strings go.
754 Not really fancy programming, and no contribution to any increase of numerical
755 efficiency or precision; just for the sake of keeping a tidy terminal output
756 of the program. The \PB{\\{strip\_away\_path}(\,)} routine is typically called
757 when
758 initializing the program name string \PB{\\{progname}} from the command line
759 string
760 \PB{\\{argv}[\T{0}]}, and is typically located in the blocks related to parsing
761 of the
762 command line options.
763 The \PB{\\{strip\_away\_path}(\,)} routine takes a character string \PB{%
764 \\{filename}} as
765 argument, and returns a pointer to the same string but without any
766 preceding path segments.
767
768 \Y\B\4\X12:Routine for removing preceding path of filenames\X${}\E{}$\6
769 \X13:Routine for checking for a valid path character\X\7
770 \&{char} ${}{*}{}$\\{strip\_away\_path}(\&{char} \\{filename}[\,])\1\1\2\2\6
771 ${}\{{}$\1\6
772 \&{int} \|j${},{}$ \|k${}\K\T{0};{}$\7
773 \&{while} (\\{pathcharacter}(\\{filename}[\|k]))\1\5
774 ${}\|k\PP;{}$\2\6
775 ${}\|j\K(\MM\|k){}$;\C{ this is the uppermost index of the full path+file
776 string }\6
777 \&{while} (\\{isalnum}((\&{int})(\\{filename}[\|j])))\1\5
778 ${}\|j\MM;{}$\2\6
779 ${}\|j\PP{}$;\C{ this is the lowermost index of the stripped file name }\6
780 \&{return} ${}({\AND}\\{filename}[\|j]);{}$\6
781 \4${}\}{}$\2\par
782 \U7.\fi
783
784 \M{13}In this program, valid path characters are any alphanumeric character or
785 `\.{.}', `\.{/}', `\.{\\}', `\.{\_}', `\.{-}', or `\.{+}'.
786
787 \Y\B\4\X13:Routine for checking for a valid path character\X${}\E{}$\6
788 \&{short} \\{pathcharacter}(\&{int} \\{ch})\1\1\2\2\6
789 ${}\{{}$\1\6
790 \&{return} ${}(\\{isalnum}(\\{ch})\V(\\{ch}\E\.{'.'})\V(\\{ch}\E\.{'/'})\V(%
791 \\{ch}\E\.{'\\\\'})\V(\\{ch}\E\.{'\_'})\V(\\{ch}\E\.{'-'})\V(\\{ch}\E%
792 \.{'+'}));{}$\6
793 \4${}\}{}$\2\par
794 \U12.\fi
795
796 \N{1}{14}Declaration of local variables of the main program.
797 Here \PB{\\{num\_labels}} is a counter that is used for determining whenever a
798 page
799 brake in the generated \TeX\ code is to appear, in order to give a nice output
800 with a $[3\times1]$ array of labels.
801
802 \Y\B\4\X14:Local variables\X${}\E{}$\6
803 \&{time\_t} \\{now}${}\K\\{time}(\NULL);{}$\6
804 \&{long} \|j${},{}$ \|k${},{}$ \|n${},{}$ \\{num\_address\_lines}${},{}$ \\{num%
805 \_toc\_lines}${},{}$ \\{num\_labels}${},{}$ \\{num\_labels\_per\_page}${}\K%
806 \T{4};{}$\6
807 \&{int} \\{no\_arg}${},{}$ \\{tmpch};\6
808 \&{FILE} ${}{*}\\{infile}\K\NULL,{}$ ${}{*}\\{outfile}\K\NULL;{}$\6
809 \&{char} \\{inputfilename}[\.{MAXCHAR}]${}\K\.{""},{}$ \\{outputfilename}[%
810 \.{MAXCHAR}]${}\K\.{""},{}$ \\{tmpstr}[\.{MAXCHAR}];\6
811 \&{char} \\{dvipsopts}[\.{MAXCHAR}]${}\K\.{DEFAULT\_DVIPSOPTS};{}$\6
812 \&{char} \\{timestamp}[\.{MAXCHAR}]${}\K\.{"\\today"},{}$ \\{title}[%
813 \.{MAXCHAR}]${}\K\.{""};{}$\6
814 \&{char} \\{author}[\.{MAXCHAR}]${}\K\.{""},{}$ \\{email}[\.{MAXCHAR}]${}\K%
815 \.{""};{}$\6
816 \&{char} ${}\\{address}[\T{10}*\.{MAXCHAR}]\K\.{""},{}$ ${}\\{toc}[\T{50}*%
817 \.{MAXCHAR}]\K\.{""};{}$\6
818 \&{short} \\{done}${},{}$ \\{verbose}${}\K\T{0},{}$ \\{compile}${}\K\T{0},{}$ %
819 \\{eps\_output}${}\K\T{0};{}$\6
820 \&{short} \\{headline}${}\K\T{1},{}$ \\{generate\_crop\_marks}${}\K\T{1};{}$\6
821 \&{short} \\{infile\_specified}${}\K\T{0},{}$ \\{outfile\_specified}${}\K%
822 \T{0},{}$ \\{dvipsopts\_specified}${}\K\T{0};{}$\6
823 \&{float} \\{linethickness}${}\K\.{DEFAULT\_LINETHICKNESS};{}$\6
824 \&{float} \\{clthick}${}\K\.{DEFAULT\_CROPLINETHICKNESS};{}$\6
825 \&{float} \\{edgeseparation}${}\K\.{DEFAULT\_EDGESEPARATION};{}$\6
826 \&{float} \\{facewidth}${},{}$ \\{faceheight}${},{}$ \\{spineheight}${},{}$ %
827 \\{flapheight};\6
828 \&{float} \\{ifacewidth}${},{}$ \\{ifaceheight}${},{}$ \\{ispineheight}${},{}$ %
829 \\{iflapheight};\par
830 \U5.\fi
831
832 \N{1}{15}Parsing command line options. All input parameters are passed to the
833 program through command line options and arguments to the program.
834 The syntax of command line options is listed whenever the program is invoked
835 with the {\tt --help} option at startup, or whenever an error occurs in the
836 input.
837
838 \Y\B\4\X15:Parse command line\X${}\E{}$\6
839 ${}\{{}$\1\6
840 ${}\\{progname}\K\\{strip\_away\_path}(\\{argv}[\T{0}]);{}$\6
841 ${}\\{no\_arg}\K\\{argc};{}$\6
842 \&{while} ${}(\MM\\{argc}){}$\5
843 ${}\{{}$\1\6
844 \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-o"})\V\R%
845 \\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--outputfile"})){}$\5
846 ${}\{{}$\1\6
847 ${}\MM\\{argc};{}$\6
848 ${}\\{strcpy}(\\{outputfilename},\39\\{argv}[\\{no\_arg}-\\{argc}]);{}$\6
849 ${}\\{outfile\_specified}\K\T{1};{}$\6
850 \4${}\}{}$\2\6
851 \&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-i"})\V%
852 \R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--inputfile"})){}$\5
853 ${}\{{}$\1\6
854 ${}\MM\\{argc};{}$\6
855 ${}\\{strcpy}(\\{inputfilename},\39\\{argv}[\\{no\_arg}-\\{argc}]);{}$\6
856 ${}\\{infile\_specified}\K\T{1};{}$\6
857 \4${}\}{}$\2\6
858 \&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-v"})\V%
859 \R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--verbose"})){}$\5
860 ${}\{{}$\1\6
861 ${}\\{verbose}\K(\\{verbose}\?\T{0}:\T{1});{}$\6
862 \4${}\}{}$\2\6
863 \&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-h"})\V%
864 \R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--help"})){}$\5
865 ${}\{{}$\1\6
866 \\{showsomehelp}(\,);\6
867 \\{exit}(\.{SUCCESS});\6
868 \4${}\}{}$\2\6
869 \&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-H"})\V%
870 \R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--headline"})){}$\5
871 ${}\{{}$\1\6
872 ${}\\{headline}\K(\\{headline}\?\T{0}:\T{1});{}$\6
873 \4${}\}{}$\2\6
874 \&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-C"})\V%
875 \R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--cropmarks"})){}$\5
876 ${}\{{}$\1\6
877 ${}\\{generate\_crop\_marks}\K(\\{generate\_crop\_marks}\?\T{0}:\T{1});{}$\6
878 \4${}\}{}$\2\6
879 \&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-t"})\V%
880 \R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--linethick"})){}$\5
881 ${}\{{}$\1\6
882 ${}\MM\\{argc};{}$\6
883 \&{if} ${}(\R\\{sscanf}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"\%f"},\39{\AND}%
884 \\{linethickness})){}$\5
885 ${}\{{}$\1\6
886 \\{log}(\.{"Error\ in\ linethickn}\)\.{ess\ argument."});\6
887 \\{exit}(\T{1});\6
888 \4${}\}{}$\2\6
889 \4${}\}{}$\2\6
890 \&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-s"})\V%
891 \R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--edgeseparation"})){}$\5
892 ${}\{{}$\1\6
893 ${}\MM\\{argc};{}$\6
894 \&{if} ${}(\R\\{sscanf}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"\%f"},\39{\AND}%
895 \\{edgeseparation})){}$\5
896 ${}\{{}$\1\6
897 \\{log}(\.{"Error\ in\ edgesepara}\)\.{tion\ argument."});\6
898 \\{exit}(\T{1});\6
899 \4${}\}{}$\2\6
900 \4${}\}{}$\2\6
901 \&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-c"})\V%
902 \R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--compile"})){}$\5
903 ${}\{{}$\1\6
904 ${}\\{compile}\K(\\{compile}\?\T{0}:\T{1});{}$\6
905 \4${}\}{}$\2\6
906 \&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-e"})\V%
907 \R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--eps"})){}$\5
908 ${}\{{}$\1\6
909 ${}\\{eps\_output}\K(\\{eps\_output}\?\T{0}:\T{1});{}$\6
910 \4${}\}{}$\2\6
911 \&{else} \&{if} ${}(\R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"-d"})\V%
912 \R\\{strcmp}(\\{argv}[\\{no\_arg}-\\{argc}],\39\.{"--dvipsopts"})){}$\5
913 ${}\{{}$\1\6
914 ${}\MM\\{argc};{}$\6
915 ${}\\{strcpy}(\\{dvipsopts},\39\\{argv}[\\{no\_arg}-\\{argc}]);{}$\6
916 ${}\\{dvipsopts\_specified}\K\T{1};{}$\6
917 \4${}\}{}$\2\6
918 \&{else}\5
919 ${}\{{}$\1\6
920 ${}\\{log}(\.{"Error:\ Unknown\ opti}\)\.{on\ '\%s'."},\39\\{argv}[\\{no\_arg}-%
921 \\{argc}]);{}$\6
922 \\{showsomehelp}(\,);\6
923 \\{exit}(\.{FAILURE});\6
924 \4${}\}{}$\2\6
925 \4${}\}{}$\2\6
926 \&{if} ${}(\\{verbose}\W\R\\{outfile\_specified}){}$\5
927 ${}\{{}$\1\6
928 ${}\\{fprintf}(\\{stdout},\39\.{"You\ have\ specified\ }\)\.{verbose\ mode\
929 without}\)\.{\ any\ specification\ o}\)\.{f\\n"}\.{"a\ file\ where\ to\ sav}\)%
930 \.{e\ the\ generated\ TeX\ }\)\.{source\ code.\ This\ me}\)\.{ans\\n"}\.{"that\
931 any\ program\ co}\)\.{mments\ that\ appear,\ }\)\.{due\ to\ the\ verbose\ m}\)%
932 \.{ode,\\n"}\.{"will\ be\ mixed\ with\ }\)\.{the\ source\ code.\ It\ }\)\.{is\
933 highly\ recommende}\)\.{d\ that\\n"}\.{"you\ either\ turn\ off}\)\.{\ verbose\
934 mode\ or\ spe}\)\.{cify\ a\ file\ where\ to}\)\.{\ save\\n"}\.{"the\ generated\
935 outpu}\)\.{t\ (using\ the\ -o\ or\ -}\)\.{-outputfile\ option).}\)\.{\\n"});{}$%
936 \6
937 ${}\\{fprintf}(\\{stdout},\39\.{"In\ order\ to\ make\ a\ }\)\.{clean\ output,\
938 the\ Te}\)\.{X\ code\ is\ separately}\)\.{\\n"}\.{"enclosed\ in\ the\ blo}\)%
939 \.{cks\ below.\\n"});{}$\6
940 \4${}\}{}$\2\6
941 \&{if} ${}(\\{verbose}\W\\{dvipsopts\_specified}){}$\5
942 ${}\{{}$\1\6
943 ${}\\{fprintf}(\\{stdout},\39\.{"Specified\ options\ f}\)\.{or\ later\ use\
944 with\ DV}\)\.{IPS:\ "});{}$\6
945 ${}\\{fprintf}(\\{stdout},\39\.{"\%s\\n"},\39\\{dvipsopts});{}$\6
946 \4${}\}{}$\2\6
947 \4${}\}{}$\2\par
948 \U5.\fi
949
950 \M{16}Display a banner at start-up of the program.
951
952 \Y\B\4\X16:Display banner\X${}\E{}$\6
953 ${}\{{}$\1\6
954 ${}\\{fprintf}(\\{stdout},\39\.{"This\ is\ \%s,\ Version}\)\.{\ \%s\\n"},\39%
955 \\{progname},\39\.{VERSION});{}$\6
956 \4${}\}{}$\2\par
957 \U5.\fi
958
959 \N{1}{17}Opening and closing files for data output.
960
961 \fi
962
963 \M{18}Open files for reading. In order to read the text to typeset from an
964 external
965 file rather than the default standard input stream {\tt stdin}, the name of the
966 input file is specified with the {\tt -i} or {\tt --inputfile} command line
967 options.
968 If the filename as specified on the command line does not exist, then the
969 program will instead try to open a file with the suffix {\tt .dvl} concatenated
970 to the name. This way, the program will accept short-hand filenames as well, in
971 a way analogous to the input syntax rules of, for example, the \TeX\ program.
972 If no input file can be opened, an error message is displayed and the program
973 will exit with return value \PB{\.{FAILURE}}.
974
975 \Y\B\4\X18:Open files for reading\X${}\E{}$\6
976 ${}\{{}$\1\6
977 \&{if} (\\{infile\_specified})\5
978 ${}\{{}$\1\6
979 \&{if} ${}((\\{infile}\K\\{fopen}(\\{inputfilename},\39\.{"r"}))\E\NULL){}$\5
980 ${}\{{}$\1\6
981 \&{if} ${}((\\{infile}\K\\{fopen}(\\{strcat}(\\{inputfilename},\39\.{".dvl"}),%
982 \39\.{"r"}))\E\NULL){}$\5
983 ${}\{{}$\1\6
984 ${}\\{log}(\.{"Could\ not\ open\ file}\)\.{\ \%s\ for\ reading!"},\39%
985 \\{inputfilename});{}$\6
986 \\{exit}(\.{FAILURE});\6
987 \4${}\}{}$\2\6
988 \4${}\}{}$\2\6
989 ${}\\{fseek}(\\{infile},\39\T{0\$L},\39\.{SEEK\_SET});{}$\6
990 \&{if} (\\{verbose})\5
991 ${}\{{}$\1\6
992 ${}\\{log}(\.{"Opened\ input\ file\ \%}\)\.{s\ for\ reading."},\39%
993 \\{inputfilename});{}$\6
994 \4${}\}{}$\2\6
995 \4${}\}{}$\2\6
996 \&{else}\5
997 ${}\{{}$\1\6
998 \&{if} (\\{verbose})\1\5
999 \\{log}(\.{"No\ input\ filename\ s}\)\.{pecified\ (Entering\ i}\)\.{nteractive\
1000 mode)."});\2\6
1001 \4${}\}{}$\2\6
1002 \4${}\}{}$\2\par
1003 \U5.\fi
1004
1005 \M{19}Open files for writing.
1006
1007 \Y\B\4\X19:Open files for writing\X${}\E{}$\6
1008 ${}\{{}$\1\6
1009 \&{if} (\\{outfile\_specified})\5
1010 ${}\{{}$\1\6
1011 ${}\\{sprintf}(\\{tmpstr},\39\.{"\%s.tex"},\39\\{outputfilename});{}$\6
1012 \&{if} ${}((\\{outfile}\K\\{fopen}(\\{tmpstr},\39\.{"w"}))\E\NULL){}$\5
1013 ${}\{{}$\1\6
1014 ${}\\{log}(\.{"Could\ not\ open\ file}\)\.{\ \%s\ for\ writing!"},\39%
1015 \\{tmpstr});{}$\6
1016 \\{exit}(\.{FAILURE});\6
1017 \4${}\}{}$\2\6
1018 ${}\\{fseek}(\\{outfile},\39\T{0\$L},\39\.{SEEK\_SET});{}$\6
1019 \&{if} (\\{verbose})\5
1020 ${}\{{}$\1\6
1021 ${}\\{log}(\.{"Opened\ output\ file\ }\)\.{\%s\ for\ writing."},\39%
1022 \\{outputfilename});{}$\6
1023 \4${}\}{}$\2\6
1024 \4${}\}{}$\2\6
1025 \&{else}\5
1026 ${}\{{}$\1\6
1027 \&{if} (\\{verbose})\5
1028 ${}\{{}$\1\6
1029 \\{log}(\.{"No\ output\ filename\ }\)\.{specified."});\6
1030 \\{log}(\.{"Will\ write\ generate}\)\.{d\ TeX\ output\ to\ stan}\)\.{dard\
1031 terminal\ output}\)\.{."});\6
1032 \4${}\}{}$\2\6
1033 \4${}\}{}$\2\6
1034 \4${}\}{}$\2\par
1035 \U5.\fi
1036
1037 \M{20}Close all open files.
1038
1039 \Y\B\4\X20:Close files\X${}\E{}$\6
1040 ${}\{{}$\1\6
1041 \&{if} (\\{infile\_specified})\1\5
1042 \\{fclose}(\\{infile});\2\6
1043 \&{if} (\\{outfile\_specified})\1\5
1044 \\{fclose}(\\{outfile});\2\6
1045 \4${}\}{}$\2\par
1046 \U5.\fi
1047
1048 \N{1}{21}Reading input as supplied by the user.
1049
1050 \fi
1051
1052 \M{22}Parsing the input as supplied by the user. When reading the input, the
1053 \dvlabel\ program makes use of either the \PB{\\{stdin}} stream (in the case of
1054 interactive mode), or the file pointed out by the \PB{\\{infile}} pointer (in
1055 the
1056 case of processing of an input text file).
1057 In the latter case, the syntax of the supplied file is identical to the
1058 syntax as if operating the program in interactive mode, with every newline
1059 character ({\tt /n}) interpreted as an end-of-line of a corresponding
1060 interactive input.
1061
1062 Example: [TO BE INSERTED]
1063
1064 As the individual lines of text generally contain different number of
1065 characters, the feedline character {\tt /n} of standard \CEE\ is throughout
1066 the program used to keep track of the end of line. (This is more convenient
1067 than keeping track of the indvidual line widths in, for example, and array
1068 of integers.)
1069
1070 \Y\B\4\X22:Scan text lines of one label from input stream\X${}\E{}$\6
1071 ${}\{{}$\1\6
1072 \X23:Read table of contents\X\6
1073 \X24:Read time stamp\X\6
1074 \X25:Read title\X\6
1075 \X26:Read author name\X\6
1076 \X27:Read address\X\6
1077 \X28:Read email address\X\6
1078 \4${}\}{}$\2\par
1079 \U5.\fi
1080
1081 \M{23}Parse for the table of contents of the tape.
1082 The syntax for specifying the table of contents is similar to that of the
1083 address, with arbitrary number of lines of text. The input is ended by
1084 a single dot on a new line, in similar to the way of entering, for example,
1085 email messages in terminal mode using the basic engine of {\tt sendmail} on
1086 regular UNIX and Linux systems.
1087
1088 \Y\B\4\X23:Read table of contents\X${}\E{}$\6
1089 ${}\{{}$\1\6
1090 ${}\\{fprintf}(\\{stdout},\39\.{"Specify\ table\ of\ co}\)\.{ntents\ of\ the\
1091 DV\ tap}\)\.{e\\n"});{}$\6
1092 ${}\\{fprintf}(\\{stdout},\39\.{"[Enter\ text\ and\ fin}\)\.{ish\ with\ single\
1093 dot\ }\)\.{on\ blank\ line]:\\n"});{}$\6
1094 ${}\\{done}\K\T{0};{}$\6
1095 ${}\|n\K\T{0};{}$\6
1096 ${}\\{num\_toc\_lines}\K\T{0};{}$\6
1097 \&{while} ${}(\R\\{done}){}$\5
1098 ${}\{{}$\1\6
1099 ${}\\{fprintf}(\\{stdout},\39\.{"**"});{}$\6
1100 \&{while} ${}((\\{tmpch}\K\\{fgetc}(\.{INSTREAM}))\E\.{'\ '}){}$\1\5
1101 ;\C{ Get rid of leading blanks }\2\6
1102 ${}\\{ungetc}(\\{tmpch},\39\.{INSTREAM});{}$\6
1103 ${}\|k\K\T{0};{}$\6
1104 \&{while} ${}((\\{tmpstr}[\|k\PP]\K\\{fgetc}(\.{INSTREAM}))\I\.{'\\n'}){}$\1\5
1105 ;\C{ Read line }\2\6
1106 \&{if} ${}(\|k>\T{1}){}$\5
1107 ${}\{{}$\C{ If more text than just spaces and a linefeed character }\1\6
1108 \&{if} ${}((\\{tmpstr}[\T{0}]\E\.{'.'})\W(\\{tmpstr}[\T{1}]\E\.{'\\n'})){}$\5
1109 ${}\{{}$\1\6
1110 ${}\\{done}\K\T{1};{}$\6
1111 \4${}\}{}$\2\6
1112 \&{else}\5
1113 ${}\{{}$\1\6
1114 \&{for} ${}(\|j\K\T{0};{}$ ${}\|j<\|k;{}$ ${}\|j\PP){}$\1\5
1115 ${}\\{toc}[\|n+\|j]\K\\{tmpstr}[\|j];{}$\2\6
1116 \&{if} ${}(\T{1}\E\T{0}){}$\1\5
1117 ${}\\{toc}[\|n+\|j]\K\.{'\\n'};{}$\2\6
1118 ${}\|n\K\|n+\|j{}$;\C{ Keep track of last index of the \PB{\\{toc}} array }\6
1119 ${}\\{num\_toc\_lines}\PP;{}$\6
1120 \4${}\}{}$\2\6
1121 \4${}\}{}$\2\6
1122 \&{else}\5
1123 ${}\{{}$\C{ If just spaces and a linefeed character }\1\6
1124 ${}\\{toc}[\|n]\K\.{'\\n'}{}$;\C{ Blank line of table-of-contents field }\6
1125 \4${}\}{}$\2\6
1126 \4${}\}{}$\2\6
1127 \&{if} (\\{verbose})\5
1128 ${}\{{}$\1\6
1129 ${}\\{fprintf}(\\{stdout},\39\.{"\%s:\ Counted\ \%ld\ num}\)\.{ber\ of\
1130 table-of-cont}\)\.{ents\ lines.\\n"},\39\\{progname},\39\\{num\_toc%
1131 \_lines});{}$\6
1132 ${}\\{fprintf}(\\{stdout},\39\.{"Table\ of\ contents:\\}\)\.{n"});{}$\6
1133 ${}\|n\K\T{0};{}$\6
1134 \&{for} ${}(\|k\K\T{1};{}$ ${}\|k\Z\\{num\_toc\_lines};{}$ ${}\|k\PP){}$\5
1135 ${}\{{}$\1\6
1136 \&{for} ${}(\|j\K\|n;{}$ ${}\\{toc}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
1137 ${}\\{fprintf}(\\{stdout},\39\.{"\%c"},\39\\{toc}[\|j]);{}$\2\6
1138 ${}\\{fprintf}(\\{stdout},\39\.{"\\n"});{}$\6
1139 ${}\|n\K\|j+\T{1};{}$\6
1140 \4${}\}{}$\2\6
1141 \4${}\}{}$\2\6
1142 \4${}\}{}$\2\par
1143 \U22.\fi
1144
1145 \M{24}Parse for the time stamp to be used.
1146
1147 \Y\B\4\X24:Read time stamp\X${}\E{}$\6
1148 ${}\{{}$\1\6
1149 ${}\\{fprintf}(\\{stdout},\39\.{"Specify\ time\ stamp\ }\)\.{of\ DV\ tape.\
1150 This\ is\ }\)\.{typically\\n"});{}$\6
1151 ${}\\{fprintf}(\\{stdout},\39\.{"the\ last\ date\ that\ }\)\.{appears\ as\ time%
1152 \ stam}\)\.{p\ in\ the\\n"});{}$\6
1153 ${}\\{fprintf}(\\{stdout},\39\.{"recorded\ tape.\ [Pre}\)\.{ss\ enter\ to\ use\
1154 the\ }\)\.{current\ date]\\n"});{}$\6
1155 ${}\\{fprintf}(\\{stdout},\39\.{"**"});{}$\6
1156 \&{while} ${}((\\{tmpch}\K\\{fgetc}(\.{INSTREAM}))\E\.{'\ '}){}$\1\5
1157 ;\C{ Get rid of leading blank spaces }\2\6
1158 ${}\\{ungetc}(\\{tmpch},\39\.{INSTREAM});{}$\6
1159 ${}\|k\K\T{0};{}$\6
1160 \&{while} ${}((\\{tmpstr}[\|k\PP]\K\\{fgetc}(\.{INSTREAM}))\I\.{'\\n'}){}$\1\5
1161 ;\C{ Read line }\2\6
1162 \&{if} ${}(\|k>\T{1}{}$)\C{ If more text than just spaces and a linefeed
1163 character }\1\6
1164 \&{for} ${}(\|j\K\T{0};{}$ ${}\|j<\|k;{}$ ${}\|j\PP){}$\1\5
1165 ${}\\{timestamp}[\|j]\K\\{tmpstr}[\|j];{}$\2\2\6
1166 \&{else}\C{ If just spaces and a linefeed character }\1\6
1167 \&{for} ${}(\|j\K\T{0};{}$ ${}\|j<\T{7};{}$ ${}\|j\PP){}$\1\5
1168 ${}\\{timestamp}[\|j]\K\.{"\\\\today\\n"}[\|j];{}$\2\2\6
1169 \&{if} (\\{verbose})\5
1170 ${}\{{}$\1\6
1171 ${}\\{fprintf}(\\{stdout},\39\.{"Time\ stamp:\ "});{}$\6
1172 \&{for} ${}(\|j\K\T{0};{}$ ${}\\{timestamp}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1%
1173 \5
1174 ${}\\{fprintf}(\\{stdout},\39\.{"\%c"},\39\\{timestamp}[\|j]);{}$\2\6
1175 ${}\\{fprintf}(\\{stdout},\39\.{"\\n"});{}$\6
1176 \4${}\}{}$\2\6
1177 \4${}\}{}$\2\par
1178 \U22.\fi
1179
1180 \M{25}Parse for the title to be used.
1181
1182 \Y\B\4\X25:Read title\X${}\E{}$\6
1183 ${}\{{}$\1\6
1184 ${}\\{fprintf}(\\{stdout},\39\.{"Specify\ title\ of\ th}\)\.{e\ DV\ tape\
1185 [Press\ ent}\)\.{er\ to\ leave\ blank\ ti}\)\.{tle]:\\n"});{}$\6
1186 ${}\\{fprintf}(\\{stdout},\39\.{"**"});{}$\6
1187 \&{while} ${}((\\{tmpch}\K\\{fgetc}(\.{INSTREAM}))\E\.{'\ '}){}$\1\5
1188 ;\C{ Get rid of leading blank spaces }\2\6
1189 ${}\\{ungetc}(\\{tmpch},\39\.{INSTREAM});{}$\6
1190 ${}\|k\K\T{0};{}$\6
1191 \&{while} ${}((\\{tmpstr}[\|k\PP]\K\\{fgetc}(\.{INSTREAM}))\I\.{'\\n'}){}$\1\5
1192 ;\C{ Read line }\2\6
1193 \&{if} ${}(\|k>\T{1}{}$)\C{ If more text than just spaces and a linefeed
1194 character }\1\6
1195 \&{for} ${}(\|j\K\T{0};{}$ ${}\|j<\|k;{}$ ${}\|j\PP){}$\1\5
1196 ${}\\{title}[\|j]\K\\{tmpstr}[\|j];{}$\2\2\6
1197 \&{else}\C{ If just spaces and a linefeed character }\1\6
1198 ${}\\{title}[\T{0}]\K\.{'\\n'}{}$;\C{ Blank title }\2\6
1199 \&{if} (\\{verbose})\5
1200 ${}\{{}$\1\6
1201 ${}\\{fprintf}(\\{stdout},\39\.{"Title:\ "});{}$\6
1202 \&{for} ${}(\|j\K\T{0};{}$ ${}\\{title}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
1203 ${}\\{fprintf}(\\{stdout},\39\.{"\%c"},\39\\{title}[\|j]);{}$\2\6
1204 ${}\\{fprintf}(\\{stdout},\39\.{"\\n"});{}$\6
1205 \4${}\}{}$\2\6
1206 \4${}\}{}$\2\par
1207 \U22.\fi
1208
1209 \M{26}Parse for the author name to be used.
1210
1211 \Y\B\4\X26:Read author name\X${}\E{}$\6
1212 ${}\{{}$\1\6
1213 ${}\\{fprintf}(\\{stdout},\39\.{"Specify\ author\ of\ t}\)\.{he\ DV\ tape\
1214 [Press\ en}\)\.{ter\ to\ leave\ blank]:}\)\.{\\n"});{}$\6
1215 ${}\\{fprintf}(\\{stdout},\39\.{"**"});{}$\6
1216 \&{while} ${}((\\{tmpch}\K\\{fgetc}(\.{INSTREAM}))\E\.{'\ '}){}$\1\5
1217 ;\C{ Get rid of leading blank spaces }\2\6
1218 ${}\\{ungetc}(\\{tmpch},\39\.{INSTREAM});{}$\6
1219 ${}\|k\K\T{0};{}$\6
1220 \&{while} ${}((\\{tmpstr}[\|k\PP]\K\\{fgetc}(\.{INSTREAM}))\I\.{'\\n'}){}$\1\5
1221 ;\C{ Read line }\2\6
1222 \&{if} ${}(\|k>\T{1}{}$)\C{ If more text than just spaces and a linefeed
1223 character }\1\6
1224 \&{for} ${}(\|j\K\T{0};{}$ ${}\|j<\|k;{}$ ${}\|j\PP){}$\1\5
1225 ${}\\{author}[\|j]\K\\{tmpstr}[\|j];{}$\2\2\6
1226 \&{else}\C{ If just spaces and a linefeed character }\1\6
1227 ${}\\{author}[\T{0}]\K\.{'\\n'}{}$;\C{ Blank author field }\2\6
1228 \&{if} (\\{verbose})\5
1229 ${}\{{}$\1\6
1230 ${}\\{fprintf}(\\{stdout},\39\.{"Author:\ "});{}$\6
1231 \&{for} ${}(\|j\K\T{0};{}$ ${}\\{author}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
1232 ${}\\{fprintf}(\\{stdout},\39\.{"\%c"},\39\\{author}[\|j]);{}$\2\6
1233 ${}\\{fprintf}(\\{stdout},\39\.{"\\n"});{}$\6
1234 \4${}\}{}$\2\6
1235 \4${}\}{}$\2\par
1236 \U22.\fi
1237
1238 \M{27}Parse for the address to be used.
1239 The syntax for specifying the address is similar to that of the table of
1240 contents, with arbitrary number of lines of text. The input is ended by
1241 a single dot on a new line, in similar to the way of entering, for example,
1242 email messages in terminal mode using the basic engine of {\tt sendmail} on
1243 regular UNIX and Linux systems.
1244
1245 \Y\B\4\X27:Read address\X${}\E{}$\6
1246 ${}\{{}$\1\6
1247 ${}\\{fprintf}(\\{stdout},\39\.{"Specify\ address\ of\ }\)\.{author\ of\ the\
1248 DV\ tap}\)\.{e\\n"});{}$\6
1249 ${}\\{fprintf}(\\{stdout},\39\.{"[Enter\ text\ and\ fin}\)\.{ish\ with\ single\
1250 dot\ }\)\.{on\ blank\ line]:\\n"});{}$\6
1251 ${}\\{fprintf}(\\{stdout},\39\.{"**"});{}$\6
1252 ${}\\{done}\K\T{0};{}$\6
1253 ${}\|n\K\T{0};{}$\6
1254 ${}\\{num\_address\_lines}\K\T{0};{}$\6
1255 \&{while} ${}(\R\\{done}){}$\5
1256 ${}\{{}$\1\6
1257 \&{while} ${}((\\{tmpch}\K\\{fgetc}(\.{INSTREAM}))\E\.{'\ '}){}$\1\5
1258 ;\C{ Get rid of leading spaces }\2\6
1259 ${}\\{ungetc}(\\{tmpch},\39\.{INSTREAM});{}$\6
1260 ${}\|k\K\T{0};{}$\6
1261 \&{while} ${}((\\{tmpstr}[\|k\PP]\K\\{fgetc}(\.{INSTREAM}))\I\.{'\\n'}){}$\1\5
1262 ;\C{ Read line }\2\6
1263 \&{if} ${}(\|k>\T{1}){}$\5
1264 ${}\{{}$\C{ If more text than just spaces and a linefeed character }\1\6
1265 \&{if} ${}((\\{tmpstr}[\T{0}]\E\.{'.'})\W(\\{tmpstr}[\T{1}]\E\.{'\\n'})){}$\5
1266 ${}\{{}$\1\6
1267 ${}\\{done}\K\T{1};{}$\6
1268 \4${}\}{}$\2\6
1269 \&{else}\5
1270 ${}\{{}$\1\6
1271 \&{for} ${}(\|j\K\T{0};{}$ ${}\|j<\|k;{}$ ${}\|j\PP){}$\1\5
1272 ${}\\{address}[\|n+\|j]\K\\{tmpstr}[\|j];{}$\2\6
1273 \&{if} ${}(\T{1}\E\T{0}){}$\1\5
1274 ${}\\{address}[\|n+\|j]\K\.{'\\n'};{}$\2\6
1275 ${}\|n\K\|n+\|j{}$;\C{ Keep track of last index of the \PB{\\{address}} array }%
1276 \6
1277 ${}\\{num\_address\_lines}\PP;{}$\6
1278 \4${}\}{}$\2\6
1279 \4${}\}{}$\2\6
1280 \&{else}\5
1281 ${}\{{}$\C{ If just spaces and a linefeed character }\1\6
1282 ${}\\{address}[\|n]\K\.{'\\n'}{}$;\C{ Blank line of address field }\6
1283 \4${}\}{}$\2\6
1284 ${}\\{fprintf}(\\{stdout},\39\.{"**"});{}$\6
1285 \4${}\}{}$\2\6
1286 \&{if} (\\{verbose})\5
1287 ${}\{{}$\1\6
1288 ${}\\{fprintf}(\\{stdout},\39\.{"\%s:\ Counted\ \%ld\ add}\)\.{ress\ lines.%
1289 \\n"},\39\\{progname},\39\\{num\_address\_lines});{}$\6
1290 ${}\\{fprintf}(\\{stdout},\39\.{"Address:\\n"});{}$\6
1291 ${}\|n\K\T{0};{}$\6
1292 \&{for} ${}(\|k\K\T{1};{}$ ${}\|k\Z\\{num\_address\_lines};{}$ ${}\|k\PP){}$\5
1293 ${}\{{}$\1\6
1294 \&{for} ${}(\|j\K\|n;{}$ ${}\\{address}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
1295 ${}\\{fprintf}(\\{stdout},\39\.{"\%c"},\39\\{address}[\|j]);{}$\2\6
1296 ${}\\{fprintf}(\\{stdout},\39\.{"\\n"});{}$\6
1297 ${}\|n\K\|j+\T{1};{}$\6
1298 \4${}\}{}$\2\6
1299 \4${}\}{}$\2\6
1300 \4${}\}{}$\2\par
1301 \U22.\fi
1302
1303 \M{28}Parse for the email address to be used.
1304
1305 \Y\B\4\X28:Read email address\X${}\E{}$\6
1306 ${}\{{}$\1\6
1307 ${}\\{fprintf}(\\{stdout},\39\.{"Specify\ email\ of\ au}\)\.{thor\ of\ the\ DV\
1308 tape\ }\)\.{[Press\ enter\ to\ leav}\)\.{e\ blank]:\\n"});{}$\6
1309 ${}\\{fprintf}(\\{stdout},\39\.{"**"});{}$\6
1310 \&{while} ${}((\\{tmpch}\K\\{fgetc}(\.{INSTREAM}))\E\.{'\ '}){}$\1\5
1311 ;\C{ Get rid of leading blank spaces }\2\6
1312 ${}\\{ungetc}(\\{tmpch},\39\.{INSTREAM});{}$\6
1313 ${}\|k\K\T{0};{}$\6
1314 \&{while} ${}((\\{tmpstr}[\|k\PP]\K\\{fgetc}(\.{INSTREAM}))\I\.{'\\n'}){}$\1\5
1315 ;\C{ Read line }\2\6
1316 \&{if} ${}(\|k>\T{1}{}$)\C{ If more text than just spaces and a linefeed
1317 character }\1\6
1318 \&{for} ${}(\|j\K\T{0};{}$ ${}\|j<\|k;{}$ ${}\|j\PP){}$\1\5
1319 ${}\\{email}[\|j]\K\\{tmpstr}[\|j];{}$\2\2\6
1320 \&{else}\C{ If just spaces and a linefeed character }\1\6
1321 ${}\\{email}[\T{0}]\K\.{'\\n'}{}$;\C{ Blank email field }\2\6
1322 \&{if} (\\{verbose})\5
1323 ${}\{{}$\1\6
1324 ${}\\{fprintf}(\\{stdout},\39\.{"Email:\ "});{}$\6
1325 \&{for} ${}(\|j\K\T{0};{}$ ${}\\{email}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
1326 ${}\\{fprintf}(\\{stdout},\39\.{"\%c"},\39\\{email}[\|j]);{}$\2\6
1327 ${}\\{fprintf}(\\{stdout},\39\.{"\\n"});{}$\6
1328 \4${}\}{}$\2\6
1329 \4${}\}{}$\2\par
1330 \U22.\fi
1331
1332 \M{29}Generating the preamble of output \TeX\ source code for the labels.
1333 The physical outer of the Mini Digital Label dimensions are based on the inset
1334 of TDK cassettes, with \PB{\\{flapheight}} of 14.5~mm (41.3~pt), spineheight of
1335 12.5~mm (35.6~pt), \PB{\\{faceheight}} of 47~mm (133.7~pt), and \PB{%
1336 \\{facewidth}} of
1337 67~mm (190.6~pt), hence summing up to overall outer dimensions of
1338 $190.6\times210.6$~pt of the label.
1339
1340 \Y\B\4\X29:Save preamble source code\X${}\E{}$\6
1341 ${}\{{}$\1\6
1342 ${}\\{facewidth}\K\T{190.6}+\T{3.0}*\T{72.27}/\T{25.4};{}$\6
1343 ${}\\{faceheight}\K\T{133.7};{}$\6
1344 ${}\\{spineheight}\K\T{35.6};{}$\6
1345 ${}\\{flapheight}\K\T{41.3};{}$\6
1346 ${}\\{ifacewidth}\K\\{facewidth}-\T{14.0}*\\{linethickness};{}$\6
1347 ${}\\{ifaceheight}\K\\{faceheight}-\T{11.0}*\\{linethickness}-\T{0.5}*%
1348 \\{edgeseparation};{}$\6
1349 ${}\\{ispineheight}\K\\{spineheight}-\T{8.0}*\\{linethickness}-%
1350 \\{edgeseparation};{}$\6
1351 ${}\\{iflapheight}\K\\{flapheight}-\T{11.0}*\\{linethickness}-\T{0.5}*%
1352 \\{edgeseparation};{}$\6
1353 \&{if} ${}(\R\\{outfile\_specified}){}$\1\5
1354 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%\%--------\ TEX\ CODE}\)\.{\ BEGINS\ HERE%
1355 \ -------}\)\.{----------\\n"});{}$\2\6
1356 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%\%\ File:\ \%s.tex\\n"},\39%
1357 \\{outputfilename});{}$\6
1358 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%\%\ TeX\ code\ generat}\)\.{ed\ by\ \%s,\
1359 v.\%s,\ \%s"},\39\\{progname},\39\.{VERSION},\39\\{ctime}({\AND}\\{now}));{}$\6
1360 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%\%\ Copyright\ (C)\ Fr}\)\.{edrik\
1361 Jonsson,\ 2003-}\)\.{2005\\n\%\%\\n"});{}$\6
1362 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hoffset=-35pt\\\\vo}\)\.{ffset=-25pt%
1363 \\n"});{}$\6
1364 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hsize=175mm\\\\vsiz}\)\.{e=254mm%
1365 \\n"});{}$\6
1366 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\font\\\\eightcmssqe}\)\.{ight=cmssq8%
1367 \\n"});{}$\6
1368 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\font\\\\sevencmtt=c}\)\.{mtt7\\n"});{}$%
1369 \6
1370 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\font\\\\tencmssqten}\)\.{=cmssq8\ at\
1371 10\ truept}\)\.{\\n"});{}$\6
1372 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\font\\\\deffacefont}\)\.{=cmr7%
1373 \\n"});{}$\6
1374 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\font\\\\deftimestam}\)\.{pfont=cmtt8\
1375 at\ 7\ tru}\)\.{ept\\n"});{}$\6
1376 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\font\\\\defspinefon}\)\.{t=cmr9%
1377 \\n"});{}$\6
1378 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\font\\\\defflapfont}\)\.{=cmr7%
1379 \\n"});{}$\6
1380 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\monthname\{\\\\}\)\.{ifcase%
1381 \\\\month\%\%\\n"});{}$\6
1382 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \\\\or\ Jan\\\\or\ Feb\\\\}\)\.{or\ Mar%
1383 \\\\or\ Apr\\\\or\ M}\)\.{ay\\\\or\ Jun\%\%\\n"});{}$\6
1384 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \\\\or\ Jul\\\\or\ Aug\\\\}\)\.{or\ Sep%
1385 \\\\or\ Oct\\\\or\ N}\)\.{ov\\\\or\ Dec\%\%\\n"});{}$\6
1386 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \\\\fi\}\\n"});{}$\6
1387 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\fullmonthnam}\)\.{e\{\\\\ifcase%
1388 \\\\month\%\%\\}\)\.{n"});{}$\6
1389 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \\\\or\ January\\\\or\ F}\)\.{ebruary%
1390 \\\\or\ March\\\\o}\)\.{r\ April\%\%\\n"});{}$\6
1391 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \\\\or\ May\\\\or\ June\\}\)\.{\\or\ July%
1392 \\\\or\ August\\}\)\.{\\or\ September\\n"});{}$\6
1393 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \\\\or\ October\\\\or\ N}\)\.{ovember%
1394 \\\\or\ December}\)\.{\\\\fi\}\\n"});{}$\6
1395 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\today\{\\\\full}\)\.{monthname%
1396 \\\\space\\\\nu}\)\.{mber\\\\day,\%\%\\n"});{}$\6
1397 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\space\\\\number\\\\}\)\.{year\}%
1398 \\n"});{}$\6
1399 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\dvby\{Digital}\)\.{\ Video\ by%
1400 \\\\\ \}\\n"});{}$\6
1401 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\parindent\ 0pt\\n"});{}$\6
1402 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\newdimen\\\\facewid}\)\.{th\\n"});{}$\6
1403 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\newdimen\\\\facehei}\)\.{ght\\n"});{}$\6
1404 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\newdimen\\\\spinehe}\)\.{ight\\n"});{}$%
1405 \6
1406 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\newdimen\\\\flaphei}\)\.{ght\\n"});{}$\6
1407 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\newdimen\\\\linethi}\)\.{ck\\n"});{}$\6
1408 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\newdimen\\\\spaceth}\)\.{ick\\n"});{}$\6
1409 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\newdimen\\\\edgesep}\)\.{aration%
1410 \\n"});{}$\6
1411 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\newdimen\\\\cropthi}\)\.{ck\\n"});{}$\6
1412 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\facewidth=\%1.3fpt}\)\.{\\n"},\39%
1413 \\{facewidth});{}$\6
1414 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\faceheight=\%1.3fp}\)\.{t\\n"},\39%
1415 \\{faceheight});{}$\6
1416 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\spineheight=\%1.3f}\)\.{pt\\n"},\39%
1417 \\{spineheight});{}$\6
1418 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\flapheight=\%1.3fp}\)\.{t\\n"},\39%
1419 \\{flapheight});{}$\6
1420 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\linethick=\%1.3fpt}\)\.{\\n"},\39%
1421 \\{linethickness});{}$\6
1422 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\spacethick=\%1.3fp}\)\.{t\\n"},\39%
1423 \T{2.0}*\\{linethickness});{}$\6
1424 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\edgeseparation=\%1}\)\.{.3fpt\\n"},\39%
1425 \\{edgeseparation});{}$\6
1426 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\cropthick=\%1.3fpt}\)\.{\\n"},\39%
1427 \\{clthick});{}$\6
1428 \&{if} (\\{headline})\5
1429 ${}\{{}$\1\6
1430 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\headline=\{\\\\hfill}\)\.{\{\\\\tt\
1431 dvlabel\ output}\)\.{"});{}$\6
1432 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \%s"},\39\\{ctime}({\AND}\\{now}));{}$\6
1433 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ [\%s]\}\}\\n"},\39(\\{infile\_specified}%
1434 \?\\{inputfilename}:\.{"stdin"}));{}$\6
1435 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\footline=\{\\\\hfill}\)\.{\\\\folio%
1436 \\\\hfill\}\\n"});{}$\6
1437 \4${}\}{}$\2\6
1438 \&{else}\5
1439 ${}\{{}$\1\6
1440 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\headline=\{\\\\hfil\}}\)\.{\\n"});{}$\6
1441 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\nopagenumbers\\n"});{}$\6
1442 \4${}\}{}$\2\6
1443 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\boxit\#1\{\\\\vb}\)\.{ox\{%
1444 \\\\hrule\ height\\\\l}\)\.{inethick\%\%\\n"});{}$\6
1445 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\hbox\{\\\\vrule\ wi}\)\.{dth%
1446 \\\\linethick\\\\kern}\)\.{\\\\spacethick\%\%\\n"});{}$\6
1447 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\vbox\{\\\\kern\\\\sp}\)\.{acethick%
1448 \#1\\\\kern\\\\sp}\)\.{acethick\}\%\%\\n"});{}$\6
1449 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\kern\\\\spacethic}\)\.{k\\\\vrule\
1450 width\\\\line}\)\.{thick\}\%\%\\n"});{}$\6
1451 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\hrule\ height\\\\l}\)\.{inethick\}%
1452 \}\%\%\\n"});{}$\6
1453 \4${}\}{}$\2\par
1454 \U5.\fi
1455
1456 \M{30}Generating the output \TeX\ source code for the labels.
1457
1458 \Y\B\4\X30:Save label source code\X${}\E{}$\6
1459 ${}\{{}$\1\6
1460 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\timestamp\{"});{}$\6
1461 \&{for} ${}(\|j\K\T{0};{}$ ${}\\{timestamp}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1%
1462 \5
1463 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%c"},\39\\{timestamp}[\|j]);{}$\2\6
1464 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\}\%\%\\n"});{}$\6
1465 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\title\{"});{}$\6
1466 \&{for} ${}(\|j\K\T{0};{}$ ${}\\{title}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
1467 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%c"},\39\\{title}[\|j]);{}$\2\6
1468 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\}\%\%\\n"});{}$\6
1469 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\author\{"});{}$\6
1470 \&{for} ${}(\|j\K\T{0};{}$ ${}\\{author}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
1471 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%c"},\39\\{author}[\|j]);{}$\2\6
1472 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\}\%\%\\n"});{}$\6
1473 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\email\{"});{}$\6
1474 \&{for} ${}(\|j\K\T{0};{}$ ${}\\{email}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
1475 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%c"},\39\\{email}[\|j]);{}$\2\6
1476 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\}\%\%\\n"});{}$\6
1477 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%\%\ Define\ the\ outli}\)\.{ne\ of\ the\
1478 face\ of\ th}\)\.{e\ label\\n"});{}$\6
1479 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\setbox1=\\\\hbox\ to}\)\.{\ \%1.3fpt\{%
1480 \{\%\%\\n"},\39\\{ifacewidth});{}$\6
1481 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\vbox\ to\ \\\\faceh}\)\.{eight\{\%%
1482 \%\\n"});{}$\6
1483 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \ \ \\\\hbox\{\\\\deffac}\)\.{efont%
1484 \\\\timestamp\\\\hf}\)\.{il\}\%\%\\n"});{}$\6
1485 ${}\|n\K\T{0};{}$\6
1486 \&{for} ${}(\|k\K\T{1};{}$ ${}\|k\Z\\{num\_toc\_lines};{}$ ${}\|k\PP){}$\5
1487 ${}\{{}$\1\6
1488 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \ \ \\\\vskip\ -3pt\\\\h}\)\.{box\{%
1489 \\\\deffacefont\ "});{}$\6
1490 \&{for} ${}(\|j\K\|n;{}$ ${}\\{toc}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
1491 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%c"},\39\\{toc}[\|j]);{}$\2\6
1492 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hfil\}\%\%\\n"});{}$\6
1493 ${}\|n\K\|j+\T{1};{}$\6
1494 \4${}\}{}$\2\6
1495 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\vfil\}\}\\\\hfil\}\%\%}\)\.{%
1496 \\n"});{}$\6
1497 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%\%\ Define\ the\ outli}\)\.{ne\ of\ the\
1498 spine\ of\ t}\)\.{he\ label\\n"});{}$\6
1499 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\setbox2=\\\\hbox\ to}\)\.{\ \%1.3fpt\{%
1500 \{\%\%\\n"},\39\\{ifacewidth});{}$\6
1501 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\vbox\ to\ \%1.3fpt}\)\.{\{\%\%%
1502 \\n"},\39\\{ispineheight});{}$\6
1503 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \ \ \\\\hbox\{\\\\deftim}\)%
1504 \.{estampfont\\\\timestam}\)\.{p\\\\hfil\}\%\%\\n"});{}$\6
1505 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \ \ \\\\hbox\{\\\\defspi}\)\.{nefont%
1506 \\\\title\\\\hfil\}}\)\.{\%\%\\n"});{}$\6
1507 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\vfil\}\}\\\\hfil\}\%\%}\)\.{%
1508 \\n"});{}$\6
1509 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%\%\ Define\ the\ outli}\)\.{ne\ of\ the\
1510 flap\ of\ th}\)\.{e\ label\\n"});{}$\6
1511 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\setbox3=\\\\hbox\ to}\)\.{\ \%1.3fpt\{%
1512 \{\%\%\\n"},\39\\{ifacewidth});{}$\6
1513 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\vbox\ to\ \%1.3fpt}\)\.{\{\%\%%
1514 \\n"},\39\\{iflapheight});{}$\6
1515 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \ \ \\\\hbox\{\\\\deffla}\)\.{pfont%
1516 \\\\dvby\\\\author\\}\)\.{\\hfil\}\%\%\\n"});{}$\6
1517 ${}\|n\K\T{0};{}$\6
1518 \&{for} ${}(\|k\K\T{1};{}$ ${}\|k\Z\\{num\_address\_lines};{}$ ${}\|k\PP){}$\5
1519 ${}\{{}$\1\6
1520 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \ \ \\\\vskip\ -3pt\\\\h}\)\.{box\{%
1521 \\\\defflapfont\ "});{}$\6
1522 \&{for} ${}(\|j\K\|n;{}$ ${}\\{address}[\|j]\I\.{'\\n'};{}$ ${}\|j\PP){}$\1\5
1523 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%c"},\39\\{address}[\|j]);{}$\2\6
1524 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hfil\}\\n"});{}$\6
1525 ${}\|n\K\|j+\T{1};{}$\6
1526 \4${}\}{}$\2\6
1527 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \ \ \\\\vskip\ -3pt\\\\h}\)\.{box\{%
1528 \\\\defflapfont\\\\e}\)\.{mail\\\\hfil\}\%\%\\n"});{}$\6
1529 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\vfil\}\}\\\\hfil\}\%\%}\)\.{%
1530 \\n"});{}$\6
1531 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\def\\\\dvlabel\{\\\\hs}\)\.{kip%
1532 \\\\linethick\\\\boxi}\)\.{t\{\%\%\\n"});{}$\6
1533 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\boxit\{\\\\box1\}\\\\}\)\.{vskip%
1534 \\\\edgeseparatio}\)\.{n\%\%\\n"});{}$\6
1535 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\boxit\{\\\\box2\}\\\\}\)\.{vskip%
1536 \\\\edgeseparatio}\)\.{n\%\%\\n"});{}$\6
1537 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\ \ \\\\boxit\{\\\\box3\}\}\\}\)\.{\\hskip%
1538 \\\\linethick\}\%\%}\)\.{\\n"});{}$\6
1539 \&{if} ${}((\\{num\_labels}\E\T{1})\V(\\{num\_labels}\E\T{3})){}$\1\5
1540 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hskip\ \%1.3fpt"},\39(\T{20.0}));{}$\2\6
1541 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\dvlabel\\n"});{}$\6
1542 \&{if} ${}((\\{num\_labels}\E\T{2})\V(\\{num\_labels}\E\T{4})\V(\\{num\_labels}%
1543 \E\T{6})){}$\5
1544 ${}\{{}$\1\6
1545 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\par\\\\nointerlines}\)\.{kip\\n"});{}$\6
1546 \4${}\}{}$\2\6
1547 \4${}\}{}$\2\par
1548 \U5.\fi
1549
1550 \M{31}Close one page of output, with each page containing \PB{\\{num\_labels%
1551 \_per\_page}}
1552 labels, and write any preamble for initialization of a new page to the output
1553 stream.
1554
1555 \Y\B\4\X31:Close output page\X${}\E{}$\6
1556 ${}\{{}$\1\6
1557 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\vfill\\\\eject\\n"});{}$\6
1558 \4${}\}{}$\2\par
1559 \Us5\ET34.\fi
1560
1561 \M{32}Before writing the first row of labels to the page output, save the
1562 vertical
1563 crop marks to be used as alignment marks in vertical cutting of the final
1564 pages.
1565
1566 \Y\B\4\X32:Write vertical crop marks with width measure\X${}\E{}$\6
1567 ${}\{{}$\1\6
1568 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hskip\ \%1.3fpt\\\\vr}\)\.{ule\
1569 height20pt\ width}\)\.{\%1.3fpt\%\%\\n"},\39\T{20.0}-\\{clthick}/\T{2.0},\39%
1570 \\{clthick});{}$\6
1571 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hbox\ to\%1.3fpt\{\\\\}\)\.{hfil"},\39%
1572 \\{facewidth}-\\{clthick});{}$\6
1573 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\$\\\\matrix\{\{\%1.3f\{\\\\}\)\.{rm\\\\\
1574 pt\}/\%1.3f\{\\\\rm\\}\)\.{\\\ mm\}\}"}\.{"\\\\cr\{\}\\\\cr\}\$\\\\hfil\}}\)\.{%
1575 \%\%\\n"},\39\\{facewidth},\39\\{facewidth}*(\T{25.4}/\T{72.27}));{}$\6
1576 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\vrule\ height20pt\ }\)\.{width\%1.3fpt%
1577 \%\%\\n"},\39\\{clthick});{}$\6
1578 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hbox\ to\ \%1.3fpt\{\\}\)\.{\\hfil"},%
1579 \39\\{facewidth}-\\{clthick});{}$\6
1580 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\$\\\\matrix\{\{\%1.3f\{\\\\}\)\.{rm\\\\\
1581 pt\}/\%1.3f\{\\\\rm\\}\)\.{\\\ mm\}\}"}\.{"\\\\cr\{\}\\\\cr\}\$\\\\hfil\}}\)\.{%
1582 \%\%\\n"},\39\\{facewidth},\39\\{facewidth}*(\T{25.4}/\T{72.27}));{}$\6
1583 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\vrule\ height20pt\ }\)\.{width\%1.3fpt%
1584 \\\\par\\\\n}\)\.{ointerlineskip\\n"},\39\\{clthick});{}$\6
1585 \4${}\}{}$\2\par
1586 \Us5\ET34.\fi
1587
1588 \M{33}The following block is analogous to the previous one, but now instead
1589 considering horizontal crop marks, to be used as alignment marks in
1590 horizontal cutting of the final pages.
1591
1592 \Y\B\4\X33:Write horizontal crop marks with height measure\X${}\E{}$\6
1593 ${}\{{}$\1\6
1594 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\vskip\\\\linethick\\}\)\.{n"});{}$\6
1595 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\vrule\ height\%1.3f}\)\.{pt\
1596 width20pt"},\39\\{clthick});{}$\6
1597 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\hskip\ \%1.3fpt"},\39\T{2.0}*%
1598 \\{facewidth});{}$\6
1599 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\vrule\ height\%1.3f}\)\.{pt\ width20pt%
1600 \\\\par\\\\n}\)\.{ointerlineskip\\n"},\39\\{clthick});{}$\6
1601 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\vskip\\\\linethick\\}\)\.{n"});{}$\6
1602 \4${}\}{}$\2\par
1603 \Us5\ET34.\fi
1604
1605 \M{34}Generating the closing \TeX\ source code for the labels.
1606
1607 \Y\B\4\X34:Save closing source code\X${}\E{}$\6
1608 ${}\{{}$\1\6
1609 \&{if} ${}((\\{num\_labels}\I\T{2})\W(\\{num\_labels}\I\T{4})){}$\5
1610 ${}\{{}$\1\6
1611 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\par\\\\nointerlines}\)\.{kip\\n"});{}$\6
1612 \4${}\}{}$\2\6
1613 \&{if} ${}(\\{num\_labels}\I\\{num\_labels\_per\_page}){}$\5
1614 ${}\{{}$\1\6
1615 \&{if} ${}(\\{num\_labels}\I\T{0}){}$\5
1616 ${}\{{}$\1\6
1617 \&{if} (\\{generate\_crop\_marks})\5
1618 ${}\{{}$\1\6
1619 \X33:Write horizontal crop marks with height measure\X\6
1620 \X32:Write vertical crop marks with width measure\X\6
1621 \4${}\}{}$\2\6
1622 \4${}\}{}$\2\6
1623 \X31:Close output page\X\6
1624 \4${}\}{}$\2\6
1625 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\\\\bye\\n"});{}$\6
1626 \&{if} ${}(\R\\{outfile\_specified}){}$\1\5
1627 ${}\\{fprintf}(\.{OUTSTREAM},\39\.{"\%\%--------\ TEX\ CODE}\)\.{\ ENDS\ HERE\
1628 ---------}\)\.{--------\\n"});{}$\2\6
1629 \4${}\}{}$\2\par
1630 \U5.\fi
1631
1632 \M{35}Compiling the output \TeX\ source code. If the {\tt -c} or {\tt
1633 --compile}
1634 option was present at the command line during startup of \dvlabel, then
1635 the program will make use of \DVIPS\ to compile the previously generated
1636 \TeX\ source code into PostScript.
1637 If the {\tt -c} or {\tt --compile} option is used together with a specified
1638 output file (specified using the {\tt-o} or {\tt --outputfile} options),
1639 then this output file will be compiled.
1640 On the other hand, if the {\tt -c} or {\tt --compile} option is used while
1641 the program should send the generated source to \PB{\\{stdout}}, then the
1642 internally
1643 stored lines of output will be compiled instead (hence eliminating the need
1644 for a temporary file for the compilation).
1645
1646 \Y\B\4\X35:Compile source code\X${}\E{}$\6
1647 ${}\{{}$\1\6
1648 \&{if} (\\{compile})\5
1649 ${}\{{}$\1\6
1650 \&{if} (\\{verbose})\5
1651 ${}\{{}$\1\6
1652 ${}\\{fprintf}(\\{stdout},\39\.{"\%s:\ Compiling\ the\ T}\)\.{eX\ source\ code\
1653 into\ }\)\.{PostScript.\\n"},\39\\{progname});{}$\6
1654 \4${}\}{}$\2\6
1655 \&{if} (\\{outfile\_specified})\5
1656 ${}\{{}$\1\6
1657 \&{if} (\\{eps\_output})\5
1658 ${}\{{}$\1\6
1659 ${}\\{sprintf}(\\{tmpstr},\39\.{"tex\ \%s;\ dvips\ \%s\ \%s}\)\.{\ -E\ -o\ %
1660 \%s.eps"},\39\\{outputfilename},\39\\{dvipsopts},\39\\{outputfilename},\39%
1661 \\{outputfilename});{}$\6
1662 \4${}\}{}$\2\6
1663 \&{else}\5
1664 ${}\{{}$\1\6
1665 ${}\\{sprintf}(\\{tmpstr},\39\.{"tex\ \%s;\ dvips\ \%s\ \%s}\)\.{\ -o\ %
1666 \%s.ps"},\39\\{outputfilename},\39\\{dvipsopts},\39\\{outputfilename},\39%
1667 \\{outputfilename});{}$\6
1668 \4${}\}{}$\2\6
1669 \\{system}(\\{tmpstr});\C{ System call to execute \PB{\\{tmpstr}} }\6
1670 \4${}\}{}$\2\6
1671 \&{else}\5
1672 ${}\{{}$\1\6
1673 ${}\\{fprintf}(\\{stdout},\39\.{"Compiling\ terminal\ }\)\.{output:\ Not\
1674 implemen}\)\.{ted\ yet.\\n"});{}$\6
1675 \\{exit}(\.{FAILURE});\6
1676 \4${}\}{}$\2\6
1677 \4${}\}{}$\2\6
1678 \4${}\}{}$\2\par
1679 \U5.\fi
1680
1681 \N{1}{36}Index.
1682 \fi
1683
1684 \inx
1685 \fin
1686 \con
1687
Generated by ::viewsrc::