diff options
| author | Mosder <xmosder12@gmail.com> | 2026-07-13 15:32:27 +0200 |
|---|---|---|
| committer | Mosder <xmosder12@gmail.com> | 2026-07-13 15:32:27 +0200 |
| commit | 32bb25cc2666809759371436a6450574b00c0e6d (patch) | |
| tree | 119171e968949292509ff2e190ae72acaa5d0fc3 /analyzer/parser/parser_defs.h | |
| parent | 0e9be0d902b44894ed747cabb82ea2120f2e4b45 (diff) | |
feat: added generic functionallity for getting the parsed data from stream
Diffstat (limited to 'analyzer/parser/parser_defs.h')
| -rw-r--r-- | analyzer/parser/parser_defs.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/analyzer/parser/parser_defs.h b/analyzer/parser/parser_defs.h new file mode 100644 index 0000000..f99c2f3 --- /dev/null +++ b/analyzer/parser/parser_defs.h @@ -0,0 +1,46 @@ +// parser/parser_defs.h +// useful definitions for parser files + +#include "../utils/tcp.h" + +#ifndef RESULTS_ENUM_DEFINED +#define RESULTS_ENUM_DEFINED +typedef enum { TYPE_FIGHT_RESULTS } ResultsEnum; +#endif + +#ifndef PARSED_DATA_DEFINED +#define PARSED_DATA_DEFINED +// "generic" type for parsed data +typedef struct { + ResultsEnum data_type; // type of data represented by an enum + void *data; // pointer to the parsed data + void (*data_cleanup)(void *data); // function to cleanup internal allocations inside data + // if no internal allocations - this should be NULL +} ParsedData; +#endif + +// find the first results data of specific type in stream +// params: +// - stream - stream to find the data in +// - offset - offset to start finding data from +// - length - length of the data or -1 if there's no end yet +// returns: +// pointer to the beginning of data or NULL if there's none +typedef byte_t *find_function_t(TCPStream *stream, int offset, int *length); + +// parse given data of specifc type +// params: +// - data - data to parse +// - length - length of data +// returns: +// ParsedData struct including the parsed data +typedef ParsedData parse_function_t(byte_t *data, size_t length); + +// struct for holding the find and parse function for every result type +#ifndef FIND_PARSE_FUNCTIONS_DEFINED +#define FIND_PARSE_FUNCTIONS_DEFINED +typedef struct { + find_function_t *find_fn; + parse_function_t *parse_fn; +} FindParseFunctions; +#endif |
