libcmml
0.9.1
Main Page
Modules
Data Structures
Files
Examples
File List
Globals
src
cmml.h
Go to the documentation of this file.
1
/* Copyright (C) 2003 CSIRO Australia
2
3
Redistribution and use in source and binary forms, with or without
4
modification, are permitted provided that the following conditions
5
are met:
6
7
- Redistributions of source code must retain the above copyright
8
notice, this list of conditions and the following disclaimer.
9
10
- Redistributions in binary form must reproduce the above copyright
11
notice, this list of conditions and the following disclaimer in the
12
documentation and/or other materials provided with the distribution.
13
14
- Neither the name of the CSIRO nor the names of its
15
contributors may be used to endorse or promote products derived from
16
this software without specific prior written permission.
17
18
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
22
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31
/* cmml.h */
32
33
#ifndef __CMML_H__
34
#define __CMML_H__
35
43
#include <stdio.h>
44
#include <expat.h>
45
49
#ifndef _CMML_PRIVATE
50
typedef
void
CMML
;
51
#endif
52
53
/* ------------------------- TYPES --------------------------------- */
54
/* CMML_Time and CMML_List are kept here and not in cmml_private.h */
55
/* because the library user may need detailed access to these fields */
56
61
typedef
struct
{
62
short
tm_hsec
;
63
short
tm_sec
;
64
short
tm_min
;
65
short
tm_hour
;
66
short
tm_mday
;
67
short
tm_mon
;
68
short
tm_year
;
70
}
CMML_UTC
;
71
75
typedef
enum
_CMML_Time_Type
{
76
CMML_SEC_TIME
,
77
CMML_UTC_TIME
78
}
CMML_Time_Type
;
79
80
85
typedef
struct
{
86
char
*
tstr
;
87
CMML_Time_Type
type
;
89
union
{
90
CMML_UTC
*
utc
;
91
double
sec
;
92
} t;
93
}
CMML_Time
;
94
95
99
typedef
struct
_CMML_List
CMML_List
;
105
struct
_CMML_List
{
106
CMML_List
*
prev
;
107
CMML_List
*
next
;
108
void
*
data
;
109
};
110
114
typedef
void
* (*CMML_CloneFunc) (
void
* data);
115
119
typedef
void
* (*CMML_FreeFunc) (
void
* data);
120
128
typedef
int (*
CMML_CmpFunc
) (
void
* cmp_ctx,
void
* s1,
void
* s2);
129
130
136
typedef
struct
{
137
char
*
xml_version
;
138
char
*
xml_encoding
;
139
int
xml_standalone
;
140
int
doctype_declared
;
141
char
*
cmml_lang
;
142
char
*
cmml_dir
;
143
char
*
cmml_id
;
144
char
*
cmml_xmlns
;
145
char
*
cmml_granulerate
;
146
}
CMML_Preamble
;
147
148
153
typedef
struct
{
154
char
*
id
;
155
char
*
name
;
156
char
*
value
;
157
}
CMML_ParamElement
;
158
162
typedef
struct
{
163
char
*
id
;
164
char
*
lang
;
165
char
*
dir
;
166
char
*
granulerate
;
167
char
*
contenttype
;
168
char
*
src
;
169
CMML_Time
*
start_time
;
170
CMML_Time
*
end_time
;
171
char
*
title
;
172
CMML_List
*
param
;
174
}
CMML_ImportElement
;
175
182
typedef
struct
{
183
char
*
id
;
184
CMML_Time
*
basetime
;
185
CMML_Time
*
utc
;
186
CMML_List
*
import
;
187
}
CMML_Stream
;
188
189
194
typedef
struct
{
195
char
*
id
;
196
char
*
lang
;
197
char
*
dir
;
198
char
*
name
;
199
char
*
content
;
200
char
*
scheme
;
201
}
CMML_MetaElement
;
202
207
typedef
struct
{
208
char
*
id
;
209
char
*
class
;
210
char
*
title
;
211
char
*
lang
;
212
char
*
dir
;
213
char
*
href
;
214
char
*
type
;
215
char
*
rel
;
216
char
*
rev
;
217
char
*
media
;
218
}
CMML_LinkElement
;
219
223
typedef
struct
{
224
char
*
head_id
;
225
char
*
lang
;
226
char
*
dir
;
227
char
*
profile
;
228
char
*
title
;
229
char
*
title_id
;
230
char
*
title_lang
;
231
char
*
title_dir
;
232
char
*
base_id
;
233
char
*
base_href
;
234
CMML_List
*
meta
;
235
CMML_List
*
link
;
236
}
CMML_Head
;
237
238
242
typedef
struct
{
243
char
*
clip_id
;
244
char
*
class
;
245
char
*
title
;
246
char
*
lang
;
247
char
*
dir
;
248
char
*
track
;
249
CMML_Time
*
start_time
;
250
CMML_Time
*
end_time
;
251
CMML_List
*
meta
;
252
char
*
anchor_id
;
253
char
*
anchor_class
;
254
char
*
anchor_title
;
255
char
*
anchor_lang
;
256
char
*
anchor_dir
;
257
char
*
anchor_href
;
258
char
*
anchor_text
;
259
char
*
img_id
;
260
char
*
img_class
;
261
char
*
img_title
;
262
char
*
img_lang
;
263
char
*
img_dir
;
264
char
*
img_src
;
265
char
*
img_alt
;
266
char
*
desc_id
;
267
char
*
desc_class
;
268
char
*
desc_title
;
269
char
*
desc_lang
;
270
char
*
desc_dir
;
271
char
*
desc_text
;
272
}
CMML_Clip
;
273
278
typedef
enum
_CMML_Element_Type
{
279
CMML_NONE
,
280
CMML_CMML
,
281
CMML_STREAM
,
282
CMML_IMPORT
,
283
CMML_HEAD
,
284
CMML_CLIP
285
}
CMML_Element_Type
;
286
287
293
typedef
struct
{
294
CMML_Element_Type
type
;
296
union
{
297
CMML_Stream
*
stream
;
298
CMML_Head
*
head
;
299
CMML_Clip
*
clip
;
300
} e;
301
}
CMML_Element
;
302
303
312
typedef
enum
_CMML_Error_Type
{
313
/* general processing feedback */
314
CMML_OK
,
315
CMML_EOF
,
316
/* fatal errors */
317
CMML_READ_ERROR
,
318
CMML_TIME_ERROR
,
319
CMML_MALLOC_ERROR
,
320
CMML_EXPAT_ERROR
,
321
CMML_PARSE_ERROR
,
322
CMML_NO_CMML_TAG
,
323
CMML_NO_HEAD_TAG
,
324
CMML_STREAM_NOT_FIRST
,
325
CMML_HEAD_AFTER_CLIP
,
326
CMML_DUPLICATE_STREAM
,
327
CMML_DUPLICATE_HEAD
,
328
/* sloppy errors */
329
CMML_FORMAT_ERROR
,
330
CMML_UNKNOWN_TAG
,
331
CMML_TAG_IGNORED
,
332
CMML_XMLNS_REDEFINED
,
333
CMML_NONSEQUENTIAL_CLIP
334
}
CMML_Error_Type
;
335
340
typedef
struct
{
341
CMML_Error_Type
type
;
342
long
line
;
343
long
col
;
344
}
CMML_Error
;
345
357
typedef
int (*
CMMLReadStream
) (
CMML
*cmml,
const
CMML_Stream
*stream,
358
void
* user_data);
370
typedef
int (*
CMMLReadHead
) (
CMML
*cmml,
const
CMML_Head
*head,
371
void
* user_data);
372
384
typedef
int (*
CMMLReadClip
) (
CMML
*cmml,
const
CMML_Clip
*clip,
385
void
* user_data);
386
387
388
/* ---------------------- API --------------------------------*/
389
390
/* --------------------------------- *
391
* CMML parsing: functions in cmml.c *
392
* --------------------------------- */
393
404
CMML
*
cmml_open
(
char
*XMLfilename);
405
417
CMML
*
cmml_new
(FILE * file);
418
427
FILE *
cmml_destroy
(
CMML
* cmml);
428
437
CMML
*
cmml_close
(
CMML
* cmml);
438
454
int
cmml_set_read_callbacks
(
CMML
*cmml,
455
CMMLReadStream
read_stream
,
456
CMMLReadHead
read_head
,
457
CMMLReadClip
read_clip
,
458
void
* user_data);
459
472
long
cmml_read
(
CMML
*cmml,
long
n);
/* file */
473
483
void
cmml_set_sloppy
(
CMML
*cmml,
int
value);
484
493
CMML_Preamble
*
cmml_get_preamble
(
CMML
*cmml);
494
503
CMML_Stream
*
cmml_get_last_stream
(
CMML
*cmml);
504
513
CMML_Head
*
cmml_get_last_head
(
CMML
*cmml);
514
523
CMML_Clip
*
cmml_get_last_clip
(
CMML
*cmml);
524
534
CMML_Clip
*
cmml_get_previous_clip
(
CMML
*cmml);
535
545
CMML_Error
*
cmml_get_last_error
(
CMML
* cmml);
546
547
553
void
cmml_error_clear
(
CMML
* cmml);
554
565
int
cmml_set_window
(
CMML
* cmml,
CMML_Time
* start,
CMML_Time
* end);
566
576
double
cmml_skip_to_secs
(
CMML
*cmml,
double
seconds);
577
587
double
cmml_skip_to_utc
(
CMML
*cmml,
const
char
* utc);
588
598
double
cmml_skip_to_id
(
CMML
*cmml,
const
char
*
id
);
599
609
double
cmml_skip_to_offset
(
CMML
*cmml,
const
char
* offset);
610
611
612
/* ---------------------------------------------------- *
613
* CMML element handling: cmml_element.c cmml_snprint.c *
614
* ---------------------------------------------------- */
615
627
CMML_Preamble
*
cmml_preamble_new
(
char
*encoding,
char
*
id
,
char
*lang,
char
*dir,
char
*granulerate);
628
636
CMML_Element
*
cmml_element_new
(
CMML_Element_Type
type);
637
643
CMML_Stream
*
cmml_stream_new
(
void
);
644
650
CMML_Head
*
cmml_head_new
(
void
);
651
660
CMML_Clip
*
cmml_clip_new
(
CMML_Time
*start_time,
CMML_Time
*end_time);
661
669
CMML_Error
*
cmml_error_new
(
CMML_Error_Type
type);
670
678
CMML_Preamble
*
cmml_preamble_clone
(
CMML_Preamble
* src);
679
687
CMML_Element
*
cmml_element_clone
(
CMML_Element
* src);
688
696
CMML_Stream
*
cmml_stream_clone
(
CMML_Stream
* src);
697
705
CMML_Head
*
cmml_head_clone
(
CMML_Head
* src);
706
714
CMML_Clip
*
cmml_clip_clone
(
CMML_Clip
* src);
715
722
void
cmml_preamble_destroy
(
CMML_Preamble
*preamble);
723
730
void
cmml_element_destroy
(
CMML_Element
*element);
731
737
void
cmml_stream_destroy
(
CMML_Stream
*stream);
738
744
void
cmml_head_destroy
(
CMML_Head
*head);
745
751
void
cmml_clip_destroy
(
CMML_Clip
*clip);
752
758
void
cmml_error_destroy
(
CMML_Error
*error);
759
771
int
cmml_preamble_snprint
(
char
*buf,
int
n,
CMML_Preamble
*pre);
772
785
int
cmml_element_snprint
(
char
*buf,
int
n,
CMML_Element
*elem);
786
797
int
cmml_stream_snprint
(
char
*buf,
int
n,
CMML_Stream
*stream);
798
809
int
cmml_stream_pretty_snprint
(
char
*buf,
int
n,
CMML_Stream
*stream);
810
821
int
cmml_head_snprint
(
char
*buf,
int
n,
CMML_Head
*head);
822
833
int
cmml_head_pretty_snprint
(
char
*buf,
int
n,
CMML_Head
*head);
834
845
int
cmml_clip_snprint
(
char
*buf,
int
n,
CMML_Clip
*clip);
846
857
int
cmml_clip_pretty_snprint
(
char
*buf,
int
n,
CMML_Clip
*clip);
858
870
int
cmml_error_snprint
(
char
*buf,
int
n,
CMML_Error
*error,
CMML
*cmml);
871
872
873
/* ----------------------------------------------- *
874
* helper functions for list handling: cmml_list.c *
875
* ----------------------------------------------- */
876
882
CMML_List
*
cmml_list_new
(
void
);
883
891
CMML_List
*
cmml_list_clone
(
CMML_List
* list);
892
901
CMML_List
*
cmml_list_clone_with
(
CMML_List
* list,
CMML_CloneFunc
clone);
902
910
CMML_List
*
cmml_list_tail
(
CMML_List
* list);
911
920
CMML_List
*
cmml_list_prepend
(
CMML_List
* list,
void
* data);
921
930
CMML_List
*
cmml_list_append
(
CMML_List
* list,
void
* data);
931
942
CMML_List
*
cmml_list_add_before
(
CMML_List
* list,
void
* data,
943
CMML_List
* node);
954
CMML_List
*
cmml_list_add_after
(
CMML_List
* list,
void
* data,
955
CMML_List
* node);
956
965
CMML_List
*
cmml_list_find
(
CMML_List
* list,
void
* data);
966
975
CMML_List
*
cmml_list_remove
(
CMML_List
* list,
CMML_List
* node);
976
984
int
cmml_list_length
(
CMML_List
* list);
985
993
int
cmml_list_is_empty
(
CMML_List
* list);
994
1003
int
cmml_list_is_singleton
(
CMML_List
* list);
1004
1014
CMML_List
*
cmml_list_free_with
(
CMML_List
* list,
1015
CMML_FreeFunc
free_func);
1016
1025
CMML_List
*
cmml_list_free
(
CMML_List
* list);
1026
1027
1028
/* ----------------------------------------------- *
1029
* helper functions for time handling: cmml_time.c *
1030
* ----------------------------------------------- */
1031
1040
CMML_Time
*
cmml_time_new
(
const
char
* s);
1041
1049
CMML_Time
*
cmml_sec_new
(
const
char
* s);
1050
1058
CMML_Time
*
cmml_time_new_secs
(
double
seconds);
1059
1067
CMML_Time
*
cmml_utc_new
(
const
char
* s);
1068
1082
int
cmml_time_interval_new
(
const
char
* s,
1083
CMML_Time
** t_start,
CMML_Time
** t_end);
1084
1096
CMML_Time
*
cmml_time_new_in_sec
(
const
char
* s,
CMML_Time
* ref,
double
base);
1097
1108
CMML_Time
*
cmml_time_utc_to_sec
(
CMML_Time
* t,
CMML_Time
* ref,
double
base);
1109
1115
void
cmml_time_free
(
CMML_Time
*t);
1116
1124
CMML_Time
*
cmml_time_clone
(
CMML_Time
*t);
1125
1133
double
cmml_sec_parse
(
const
char
*s);
1134
1143
CMML_UTC
*
cmml_utc_parse
(
const
char
* s);
1144
1152
CMML_UTC
*
cmml_utc_clone
(
CMML_UTC
*t);
1153
1163
double
cmml_utc_diff
(
CMML_UTC
*t2,
CMML_UTC
*t1);
1164
1175
int
cmml_npt_snprint
(
char
* buf,
int
n,
double
seconds);
1176
1187
int
cmml_utc_snprint
(
char
*buf,
int
n,
CMML_UTC
*t);
1188
1199
int
cmml_utc_pretty_snprint
(
char
*buf,
int
n,
CMML_UTC
*t);
1200
1201
1202
1203
#endif
/* __CMML_H__ */
Generated by
1.8.4