\hypertarget{ebf2c_8c}{
\section{ebf2c.c File Reference}
\label{ebf2c_8c}\index{ebf2c.c@{ebf2c.c}}
}
Converts a .ebf file into a C file. 

{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$string.h$>$}\par
{\tt \#include \char`\"{}EDS/io/EBF\_\-swap.h\char`\"{}}\par
{\tt \#include \char`\"{}EDS/io/EBF\_\-stream.h\char`\"{}}\par
{\tt \#include \char`\"{}EDS/io/EBF\_\-evts.h\char`\"{}}\par
{\tt \#include \char`\"{}EDS/EBF\_\-evt.h\char`\"{}}\par
\subsection*{Classes}
\begin{CompactItemize}
\item 
struct \hyperlink{struct__Ctl}{\_\-Ctl}
\begin{CompactList}\small\item\em Collections all the control parameters together. These are essentially the interpretted command line options. \item\end{CompactList}\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define \hyperlink{ebf2c_8c_e4aaddbffbdff7c519c660b4f57ff86c}{\_\-ADVANCE}(\_\-ptr, \_\-nbytes)~(typeof (\_\-ptr))((unsigned char $\ast$)(\_\-ptr) + (\_\-nbytes))
\begin{CompactList}\small\item\em Advances {\em \_\-ptr\/} by {\em \_\-nbytes\/}. The return value is always recast to the type of {\em \_\-ptr\/}. \item\end{CompactList}\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{ebf2c_8c_3c7ca9a0cd4663bddc8a32c1af11d0f9}{
typedef struct \hyperlink{struct__Ctl}{\_\-Ctl} \hyperlink{ebf2c_8c_3c7ca9a0cd4663bddc8a32c1af11d0f9}{Ctl}}
\label{ebf2c_8c_3c7ca9a0cd4663bddc8a32c1af11d0f9}

\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__Ctl}{\_\-Ctl}. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
int \hyperlink{ebf2c_8c_3c04138a5bfe5d72780bb7e82a18e627}{main} (int argc, char $\ast$$\ast$argv)
\begin{CompactList}\small\item\em Entry point for filter. \item\end{CompactList}\item 
static int \hyperlink{ebf2c_8c_30a02656cd6afbf59cf568153f5f6d7a}{fillCtl} (int argc, char $\ast$argv\mbox{[}$\,$\mbox{]}, \hyperlink{struct__Ctl}{Ctl} $\ast$ctl)
\begin{CompactList}\small\item\em Examines the command line parameters and fills the print control structure. \item\end{CompactList}\item 
static void \hyperlink{ebf2c_8c_4fee33385c73d68b91d313813e1c3807}{printCtl} (const \hyperlink{struct__Ctl}{Ctl} $\ast$ctl)
\begin{CompactList}\small\item\em Prints the contents of the print control context. \item\end{CompactList}\item 
static int \hyperlink{ebf2c_8c_294a08d551da253c619c6f84db3cb430}{convert} (const \hyperlink{struct__Ctl}{Ctl} $\ast$ctl)
\begin{CompactList}\small\item\em converts the .ebf to an output .c file \item\end{CompactList}\item 
\hypertarget{ebf2c_8c_490f516ea3835fd9264b518b0f6502bb}{
static void \hyperlink{ebf2c_8c_490f516ea3835fd9264b518b0f6502bb}{reportUsage} (void)}
\label{ebf2c_8c_490f516ea3835fd9264b518b0f6502bb}

\begin{CompactList}\small\item\em Describes the command line parameters for daqeb\_\-print. \item\end{CompactList}\item 
static const char $\ast$ \hyperlink{ebf2c_8c_5b01426d65c0831b3684a93d9587ef6a}{constructCname} (const char $\ast$iname)
\begin{CompactList}\small\item\em Returns a pointer to the name of the output file. \item\end{CompactList}\item 
static const char $\ast$ \hyperlink{ebf2c_8c_69e3f0f98a228933472fcddc93de57d9}{constructDname} (const char $\ast$cname)
\begin{CompactList}\small\item\em Returns a pointer to the name of data structure. \item\end{CompactList}\item 
static \_\-\_\-inline EBF\_\-evts \hyperlink{ebf2c_8c_659d5a71b8da2a252796ca5be1ee6471}{setupEvents} (EBF\_\-evts evts, int maxevts, int nskip, int $\ast$nevts)
\begin{CompactList}\small\item\em Skips to the first event to be output. \item\end{CompactList}\item 
static void \hyperlink{ebf2c_8c_129052ba1915e53ca6540d7a3fa6c15b}{printHeader} (FILE $\ast$cfile, const char $\ast$iname, const char $\ast$dname, int totsize)
\begin{CompactList}\small\item\em Prints the C file heading. \item\end{CompactList}\item 
static void \hyperlink{ebf2c_8c_46891e55ec9488410f0667595698b798}{printEvents} (FILE $\ast$cfile, EBF\_\-evts evts, int nevts)
\begin{CompactList}\small\item\em Writes out the data, ASCII, for the each event. \item\end{CompactList}\item 
static void \hyperlink{ebf2c_8c_78bade93c203e43d1a7746ffd52736ab}{printTrailer} (FILE $\ast$cfile)
\begin{CompactList}\small\item\em Adds the trailer to words to the output file. \item\end{CompactList}\item 
static \_\-\_\-inline const unsigned int $\ast$ \hyperlink{ebf2c_8c_6aa3093d761493cae7c3a65706e71b77}{printWrds} (FILE $\ast$cfile, const unsigned int $\ast$wrds, int nwrds)
\begin{CompactList}\small\item\em Prints the array of 32-bit words in to the output file. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Converts a .ebf file into a C file. 

\begin{Desc}
\item[Author:]JJRussell - \href{mailto:russell@slac.stanford.edu}{\tt russell@slac.stanford.edu}\end{Desc}


\footnotesize\begin{verbatim}
    CVS $Id: ebf2c.c,v 1.3 2005/10/13 22:01:00 russell Exp $
\end{verbatim}
\normalsize
 

\subsection{Define Documentation}
\hypertarget{ebf2c_8c_e4aaddbffbdff7c519c660b4f57ff86c}{
\index{ebf2c.c@{ebf2c.c}!_ADVANCE@{\_\-ADVANCE}}
\index{_ADVANCE@{\_\-ADVANCE}!ebf2c.c@{ebf2c.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define \_\-ADVANCE(\_\-ptr, \_\-nbytes)~(typeof (\_\-ptr))((unsigned char $\ast$)(\_\-ptr) + (\_\-nbytes))}}
\label{ebf2c_8c_e4aaddbffbdff7c519c660b4f57ff86c}


Advances {\em \_\-ptr\/} by {\em \_\-nbytes\/}. The return value is always recast to the type of {\em \_\-ptr\/}. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-ptr}]The pointer to advance \item[{\em \_\-nbytes}]The number of nbytes to advance {\em \_\-ptr\/} by. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The advanced pointer, recast to the type of {\em \_\-ptr\/}. \end{Desc}


\subsection{Function Documentation}
\hypertarget{ebf2c_8c_5b01426d65c0831b3684a93d9587ef6a}{
\index{ebf2c.c@{ebf2c.c}!constructCname@{constructCname}}
\index{constructCname@{constructCname}!ebf2c.c@{ebf2c.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static const char $\ast$ constructCname (const char $\ast$ {\em iname})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{ebf2c_8c_5b01426d65c0831b3684a93d9587ef6a}


Returns a pointer to the name of the output file. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em iname}]The name of the input file \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The name of the output file\end{Desc}
A name for the output file is constructed by appending a \char`\"{}.c\char`\"{} to the input file name. \hypertarget{ebf2c_8c_69e3f0f98a228933472fcddc93de57d9}{
\index{ebf2c.c@{ebf2c.c}!constructDname@{constructDname}}
\index{constructDname@{constructDname}!ebf2c.c@{ebf2c.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static const char $\ast$ constructDname (const char $\ast$ {\em cname})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{ebf2c_8c_69e3f0f98a228933472fcddc93de57d9}


Returns a pointer to the name of data structure. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cname}]The name of the output \char`\"{}C\char`\"{} file \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The name of the output data structure\end{Desc}
A name for the output data structure is constructed by stripping the directory and extensions from the input file name and prefixing it with \char`\"{}EBD\_\-\char`\"{}.

\begin{Desc}
\item[Warning:]Currently the algorithm is not smart enough to deal with characters that are valid in filenames but invalid in C names, eg '-'. \end{Desc}
\hypertarget{ebf2c_8c_294a08d551da253c619c6f84db3cb430}{
\index{ebf2c.c@{ebf2c.c}!convert@{convert}}
\index{convert@{convert}!ebf2c.c@{ebf2c.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static int convert (const {\bf Ctl} $\ast$ {\em ctl})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{ebf2c_8c_294a08d551da253c619c6f84db3cb430}


converts the .ebf to an output .c file 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ctl}]The control parameters, assumed to be already filled in \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Status \end{Desc}
\hypertarget{ebf2c_8c_30a02656cd6afbf59cf568153f5f6d7a}{
\index{ebf2c.c@{ebf2c.c}!fillCtl@{fillCtl}}
\index{fillCtl@{fillCtl}!ebf2c.c@{ebf2c.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static int fillCtl (int {\em argc}, char $\ast$ {\em argv}\mbox{[}$\,$\mbox{]}, {\bf Ctl} $\ast$ {\em ctl})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{ebf2c_8c_30a02656cd6afbf59cf568153f5f6d7a}


Examines the command line parameters and fills the print control structure. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em argc}]The number of command line parameters. \item[{\em argv}]The array of pointers to the command line parameters. \item[{\em ctl}]The run time parameters control block to be filled. \end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0,Everything}]is okay. \item[{\em -1,Incorrect}]command usage. Usually this means that the input file name was absent.\end{description}
\end{Desc}
This routine uses 'getopt' to process the command line parameters. Example



\footnotesize\begin{verbatim}

      $> ebf2c -n10 -s5 -c my_file.c my_file.ebf

  \end{verbatim}
\normalsize


Skips 5 events, then processes the next 10 of my\_\-file.ebf. The output is rewritten to my\_\-file.c \hypertarget{ebf2c_8c_3c04138a5bfe5d72780bb7e82a18e627}{
\index{ebf2c.c@{ebf2c.c}!main@{main}}
\index{main@{main}!ebf2c.c@{ebf2c.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int main (int {\em argc}, char $\ast$$\ast$ {\em argv})}}
\label{ebf2c_8c_3c04138a5bfe5d72780bb7e82a18e627}


Entry point for filter. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em argc}]Standard argument count. \item[{\em argv}]Standard vector of command line parameter strings. \end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0,if}]successful -1, if the file does not exist or some other internal error.\end{description}
\end{Desc}
The usage of this routine is self-documenting. Simply type ebfcmp with no parameters for its usage. \hypertarget{ebf2c_8c_4fee33385c73d68b91d313813e1c3807}{
\index{ebf2c.c@{ebf2c.c}!printCtl@{printCtl}}
\index{printCtl@{printCtl}!ebf2c.c@{ebf2c.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static void printCtl (const {\bf Ctl} $\ast$ {\em ctl})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{ebf2c_8c_4fee33385c73d68b91d313813e1c3807}


Prints the contents of the print control context. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ctl}]Pointer to the print control context block. \end{description}
\end{Desc}
\hypertarget{ebf2c_8c_46891e55ec9488410f0667595698b798}{
\index{ebf2c.c@{ebf2c.c}!printEvents@{printEvents}}
\index{printEvents@{printEvents}!ebf2c.c@{ebf2c.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static void printEvents (FILE $\ast$ {\em cfile}, EBF\_\-evts {\em evts}, int {\em nevts})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{ebf2c_8c_46891e55ec9488410f0667595698b798}


Writes out the data, ASCII, for the each event. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cfile}]The output file stream. \item[{\em evts}]The array of events to write out \item[{\em nevts}]The number of events to write out \end{description}
\end{Desc}
\hypertarget{ebf2c_8c_129052ba1915e53ca6540d7a3fa6c15b}{
\index{ebf2c.c@{ebf2c.c}!printHeader@{printHeader}}
\index{printHeader@{printHeader}!ebf2c.c@{ebf2c.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static void printHeader (FILE $\ast$ {\em cfile}, const char $\ast$ {\em iname}, const char $\ast$ {\em dname}, int {\em esize})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{ebf2c_8c_129052ba1915e53ca6540d7a3fa6c15b}


Prints the C file heading. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cfile}]The output file stream \item[{\em iname}]The name of the input file \item[{\em dname}]The name of the output data structure \item[{\em esize}]The size, in bytes, of the output data \end{description}
\end{Desc}
\hypertarget{ebf2c_8c_78bade93c203e43d1a7746ffd52736ab}{
\index{ebf2c.c@{ebf2c.c}!printTrailer@{printTrailer}}
\index{printTrailer@{printTrailer}!ebf2c.c@{ebf2c.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static void printTrailer (FILE $\ast$ {\em cfile})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{ebf2c_8c_78bade93c203e43d1a7746ffd52736ab}


Adds the trailer to words to the output file. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cfile}]The output file stream. \end{description}
\end{Desc}
\hypertarget{ebf2c_8c_6aa3093d761493cae7c3a65706e71b77}{
\index{ebf2c.c@{ebf2c.c}!printWrds@{printWrds}}
\index{printWrds@{printWrds}!ebf2c.c@{ebf2c.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static const unsigned int $\ast$ printWrds (FILE $\ast$ {\em cfile}, const unsigned int $\ast$ {\em wrds}, int {\em nwrds})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{ebf2c_8c_6aa3093d761493cae7c3a65706e71b77}


Prints the array of 32-bit words in to the output file. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cfile}]The file handle \item[{\em wrds}]The array of words to format \item[{\em nwrds}]The number of words to format \end{description}
\end{Desc}
\hypertarget{ebf2c_8c_659d5a71b8da2a252796ca5be1ee6471}{
\index{ebf2c.c@{ebf2c.c}!setupEvents@{setupEvents}}
\index{setupEvents@{setupEvents}!ebf2c.c@{ebf2c.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}static \_\-\_\-inline EBF\_\-evts setupEvents (EBF\_\-evts {\em evts}, int {\em maxevts}, int {\em nskip}, int $\ast$ {\em nevts})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{ebf2c_8c_659d5a71b8da2a252796ca5be1ee6471}


Skips to the first event to be output. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em evts}]The events \item[{\em maxevts}]The maximum number of events to process, if -1, do all \item[{\em nskip}]The number of events to skip \item[{\em nevts}]Returned as the number of events to process \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A pointer to the first event to be output \end{Desc}
