cmml-seek-clip.c

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 cmml_skip_to_id() 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:

00001 
00031 #include <stdio.h>
00032 
00033 #include <cmml.h>
00034 
00045 #define BUFSIZE 100000
00046 
00057 static int
00058 read_clip (CMML * cmml, const CMML_Clip * clip, void * user_data) {
00059   puts(clip->desc_text);
00060   return 0;
00061 }
00062 
00069 int main(int argc, char *argv[])
00070 {
00071   char *filename = NULL;
00072   char *clip_id = NULL;
00073   CMML * doc;
00074   long n = 0;
00075 
00076   if (argc < 2) {
00077     fprintf (stderr, "Usage: %s <CMMLfile> <clipID>\n", argv[0]);
00078     exit (1);
00079   }
00080   filename = argv[1];
00081   clip_id = argv[2];
00082   
00083   doc = cmml_open(filename);
00084  
00085   /* seek to clip_id; if not found, to file end */
00086   if (clip_id != NULL) {
00087     cmml_skip_to_id (doc, clip_id);
00088   }
00089 
00090   cmml_set_read_callbacks (doc, NULL, NULL, read_clip, NULL);
00091  
00092   while (((n = cmml_read (doc, BUFSIZE)) > 0));
00093    
00094   cmml_close(doc);
00095 
00096   return 0;
00097 }

Generated on Sun Mar 5 09:58:51 2006 for libcmml by  doxygen 1.4.6