diff options
| author | Markus Uhlin <markus@nifty-networks.net> | 2025-10-18 13:15:15 +0200 |
|---|---|---|
| committer | Markus Uhlin <markus@nifty-networks.net> | 2025-10-18 13:15:15 +0200 |
| commit | 207978267241afb74ce7132ed9132c2467850941 (patch) | |
| tree | ad14db590a01cc52c9582e23e45e911868029fd5 /FICS/interpreter.h | |
| parent | fd39305a6d1b05f18096c31c2abf083e6839eba1 (diff) | |
Config file interpreter
Diffstat (limited to 'FICS/interpreter.h')
| -rw-r--r-- | FICS/interpreter.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/FICS/interpreter.h b/FICS/interpreter.h new file mode 100644 index 0000000..b807ad6 --- /dev/null +++ b/FICS/interpreter.h @@ -0,0 +1,57 @@ +#ifndef INTERPRETER_H +#define INTERPRETER_H + +#include <ctype.h> /* isspace */ +#include <stdbool.h> +#include <stdio.h> /* FILE */ +#include <string.h> + +#include "common.h" + +/* + * Set to 0 to turn off this feature. + */ +#define IGNORE_UNRECOGNIZED_IDENTIFIERS 1 + +#define MAXLINE 3200 + +enum setting_type { + TYPE_BOOLEAN, + TYPE_INTEGER, + TYPE_STRING +}; + +typedef bool (*Interpreter_vFunc)(const char *); +typedef int (*Interpreter_instFunc)(const char *, const char *); + +struct Interpreter_in { + char *path; + char *line; + long int line_num; + Interpreter_vFunc validator_func; + Interpreter_instFunc install_func; +}; + +__FICS_BEGIN_DECLS +extern const char g_fgets_nullret_err1[70]; +extern const char g_fgets_nullret_err2[70]; + +void Interpreter(const struct Interpreter_in *); +void Interpreter_processAllLines(FILE *, const char *, Interpreter_vFunc, + Interpreter_instFunc); +__FICS_END_DECLS + +static inline void +adv_while_isspace(const char **ptr) +{ + while (isspace(**ptr)) + (*ptr)++; +} + +static inline bool +strings_match(const char *str1, const char *str2) +{ + return (strcmp(str1, str2) == 0); +} + +#endif |
