\section{cmml-validate.c File Reference}
\label{cmml-validate_8c}\index{cmml-validate.c@{cmml-validate.c}}
{\tt \#include \char`\"{}config.h\char`\"{}}\par
{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$fcntl.h$>$}\par
{\tt \#include $<$ctype.h$>$}\par
{\tt \#include $<$string.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 int {\bf verbose}
\end{CompactItemize}


\subsection{Detailed Description}
cmml-validate: parses a CMML instance document and validates it against the CMML.dtd returning true/false and in case of fault the faulty tag including line and col number. Also spits out warnings for strange stuff.



\footnotesize\begin{verbatim}
Usage: cmml-validate [Options] filename
Validate a CMML file.
 
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
  -b, --verbose  Output parsed file to stdout
  -h, --help     Display this help information
  -v, --version  Display version information
\end{verbatim}
\normalsize


View source code at: {\tt cmml-validate.c} 

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


the size of the print buffer \begin{Desc}
\item[Examples: ]\par
{\bf cmml-parse.c}, {\bf cmml-seek-clip.c}, {\bf cmml-seek-offset.c}, {\bf cmml-seek-utc.c}, {\bf cmml-uri-file.c}, {\bf cmml-validate.c}, and {\bf cmml-write.c}.\end{Desc}


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

\subsection{Function Documentation}
\index{cmml-validate.c@{cmml-validate.c}!PrintUsage@{PrintUsage}}
\index{PrintUsage@{PrintUsage}!cmml-validate.c@{cmml-validate.c}}
\subsubsection[{PrintUsage}]{\setlength{\rightskip}{0pt plus 5cm}static void PrintUsage (char $\ast$ {\em prog})\hspace{0.3cm}{\tt  [static]}}\label{cmml-validate_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}
\begin{Desc}
\item[Examples: ]\par
{\bf cmml-validate.c}.\end{Desc}


Referenced by main().\index{cmml-validate.c@{cmml-validate.c}!read\_\-stream@{read\_\-stream}}
\index{read\_\-stream@{read\_\-stream}!cmml-validate.c@{cmml-validate.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-validate_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}
\begin{Desc}
\item[Examples: ]\par
{\bf cmml-validate.c}.\end{Desc}


References BUFSIZE, cmml\_\-error\_\-snprint(), cmml\_\-get\_\-last\_\-error(), cmml\_\-stream\_\-pretty\_\-snprint(), and verbose.

Referenced by main().\index{cmml-validate.c@{cmml-validate.c}!read\_\-head@{read\_\-head}}
\index{read\_\-head@{read\_\-head}!cmml-validate.c@{cmml-validate.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-validate_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}
\begin{Desc}
\item[Examples: ]\par
{\bf cmml-parse.c}, and {\bf cmml-validate.c}.\end{Desc}


References BUFSIZE, cmml\_\-error\_\-snprint(), cmml\_\-get\_\-last\_\-error(), cmml\_\-head\_\-pretty\_\-snprint(), and verbose.

Referenced by main().\index{cmml-validate.c@{cmml-validate.c}!read\_\-clip@{read\_\-clip}}
\index{read\_\-clip@{read\_\-clip}!cmml-validate.c@{cmml-validate.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-validate_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}
\begin{Desc}
\item[Examples: ]\par
{\bf cmml-seek-clip.c}, {\bf cmml-seek-offset.c}, {\bf cmml-seek-utc.c}, {\bf cmml-uri-file.c}, and {\bf cmml-validate.c}.\end{Desc}


References BUFSIZE, cmml\_\-clip\_\-pretty\_\-snprint(), cmml\_\-error\_\-snprint(), cmml\_\-get\_\-last\_\-error(), and verbose.

Referenced by main().\index{cmml-validate.c@{cmml-validate.c}!main@{main}}
\index{main@{main}!cmml-validate.c@{cmml-validate.c}}
\subsubsection[{main}]{\setlength{\rightskip}{0pt plus 5cm}int main (int {\em argc}, \/  char $\ast$ {\em argv}[$\,$])}\label{cmml-validate_8c_0ddf1224851353fc92bfbff6f499fa97}


main function of cmml-validate, 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. \begin{Desc}
\item[Examples: ]\par
{\bf cmml-parse.c}, {\bf cmml-seek-clip.c}, {\bf cmml-seek-offset.c}, {\bf cmml-seek-utc.c}, {\bf cmml-uri-file.c}, {\bf cmml-validate.c}, and {\bf cmml-write.c}.\end{Desc}


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(), PrintUsage(), read\_\-clip(), read\_\-head(), read\_\-stream(), secs, CMML\_\-Error::type, and verbose.

\subsection{Variable Documentation}
\index{cmml-validate.c@{cmml-validate.c}!verbose@{verbose}}
\index{verbose@{verbose}!cmml-validate.c@{cmml-validate.c}}
\subsubsection[{verbose}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf verbose}\hspace{0.3cm}{\tt  [static]}}\label{cmml-validate_8c_0b2caeb4b6f130be43e5a2f0267dd453}


verbose: turns on printing of parsed CMML file \begin{Desc}
\item[Examples: ]\par
{\bf cmml-validate.c}.\end{Desc}


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