summaryrefslogtreecommitdiff
path: root/2004/netfilter-failover-ols2004/OLS2004-proceedings/EXAMPLE/complexCode/lgrind.sty
blob: 2d04753d65208a09ae4ec218108cab076f83ed93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
%%
%% This is file `lgrind.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% lgrind.dtx  (with options: `package')
%% 
%% LGrind is used to format source code of different programming
%% languages for LaTeX.
%% 
%% LGrind is a minor adaptation of Jerry Leichter's tgrind for LaTeX,
%% which was a notable improvement upon Van Jacobsen's tgrind for
%% plain TeX, which was adapted from vgrind, a troff prettyprinter.
%% 
%% Based on Van Jacobson's ``tgrindmac'', a macro package for TeX.
%% Modified, 1987 by Jerry Leichter. Put '@' in all internal names.
%% Modified, 1991 by George Reilly. Changed name from tgrind to lgrind.
%% Modified, 1995 by Michael Piefel. Made it work with \LaTeXe.
\NeedsTeXFormat{LaTeX2e}[1995/06/01]
\ProvidesPackage{lgrind}
          [1997/01/30 v3.4 LGrind environment and supporting stuff]
\newcount\lc@unt
\newcount\ln@xt
\newcount\LGnuminterval
\LGnuminterval=10
\DeclareOption{nolineno}{\LGnuminterval=50000}
\DeclareOption{lineno5}{\LGnuminterval=5}
\newif\ifLGleftnum
\DeclareOption{leftnum}{\LGleftnumtrue}
\newskip\LGindent
\LGindent=1.6667\parindent
\DeclareOption{noindent}{\LGindent=0pt}
\newif\ifLGnorules
\DeclareOption{norules}{\LGnorulestrue}
\newlength{\LGsloppy}
\setlength{\LGsloppy}{7.2pt}
\DeclareOption{fussy}{\LGsloppy=0pt}
\newcommand{\DefaultProc}{\@gobble}
\newcommand{\DefaultProcCont}{\@gobble}
\DeclareOption{procnames}{
\renewcommand{\DefaultProc}[1]{\renewcommand{\Procname}{#1}%
\global\setbox\procbox=\hbox{\PNsize #1}}
\renewcommand{\DefaultProcCont}[1]{\renewcommand\Procname{#1}
\global\setbox\procbox=\hbox{\PNsize\dots #1}}}
\newbox\procbox
\newcommand{\Procname}{}
\ProcessOptions
\def\BGfont{\sffamily}
\def\CMfont{\rmfamily\itshape}
\def\NOfont{\sffamily}
\def\KWfont{\rmfamily\bfseries}
\def\STfont{\ttfamily}
\def\VRfont{\rmfamily}
\def\PNsize{\BGfont\small}
\def\LGsize{\small}
\def\LGfsize{\footnotesize}
\newif\ifLGinline
\newif\ifLGd@fault
\def\LGbegin{\ifLGinline$\hbox\else$$\vbox\fi\bgroup\LGd@faulttrue}
\def\LGend{\ifLGd@fault\egroup\ifLGinline$\else$$\fi\LGd@faultfalse\fi}
\newif\ifc@mment
\newif\ifstr@ng
\newif\ifright@
\newbox\ls@far
\newbox\tb@x
\newdimen\TBw@d
\newdimen\@ts
{\catcode`\_=\active \gdef\@setunder{\let_=\sp@ce}}
\newcommand{\lgrindheader}{}
\newcommand{\lgrindfilename}{}\newcommand{\lgrindfilesize}{}
\newcommand{\lgrindmodyear}{}\newcommand{\lgrindmodmonth}{}
\newcommand{\lgrindmodday}{}\newcommand{\lgrindmodtime}{}
\newenvironment{lgrind}[1][1]{%
\def\Line##1{\L{\LB{##1}}}%
\newcommand{\Head}[1]{\gdef\lgrindhead{##1}}%
\newcommand{\File}[6]{\gdef\lgrindfilename{##1}\message{(LGround: ##1)}%
    \gdef\lgrindmodyear{##2}\gdef\lgrindmodmonth{##3}%
    \gdef\lgrindmodday{##4}\gdef\lgrindmodtime{##5}%
    \gdef\lgrindfilesize{##6}}%
\let\Proc=\DefaultProc%
\let\ProcCont=\DefaultProcCont%
\hfuzz=\LGsloppy
\def\NewPage{\filbreak\bigskip}%
\ifLGinline
 \def\L##1{\setbox\ls@far\null{\CF\strut##1}\ignorespaces}%
\else
 \let\r@ghtlno\relax\let\l@ftlno\relax
 \ifnum\LGnuminterval>\z@
  \ifLGleftnum
   \def\l@ftlno{\ifvoid\procbox\ifnum\lc@unt>\ln@xt
     \global\advance\ln@xt by\LGnuminterval
     \llap{{\normalfont\scriptsize\the\lc@unt\quad}}\fi
     \else\llap{\box\procbox\quad}\fi}%
  \else
   \def\r@ghtlno{\ifvoid\procbox\ifnum\lc@unt>\ln@xt
     \global\advance\ln@xt by\LGnuminterval
     \rlap{{\normalfont\scriptsize\enspace\the\lc@unt}}\fi
     \else\rlap{\enspace\box\procbox}\fi}%
  \fi
 \fi
 \def\L##1{\@@par\setbox\ls@far=\null\strut
  \global\advance\lc@unt by1%
  \hbox to \hsize{\hskip\LGindent\l@ftlno ##1\egroup%
  \hfil\r@ghtlno}%
  \ignorespaces}%
\fi
\lc@unt=#1\advance\lc@unt by-1%
\ln@xt=\LGnuminterval\advance\ln@xt by-1%
\loop\ifnum\lc@unt>\ln@xt\advance\ln@xt by\LGnuminterval\repeat%
\def\LB{\hbox\bgroup\bgroup\box\ls@far\CF\let\next=}%
\def\Tab##1{\egroup\setbox\tb@x=\lastbox\TBw@d=\wd\tb@x%
 \advance\TBw@d by 1\@ts\ifdim\TBw@d>##1\@ts
  \setbox\ls@far=\hbox{\box\ls@far \box\tb@x \sp@ce}\else
  \setbox\ls@far=\hbox to ##1\@ts{\box\ls@far \box\tb@x \hfil}\fi\LB}%
\ifLGinline\def\sp@ce{\hskip .3333em}%
\else \setbox\tb@x=\hbox{\texttt{0}}%
      \@ts=0.8\wd\tb@x \def\sp@ce{\hskip 1\@ts}\fi
\catcode`\_=\active \@setunder
\def\CF{\ifc@mment\CMfont\else\ifstr@ng\STfont\fi\fi}
\def\N##1{{\NOfont ##1}\global\futurelet\next\ic@r}%
\def\K##1{{\KWfont ##1}\global\futurelet\next\ic@r}%
\def\V##1{{\VRfont ##1}\global\futurelet\next\ic@r}%
\def\ic@r{\let\@tempa\/\ifx.\next\let\@tempa\relax%
 \else\ifx,\next\let\@tempa\relax\fi\fi\@tempa}%
\def\C{\egroup\bgroup\CMfont \global\c@mmenttrue \global\right@false}%
\def\CE{\egroup\bgroup \global\c@mmentfalse}%
\def\S{\egroup\bgroup\STfont \global\str@ngtrue}%
\def\SE{\egroup\bgroup \global\str@ngfalse}%
\def\,{\relax \ifmmode\mskip\thinmuskip \else\thinspace \fi}%
\def\!{\relax \ifmmode\mskip-\thinmuskip \else\negthinspace \fi}%
\def\CH##1##2##3{\relax\ifmmode ##1\relax
\else\ifstr@ng ##2\relax\else$##3$\fi\fi }%
\def\{{\CH\lbrace {\char'173}\lbrace }%
\def\}{\CH\rbrace {\char'175}\rbrace }%
\def\1{\CH///}%                                % /
\def\2{\CH\backslash {\char'134}\backslash }%  % \
\def\|{\CH|{\char'174}|}%
\def\<{\CH<<<}%
\def\>{\CH>>>}%
\def\*{\CH***}\relax %\relax for DOCSTY
\def\-{\CH---}%
\def\_{\ifstr@ng {\char'137}\else
  \leavevmode \kern.06em \vbox{\hrule width.35em}%
  \ifdim\fontdimen\@ne\font=\z@ \kern.06em \fi\fi }%
\def\&{\textsf{\char'046}}%
\def\#{{\STfont\char'043}}%
\def\%{{\char'045}}%
\def\~{{\char'176}}%
\def\3{\ifc@mment\ifright@ ''\global\right@false%
                      \else``\global\right@true \fi
   \else{\texttt{\char'042}}\fi}%
\def\4{\ifc@mment'\else {\texttt{\char'015}}\fi}%
\def\5{{\texttt{\char'136}}}%
\def\${{\ifmmode\slshape\else\ifdim\fontdimen\@ne\font>\z@\slshape\fi\fi
  \char'044}}% %No $ in \it, use \sl
\parindent\z@\parskip\z@ plus 1pt\hsize\linewidth%
\bgroup\BGfont
}
{\egroup\@@par}           % end of environment lgrind
\def\lgrinde{\ifLGinline\else\LGsize\fi\begin{lgrind}}
\def\endlgrinde{\end{lgrind}}
\def\lagrind{\@ifstar{\@slagrind}{\@lagrind}}

\def\@lagrind{\@ifnextchar[{\@@lagrind}{\@@lagrind[t]}}
\def\@slagrind{\@ifnextchar[{\@@slagrind}{\@@slagrind[t]}}
\def\@@lagrind[#1]#2#3#4{%
    \begin{figure}[#1]
\ifLGnorules\else\hrule\fi
\vskip .5\baselineskip
\begin{minipage}\columnwidth\LGsize\LGindent\z@
    \begin{lgrind}
\input #2\relax
    \end{lgrind}
\end{minipage}
\vskip .5\baselineskip plus .5\baselineskip
\ifLGnorules\else\hrule\fi\vskip .5\baselineskip
\begingroup
    \setbox\z@=\hbox{#4}%
    \ifdim\wd\z@>\z@
\caption{#3}%
\label{#4}%
    \else
\captcont{#3}%
    \fi
\endgroup
\vskip 2pt
    \end{figure}
}
\def\@@slagrind[#1]#2#3#4{%
    \begin{figure*}[#1]
\ifLGnorules\else\hrule\fi
\vskip .5\baselineskip
\begin{minipage}\linewidth\LGsize\LGindent\z@
    \begin{lgrind}
\input #2\relax
    \end{lgrind}
\end{minipage}
\vskip .5\baselineskip plus .5\baselineskip
\ifLGnorules\else\hrule\fi\vskip .5\baselineskip
\begingroup
    \setbox\z@=\hbox{#4}%
    \ifdim\wd\z@>\z@
\caption{#3}%
\label{#4}%
    \else
\captcont{#3}%
    \fi
\endgroup
\vskip 2pt
    \end{figure*}
}
\def\lgrindfile#1{%
    \par\addvspace{0.1in}
    \ifLGnorules\else\hrule\fi
    \vskip .5\baselineskip
    \begingroup\LGfsize\LGindent\z@
\begin{lgrind}
    \input #1\relax
\end{lgrind}
    \endgroup
    \vskip .5\baselineskip
    \ifLGnorules\else\hrule\fi
    \addvspace{0.1in}
}
\endinput
%%
%% End of file `lgrind.sty'.
personal git repositories of Harald Welte. Your mileage may vary