
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This is a set of LaTeX macros for documenting C source code.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \function{name}{prototype) makes a new section in which to
% describe the function, and makes a reference with the function's 
% name
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\function}[2]{ 
	\section*{#1}
	\addcontentsline{toc}{section}{#1}
	\label{#1}
	{\large\tt\raggedright #2 \par}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The code environment does formatting intended to set quoted
% source code apart from the text.  Currently this is done with
% a rule above and below the source.
% It also sets up a fixed with font and stops processing of TeX
% macros and special characters (except \endcode).
%
% If Docstrip is used to extract LaTeX from a C file, the call 
%
%   docstrip -v -s\begincode e\endcode -fout.tex in.c
%
% will cause the complete source to be correctly embedded.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chardef\other=12
\def\jklverbatim{\codesep \begingroup 
	\catcode`\\=\other \catcode`\{=\other
  \catcode`\}=\other \catcode`\$=\other \catcode`\&=\other
  \catcode`\#=\other \catcode`\%=\other \catcode`\~=\other
  \catcode`\_=\other \catcode`\^=\other
  \obeyspaces \obeylines \tt \parindent=0pt}
{\obeyspaces\gdef {\ }} % \obeyspaces now gives \ , not \space
\outer\def\begincode{\def\par{\leavevmode\endgraf} 
	\jklverbatim \parskip=0pt \catcode`\|=12 \rightskip=-5pc \jklfinish}
{\catcode`\|=0 |catcode`|\=\other % | is temporary escape character
  |obeylines % end of line is active
  |gdef|jklfinish#1\endcode{#1|endgroup|codesep}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  the codesep macro defines the stuff to put before and after
% literal source code.  It is used by the \begincode and \endcode
% macros.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\codesep{\vspace{1em}\hrule\vspace{1em}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Style parameters for formatting little bits of code
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\textc{\texttt}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Formatting Preferences
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\endsection {\pagebreak}
\setlength{\parindent}{3pc}
\textwidth = 6 in % make lines wider so 80 column code will format right
\textheight = 8 in
\oddsidemargin = 0.25 in
\evensidemargin = 0.25 in
\topmargin = 0.0 in

