564d0b286d99ef5454c02da8c25cbe9dfaf5ab41
[gapil.git] / macro.tex
1 %% macro.tex
2 %%
3 %% Copyright (C) 2000-2018 Simone Piccardi.  Permission is granted to
4 %% copy, distribute and/or modify this document under the terms of the GNU Free
5 %% Documentation License, Version 1.1 or any later version published by the
6 %% Free Software Foundation; with the Invariant Sections being "Un preambolo",
7 %% with no Front-Cover Texts, and with no Back-Cover Texts.  A copy of the
8 %% license is included in the section entitled "GNU Free Documentation
9 %% License".
10 %%
11 %
12 %
13 % Defining some special character for use inside typewriter 
14 % text without using the verbatim environment
15 %
16 \def\tild{\char'176}
17 \def\bslash{\char'134}
18 \def\circonf{\char'136}
19 \def\invap{\char'140}
20
21 \newcommand{\includecodesnip}[1]{\lstinputlisting[stepnumber=0,xleftmargin=\parindent,frame=]{#1}}{}
22 \newcommand{\includestruct}[1]{\lstinputlisting[stepnumber=0]{#1}}{}
23 \newcommand{\includecodesample}[1]{\lstinputlisting{#1}}{}
24
25 %
26 % Defining some commands to manipulate counter to avoid ude of 
27 % \label and \ref commands (and related problem to remeber the 
28 % used labels) to refer nearest objects
29 %
30 %
31 \newcounter{usercount}       % define a new counter for internal use
32 %
33 % equations commands
34 %
35 \newcommand{\cureq}{(\theequation)}
36 \newcommand{\nxeq}{%
37 \setcounter{usercount}{\value{equation}}%
38 \addtocounter{usercount}{1}%
39 (\thechapter.\theusercount)}
40 \newcommand{\preeq}{%
41 \setcounter{usercount}{\value{equation}}%
42 \addtocounter{usercount}{-1}%
43 (\thechapter.\theusercount)}
44 %
45 % Macro to put picture (in format PICT) inside a figure
46 %
47 \newcommand{\pictfig}[3]{
48         \begin{minipage}[t][#1][b]{#2}
49         \mbox{\special{pict=#3}}
50 %    \vspace{3cm}
51     \end{minipage}
52 }
53 %
54 % Macro to create a special environment for function prototypes
55 % boxed description
56 %
57 \newenvironment{prototype}[2]
58 {% defining what is done by \begin
59   \nobreak
60   \center
61   \begin{boxedminipage}[c]{14cm}
62   \footnotesize
63     \begin{description*}{}{} 
64     \item \texttt{\#include <#1>}
65     \item \texttt{#2} \par
66 %   \begin{lstlisting}{}
67 % #1
68 % #2
69 %   \end{lstlisting}
70 }
71 {% defining what is done by \end
72 %  \end{list} 
73 %  \par 
74 \end{description*}
75 \end{boxedminipage}
76 \vspace{6pt}
77 \par
78 \normalsize 
79 }
80 \newenvironment{errlist}{\begin{basedescript}{\desclabelwidth{1.0cm}}}
81 {\end{basedescript}}
82 %
83 % Slighty different environment to be used for multi-header, 
84 % multi-functions boxed description
85 %
86 \newcommand{\headdecl}[1]{\item\texttt{\#include <#1>}}
87 \newcommand{\funcdecl}[1]{\item\texttt{#1}\par}
88 \newcommand{\bodydesc}[1]{\par \end{description*} #1
89  \begin{description*}{}{} \baselineskip=0pt
90  \item \vspace{-4pt}
91
92
93 \newenvironment{functions}
94 {% defining what is done by \begin
95   \nobreak
96   \center
97     \begin{boxedminipage}[c]{14cm}
98       \footnotesize
99     \begin{description*}{}{} 
100 }
101 {% defining what is done by \end
102       \end{description*}
103     \end{boxedminipage}
104     \vspace{6pt}
105      \par
106     \normalsize 
107 %\break
108 }
109
110 %
111 % Wrapper for shell command, functions, filenames, links,
112 % variables, macros,  and everything can be useul, 
113 %
114 \newcommand{\cmd}[1]{\texttt{#1}}     % shell command
115 \newcommand{\code}[1]{\texttt{#1}}    % for simple code
116
117 \newcommand{\myfunc}[1]{\texttt{#1}}    % for my functions
118
119 \newcommand{\func}[1]{%
120 \texttt{#1}%
121 %\index{funzione!{#1}@{{\tt {#1}}}}\texttt{#1}%
122 %\index{#1@{{\tt {#1}} (funzione)}}\texttt{#1}%
123 }
124
125 \newcommand{\funcd}[1]{%
126 \index{funzione!{#1}@{{\tt {#1}}}}\texttt{#1}%
127 %\index{funzione!{#1}@{{\tt {#1}}}!definizione di}\texttt{#1}%
128 %\index{#1@{{\tt {#1}} (funzione)}!definizione di}\texttt{#1}%
129 }
130 \newcommand{\funcm}[1]{%
131 \index{funzione!{#1}@{{\tt {#1}}}}\texttt{#1}%
132 %\index{funzione!{#1}@{{\tt {#1}}}!menzione di}\texttt{#1}%
133 %\index{#1@{{\tt {#1}} (funzione)}!definizione di}\texttt{#1}%
134 }
135
136 \newcommand{\macro}[1]{%
137 \texttt{#1}%
138 %\index{macro!{#1}@{{\tt {#1}}}}\texttt{#1}%
139 %\index{#1@{{\tt {#1}} (macro)}}\texttt{#1}%
140 }
141
142 \newcommand{\macrod}[1]{%
143 \index{macro!{#1}@{{\tt {#1}}}}\texttt{#1}%
144 %\index{#1@{{\tt {#1}} (macro)}}\texttt{#1}%
145 }
146
147 \newcommand{\macrobeg}[1]{%
148 \index{macro!{#1}@{{\tt {#1}}}|(}%
149 %\index{#1@{{\tt {#1}} (macro)}}\texttt{#1}%
150 }
151 \newcommand{\macroend}[1]{%
152 \index{macro!{#1}@{{\tt {#1}}}|)}%
153 %\index{#1@{{\tt {#1}} (macro)}}\texttt{#1}%
154 }
155
156 \newcommand{\errcode}[1]{%
157 \texttt{#1}%
158 %\index{errore!{#1}@{{\tt {#1}}}}\texttt{#1}%
159 %\index{#1@{{\tt {#1}} (errore)}}\texttt{#1}%
160 }
161
162 \newcommand{\errval}[1]{\texttt{#1}}     % value 
163 \newcommand{\var}[1]{\texttt{#1}}     % variable 
164 \newcommand{\val}[1]{\texttt{#1}}     % value 
165
166 \newcommand{\signal}[1]{%
167 \texttt{#1}%
168 %\index{segnale!{#1}@{{\tt {#1}}}}\texttt{#1}%
169 %\index{#1@{{\tt {#1}} (costante)}}\texttt{#1}%
170 }                                     % constant name
171
172 \newcommand{\signald}[1]{%
173 \index{segnale!{#1}@{{\tt {#1}}}}\texttt{#1}%
174 %\index{#1@{{\tt {#1}} (costante)}}\texttt{#1}%
175 }                                     % constant name
176
177 \newcommand{\constd}[1]{%
178 \index{costante!{#1}@{{\tt {#1}}}}\texttt{#1}%
179 %\index{#1@{{\tt {#1}} (costante)}}\texttt{#1}%
180 }                                     % constant name
181
182 \newcommand{\constbeg}[1]{%
183 \index{costante!{#1}@{{\tt {#1}}}|(}%
184 %\index{#1@{{\tt {#1}} (costante)}}\texttt{#1}%
185 }                                     % constant name
186 \newcommand{\constend}[1]{%
187 \index{costante!{#1}@{{\tt {#1}}}|)}%
188 %\index{#1@{{\tt {#1}} (costante)}}\texttt{#1}%
189 }                                     % constant name
190
191 \newcommand{\const}[1]{%
192 \texttt{#1}%
193 %\index{costante!{#1}@{{\tt {#1}}}}\texttt{#1}%
194 %\index{#1@{{\tt {#1}} (costante)}}\texttt{#1}%
195 }                                     % constant name
196
197 \newcommand{\instruction}[1]{%
198 \index{istruzione linguaggio C!{#1}@{{\tt {#1}}}}\texttt{#1}%
199 %\index{#1@{{\tt {#1}} (direttiva)}}\texttt{#1}%
200 }                                      % instruction name
201
202 \newcommand{\instr}[1]{\texttt{#1}}    % instruction
203
204 \newcommand{\direct}[1]{%
205 \index{direttiva linguaggio C!{#1}@{{\tt {#1}}}}\texttt{#1}%
206 %\index{#1@{{\tt {#1}} (direttiva)}}\texttt{#1}%
207 }                                     % directive name
208
209 \newcommand{\dirct}[1]{\texttt{#1}}   % directive
210
211
212 \newcommand{\file}[1]{\texttt{#1}}    % file name
213 \newcommand{\link}[1]{\texttt{#1}}    % html link
214 \newcommand{\ctyp}[1]{\texttt{#1}}    % C standard type
215
216 \newcommand{\headfile}[1]{%
217 \texttt{#1}%
218 }                                     % header file name
219 \newcommand{\headfiled}[1]{%
220 \index{file!include!{#1}@{{\tt {#1}}}}\texttt{#1}%
221 }                                     % header file name
222
223 \newcommand{\procfile}[1]{%
224 \index{file!filesystem~\texttt{/proc}!{#1}@{{\tt {#1}}}}\texttt{#1}%
225 }                                     % /proc file name
226 \newcommand{\procfilem}[1]{%
227 \texttt{#1}%
228 %\index{file!filesystem~\texttt{/proc}!{#1}@{{\tt {#1}}}}\texttt{#1}%
229 %\index{#1@{{\tt {#1}} (direttiva)}}\texttt{#1}%
230 }                                     % /proc file name
231
232 \newcommand{\sysfile}[1]{%
233 \texttt{#1}%
234 %\index{file!di~sistema!{#1}@{{\tt {#1}}}}\texttt{#1}%
235 }                                     % system file name
236 \newcommand{\sysfiled}[1]{%
237 \index{file!di~sistema!{#1}@{{\tt {#1}}}}\texttt{#1}%
238 }                                     % system file name
239
240 \newcommand{\conffile}[1]{%
241 \texttt{#1}%
242 %\index{file!di~configurazione!{#1}@{{\tt {#1}}}}\texttt{#1}%
243 }                                     % configuration file name
244 \newcommand{\conffiled}[1]{%
245 \index{file!di~configurazione!{#1}@{{\tt {#1}}}}\texttt{#1}%
246 }                                     % configuration file name
247 \newcommand{\conffilebeg}[1]{%
248 \index{file!di~configurazione!{#1}@{{\tt {#1}}}}%
249 }                                     % configuration file name
250 \newcommand{\conffileend}[1]{%
251 \index{file!di~configurazione!{#1}@{{\tt {#1}}}}%
252 }                                     % configuration file name
253
254 \newcommand{\procrelfile}[2]{%
255 \index{file!filesystem~\texttt{/proc}!{#1/#2}@{{\tt {#1/#2}}}}\texttt{#2}%
256 }   
257
258 \newcommand{\sysctlfiled}[1]{%
259 \index{file!file di controllo (sotto \texttt{/proc/sys})!{#1}@{{\tt {#1}}}}\texttt{/proc/sys/#1}%
260 }                                     % /proc/sys file 
261
262 \newcommand{\sysctlfile}[1]{%
263 \texttt{/proc/sys/#1}%
264 %\index{file!file di controllo (sotto \texttt{/proc/sys})!{#1}@{{\tt {#1}}}}\texttt{/proc/sys/#1}%
265 }                                     % /proc/sys file 
266
267 \newcommand{\sysctlrelfile}[2]{%
268 \texttt{#2}%
269 %\index{file!file di controllo (sotto \texttt{/proc/sys})!{#1/#2}@{{\tt {#1/#2}}}}\texttt{#2}%
270 }                                     % /proc/sys file name
271
272 \newcommand{\sysctlrelfiled}[2]{%
273 \index{file!file di controllo (sotto \texttt{/proc/sys})!{#1/#2}@{{\tt {#1/#2}}}}\texttt{#2}%
274 }                                     % /proc/sys file name
275
276 \newcommand{\kstruct}[1]{%
277 \texttt{#1}%
278 %\index{struttura dati del kernel!{#1}@{{\tt {#1}}}}\texttt{#1}%
279 }                                     % struttura dati del kernel
280 \newcommand{\kstructd}[1]{%
281 \index{struttura dati del kernel!{#1}@{{\tt {#1}}}}\texttt{#1}%
282 %\index{struttura dati del kernel!{#1}@{{\tt {#1}}}!definizione di}\texttt{#1}%
283 }                                     % struttura dati
284
285 \newcommand{\typed}[1]{%
286 \index{tipo di dato!{#1}@{{\tt {#1}}}}\texttt{#1}%
287 %\index{#1@{{\tt {#1}} (tipo)}}\texttt{#1}%
288 }                                     % system type
289 \newcommand{\type}[1]{%
290 \texttt{#1}%
291 %\index{tipo di dato!{#1}@{{\tt {#1}}}}\texttt{#1}%
292 %\index{#1@{{\tt {#1}} (tipo)}}\texttt{#1}%
293 }                                     % system type
294 \newcommand{\struct}[1]{%
295 \texttt{#1}%
296 %\index{struttura dati!{#1}@{{\tt {#1}}}}\texttt{#1}%
297 %\index{#1@{{\tt {#1}} (struttura dati)}}\texttt{#1}%
298 }                                     % struttura dati
299 \newcommand{\structd}[1]{%
300 \index{struttura dati!{#1}@{{\tt {#1}}}}\texttt{#1}%
301 %\index{struttura dati!{#1}@{{\tt {#1}}}!definizione di}\texttt{#1}%
302 }                                     % struttura dati
303 \newcommand{\param}[1]{\texttt{#1}}   % function parameter
304 \newcommand{\acr}[1]{\textsl{#1}}     % acrostic (for glibc, ext2, ecc.)
305
306 \newcommand{\ids}[1]{\textsl{#1}}     % Identifier (PID, GID, UID, TID, ecc.)
307 \newcommand{\envvar}[1]{\texttt{#1}}   % environment variable
308 \newcommand{\samplefunc}[1]{\texttt{#1}}   % funzione degli esempi
309
310 \newcommand{\itindex}[1]{%
311 \index{#1@{\textit{#1}}}%
312 }
313
314 \newcommand{\itindbeg}[1]{%
315 \index{#1@{\textit{#1}}|(}%
316 }
317 \newcommand{\itindend}[1]{%
318 \index{#1@{\textit{#1}}|)}%
319 }
320 \newcommand{\itindsub}[2]{%
321 \index{#1@{\textit{#1}}!\textit{#2}}%
322 }
323 \newcommand{\itindsubbeg}[2]{%
324 \index{#1@{\textit{#1}}!\textit{#2}}%
325 }
326 \newcommand{\itindsubend}[2]{%
327 \index{#1@{\textit{#1}}!\textit{#2}}%
328 }
329
330 % Aggiunte di Mirko per la gestione delle tabelle complicate come immagini
331 % nella traslazione in HTML
332 \newenvironment{usepicture}{}{}{}{}
333
334 %
335 % Macro di definizione di alcune lunghezze usate per le formattazioni
336 %
337 \newlength{\codesamplewidth}
338 \setlength{\codesamplewidth}{0.95\textwidth}
339
340 \newlength{\funcboxwidth}
341 \setlength{\funcboxwidth}{0.85\textwidth}
342
343
344 %
345 % Nuove macro per diversa formattazione delle definizioni delle funzioni
346 %
347 \newcommand{\fhead}[1]{\texttt{\#include <#1>}\par}
348 \newcommand{\fdecl}[1]{\texttt{#1}\par}
349 \newcommand{\fdesc}[1]{\hfill{#1}\par}
350
351 \newenvironment{funcproto}[2]
352 {% defining what is done by \begin
353 \centering
354 \vspace{3pt}
355 \begin{funcbox}
356 #1
357 \end{funcbox}
358 \begin{funcbox}
359 #2
360 }
361 {% defining what is done by \end
362 \end{funcbox}
363 %\vspace{6pt}
364 %\break
365 }
366
367 \newenvironment{funcbox}
368 {% defining what is done by \begin
369   \nobreak
370   \begin{boxedminipage}[c]{\funcboxwidth}
371     \footnotesize
372 }
373 {% defining what is done by \end
374 \end{boxedminipage}
375 \break
376 \normalsize
377 \par
378 }
379
380 \newcommand{\unavref}[1]{\ifx\incomplete\undefined\relax\else #1\fi}
381
382
383 %%% Local Variables: 
384 %%% mode: latex
385 %%% TeX-master: "gapil"
386 %%% End: