Definitions and data structures needed for routines that assign values to elements of arbitrary data structures, the layout of which is described by tables of "bu_structparse" structures.
More...
|
#define | offsetof(_t, _m) (size_t)(&(((_t *)0)->_m)) |
|
#define | bu_offsetof(_t, _m) (size_t)offsetof(_t, _m) |
|
#define | bu_offsetofarray(_t, _a, _d, _i) bu_offsetof(_t, _a) + sizeof(_d) * _i |
|
#define | bu_byteoffset(_i) ((size_t)(((char *)&(_i))-((char *)0))) |
|
#define | BU_STRUCTPARSE_NULL ((struct bu_structparse *)0) |
|
#define | BU_STRUCTPARSE_FUNC_NULL ((void(*)(const struct bu_structparse *, const char *, void *, const char *, void *))0) |
|
#define | BU_CK_STRUCTPARSE(_sp) /* nothing to do */ |
|
#define | BU_STRUCTPARSE_INIT(_sp) |
|
#define | BU_STRUCTPARSE_INIT_ZERO { {'\0', '\0', '\0', '\0'}, 0, NULL, 0, BU_STRUCTPARSE_FUNC_NULL, NULL, NULL } |
|
#define | BU_STRUCTPARSE_IS_INITIALIZED(_sp) ((struct bu_structparse *)(_sp) != BU_STRUCTPARSE_NULL) |
|
#define | BU_EXTERNAL_NULL ((struct bu_external *)0) |
|
#define | BU_CK_EXTERNAL(_p) BU_CKMAG(_p, BU_EXTERNAL_MAGIC, "bu_external") |
|
#define | BU_EXTERNAL_INIT(_p) |
|
#define | BU_EXTERNAL_INIT_ZERO { BU_EXTERNAL_MAGIC, 0, NULL } |
|
#define | BU_EXTERNAL_IS_INITIALIZED(_p) (((struct bu_external *)(_p) != BU_EXTERNAL_NULL) && (_p)->ext_magic == BU_EXTERNAL_MAGIC) |
|
#define | BU_SP_SKIP_SEP(_cp) |
|
|
int | bu_struct_parse (const struct bu_vls *in_vls, const struct bu_structparse *desc, const char *base, void *data) |
| routines for parsing arbitrary structures
|
|
void | bu_struct_print (const char *title, const struct bu_structparse *parsetab, const char *base) |
|
int | bu_struct_export (struct bu_external *ext, const void *base, const struct bu_structparse *imp) |
|
int | bu_struct_import (void *base, const struct bu_structparse *imp, const struct bu_external *ext, void *data) |
|
size_t | bu_struct_put (FILE *fp, const struct bu_external *ext) |
|
size_t | bu_struct_get (struct bu_external *ext, FILE *fp) |
|
void | bu_struct_wrap_buf (struct bu_external *ext, void *buf) |
|
void | bu_vls_struct_print (struct bu_vls *vls, const struct bu_structparse *sdp, const char *base) |
|
void | bu_vls_struct_print2 (struct bu_vls *vls, const char *title, const struct bu_structparse *sdp, const char *base) |
|
void | bu_vls_struct_item (struct bu_vls *vp, const struct bu_structparse *sdp, const char *base, int sep_char) |
|
int | bu_vls_struct_item_named (struct bu_vls *vp, const struct bu_structparse *sdp, const char *name, const char *base, int sep_char) |
|
int | bu_key_eq_to_key_val (const char *in, const char **next, struct bu_vls *vls) |
|
int | bu_fwrite_external (FILE *fp, const struct bu_external *ep) |
|
void | bu_hexdump_external (FILE *fp, const struct bu_external *ep, const char *str) |
|
void | bu_free_external (struct bu_external *ep) |
|
void | bu_copy_external (struct bu_external *op, const struct bu_external *ip) |
|
char * | bu_next_token (char *str) |
|
void | bu_structparse_get_terse_form (struct bu_vls *logstr, const struct bu_structparse *sp) |
|
int | bu_structparse_argv (struct bu_vls *str, int argc, const char **argv, const struct bu_structparse *desc, char *base, void *data) |
|
Definitions and data structures needed for routines that assign values to elements of arbitrary data structures, the layout of which is described by tables of "bu_structparse" structures.
parse.c defines routines to assign values to elements of arbitrary structures. The layout of a structure to be processed is described by a structure of type "bu_structparse", giving element names, element formats, an offset from the beginning of the structure, and a pointer to an optional "hooked" function that is called whenever that structure element is changed.
◆ offsetof
The general problem of word-addressed hardware where (int *) and (char *) have different representations is handled in the parsing routines that use sp_offset, because of the limitations placed on compile-time initializers.
Files using bu_offsetof or bu_offsetofarray will need to include stddef.h in order to get offsetof()
Definition at line 65 of file parse.h.
◆ bu_offsetof
◆ bu_offsetofarray
◆ bu_byteoffset
Convert address of global data object into byte "offset" from address 0.
Strictly speaking, the C language only permits initializers of the form: address +- constant, where here the intent is to measure the byte address of the indicated variable. Matching compensation code for the CRAY is located in librt/parse.c
Definition at line 84 of file parse.h.
◆ BU_STRUCTPARSE_NULL
◆ BU_STRUCTPARSE_FUNC_NULL
◆ BU_CK_STRUCTPARSE
◆ BU_STRUCTPARSE_INIT
Value: { \
(
_sp)->sp_fmt[0] = (
_sp)->sp_fmt[1] = (
_sp)->sp_fmt[2] = (
_sp)->sp_fmt[3] =
'\0'; \
}
#define BU_STRUCTPARSE_FUNC_NULL
initialize a bu_structparse struct without allocating any memory.
Definition at line 179 of file parse.h.
◆ BU_STRUCTPARSE_INIT_ZERO
macro suitable for declaration statement initialization of a bu_structparse struct. does not allocate memory.
Definition at line 193 of file parse.h.
◆ BU_STRUCTPARSE_IS_INITIALIZED
returns truthfully whether a bu_structparse struct has been initialized. validates whether pointer is non-NULL.
Definition at line 199 of file parse.h.
◆ BU_EXTERNAL_NULL
◆ BU_CK_EXTERNAL
◆ BU_EXTERNAL_INIT
Value: { \
}
#define BU_EXTERNAL_MAGIC
initializes a bu_external struct without allocating any memory.
Definition at line 240 of file parse.h.
◆ BU_EXTERNAL_INIT_ZERO
macro suitable for declaration statement initialization of a bu_external struct. does not allocate memory.
Definition at line 254 of file parse.h.
◆ BU_EXTERNAL_IS_INITIALIZED
◆ BU_SP_SKIP_SEP
Value:Skip the separator(s) (i.e. whitespace and open-braces)
- Parameters
-
Definition at line 432 of file parse.h.
◆ bu_structparse_t
◆ bu_external_t
◆ bu_struct_parse()
routines for parsing arbitrary structures
ASCII to struct elements.
Parse the structure element description in the vls string "vls" according to the structure description in "parsetab"
- Returns
- <0 failure
-
0 OK
◆ bu_struct_print()
struct elements to ASCII.
◆ bu_struct_export()
struct elements to machine-independent binary.
copies ext data to base
◆ bu_struct_import()
machine-independent binary to struct elements.
copies ext data to base
◆ bu_struct_put()
Put a structure in external form to a stdio file. All formatting must have been accomplished previously.
Returns number of bytes written. On error, a short byte count (or zero) is returned. Use feof(3) or ferror(3) to determine which errors occur.
◆ bu_struct_get()
Obtain the next structure in external form from a stdio file.
Returns number of bytes read into the bu_external. On error, zero is returned.
◆ bu_struct_wrap_buf()
Given a buffer with an external representation of a structure (e.g. the ext_buf portion of the output from bu_struct_export), check it for damage in shipment, and if it's OK, wrap it up in an bu_external structure, suitable for passing to bu_struct_import().
◆ bu_vls_struct_print()
This differs from bu_struct_print in that this output is less readable by humans, but easier to parse with the computer.
◆ bu_vls_struct_print2()
This differs from bu_struct_print in that it prints to a vls.
◆ bu_vls_struct_item()
Convert a structure element (indicated by sdp) to its ASCII representation in a VLS.
◆ bu_vls_struct_item_named()
Convert a structure element called "name" to an ASCII representation in a VLS.
◆ bu_key_eq_to_key_val()
◆ bu_fwrite_external()
Take a block of memory, and write it into a file.
Caller is responsible for freeing memory of external representation, using bu_free_external().
- Returns
- <0 error
-
0 OK
◆ bu_hexdump_external()
◆ bu_free_external()
◆ bu_copy_external()
◆ bu_next_token()
Advance pointer through string over current token, across white space, to beginning of next token.
◆ bu_structparse_get_terse_form()
◆ bu_structparse_argv()
Support routine for db adjust and db put. Much like the bu_struct_parse routine which takes its input as a bu_vls. This routine, however, takes the arguments as lists, a more Tcl-friendly method. There is a log vls for storing messages.
Operates on argv[0] and argv[1], then on argv[2] and argv[3], ...
- Parameters
-
str | - vls for dumping info that might have gone to bu_log |
argc | - number of elements in argv |
argv | - contains the keyword-value pairs |
desc | - structure description |
base | - base addr of users struct |
data | - user data to be passed to the sp_hook function |
- Return values
-
BRLCAD_OK | if successful, |
BRLCAD_ERROR | on failure |