#ifndef COMET_FORMAT_H #define COMET_FORMAT_H #include #include typedef struct { char **parts; size_t length; } format_t; typedef enum { FORMAT_SUCCESS, FORMAT_NESTED, FORMAT_UNKNOWN, FORMAT_UNTERMINATED, } format_status_t; typedef enum { FORMAT_NONE, FORMAT_STRING, FORMAT_BYTE, FORMAT_FUNCTION, } format_action_t; typedef char *(*format_function_t)(const char *key); typedef struct { format_action_t action; const char *key; union { const char *value; uint8_t byte; format_function_t fn; }; } format_pair_t; format_status_t format_init(format_t *format, const char *string, char delim, const format_pair_t *pairs); void format_free(format_t *format); #endif