/* Copyright (c) 2008-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "hash.h"
#include "settings.h"
#include "dict-sql-settings.h"
#include <ctype.h>
enum section_type {
SECTION_ROOT = 0,
};
struct dict_sql_map_field {
const char *variable;
};
struct setting_parser_ctx {
};
{ 0, NULL, 0 }
};
struct dict_sql_settings_cache {
const char *path;
};
{
if (*p == '{') {
/* ${name} */
name = ++p;
p = strchr(p, '}');
if (p == NULL) {
/* error, but allow anyway */
return "";
}
*pattern = p + 1;
} else {
/* $name - ends at the first non-alnum_ character */
name = p;
for (; *p != '\0'; p++) {
if (!i_isalnum(*p) && *p != '_')
break;
}
*pattern = p;
}
return name;
}
{
const char *p, *name;
unsigned int i, count;
/* go through the variables in the pattern, replace them with plain
'$' character and add its sql field */
if (*p != '$') {
str_append_c(pattern, *p);
p++;
continue;
}
p++;
name = pattern_read_name(&p);
for (i = 0; i < count; i++) {
break;
}
if (i == count) {
return t_strconcat("Missing SQL field for variable: ",
}
/* mark this field as used */
}
/* make sure there aren't any unused fields */
for (i = 0; i < count; i++) {
return t_strconcat("Unused variable: ",
}
}
return NULL;
}
static bool
{
else
return FALSE;
return TRUE;
}
{
unsigned int i;
return "Missing setting: pattern";
return "Missing setting: table";
return "Missing setting: value_field";
const char *const *types =
return "Number of fields in value_fields doesn't match value_type";
return "Invalid value in value_type";
}
} else {
}
}
/* not all queries require this */
}
/* no fields besides value. allocate the array anyway. */
return "Missing fields for pattern variables";
}
return NULL;
}
static const char *
struct setting_parser_ctx *ctx)
{
case SECTION_ROOT:
return NULL;
}
break;
case SECTION_MAP:
case SECTION_FIELDS:
if (*value != '$') {
return t_strconcat("Value is missing '$' for field: ",
}
} else {
}
return NULL;
}
}
static bool
{
case SECTION_ROOT:
return FALSE;
return TRUE;
}
break;
case SECTION_MAP:
return FALSE;
}
return TRUE;
}
break;
case SECTION_FIELDS:
return FALSE;
}
break;
}
return FALSE;
}
struct dict_sql_settings *
{
}
pool_unref(&pool);
return NULL;
}
"Missing connect setting", path);
pool_unref(&pool);
return NULL;
}
}
void dict_sql_settings_deinit(void)
{
const char *key;
return;
}