Ulteriori revisioni, finita l'introduzione con vari spostamenti e
[gapil.git] / macro.tex
1 %% macro.tex
2 %%
3 %% Copyright (C) 2000-2011 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{\func}[1]{%
118 \index{funzione!{#1}@{{\tt {#1}}}}\texttt{#1}%
119 %\index{#1@{{\tt {#1}} (funzione)}}\texttt{#1}%
120 }
121
122 \newcommand{\funcd}[1]{%
123 \index{funzione!{#1}@{{\tt {#1}}}!definizione di}\texttt{#1}%
124 %\index{#1@{{\tt {#1}} (funzione)}!definizione di}\texttt{#1}%
125 }
126
127 \newcommand{\macro}[1]{%
128 \index{macro!{#1}@{{\tt {#1}}}}\texttt{#1}%
129 %\index{#1@{{\tt {#1}} (macro)}}\texttt{#1}%
130 }
131
132 \newcommand{\errcode}[1]{%
133 \index{errore!{#1}@{{\tt {#1}}}}\texttt{#1}%
134 %\index{#1@{{\tt {#1}} (errore)}}\texttt{#1}%
135 }
136
137 \newcommand{\errval}[1]{\texttt{#1}}     % value 
138 \newcommand{\var}[1]{\texttt{#1}}     % variable 
139 \newcommand{\val}[1]{\texttt{#1}}     % value 
140
141 \newcommand{\const}[1]{%
142 \index{costante!{#1}@{{\tt {#1}}}}\texttt{#1}%
143 %\index{#1@{{\tt {#1}} (costante)}}\texttt{#1}%
144 }                                     % constant name
145
146 \newcommand{\direct}[1]{%
147 \index{direttiva!{#1}@{{\tt {#1}}}}\texttt{#1}%
148 %\index{#1@{{\tt {#1}} (direttiva)}}\texttt{#1}%
149 }                                     % constant name
150
151 \newcommand{\file}[1]{\texttt{#1}}    % file name
152 \newcommand{\link}[1]{\texttt{#1}}    % html link
153 \newcommand{\ctyp}[1]{\texttt{#1}}    % C standard type
154
155 \newcommand{\headfile}[1]{%
156 \index{file!include!{#1}@{{\tt {#1}}}}\texttt{#1}%
157 %\index{#1@{{\tt {#1}} (direttiva)}}\texttt{#1}%
158 }                                     % header file name
159 \newcommand{\procfile}[1]{%
160 \index{file!filesystem~\texttt{/proc}!{#1}@{{\tt {#1}}}}\texttt{#1}%
161 %\index{#1@{{\tt {#1}} (direttiva)}}\texttt{#1}%
162 }                                     % /proc file name
163 \newcommand{\sysfile}[1]{%
164 \index{file!di~sistema!{#1}@{{\tt {#1}}}}\texttt{#1}%
165 %\index{#1@{{\tt {#1}} (direttiva)}}\texttt{#1}%
166 }                                     % system file name
167 \newcommand{\conffile}[1]{%
168 \index{file!di~configurazione!{#1}@{{\tt {#1}}}}\texttt{#1}%
169 %\index{#1@{{\tt {#1}} (direttiva)}}\texttt{#1}%
170 }                                     % configuration file name
171 \newcommand{\procrelfile}[2]{%
172 \index{file!filesystem~\texttt{/proc}!{#1/#2}@{{\tt {#1/#2}}}}\texttt{#2}%
173 %\index{#1@{{\tt {#1}} (direttiva)}}\texttt{#1}%
174 }   
175
176
177 \newcommand{\type}[1]{%
178 \index{tipo!{#1}@{{\tt {#1}}}}\texttt{#1}%
179 %\index{#1@{{\tt {#1}} (tipo)}}\texttt{#1}%
180 }                                     % system type
181 \newcommand{\struct}[1]{%
182 \index{struttura dati!{#1}@{{\tt {#1}}}}\texttt{#1}%
183 %\index{#1@{{\tt {#1}} (struttura dati)}}\texttt{#1}%
184 }                                     % struttura dati
185 \newcommand{\structd}[1]{%
186 \index{struttura dati!{#1}@{{\tt {#1}}}!definizione di}\texttt{#1}%
187 %\index{#1@{{\tt {#1}} (struttura dati)}!definizione di}\texttt{#1}%
188 }                                     % struttura dati
189 \newcommand{\param}[1]{\texttt{#1}}   % function parameter
190 \newcommand{\acr}[1]{\textsl{#1}}     % acrostic (for pid, suid, ecc.)
191
192 \newcommand{\itindex}[1]{%
193 \index{#1@{\textit{#1}}}%
194 }
195
196 \newcommand{\itindbeg}[1]{%
197 \index{#1@{\textit{#1}}|(}%
198 }
199 \newcommand{\itindend}[1]{%
200 \index{#1@{\textit{#1}}|)}%
201 }
202 \newcommand{\itindsub}[2]{%
203 \index{#1@{\textit{#1}}!\textit{#2}}%
204 }
205
206 % Aggiunte di Mirko per la gestione delle tabelle complicate come immagini
207 % nella traslazione in HTML
208 \newenvironment{usepicture}{}{}{}{}
209
210 %
211 % Macro di definizione di alcune lunghezze usate per le formattazioni
212 %
213 \newlength{\codesamplewidth}
214 \setlength{\codesamplewidth}{0.95\textwidth}
215
216 \newlength{\funcboxwidth}
217 \setlength{\funcboxwidth}{0.85\textwidth}
218
219 %
220 % Nuove macro per diversa formattazione delle definizioni delle funzioni
221 %
222 \newcommand{\fhead}[1]{\texttt{\#include <#1>}\par}
223 \newcommand{\fdecl}[1]{\texttt{#1}\par}
224 \newcommand{\fdesc}[1]{\hfill{#1}\par}
225
226 \newenvironment{funcproto}[2]
227 {% defining what is done by \begin
228 \centering
229 \vspace{6pt}
230 \begin{funcbox}
231 #1
232 \end{funcbox}
233 \begin{funcbox}
234 #2
235 }
236 {% defining what is done by \end
237 \end{funcbox}
238 \vspace{6pt}
239 %\break
240 }
241
242 \newenvironment{funcbox}
243 {% defining what is done by \begin
244   \nobreak
245   \begin{boxedminipage}[c]{\funcboxwidth}
246     \footnotesize
247 }
248 {% defining what is done by \end
249 \end{boxedminipage}
250 \break
251 \normalsize
252 \par
253 }
254
255
256
257 %%% Local Variables: 
258 %%% mode: latex
259 %%% TeX-master: "gapil"
260 %%% End: