\section{cmml-fix.c File Reference}
\label{cmml-fix_8c}\index{cmml-fix.c@{cmml-fix.c}}
{\tt \#include $<$config.h$>$}\par
{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$string.h$>$}\par
{\tt \#include $<$ctype.h$>$}\par
{\tt \#include $<$fcntl.h$>$}\par
{\tt \#include $<$errno.h$>$}\par
{\tt \#include $<$unistd.h$>$}\par
{\tt \#include $<$cmml.h$>$}\par
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define {\bf BUFSIZE}~100000
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
static void {\bf PrintUsage} (char $\ast$prog)
\item 
static int {\bf read\_\-stream} ({\bf CMML} $\ast$cmml, const {\bf CMML\_\-Stream} $\ast$stream, void $\ast$user\_\-data)
\item 
static int {\bf read\_\-head} ({\bf CMML} $\ast$cmml, const {\bf CMML\_\-Head} $\ast$head, void $\ast$user\_\-data)
\item 
static int {\bf read\_\-clip} ({\bf CMML} $\ast$cmml, const {\bf CMML\_\-Clip} $\ast$clip, void $\ast$user\_\-data)
\item 
int {\bf main} (int argc, char $\ast$argv[$\,$])
\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
static FILE $\ast$ {\bf outfile}
\end{CompactItemize}


\subsection{Detailed Description}
cmml-fix: parses a CMML instance document, validates it against the CMML.dtd ignoring sloppy errors and prints out a valid version of the file if possible.



\footnotesize\begin{verbatim}
Usage: cmml-fix [options] filename
Transform a sloppy CMML file to a valid one.
 
Possible options:
  -i clip_id,  --id clip_id
                 Start parsing from the named clip.
  -s seconds,  --sec seconds
                 Start parsing from the given seconds offset
  -u utc,      --utc utc
                 Start parsing from the given utc time
  -o filename, --output filename
                 Specify the output filename. The file is written
                 to standard output by default.
  -h, --help     Display this help information
  -v, --version  Display version information
\end{verbatim}
\normalsize
 

\subsection{Define Documentation}
\index{cmml-fix.c@{cmml-fix.c}!BUFSIZE@{BUFSIZE}}
\index{BUFSIZE@{BUFSIZE}!cmml-fix.c@{cmml-fix.c}}
\subsubsection[{BUFSIZE}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUFSIZE~100000}\label{cmml-fix_8c_eca034f67218340ecb2261a22c2f3dcd}


the size of the print buffer 

\subsection{Function Documentation}
\index{cmml-fix.c@{cmml-fix.c}!PrintUsage@{PrintUsage}}
\index{PrintUsage@{PrintUsage}!cmml-fix.c@{cmml-fix.c}}
\subsubsection[{PrintUsage}]{\setlength{\rightskip}{0pt plus 5cm}static void PrintUsage (char $\ast$ {\em prog})\hspace{0.3cm}{\tt  [static]}}\label{cmml-fix_8c_f6ee0e4e38011fad22b9afdf7e318422}


PrintUsage: prints out help on how to use this program

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em prog}]the program's name \end{description}
\end{Desc}
\index{cmml-fix.c@{cmml-fix.c}!read\_\-stream@{read\_\-stream}}
\index{read\_\-stream@{read\_\-stream}!cmml-fix.c@{cmml-fix.c}}
\subsubsection[{read\_\-stream}]{\setlength{\rightskip}{0pt plus 5cm}static int read\_\-stream ({\bf CMML} $\ast$ {\em cmml}, \/  const {\bf CMML\_\-Stream} $\ast$ {\em stream}, \/  void $\ast$ {\em user\_\-data})\hspace{0.3cm}{\tt  [static]}}\label{cmml-fix_8c_264d099fdb2e7fe0a8ace65bedf2a544}


read\_\-stream: the callback for a stream element

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmml}]the CMML$\ast$ handle in use \item[{\em stream}]the stream element's content represented in a CMML\_\-Stream$\ast$ \item[{\em user\_\-data}]user defined data\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]0 on success, 1 on error \end{Desc}


References BUFSIZE, cmml\_\-error\_\-snprint(), cmml\_\-get\_\-last\_\-error(), cmml\_\-stream\_\-pretty\_\-snprint(), and outfile.\index{cmml-fix.c@{cmml-fix.c}!read\_\-head@{read\_\-head}}
\index{read\_\-head@{read\_\-head}!cmml-fix.c@{cmml-fix.c}}
\subsubsection[{read\_\-head}]{\setlength{\rightskip}{0pt plus 5cm}static int read\_\-head ({\bf CMML} $\ast$ {\em cmml}, \/  const {\bf CMML\_\-Head} $\ast$ {\em head}, \/  void $\ast$ {\em user\_\-data})\hspace{0.3cm}{\tt  [static]}}\label{cmml-fix_8c_ff63a79594eaec0ef855a6660e399ce8}


read\_\-head: the callback for a head element

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmml}]the CMML$\ast$ handle in use \item[{\em head}]the head element's content represented in a CMML\_\-Head$\ast$ \item[{\em user\_\-data}]user defined data\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]0 on success, 1 on error \end{Desc}


References BUFSIZE, cmml\_\-error\_\-snprint(), cmml\_\-get\_\-last\_\-error(), cmml\_\-head\_\-pretty\_\-snprint(), and outfile.\index{cmml-fix.c@{cmml-fix.c}!read\_\-clip@{read\_\-clip}}
\index{read\_\-clip@{read\_\-clip}!cmml-fix.c@{cmml-fix.c}}
\subsubsection[{read\_\-clip}]{\setlength{\rightskip}{0pt plus 5cm}static int read\_\-clip ({\bf CMML} $\ast$ {\em cmml}, \/  const {\bf CMML\_\-Clip} $\ast$ {\em clip}, \/  void $\ast$ {\em user\_\-data})\hspace{0.3cm}{\tt  [static]}}\label{cmml-fix_8c_c75b92ae4d99efa0356efdcc7a5158dc}


read\_\-clip: the callback for a clip element

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmml}]the CMML$\ast$ handle in use \item[{\em clip}]the clip element's content represented in a CMML\_\-Clip$\ast$ \item[{\em user\_\-data}]user defined data\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]0 on success, 1 on error \end{Desc}


References BUFSIZE, cmml\_\-clip\_\-pretty\_\-snprint(), cmml\_\-error\_\-snprint(), cmml\_\-get\_\-last\_\-error(), and outfile.\index{cmml-fix.c@{cmml-fix.c}!main@{main}}
\index{main@{main}!cmml-fix.c@{cmml-fix.c}}
\subsubsection[{main}]{\setlength{\rightskip}{0pt plus 5cm}int main (int {\em argc}, \/  char $\ast$ {\em argv}[$\,$])}\label{cmml-fix_8c_0ddf1224851353fc92bfbff6f499fa97}


main function of cmml-fix, which opens the CMML file, seeks to any given offsets, registers the callbacks, and then steps through the file in chunks of BUFSIZE size, during which the callbacks get activated as the relevant elements get parsed. 

References BUFSIZE, cmml\_\-close(), CMML\_\-EOF, cmml\_\-error\_\-snprint(), cmml\_\-get\_\-last\_\-error(), cmml\_\-get\_\-preamble(), cmml\_\-new(), cmml\_\-open(), cmml\_\-preamble\_\-snprint(), cmml\_\-read(), cmml\_\-set\_\-read\_\-callbacks(), cmml\_\-set\_\-sloppy(), cmml\_\-skip\_\-to\_\-id(), cmml\_\-skip\_\-to\_\-secs(), cmml\_\-skip\_\-to\_\-utc(), outfile, PrintUsage(), read\_\-clip(), read\_\-head(), read\_\-stream(), secs, and CMML\_\-Error::type.

\subsection{Variable Documentation}
\index{cmml-fix.c@{cmml-fix.c}!outfile@{outfile}}
\index{outfile@{outfile}!cmml-fix.c@{cmml-fix.c}}
\subsubsection[{outfile}]{\setlength{\rightskip}{0pt plus 5cm}FILE$\ast$ {\bf outfile}\hspace{0.3cm}{\tt  [static]}}\label{cmml-fix_8c_e581849c67336453bd5b81e6518019a9}


outfile: defines FILE pointer to print output to 

Referenced by main(), read\_\-clip(), read\_\-head(), and read\_\-stream().