libacfutils
A general purpose library of utility functions designed to make it easier to develop addons for the X-Plane flight simulator.
|
Go to the source code of this file.
Data Structures | |
struct | dsf_prop_t |
struct | dsf_prop_atom_t |
struct | dsf_demi_atom_t |
struct | dsf_planar_atom_t |
struct | dsf_atom_t |
struct | dsf_t |
struct | dsf_lookup_t |
struct | dsf_cmd_parser_t |
struct | dsf_idx_rng_arg_t |
struct | dsf_indices_arg_t |
struct | dsf_indices_xpool_arg_t |
struct | dsf_poly_arg_t |
struct | dsf_poly_rng_arg_t |
struct | dsf_flags_n_lod_arg_t |
struct | dsf_comment_arg_t |
Macros | |
#define | DSF_ATOM(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) |
#define | DSF_ATOM_HEAD DSF_ATOM('H', 'E', 'A', 'D') |
#define | DSF_ATOM_PROP DSF_ATOM('P', 'R', 'O', 'P') |
#define | DSF_ATOM_DEFN DSF_ATOM('D', 'E', 'F', 'N') |
#define | DSF_ATOM_TERT DSF_ATOM('T', 'E', 'R', 'T') |
#define | DSF_ATOM_OBJT DSF_ATOM('O', 'B', 'J', 'T') |
#define | DSF_ATOM_POLY DSF_ATOM('P', 'O', 'L', 'Y') |
#define | DSF_ATOM_NEWT DSF_ATOM('N', 'E', 'T', 'W') |
#define | DSF_ATOM_DEMN DSF_ATOM('D', 'E', 'M', 'N') |
#define | DSF_ATOM_GEOD DSF_ATOM('G', 'E', 'O', 'D') |
#define | DSF_ATOM_POOL DSF_ATOM('P', 'O', 'O', 'L') |
#define | DSF_ATOM_SCAL DSF_ATOM('S', 'C', 'A', 'L') |
#define | DSF_ATOM_PO32 DSF_ATOM('P', 'O', '3', '2') |
#define | DSF_ATOM_SC32 DSF_ATOM('S', 'C', '3', '2') |
#define | DSF_ATOM_DEMS DSF_ATOM('D', 'E', 'M', 'S') |
#define | DSF_ATOM_DEMI DSF_ATOM('D', 'E', 'M', 'I') |
#define | DSF_ATOM_DEMD DSF_ATOM('D', 'E', 'M', 'D') |
#define | DSF_ATOM_CMDS DSF_ATOM('C', 'M', 'D', 'S') |
#define | DSF_ATOM_ID_PRINTF(atom) |
Typedefs | |
typedef void(* | dsf_cmd_cb_t) (dsf_cmd_t cmd, const void *cmd_args, const dsf_cmd_parser_t *parser) |
Functions | |
dsf_t * | dsf_init (const char *filename) |
dsf_t * | dsf_parse (uint8_t *buf, size_t bufsz, char reason[DSF_REASON_SZ]) |
void | dsf_fini (dsf_t *dsf) |
char * | dsf_dump (const dsf_t *dsf) |
const dsf_atom_t * | dsf_lookup (const dsf_t *dsf,...) |
const dsf_atom_t * | dsf_lookup_v (const dsf_t *dsf, const dsf_lookup_t *lookup) |
const dsf_atom_t * | dsf_iter (const dsf_atom_t *parent, uint32_t atom_id, const dsf_atom_t *prev) |
bool_t | dsf_parse_cmds (const dsf_t *dsf, dsf_cmd_cb_t user_cbs[NUM_DSF_CMDS], void *userinfo, char reason[DSF_REASON_SZ]) |
const char * | dsf_cmd2str (dsf_cmd_t cmd) |
This file holds a general-purpose DSF parser. To start parsing a DSF file on disk, use dsf_init() to obtain a handle to the file. When you are done with the DSF file, use dsf_fini() to release the handle.
Definition in file dsf.h.
#define DSF_ATOM | ( | a, | |
b, | |||
c, | |||
d | |||
) | (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) |
#define DSF_ATOM_ID_PRINTF | ( | atom | ) |
typedef void(* dsf_cmd_cb_t) (dsf_cmd_t cmd, const void *cmd_args, const dsf_cmd_parser_t *parser) |
const char * dsf_cmd2str | ( | dsf_cmd_t | cmd | ) |
char * dsf_dump | ( | const dsf_t * | dsf | ) |
Generates a human-readable description of the contents of a DSF file.
dsf | The DSF file to describe. |
void dsf_fini | ( | dsf_t * | dsf | ) |
dsf_t * dsf_init | ( | const char * | filename | ) |
Reads a DSF file from disk and provides a handle to it. This function should be used as the first step to access the DSF data. If the file is compressed on disk, it is decompressed in memory first.
filename | The full file name & path to the DSF file on disk. |
NULL
instead. The reason for the failure is automatically reported using logMsg(). const dsf_atom_t * dsf_iter | ( | const dsf_atom_t * | parent, |
uint32_t | atom_id, | ||
const dsf_atom_t * | prev | ||
) |
Iterator to allow you to traverse a list of subatoms of a DSF atom.
parent | The parent atom to use as the root of the iteration. We iterate through this atom's subatoms. |
atom_id | Atom ID to filter out. This function skips subatoms which do not have an ID which matches this atom. |
prev | The previous atom in the iteration. On first call, you should pass a NULL here, to initialize the search. |
parent
which matches the atom_id
. If no matching subatoms are present in the parent, returns NULL
.Example of iterating through all subatoms matching a particular ID:
const dsf_atom_t * dsf_lookup | ( | const dsf_t * | dsf, |
... | |||
) |
Performs a DSF atom lookup inside of a DSF file. The variadic part of this function must be a list of 32-bit unsigned integers, and MUST be terminated by a zero integer argument. The integers form an path of DSF atom IDs to be searched in the DSF tree structure. If along the way a part of the path sits in a list atom with multiple instances of the same atom ID, this picks the first instance. To search through lists of same-ID atoms, use dsf_lookup_v with a varying index number for the relevant atom path segment.
NULL
instead. const dsf_atom_t * dsf_lookup_v | ( | const dsf_t * | dsf, |
const dsf_lookup_t * | lookup | ||
) |
Same as dsf_lookup(), but instead of taking a variadic list of atoms to form a path, this takes a flat array of dsf_lookup_t structures.
lookup | An array of dsf_lookup_t structures, each identifying a part of the path. The array MUST be terminated by a dsf_lookup_t structure with a zero atom_id field. Use the idx field of the structures to disambiguate which instance of a subatom in a list atom the lookup is meant for. |
NULL
instead. dsf_t * dsf_parse | ( | uint8_t * | buf, |
size_t | bufsz, | ||
char | reason[DSF_REASON_SZ] | ||
) |
Parses a decompressed DSF file from a memory buffer. You should generally not need to use this function, unless you're streaming DSFs over the net. Use dsf_init() for files store on disk.
buf | A buffer containing the decompressed DSF file data. |
bufsz | Number of bytes in buf . |
reason | A return string, which will be filled with a human-readable failure reason in case parsing of the data fails. If the parse is successful, this buffer is left unaltered. |
NULL
instead. The reason for the failure is written into the reason
argument. bool_t dsf_parse_cmds | ( | const dsf_t * | dsf, |
dsf_cmd_cb_t | user_cbs[NUM_DSF_CMDS], | ||
void * | userinfo, | ||
char | reason[DSF_REASON_SZ] | ||
) |
Given a DSF file and callback list, iterates through all encoded commands in the DSF file. You can use this to extract the command list in the DSF.
dsf | The DSF file to operate on. This file must contain a CMDS atom. |
user_cbs | An array of callbacks, with the position in the array denoting what type of command this callback will be called for. You may leave positions in the array set to NULL if you are not interested in receiving a callback for a particular command type. |
userinfo | An optional pointer, which will be stored in the dsf_cmd_parser_t structure in the userinfo field. You can extract the userinfo pointer from there. |
reason | A failure reason buffer, which will be filled with a human-readable failure description, if a parsing failure occurs. |
B_TRUE
if parsing of the command section was successful, or B_FALSE
if not.