\section{cmml-seek-clip.c}
{\bf Seeking to an clip in a CMML file}

Sometimes you don't want to access all the clips available in a CMML file, but only a specific one. libcmml provides an API for this functionality through the \doxyref{cmml\_\-skip\_\-to\_\-id()}{p.}{cmml_8h_060dfeda7d92b6a63817daa00ec9b694} function.

The procedure is illustrated in cmml-seek-clip.c, which seeks to a clip of a given name and if found prints out the descriptions of this and all the following clips:



\begin{DocInclude}\begin{verbatim}
#include <stdio.h>

#include <cmml.h>

#define BUFSIZE 100000

static int
read_clip (CMML * cmml, const CMML_Clip * clip, void * user_data) {
  puts(clip->desc_text);
  return 0;
}

int main(int argc, char *argv[])
{
  char *filename = NULL;
  char *clip_id = NULL;
  CMML * doc;
  long n = 0;

  if (argc < 2) {
    fprintf (stderr, "Usage: %s <CMMLfile> <clipID>\n", argv[0]);
    exit (1);
  }
  filename = argv[1];
  clip_id = argv[2];
  
  doc = cmml_open(filename);
 
  /* seek to clip_id; if not found, to file end */
  if (clip_id != NULL) {
    cmml_skip_to_id (doc, clip_id);
  }

  cmml_set_read_callbacks (doc, NULL, NULL, read_clip, NULL);
 
  while (((n = cmml_read (doc, BUFSIZE)) > 0));
   
  cmml_close(doc);

  return 0;
}
\end{verbatim}
\end{DocInclude}
 