25 lines
708 B
C
25 lines
708 B
C
#ifndef AOC_2021_PUZZLE_INPUT_H
|
|
#define AOC_2021_PUZZLE_INPUT_H
|
|
|
|
#include <stdint.h>
|
|
|
|
typedef enum {
|
|
PARSER_OK = 0,
|
|
PARSER_INVALID = -1,
|
|
PARSER_RANGE_OVERFLOW = -2,
|
|
PARSE_FILE_ERR = -3,
|
|
} parse_ret_t;
|
|
|
|
typedef parse_ret_t (*input_parser_t)(char * buffer, void * data, uint16_t index);
|
|
|
|
parse_ret_t read_input(const char * file_path, void * data, uint16_t max_len, input_parser_t parser, uint16_t * len);
|
|
|
|
// Parsers
|
|
parse_ret_t parse_long_from_buff(char * buffer, void * data, uint16_t index);
|
|
parse_ret_t parse_long_base_2_from_buff(char * buffer, void * data, uint16_t index);
|
|
|
|
//Helpers
|
|
parse_ret_t parse_long(char * buffer, int64_t * val, int16_t base);
|
|
|
|
#endif //AOC_2021_PUZZLE_INPUT_H
|