%% macro.tex
%%
%% Copyright (C) 2000-2013 Simone Piccardi.  Permission is granted to
%% copy, distribute and/or modify this document under the terms of the GNU Free
%% Documentation License, Version 1.1 or any later version published by the
%% Free Software Foundation; with the Invariant Sections being "Un preambolo",
%% with no Front-Cover Texts, and with no Back-Cover Texts.  A copy of the
%% license is included in the section entitled "GNU Free Documentation
%% License".
%%
%
%
% Defining some special character for use inside typewriter 
% text without using the verbatim environment
%
\def\tild{\char'176}
\def\bslash{\char'134}
\def\circonf{\char'136}
\def\invap{\char'140}

\newcommand{\includecodesnip}[1]{\lstinputlisting[stepnumber=0,xleftmargin=\parindent,frame=]{#1}}{}
\newcommand{\includestruct}[1]{\lstinputlisting[stepnumber=0]{#1}}{}
\newcommand{\includecodesample}[1]{\lstinputlisting{#1}}{}

%
% Defining some commands to manipulate counter to avoid ude of 
% \label and \ref commands (and related problem to remeber the 
% used labels) to refer nearest objects
%
%
\newcounter{usercount}       % define a new counter for internal use
%
% equations commands
%
\newcommand{\cureq}{(\theequation)}
\newcommand{\nxeq}{%
\setcounter{usercount}{\value{equation}}%
\addtocounter{usercount}{1}%
(\thechapter.\theusercount)}
\newcommand{\preeq}{%
\setcounter{usercount}{\value{equation}}%
\addtocounter{usercount}{-1}%
(\thechapter.\theusercount)}
%
% Macro to put picture (in format PICT) inside a figure
%
\newcommand{\pictfig}[3]{
        \begin{minipage}[t][#1][b]{#2}
        \mbox{\special{pict=#3}}
%    \vspace{3cm}
    \end{minipage}
}
%
% Macro to create a special environment for function prototypes
% boxed description
%
\newenvironment{prototype}[2]
{% defining what is done by \begin
  \nobreak
  \center
  \begin{boxedminipage}[c]{14cm}
  \footnotesize
    \begin{description*}{}{} 
    \item \texttt{\#include <#1>}
    \item \texttt{#2} \par
%   \begin{lstlisting}{}
% #1
% #2
%   \end{lstlisting}
}
{% defining what is done by \end
%  \end{list} 
%  \par 
\end{description*}
\end{boxedminipage}
\vspace{6pt}
\par
\normalsize 
}
\newenvironment{errlist}{\begin{basedescript}{\desclabelwidth{1.0cm}}}
{\end{basedescript}}
%
% Slighty different environment to be used for multi-header, 
% multi-functions boxed description
%
\newcommand{\headdecl}[1]{\item\texttt{\#include <#1>}}
\newcommand{\funcdecl}[1]{\item\texttt{#1}\par}
\newcommand{\bodydesc}[1]{\par \end{description*} #1
 \begin{description*}{}{} \baselineskip=0pt
 \item \vspace{-4pt}
} 
% 
\newenvironment{functions}
{% defining what is done by \begin
  \nobreak
  \center
    \begin{boxedminipage}[c]{14cm}
      \footnotesize
    \begin{description*}{}{} 
}
{% defining what is done by \end
      \end{description*}
    \end{boxedminipage}
    \vspace{6pt}
     \par
    \normalsize 
%\break
}

%
% Wrapper for shell command, functions, filenames, links,
% variables, macros,  and everything can be useul, 
%
\newcommand{\cmd}[1]{\texttt{#1}}     % shell command
\newcommand{\code}[1]{\texttt{#1}}    % for simple code

\newcommand{\myfunc}[1]{\texttt{#1}}    % for my functions

\newcommand{\func}[1]{%
\index{funzione!{#1}@{{\tt {#1}}}}\texttt{#1}%
%\index{#1@{{\tt {#1}} (funzione)}}\texttt{#1}%
}

\newcommand{\funcd}[1]{%
\index{funzione!{#1}@{{\tt {#1}}}!definizione di}\texttt{#1}%
%\index{#1@{{\tt {#1}} (funzione)}!definizione di}\texttt{#1}%
}
\newcommand{\funcm}[1]{%
\index{funzione!{#1}@{{\tt {#1}}}!menzione di}\texttt{#1}%
%\index{#1@{{\tt {#1}} (funzione)}!definizione di}\texttt{#1}%
}

\newcommand{\macro}[1]{%
\index{macro!{#1}@{{\tt {#1}}}}\texttt{#1}%
%\index{#1@{{\tt {#1}} (macro)}}\texttt{#1}%
}

\newcommand{\errcode}[1]{%
\index{errore!{#1}@{{\tt {#1}}}}\texttt{#1}%
%\index{#1@{{\tt {#1}} (errore)}}\texttt{#1}%
}

\newcommand{\errval}[1]{\texttt{#1}}     % value 
\newcommand{\var}[1]{\texttt{#1}}     % variable 
\newcommand{\val}[1]{\texttt{#1}}     % value 

\newcommand{\signal}[1]{%
\index{segnale!{#1}@{{\tt {#1}}}}\texttt{#1}%
%\index{#1@{{\tt {#1}} (costante)}}\texttt{#1}%
}                                     % constant name

\newcommand{\const}[1]{%
\index{costante!{#1}@{{\tt {#1}}}}\texttt{#1}%
%\index{#1@{{\tt {#1}} (costante)}}\texttt{#1}%
}                                     % constant name

\newcommand{\instruction}[1]{%
\index{istruzione linguaggio C!{#1}@{{\tt {#1}}}}\texttt{#1}%
%\index{#1@{{\tt {#1}} (direttiva)}}\texttt{#1}%
}                                     % constant name

\newcommand{\direct}[1]{%
\index{direttiva linguaggio C!{#1}@{{\tt {#1}}}}\texttt{#1}%
%\index{#1@{{\tt {#1}} (direttiva)}}\texttt{#1}%
}                                     % constant name

\newcommand{\file}[1]{\texttt{#1}}    % file name
\newcommand{\link}[1]{\texttt{#1}}    % html link
\newcommand{\ctyp}[1]{\texttt{#1}}    % C standard type

\newcommand{\headfile}[1]{%
%\index{file!include!{#1}@{{\tt {#1}}}}\texttt{#1}%
\texttt{#1}%
}                                     % header file name

\newcommand{\procfile}[1]{%
\index{file!filesystem~\texttt{/proc}!{#1}@{{\tt {#1}}}}\texttt{#1}%
%\index{#1@{{\tt {#1}} (direttiva)}}\texttt{#1}%
}                                     % /proc file name
\newcommand{\sysfile}[1]{%
\index{file!di~sistema!{#1}@{{\tt {#1}}}}\texttt{#1}%
%\index{#1@{{\tt {#1}} (direttiva)}}\texttt{#1}%
}                                     % system file name
\newcommand{\conffile}[1]{%
\index{file!di~configurazione!{#1}@{{\tt {#1}}}}\texttt{#1}%
%\index{#1@{{\tt {#1}} (direttiva)}}\texttt{#1}%
}                                     % configuration file name
\newcommand{\procrelfile}[2]{%
\index{file!filesystem~\texttt{/proc}!{#1/#2}@{{\tt {#1/#2}}}}\texttt{#2}%
%\index{#1@{{\tt {#1}} (direttiva)}}\texttt{#1}%
}   

\newcommand{\sysctlfile}[1]{%
\index{file!file di controllo (sotto \texttt{/proc/sys})!{#1}@{{\tt {#1}}}}\texttt{/proc/sys/#1}%
%\index{#1@{{\tt {#1}} (direttiva)}}\texttt{#1}%
}                                     % /proc/sys file name

\newcommand{\sysctlrelfile}[2]{%
\index{file!file di controllo (sotto \texttt{/proc/sys})!{#1/#2}@{{\tt {#1/#2}}}}\texttt{#2}%
%\index{#1@{{\tt {#1}} (direttiva)}}\texttt{#1}%
}                                     % /proc/sys file name


\newcommand{\kstruct}[1]{%
\index{struttura dati del kernel!{#1}@{{\tt {#1}}}}\texttt{#1}%
%\index{#1@{{\tt {#1}} (struttura dati)}}\texttt{#1}%
}                                     % struttura dati
\newcommand{\kstructd}[1]{%
\index{struttura dati del kernel!{#1}@{{\tt {#1}}}!definizione di}\texttt{#1}%
%\index{#1@{{\tt {#1}} (struttura dati)}!definizione di}\texttt{#1}%
}                                     % struttura dati
\newcommand{\type}[1]{%
\index{tipo di dato!{#1}@{{\tt {#1}}}}\texttt{#1}%
%\index{#1@{{\tt {#1}} (tipo)}}\texttt{#1}%
}                                     % system type
\newcommand{\struct}[1]{%
\index{struttura dati!{#1}@{{\tt {#1}}}}\texttt{#1}%
%\index{#1@{{\tt {#1}} (struttura dati)}}\texttt{#1}%
}                                     % struttura dati
\newcommand{\structd}[1]{%
\index{struttura dati!{#1}@{{\tt {#1}}}!definizione di}\texttt{#1}%
%\index{#1@{{\tt {#1}} (struttura dati)}!definizione di}\texttt{#1}%
}                                     % struttura dati
\newcommand{\param}[1]{\texttt{#1}}   % function parameter
\newcommand{\acr}[1]{\textsl{#1}}     % acrostic (for glibc, ext2, ecc.)

\newcommand{\ids}[1]{\textsl{#1}}     % Identifier (PID, GID, UID, TID, ecc.)
\newcommand{\envvar}[1]{\texttt{#1}}   % environment variable
\newcommand{\samplefunc}[1]{\texttt{#1}}   % funzione degli esempi

\newcommand{\itindex}[1]{%
\index{#1@{\textit{#1}}}%
}

\newcommand{\itindbeg}[1]{%
\index{#1@{\textit{#1}}|(}%
}
\newcommand{\itindend}[1]{%
\index{#1@{\textit{#1}}|)}%
}
\newcommand{\itindsub}[2]{%
\index{#1@{\textit{#1}}!\textit{#2}}%
}

% Aggiunte di Mirko per la gestione delle tabelle complicate come immagini
% nella traslazione in HTML
\newenvironment{usepicture}{}{}{}{}

%
% Macro di definizione di alcune lunghezze usate per le formattazioni
%
\newlength{\codesamplewidth}
\setlength{\codesamplewidth}{0.95\textwidth}

\newlength{\funcboxwidth}
\setlength{\funcboxwidth}{0.85\textwidth}


%
% Nuove macro per diversa formattazione delle definizioni delle funzioni
%
\newcommand{\fhead}[1]{\texttt{\#include <#1>}\par}
\newcommand{\fdecl}[1]{\texttt{#1}\par}
\newcommand{\fdesc}[1]{\hfill{#1}\par}

\newenvironment{funcproto}[2]
{% defining what is done by \begin
\centering
\vspace{3pt}
\begin{funcbox}
#1
\end{funcbox}
\begin{funcbox}
#2
}
{% defining what is done by \end
\end{funcbox}
%\vspace{6pt}
%\break
}

\newenvironment{funcbox}
{% defining what is done by \begin
  \nobreak
  \begin{boxedminipage}[c]{\funcboxwidth}
    \footnotesize
}
{% defining what is done by \end
\end{boxedminipage}
\break
\normalsize
\par
}



%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "gapil"
%%% End: 
