libcmml  0.9.1
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, NULL);
puts(buf);
/* write head */
head = cmml_head_new();
head->title = strdup("This is a test file");
cmml_head_snprint (buf, BUFSIZE, head);
puts(buf);
/* write a clip for the interval 0.6 to 3.5 seconds */
start = cmml_time_new (buf);
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);
printf ("</cmml>\n");
exit(0);
}
cmml_head_destroy
void cmml_head_destroy(CMML_Head *head)
main
int main(int argc, char *argv[])
Definition: cmml-validate.c:212
cmml_preamble_destroy
void cmml_preamble_destroy(CMML_Preamble *preamble)
cmml_clip_snprint
int cmml_clip_snprint(char *buf, int n, CMML_Clip *clip)
BUFSIZE
#define BUFSIZE
Definition: cmml-validate.c:79
cmml_npt_snprint
int cmml_npt_snprint(char *buf, int n, double seconds)
CMML_Clip
Definition: cmml.h:242
cmml_head_new
CMML_Head * cmml_head_new(void)
CMML_Clip::anchor_text
char * anchor_text
Definition: cmml.h:258
cmml_head_snprint
int cmml_head_snprint(char *buf, int n, CMML_Head *head)
cmml_preamble_new
CMML_Preamble * cmml_preamble_new(char *encoding, char *id, char *lang, char *dir, char *granulerate)
cmml.h
cmml_time_new
CMML_Time * cmml_time_new(const char *s)
CMML_Time
Definition: cmml.h:85
CMML_Head::title
char * title
Definition: cmml.h:228
CMML_Preamble
Definition: cmml.h:136
cmml_clip_new
CMML_Clip * cmml_clip_new(CMML_Time *start_time, CMML_Time *end_time)
CMML_Head
Definition: cmml.h:223
cmml_clip_destroy
void cmml_clip_destroy(CMML_Clip *clip)
cmml_preamble_snprint
int cmml_preamble_snprint(char *buf, int n, CMML_Preamble *pre)
CMML_Clip::anchor_href
char * anchor_href
Definition: cmml.h:257
CMML_Clip::desc_text
char * desc_text
Definition: cmml.h:271