Main Page | Modules | Data Structures | File List | Data Fields | Globals | Examples

cmml-write.c

Writing a CMML file

Although libcmml was created mainly for the purpose of parsing existing CMML files, it also provides rudimentary support for creating CMML files. This basically consists in providing the data structures for the different tags and API functions to print those tags. There is no validation or sequence checking available for the writing side.

The general sequence of API calls is the following:

This procedure is illustrated in cmml-write.c:

/* Copyright (C) 2003 CSIRO Australia Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the CSIRO nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stdio.h> #include <string.h> #include <cmml.h> #define BUFSIZE 100000 int main(int argc, char *argv[]) { CMML_Preamble * pre = NULL; CMML_Head * head = NULL; CMML_Clip * clip = NULL; CMML_Time * start = NULL, * end = NULL; char buf[BUFSIZE]; /* write preamble */ pre = cmml_preamble_new("UTF-8", NULL, NULL, NULL); cmml_preamble_snprint (buf, BUFSIZE, pre); puts(buf); cmml_preamble_destroy(pre); /* write head */ head = cmml_head_new(); head->title = strdup("This is a test file"); cmml_head_snprint (buf, BUFSIZE, head); puts(buf); cmml_head_destroy(head); /* write a clip for the interval 0.6 to 3.5 seconds */ cmml_npt_snprint (buf, BUFSIZE, 0.6); start = cmml_time_new (buf); cmml_npt_snprint (buf, BUFSIZE, 3.5); end = cmml_time_new (buf); clip = cmml_clip_new(start, end); clip->anchor_href = strdup("http://www.annodex.net/"); clip->anchor_text = strdup("hyperlink to annodex.net"); clip->desc_text = strdup("This is a clip"); cmml_clip_snprint (buf, BUFSIZE, clip); puts (buf); cmml_clip_destroy(clip); printf ("</cmml>\n"); exit(0); }
00001 /* Copyright (C) 2003 CSIRO Australia 00002 00003 Redistribution and use in source and binary forms, with or without 00004 modification, are permitted provided that the following conditions 00005 are met: 00006 00007 - Redistributions of source code must retain the above copyright 00008 notice, this list of conditions and the following disclaimer. 00009 00010 - Redistributions in binary form must reproduce the above copyright 00011 notice, this list of conditions and the following disclaimer in the 00012 documentation and/or other materials provided with the distribution. 00013 00014 - Neither the name of the CSIRO nor the names of its 00015 contributors may be used to endorse or promote products derived from 00016 this software without specific prior written permission. 00017 00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00019 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00020 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00021 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR 00022 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00023 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00024 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00025 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00026 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00027 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00028 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 */ 00030 00031 #include <stdio.h> 00032 #include <string.h> 00033 00034 #include <cmml.h> 00035 00045 #define BUFSIZE 100000 00046 00050 int main(int argc, char *argv[]) 00051 { 00052 CMML_Preamble * pre = NULL; 00053 CMML_Head * head = NULL; 00054 CMML_Clip * clip = NULL; 00055 CMML_Time * start = NULL, * end = NULL; 00056 char buf[BUFSIZE]; 00057 00058 /* write preamble */ 00059 pre = cmml_preamble_new("UTF-8", NULL, NULL, NULL); 00060 cmml_preamble_snprint (buf, BUFSIZE, pre); 00061 puts(buf); 00062 cmml_preamble_destroy(pre); 00063 00064 /* write head */ 00065 head = cmml_head_new(); 00066 head->title = strdup("This is a test file"); 00067 cmml_head_snprint (buf, BUFSIZE, head); 00068 puts(buf); 00069 cmml_head_destroy(head); 00070 00071 /* write a clip for the interval 0.6 to 3.5 seconds */ 00072 cmml_npt_snprint (buf, BUFSIZE, 0.6); 00073 start = cmml_time_new (buf); 00074 00075 cmml_npt_snprint (buf, BUFSIZE, 3.5); 00076 end = cmml_time_new (buf); 00077 00078 clip = cmml_clip_new(start, end); 00079 clip->anchor_href = strdup("http://www.annodex.net/"); 00080 clip->anchor_text = strdup("hyperlink to annodex.net"); 00081 clip->desc_text = strdup("This is a clip"); 00082 cmml_clip_snprint (buf, BUFSIZE, clip); 00083 puts (buf); 00084 cmml_clip_destroy(clip); 00085 00086 printf ("</cmml>\n"); 00087 00088 exit(0); 00089 }

Generated on Wed Jul 28 08:04:05 2004 for libcmml by doxygen 1.3.7