\section{cmml-timeshift.c File Reference}
\label{cmml-timeshift_8c}\index{cmml-timeshift.c@{cmml-timeshift.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}
\item 
static double {\bf secs}
\end{CompactItemize}


\subsection{Detailed Description}
cmml-timeshift: parses a CMML instance document and applies a timeshift to all the clip tags.



\footnotesize\begin{verbatim}
Usage: cmml-timeshift [options] filename
Apply a timeshift to all the clip tags.
 
Possible options:
  -s offset, --sec offset
                 Specify the offset in seconds to add to clip tags
  -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-timeshift.c@{cmml-timeshift.c}!BUFSIZE@{BUFSIZE}}
\index{BUFSIZE@{BUFSIZE}!cmml-timeshift.c@{cmml-timeshift.c}}
\subsubsection[{BUFSIZE}]{\setlength{\rightskip}{0pt plus 5cm}\#define BUFSIZE~100000}\label{cmml-timeshift_8c_eca034f67218340ecb2261a22c2f3dcd}


the size of the print buffer 

\subsection{Function Documentation}
\index{cmml-timeshift.c@{cmml-timeshift.c}!PrintUsage@{PrintUsage}}
\index{PrintUsage@{PrintUsage}!cmml-timeshift.c@{cmml-timeshift.c}}
\subsubsection[{PrintUsage}]{\setlength{\rightskip}{0pt plus 5cm}static void PrintUsage (char $\ast$ {\em prog})\hspace{0.3cm}{\tt  [static]}}\label{cmml-timeshift_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-timeshift.c@{cmml-timeshift.c}!read\_\-stream@{read\_\-stream}}
\index{read\_\-stream@{read\_\-stream}!cmml-timeshift.c@{cmml-timeshift.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-timeshift_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-timeshift.c@{cmml-timeshift.c}!read\_\-head@{read\_\-head}}
\index{read\_\-head@{read\_\-head}!cmml-timeshift.c@{cmml-timeshift.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-timeshift_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-timeshift.c@{cmml-timeshift.c}!read\_\-clip@{read\_\-clip}}
\index{read\_\-clip@{read\_\-clip}!cmml-timeshift.c@{cmml-timeshift.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-timeshift_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\_\-clone(), cmml\_\-clip\_\-destroy(), cmml\_\-clip\_\-pretty\_\-snprint(), cmml\_\-error\_\-snprint(), cmml\_\-get\_\-last\_\-error(), cmml\_\-sec\_\-parse(), cmml\_\-time\_\-free(), cmml\_\-time\_\-new\_\-secs(), CMML\_\-Clip::end\_\-time, outfile, CMML\_\-Time::sec, secs, CMML\_\-Clip::start\_\-time, CMML\_\-Time::t, and CMML\_\-Time::tstr.\index{cmml-timeshift.c@{cmml-timeshift.c}!main@{main}}
\index{main@{main}!cmml-timeshift.c@{cmml-timeshift.c}}
\subsubsection[{main}]{\setlength{\rightskip}{0pt plus 5cm}int main (int {\em argc}, \/  char $\ast$ {\em argv}[$\,$])}\label{cmml-timeshift_8c_0ddf1224851353fc92bfbff6f499fa97}


main function of cmml-timeshift, 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(), outfile, PrintUsage(), read\_\-clip(), read\_\-head(), read\_\-stream(), secs, and CMML\_\-Error::type.

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


outfile: defines FILE pointer to print output to \index{cmml-timeshift.c@{cmml-timeshift.c}!secs@{secs}}
\index{secs@{secs}!cmml-timeshift.c@{cmml-timeshift.c}}
\subsubsection[{secs}]{\setlength{\rightskip}{0pt plus 5cm}double {\bf secs}\hspace{0.3cm}{\tt  [static]}}\label{cmml-timeshift_8c_be6b5584e7a3ed004c5fe762a72e427a}


secs: number of seconds to offset the clip start/end times \begin{Desc}
\item[Examples: ]\par
{\bf cmml-validate.c}.\end{Desc}


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