%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\catcode`\@=11
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newlength{\desclen}
\newlength{\yearlen}
\newlength{\mmlen}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%{\catcode`\<=1\catcode`\>=2
%	<\catcode`\{=12\gdef\OBraceTw<{>>
%	<\catcode`\}=12\gdef\CBraceTw<}>>
%>
%\@ifundefined{specHasManual}{\let\specHasManual\relax}{}
\let\specHasManual\relax
\let\specCsgManual\relax
\let\specXilinxOptimization\relax

\def\eoa{end-of-args}
\def\@@novers#1-#2\eoa{#1}
\def\@novers#1{\ifx\relax#1\def\next{{\color{red}FIXME}}\else\def\next{\expandafter\@@novers#1\eoa}\fi\next}

\def\setMacroInAuxFile#1{%
	\hypertarget{#1}{}\vspace{-1.5ex}%
	\let\@novers\relax%
    \global\expandafter\edef\csname NOLNK#1\endcsname{\name}%
    \global\expandafter\edef\csname #1\endcsname{\noexpand\hyperlink{#1}{\name}}%
    \global\expandafter\edef\csname NOVERS#1\endcsname{\noexpand\hyperlink{#1}{\@novers{\name}}}%
    \global\expandafter\edef\csname NOVL#1\endcsname{\@novers{\name}}%
    \immediate\write\@auxout{\expandafter\string\expandafter\gdef\expandafter\string\csname NOLNK#1\endcsname{\name}}%
    \immediate\write\@auxout{\expandafter\string\expandafter\gdef\expandafter\string\csname #1\endcsname{\string\hyperlink{#1}{\name}}}%
    \immediate\write\@auxout{\expandafter\string\expandafter\gdef\expandafter\string\csname NOVERS#1\endcsname{\string\hyperlink{#1}{\@novers{\name}}}}%
    \immediate\write\@auxout{\expandafter\string\expandafter\gdef\expandafter\string\csname NOVL#1\endcsname{\@novers{\name}}}%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcount\supportercnt\supportercnt=1
\newwrite\supporter
\immediate\openout\supporter=anr-supporter.tex
\def\letterOfInterest#1#2{{%
  \let\subsection\relax%
  \let\label\relax%
  \let\begin\relax%
  \let\end\relax%
  \let\includegraphics\relax%
  \let\linewidth\relax%
  \let\newpage\relax%
  \immediate\write\supporter{%
    \subsection{#1} \label{supp:\the\supportercnt}}%
  \immediate\write\supporter{%
    \begin{center}\includegraphics[width=0.9\linewidth]{#2}\end{center}}%
    \newpage%
  }%
  #1 (page \pageref{supp:\the\supportercnt})%
  \advance\supportercnt1%
}
\def\letterOfInterestPlus#1{{%
  \let\begin\relax%
  \let\end\relax%
  \let\includegraphics\relax%
  \let\linewidth\relax%
  \let\newpage\relax%
  \immediate\write\supporter{%
    \begin{center}\includegraphics[width=0.9\linewidth]{#1}\end{center}}%
    \newpage%
  }%
}

\def\letterOfInterestNb{?}
\def\letterOfInterestClose{
  \advance\supportercnt-1
  \immediate\closeout\supporter
  \immediate\write\@auxout{%
    \string\gdef\string\letterOfInterestNb{\the\supportercnt}
  }
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\let\ganttlf\relax
\newwrite\ganttdata
\immediate\openout\ganttdata=anr.gantt

\def\enable{enable}
\def\disable{disable}
\def\leader{leader}
\newenvironment{taskinfo}%
{%
\let\ALL\disable%
\let\IRISA\disable%
\let\LIP\disable%
\let\TIMA\disable%
\let\UBS\disable%
\let\UPMC\disable%
\let\BULL\disable%
\let\THALES\disable%
\let\MDS\disable%
}{%
\ifx\ALL\enable%
  \ifx\IRISA\disable\let\IRISA\enable\fi%
  \ifx\LIP\disable\let\LIP\enable\fi%
  \ifx\UPMC\disable\let\UPMC\enable\fi%
  \ifx\TIMA\disable\let\TIMA\enable\fi%
  \ifx\UBS\disable\let\UBS\enable\fi%
  \ifx\BULL\disable\let\BULL\enable\fi%
  \ifx\THALES\disable\let\THALES\enable\fi%
  \ifx\MDS\disable\let\MDS\enable\fi%
\fi%
\def\@leader{\begin{small}\textcolor{red}{lead.}\end{small}}
\def\@partner{\begin{small}\textcolor{blue}{part.}\end{small}}
\def\@IRISA{\ifx\IRISA\disable{}\else\ifx\IRISA\enable{\@partner}\else{\@leader}\fi\fi}%
\def\@LIP{\ifx\LIP\disable{}\else\ifx\LIP\enable{\@partner}\else{\@leader}\fi\fi}%
\def\@UPMC{\ifx\UPMC\disable{}\else\ifx\UPMC\enable{\@partner}\else{\@leader}\fi\fi}%
\def\@TIMA{\ifx\TIMA\disable{}\else\ifx\TIMA\enable{\@partner}\else{\@leader}\fi\fi}%
\def\@UBS{\ifx\UBS\disable{}\else\ifx\UBS\enable{\@partner}\else{\@leader}\fi\fi}%
\def\@BULL{\ifx\BULL\disable{}\else\ifx\BULL\enable{\@partner}\else{\@leader}\fi\fi}%
\def\@THALES{\ifx\THALES\disable{}\else\ifx\THALES\enable{\@partner}\else{\@leader}\fi\fi}%
\def\@MDS{\ifx\MDS\disable{}\else\ifx\MDS\enable{\@partner}\else{\@leader}\fi\fi}%
\begin{tabular}{|c|c|c|c|c|c|c|c|}\hline
\Sirisa  & \Slip  & \Stima  & \Subs  & \Supmc  & \Smds & \Sbull  & \Sthales \\\hline
\@IRISA  & \@LIP  & \@TIMA  & \@UBS  & \@UPMC  & \@MDS & \@BULL  & \@THALES \\\hline
\end{tabular}\par
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironment{objectif}%
{\begin{description}\item[Objectives]}
{\end{description}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcount\taskcnt\taskcnt=0
\newcount\subtaskcnt
\newcount\livrablecnt
\newenvironment{workpackage}%
{\global\advance\taskcnt1
 \global\subtaskcnt0
 \def\taskname{T\the\taskcnt}%
 \begin{description}%
 %\let\itemsave\item%
 \def\subtask##1{%
    \global\advance\subtaskcnt1
    \def\subtaskname{S\taskname-\the\subtaskcnt}%
    \item[\subtaskname: ##1]%
    \IfFileExists{tmp/st\the\taskcnt-\the\subtaskcnt-partner.tex}%
      {(\input{tmp/st\the\taskcnt-\the\subtaskcnt-partner.tex})}%
      {\message{SKIPPING tmp/st\the\taskcnt-\the\subtaskcnt-partner.tex files}}%
  \mbox{}\\%
  {%
    \let\xcoach\relax%
    \let\xcoachplus\relax%
    \let\irisa\relax    \let\Sirisa\relax%
    \let\lip\relax      \let\Slip\relax%
    \let\tima\relax     \let\Stima\relax%
    \let\ubs\relax      \let\Subs\relax%
    \let\upmc\relax     \let\Supmc\relax%
    \let\altera\relax   \let\Saltera\relax%
    \let\bull\relax     \let\Sbull\relax%
    \let\thales\relax   \let\Sthales\relax%
    \let\mds\relax      \let\Smds\relax%
    \let\xilinx\relax%
    \immediate\write\ganttdata{%
        STN=\the\taskcnt\space\the\subtaskcnt\space##1
    }%
 }}%
}{%
  \end{description}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\writeganttinfo#1#2#3#4#5#6{{%
    \let\xcoach\relax
    \let\xcoachplus\relax
    \let\irisa\relax    \let\Sirisa\relax
    \let\lip\relax      \let\Slip\relax
    \let\tima\relax     \let\Stima\relax
    \let\ubs\relax      \let\Subs\relax
    \let\upmc\relax     \let\Supmc\relax
    \let\altera\relax   \let\Saltera\relax
    \let\bull\relax     \let\Sbull\relax
    \let\thales\relax   \let\Sthales\relax
    \let\mds\relax      \let\Smds\relax
    \let\xilinx\relax
    \immediate\write\ganttdata{%
      L=1 T=\the\taskcnt\space S=\the\subtaskcnt\space%
      D=\the\livrablecnt\space V=\vers\space%
      BM=#1 EM=#2 R=#3 PART={#4} KIND={#5} TITLE=#6%
    }
}}
\newenvironment{livrable}%
{%
 \newcount\verscnt\verscnt=-1
 \newif\ifIsLivrableStarted\IsLivrableStartedfalse
 \newif\ifLivrableTopLine\LivrableTopLinetrue
 \def\livrableTableDef{\begin{tabular}{|c|c|c|c|p{.625\linewidth}|}\hline}
 \def\livrableTableLine##1##2##3##4{%
    \makebox[3.5em]{\begin{small}##1\end{small}} &
    \makebox[2.2em]{\begin{small}##2\end{small}} &
    \makebox[1.5em]{\begin{small}##3\end{small}} &
    \makebox[2.2em]{\begin{small}##4\end{small}} &
 }
 \def\livrableTableTopLine{%
   \livrableTableLine{number}{date}{type}{resp.} description
 }
 \livrablecnt-1
 \ifvmode \else\par\fi
    
 \def\itemV##1##2##3##4##5{%
    \ifIsLivrableStarted
        \global\advance\verscnt1
    \else
        \global\advance\livrablecnt1
        \global\verscnt1
    \fi
    \def\vers{V\the\verscnt}
    \global\edef\name{D\the\taskcnt\the\subtaskcnt\the\livrablecnt-\vers}%
    \hypertarget{\name}{}%
    \writeganttinfo{##1}{##2}{none}{##4}{##3}{##5}
    \\\hline
    \ifLivrableTopLine
      \ifIsLivrableStarted\else\hline\hline\fi
    \else
      \ifIsLivrableStarted\else\end{tabular}\\\livrableTableDef\fi
    \fi
    \global\LivrableTopLinefalse
    \global\IsLivrableStartedtrue
    %\global\LivrableStartfalse
    \livrableTableLine%
        {\textsc{\name}}%
        {\textsc{T0+##2}}%
        {\textsc{##3}}%
        {\textsc{##4}}%
 }
 \def\itemL##1##2##3##4##5##6{%
    \ifIsLivrableStarted
        %\global\advance\verscnt1
    \else
        \global\advance\livrablecnt1
        %\global\verscnt1
    \fi
    \def\vers{VF}
    \global\edef\name{D\the\taskcnt\the\subtaskcnt\the\livrablecnt-\vers}%
    \hypertarget{\name}{}%
    \hypertarget{\expandafter\@@novers\name\eoa}{}%
    \writeganttinfo{##1}{##2}{##6}{##4}{##3}{##5}
    \\\hline
    \ifLivrableTopLine
      \ifIsLivrableStarted\else\hline\hline\fi
    \else
      \ifIsLivrableStarted\else\end{tabular}\\\livrableTableDef\fi
    \fi
    \global\LivrableTopLinefalse
    \global\IsLivrableStartedfalse
    %\global\LivrableStartfalse
    \livrableTableLine%
        {\textsc{\name}}%
        {\textsc{T0+##2}}%
        {\textsc{##3}}%
        {\textsc{##4}}%
 }
 \def\OtherPartner##1##2##3##4{{%
    \let\xcoach\relax
    \let\xcoachplus\relax
    \let\irisa\relax    \let\Sirisa\relax
    \let\lip\relax      \let\Slip\relax
    \let\tima\relax     \let\Stima\relax
    \let\ubs\relax      \let\Subs\relax
    \let\upmc\relax     \let\Supmc\relax
    \let\altera\relax   \let\Saltera\relax
    \let\bull\relax     \let\Sbull\relax
    \let\thales\relax   \let\Sthales\relax
    \let\mds\relax     \let\Smds\relax
    \immediate\write\ganttdata{%
      L=0 T=\the\taskcnt\space S=\the\subtaskcnt\space%
      D=\the\livrablecnt\space BM=##1 EM=##2 R=##4 PART={##3} TITLE=%
    }
 }}
% \begin{small}
 \livrableTableDef
 \livrableTableTopLine
 %\begin{tabular}{|c|c|c|c|p{.55\linewidth}|}\hline%
 %\makebox[3.5em]{number} & \makebox[1.5em]{date} & type & resp. & description 
}
{\\\hline\end{tabular}\\%
%\end{small}\\%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\catcode`\@=12
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
