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

cmml.h

Go to the documentation of this file.
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 /* cmml.h */ 00032 00033 #ifndef __CMML_H__ 00034 #define __CMML_H__ 00035 00043 #include <stdio.h> 00044 #include <expat.h> 00045 00049 #ifndef _CMML_PRIVATE 00050 typedef void CMML; 00051 #endif 00052 00053 /* ------------------------- TYPES --------------------------------- */ 00054 /* CMML_Time and CMML_List are kept here and not in cmml_private.h */ 00055 /* because the library user may need detailed access to these fields */ 00056 00061 typedef struct { 00062 short tm_hsec; 00063 short tm_sec; 00064 short tm_min; 00065 short tm_hour; 00066 short tm_mday; 00067 short tm_mon; 00068 short tm_year; 00070 } CMML_UTC; 00071 00075 typedef enum _CMML_Time_Type { 00076 CMML_SEC_TIME, 00077 CMML_UTC_TIME 00078 } CMML_Time_Type; 00079 00080 00085 typedef struct { 00086 char *tstr; 00087 CMML_Time_Type type; 00089 union { 00090 CMML_UTC * utc; 00091 double sec; 00092 } t; 00093 } CMML_Time ; 00094 00095 00099 typedef struct _CMML_List CMML_List; 00100 00106 struct _CMML_List { 00107 CMML_List * prev; 00108 CMML_List * next; 00109 void * data; 00110 }; 00111 00115 typedef void * (*CMML_CloneFunc) (void * data); 00116 00120 typedef void * (*CMML_FreeFunc) (void * data); 00121 00129 typedef int (*CMML_CmpFunc) (void * cmp_ctx, void * s1, void * s2); 00130 00131 00137 typedef struct { 00138 char *xml_version; 00139 char *xml_encoding; 00140 int xml_standalone; 00141 int doctype_declared; 00142 char *cmml_lang; 00143 char *cmml_dir; 00144 char *cmml_id; 00145 char *cmml_xmlns; 00146 char *cmml_granulerate; 00147 } CMML_Preamble; 00148 00149 00154 typedef struct { 00155 char *id; 00156 char *name; 00157 char *value; 00158 } CMML_ParamElement; 00159 00163 typedef struct { 00164 char *id; 00165 char *lang; 00166 char *dir; 00167 char *granulerate; 00168 char *contenttype; 00169 char *src; 00170 CMML_Time * start_time; 00171 CMML_Time * end_time; 00172 char *title; 00173 CMML_List * param; 00175 } CMML_ImportElement; 00176 00183 typedef struct { 00184 char *id; 00185 CMML_Time * basetime; 00186 CMML_Time * utc; 00187 CMML_List * import; 00188 } CMML_Stream; 00189 00190 00195 typedef struct { 00196 char *id; 00197 char *lang; 00198 char *dir; 00199 char *name; 00200 char *content; 00201 char *scheme; 00202 } CMML_MetaElement; 00203 00208 typedef struct { 00209 char *id; 00210 char *link_class; 00211 char *title; 00212 char *lang; 00213 char *dir; 00214 char *href; 00215 char *type; 00216 char *rel; 00217 char *rev; 00218 char *media; 00219 } CMML_LinkElement; 00220 00224 typedef struct { 00225 char *head_id; 00226 char *lang; 00227 char *dir; 00228 char *profile; 00229 char *title; 00230 char *title_id; 00231 char *title_lang; 00232 char *title_dir; 00233 char *base_id; 00234 char *base_href; 00235 CMML_List * meta; 00236 CMML_List * link; 00237 } CMML_Head; 00238 00239 00243 typedef struct { 00244 char *clip_id; 00245 char *clip_class; 00246 char *title; 00247 char *lang; 00248 char *dir; 00249 char *track; 00250 CMML_Time *start_time; 00251 CMML_Time *end_time; 00252 CMML_List * meta; 00253 char *anchor_id; 00254 char *anchor_class; 00255 char *anchor_title; 00256 char *anchor_lang; 00257 char *anchor_dir; 00258 char *anchor_href; 00259 char *anchor_text; 00260 char *img_id; 00261 char *img_class; 00262 char *img_title; 00263 char *img_lang; 00264 char *img_dir; 00265 char *img_src; 00266 char *img_alt; 00267 char *desc_id; 00268 char *desc_class; 00269 char *desc_title; 00270 char *desc_lang; 00271 char *desc_dir; 00272 char *desc_text; 00273 } CMML_Clip; 00274 00279 typedef enum _CMML_Element_Type { 00280 CMML_NONE, 00281 CMML_CMML, 00282 CMML_STREAM, 00283 CMML_IMPORT, 00284 CMML_HEAD, 00285 CMML_CLIP 00286 } CMML_Element_Type; 00287 00288 00294 typedef struct { 00295 CMML_Element_Type type; 00297 union { 00298 CMML_Stream * stream; 00299 CMML_Head * head; 00300 CMML_Clip * clip; 00301 } e; 00302 } CMML_Element; 00303 00304 00313 typedef enum _CMML_Error_Type { 00314 /* general processing feedback */ 00315 CMML_OK, 00316 CMML_EOF, 00317 /* fatal errors */ 00318 CMML_READ_ERROR, 00319 CMML_TIME_ERROR, 00320 CMML_MALLOC_ERROR, 00321 CMML_EXPAT_ERROR, 00322 CMML_PARSE_ERROR, 00323 CMML_NO_CMML_TAG, 00324 CMML_NO_HEAD_TAG, 00325 CMML_STREAM_NOT_FIRST, 00326 CMML_HEAD_AFTER_CLIP, 00327 CMML_DUPLICATE_STREAM, 00328 CMML_DUPLICATE_HEAD, 00329 /* sloppy errors */ 00330 CMML_FORMAT_ERROR, 00331 CMML_UNKNOWN_TAG, 00332 CMML_TAG_IGNORED, 00333 CMML_XMLNS_REDEFINED, 00334 CMML_NONSEQUENTIAL_CLIP 00335 } CMML_Error_Type; 00336 00341 typedef struct { 00342 CMML_Error_Type type; 00343 long line; 00344 long col; 00345 } CMML_Error; 00346 00358 typedef int (*CMMLReadStream) (CMML *cmml, const CMML_Stream *stream, 00359 void * user_data); 00371 typedef int (*CMMLReadHead) (CMML *cmml, const CMML_Head *head, 00372 void * user_data); 00373 00385 typedef int (*CMMLReadClip) (CMML *cmml, const CMML_Clip *clip, 00386 void * user_data); 00387 00388 00389 /* ---------------------- API --------------------------------*/ 00390 00391 /* --------------------------------- * 00392 * CMML parsing: functions in cmml.c * 00393 * --------------------------------- */ 00394 00405 CMML * cmml_open (char *XMLfilename); 00406 00418 CMML * cmml_new (FILE * file); 00419 00428 FILE * cmml_destroy (CMML * cmml); 00429 00438 CMML * cmml_close (CMML * cmml); 00439 00455 int cmml_set_read_callbacks (CMML *cmml, 00456 CMMLReadStream read_stream, 00457 CMMLReadHead read_head, 00458 CMMLReadClip read_clip, 00459 void * user_data); 00460 00473 long cmml_read (CMML *cmml, long n); /* file */ 00474 00484 void cmml_set_sloppy (CMML *cmml, int value); 00485 00494 CMML_Preamble * cmml_get_preamble (CMML *cmml); 00495 00504 CMML_Stream * cmml_get_last_stream (CMML *cmml); 00505 00514 CMML_Head * cmml_get_last_head (CMML *cmml); 00515 00524 CMML_Clip * cmml_get_last_clip (CMML *cmml); 00525 00535 CMML_Clip * cmml_get_previous_clip (CMML *cmml); 00536 00546 CMML_Error * cmml_get_last_error (CMML * cmml); 00547 00548 00554 void cmml_error_clear (CMML * cmml); 00555 00566 int cmml_set_window (CMML * cmml, CMML_Time * start, CMML_Time * end); 00567 00577 double cmml_skip_to_secs (CMML *cmml, double seconds); 00578 00588 double cmml_skip_to_utc (CMML *cmml, const char * utc); 00589 00599 double cmml_skip_to_id (CMML *cmml, const char * id); 00600 00610 double cmml_skip_to_offset (CMML *cmml, const char * offset); 00611 00612 00613 /* ---------------------------------------------------- * 00614 * CMML element handling: cmml_element.c cmml_snprint.c * 00615 * ---------------------------------------------------- */ 00616 00628 CMML_Preamble * cmml_preamble_new (char *encoding, char *id, char *lang, char *dir, char *granulerate); 00629 00637 CMML_Element * cmml_element_new (CMML_Element_Type type); 00638 00644 CMML_Stream * cmml_stream_new (void); 00645 00651 CMML_Head * cmml_head_new (void); 00652 00661 CMML_Clip * cmml_clip_new (CMML_Time *start_time, CMML_Time *end_time); 00662 00670 CMML_Error * cmml_error_new (CMML_Error_Type type); 00671 00679 CMML_Preamble * cmml_preamble_clone (CMML_Preamble * src); 00680 00688 CMML_Element * cmml_element_clone (CMML_Element * src); 00689 00697 CMML_Stream * cmml_stream_clone (CMML_Stream * src); 00698 00706 CMML_Head * cmml_head_clone (CMML_Head * src); 00707 00715 CMML_Clip * cmml_clip_clone (CMML_Clip * src); 00716 00723 void cmml_preamble_destroy (CMML_Preamble *preamble); 00724 00731 void cmml_element_destroy (CMML_Element *element); 00732 00738 void cmml_stream_destroy (CMML_Stream *stream); 00739 00745 void cmml_head_destroy (CMML_Head *head); 00746 00752 void cmml_clip_destroy (CMML_Clip *clip); 00753 00759 void cmml_error_destroy (CMML_Error *error); 00760 00772 int cmml_preamble_snprint(char *buf, int n, CMML_Preamble *pre); 00773 00786 int cmml_element_snprint (char *buf, int n, CMML_Element *elem); 00787 00798 int cmml_stream_snprint (char *buf, int n, CMML_Stream *stream); 00799 00810 int cmml_stream_pretty_snprint (char *buf, int n, CMML_Stream *stream); 00811 00822 int cmml_head_snprint (char *buf, int n, CMML_Head *head); 00823 00834 int cmml_head_pretty_snprint (char *buf, int n, CMML_Head *head); 00835 00846 int cmml_clip_snprint (char *buf, int n, CMML_Clip *clip); 00847 00858 int cmml_clip_pretty_snprint (char *buf, int n, CMML_Clip *clip); 00859 00871 int cmml_error_snprint (char *buf, int n, CMML_Error *error, CMML *cmml); 00872 00873 00874 /* ----------------------------------------------- * 00875 * helper functions for list handling: cmml_list.c * 00876 * ----------------------------------------------- */ 00877 00883 CMML_List * cmml_list_new (void); 00884 00892 CMML_List * cmml_list_clone (CMML_List * list); 00893 00902 CMML_List * cmml_list_clone_with (CMML_List * list, CMML_CloneFunc clone); 00903 00911 CMML_List * cmml_list_tail (CMML_List * list); 00912 00921 CMML_List * cmml_list_prepend (CMML_List * list, void * data); 00922 00931 CMML_List * cmml_list_append (CMML_List * list, void * data); 00932 00943 CMML_List * cmml_list_add_before (CMML_List * list, void * data, 00944 CMML_List * node); 00955 CMML_List * cmml_list_add_after (CMML_List * list, void * data, 00956 CMML_List * node); 00957 00966 CMML_List * cmml_list_find (CMML_List * list, void * data); 00967 00976 CMML_List * cmml_list_remove (CMML_List * list, CMML_List * node); 00977 00985 int cmml_list_length (CMML_List * list); 00986 00994 int cmml_list_is_empty (CMML_List * list); 00995 01004 int cmml_list_is_singleton (CMML_List * list); 01005 01015 CMML_List * cmml_list_free_with (CMML_List * list, 01016 CMML_FreeFunc free_func); 01017 01026 CMML_List * cmml_list_free (CMML_List * list); 01027 01028 01029 /* ----------------------------------------------- * 01030 * helper functions for time handling: cmml_time.c * 01031 * ----------------------------------------------- */ 01032 01041 CMML_Time * cmml_time_new (const char * s); 01042 01050 CMML_Time * cmml_sec_new (const char * s); 01051 01059 CMML_Time * cmml_time_new_secs (double seconds); 01060 01068 CMML_Time * cmml_utc_new (const char * s); 01069 01083 int cmml_time_interval_new (const char * s, 01084 CMML_Time ** t_start, CMML_Time ** t_end); 01085 01097 CMML_Time *cmml_time_new_in_sec (const char * s, CMML_Time * ref, double base); 01098 01109 CMML_Time *cmml_time_utc_to_sec (CMML_Time * t, CMML_Time * ref, double base); 01110 01116 void cmml_time_free (CMML_Time *t); 01117 01125 CMML_Time * cmml_time_clone (CMML_Time *t); 01126 01134 double cmml_sec_parse (const char *s); 01135 01144 CMML_UTC * cmml_utc_parse (const char * s); 01145 01153 CMML_UTC * cmml_utc_clone (CMML_UTC *t); 01154 01164 double cmml_utc_diff (CMML_UTC *t2, CMML_UTC *t1); 01165 01176 int cmml_npt_snprint (char * buf, int n, double seconds); 01177 01188 int cmml_utc_snprint (char *buf, int n, CMML_UTC *t); 01189 01200 int cmml_utc_pretty_snprint (char *buf, int n, CMML_UTC *t); 01201 01202 01203 01204 #endif /* __CMML_H__ */

Generated on Tue Mar 14 20:59:54 2006 for libcmml by doxygen 1.3.8