diff options
| author | Maciej Borowiec <81316152+Mosder@users.noreply.github.com> | 2026-07-23 20:17:15 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-23 20:17:15 +0200 |
| commit | 3419cad016b3c34d0630456d4390c70063462d91 (patch) | |
| tree | 3a1aa4416e45f134d38f83d4ea2285f1972f9391 /analyzer/parser/structs.h | |
| parent | 2e3f7fe39791cd671a68330f7ba7a5bb5fc6f9ae (diff) | |
| parent | 682f9fc8288fdd01de1d88af87495d9e43f56b06 (diff) | |
LGTM
Diffstat (limited to 'analyzer/parser/structs.h')
| -rw-r--r-- | analyzer/parser/structs.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/analyzer/parser/structs.h b/analyzer/parser/structs.h new file mode 100644 index 0000000..023c19b --- /dev/null +++ b/analyzer/parser/structs.h @@ -0,0 +1,33 @@ +// parser/structs.h +// generic struct functionality for parsing + +#include <stddef.h> + +#ifndef PARSER_STRUCTS_H +#define PARSER_STRUCTS_H + +typedef enum { INT, FLOAT, DOUBLE, STRING } TypeEnum; + +typedef struct { + TypeEnum type; + size_t offset; +} StructField; + +// fill generic struct with given data +// params: +// - obj - pointer to the struct to fill +// - fields - field types and offsets of the struct +// - n_fields - count of fields in the struct +// - data - data to fill the struct with +// - data_len - length of the data +// - sep - separator seperating the fields in data +extern void fill_struct(void *obj, const StructField *fields, size_t n_fields, const char *data, size_t data_len, const char *sep); + +// cleanup allocations inside generic struct +// params: +// - obj - pointer to the struct to cleanup +// - fields - field types and offsets of the struct +// - n_fields - count of fields in the struct +extern void cleanup_struct(void *obj, const StructField *fields, size_t n_fields); + +#endif |
