diff options
Diffstat (limited to 'src/lib-dict-backend/dict-sql-settings.h')
-rw-r--r-- | src/lib-dict-backend/dict-sql-settings.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/lib-dict-backend/dict-sql-settings.h b/src/lib-dict-backend/dict-sql-settings.h new file mode 100644 index 0000000..c9ee037 --- /dev/null +++ b/src/lib-dict-backend/dict-sql-settings.h @@ -0,0 +1,47 @@ +#ifndef DICT_SQL_SETTINGS_H +#define DICT_SQL_SETTINGS_H + +enum dict_sql_type { + DICT_SQL_TYPE_STRING = 0, + DICT_SQL_TYPE_INT, + DICT_SQL_TYPE_UINT, + DICT_SQL_TYPE_HEXBLOB +}; + +struct dict_sql_field { + const char *name; + enum dict_sql_type value_type; +}; + +struct dict_sql_map { + /* pattern is in simplified form: all variables are stored as simple + '$' character. fields array is sorted by the variable index. */ + const char *pattern; + const char *table; + const char *username_field; + const char *value_field; + const char *value_type; + bool value_hexblob; + + /* SQL field names, one for each $ variable in the pattern */ + ARRAY(struct dict_sql_field) pattern_fields; + + /* generated: */ + unsigned int values_count; + const char *const *value_fields; + const enum dict_sql_type *value_types; +}; + +struct dict_sql_settings { + const char *connect; + + unsigned int max_pattern_fields_count; + ARRAY(struct dict_sql_map) maps; +}; + +struct dict_sql_settings * +dict_sql_settings_read(const char *path, const char **error_r); + +void dict_sql_settings_deinit(void); + +#endif |