2 %%% Applied Crypto Hardening
5 %%% configfiles.tex -- macros for automatically inserting config file parts
12 \RequirePackage{etoolbox}
15 \newwrite\configfileout
16 \immediate\openout\configfileout configfiles.txt
18 % do not trace everything
19 \newif\iftracingsections
21 \newcommand*\currentsectionname{}%
22 \newcommand*\currentsubsectionname{}%
25 \def\@configurationdir{configuration}
26 \newcommand*\configurationdir[1]{%
27 \gdef\@configurationdir{#1}}
28 \def\@configurationbaseurl{}
29 \newcommand*\configurationbaseurl[1]{%
30 \gdef\@configurationbaseurl{#1}}
32 % patch the section command to record information for our config files
36 \def\sectn@me{section}%
37 \def\subsectn@me{subsection}%
40 \ifx\tempa\sectn@me\relax%
41 \expandafter\xdef\expandafter\currentsectionname{\tempn@me}%
43 \ifx\tempa\subsectn@me\relax%
44 \expandafter\xdef\expandafter\currentsubsectionname%
45 {\tempn@me}\else\relax\fi%
51 % \configfile[args]{filename}{range}
52 % --> \lstinputlisting[linerange={range},args]{configurations/Section/Subsection/filename}
54 \newcommand*\configfile[4][]{%
56 \edef\configfilen@me{\@configurationdir/\currentsectionname/\currentsubsectionname/#2}
57 \edef\configfilename{\expandafter\detokenize\expandafter{\configfilen@me}}
58 \def\configfilepres{\expandafter\protect\expandafter\path\expandafter{\configfilename}}
59 \immediate\write\configfileout{\configfilename}
64 caption={[#4\\\configfilepres]%
65 #4\\\mbox{\protect\href{\@configurationbaseurl\configfilename}{%
66 {\upshape [\configfilepres]}%
69 \marginpar{\vspace*{-2\baselineskip}\protect\href{\@configurationbaseurl\configfilename}{%
70 \includegraphics[height=2\baselineskip]{img/ConfigIcns}}}
72 \@warning{\string\configfile outside a sectiontraced region}%
77 % start tracing section commands to record (sub)section names
78 \newcommand*\startconfigfiles{%
83 % stop tracing section commands
84 \newcommand*\stopconfigfiles{%
85 \tracingsectionsfalse%
86 \renewcommand*\currentsectionname{%
87 \@warning{\string\currentsectionname outside sectiontraced region}}%
88 \renewcommand*\currentsubsectionname{%
89 \@warning{\string\currentsubsectionname outside sectiontraced region}}%
97 %%% TeX-master: "../applied-crypto-hardening"