libacfutils
A general purpose library of utility functions designed to make it easier to develop addons for the X-Plane flight simulator.
Loading...
Searching...
No Matches
acfutils
riff.h
1
/*
2
* CDDL HEADER START
3
*
4
* The contents of this file are subject to the terms of the
5
* Common Development and Distribution License, Version 1.0 only
6
* (the "License"). You may not use this file except in compliance
7
* with the License.
8
*
9
* You can obtain a copy of the license in the file COPYING
10
* or http://www.opensource.org/licenses/CDDL-1.0.
11
* See the License for the specific language governing permissions
12
* and limitations under the License.
13
*
14
* When distributing Covered Code, include this CDDL HEADER in each
15
* file and include the License file COPYING.
16
* If applicable, add the following below this CDDL HEADER, with the
17
* fields enclosed by brackets "[]" replaced with your own identifying
18
* information: Portions Copyright [yyyy] [name of copyright owner]
19
*
20
* CDDL HEADER END
21
*/
22
/*
23
* Copyright 2017 Saso Kiselkov. All rights reserved.
24
*/
25
26
#ifndef _ACF_UTILS_RIFF_H_
27
#define _ACF_UTILS_RIFF_H_
28
29
#include <stdint.h>
30
31
#include "
list.h
"
32
#include "types.h"
33
34
#ifdef __cplusplus
35
extern
"C"
{
36
#endif
37
38
/*
39
* This macro constructs a 32-bit RIFF chunk ID from a 4-character string
40
* (e.g. FOURCC("WAVE")). The returned 32-bit chunk ID is implicitly in
41
* little endian, since RIFF files are normally little endian. The RIFF
42
* parser performs chunk ID byteswapping internally if it determines that
43
* the file's endianness doesn't match ours, so that direct comparisons
44
* with this macro's output work regardless of machine & file byte order.
45
*/
46
#define FOURCC(str) \
47
((unsigned)((str)[0] | ((str)[1] << 8u) | ((str)[2] << 16u) | \
48
((str)[3] << 24u)))
49
50
typedef
struct
riff_chunk {
51
uint32_t fourcc;
/* In machine-native endian */
52
53
/*
54
* Indicates the file was in reverse endian to the machine's native
55
* byte order. Although the fourcc and listcc fields are in native
56
* order, anything in `data' is left as-is by the parser. So use
57
* this field to determine if you need to byteswap `data' contents.
58
*/
59
bool_t bswap;
60
uint8_t *data;
61
uint32_t datasz;
62
63
/* Populated if fourcc is RIFF_ID or LIST_ID */
64
uint32_t listcc;
/* In machine-native endian */
65
list_t
subchunks;
66
67
list_node_t
node;
68
}
riff_chunk_t
;
69
70
API_EXPORT
void
riff_free_chunk(
riff_chunk_t
*c);
71
API_EXPORT
riff_chunk_t
*riff_parse(uint32_t filetype, uint8_t *buf,
72
size_t
bufsz);
73
API_EXPORT
riff_chunk_t
*riff_find_chunk(
riff_chunk_t
*topchunk, ...);
74
API_EXPORT
char
*riff_dump(
const
riff_chunk_t
*topchunk);
75
76
#ifdef __cplusplus
77
}
78
#endif
79
80
#endif
/* _ACF_UTILS_RIFF_H_ */
list.h
list_node_t
list_t
riff_chunk_t
Definition
riff.h:50
Generated by
1.9.8