enum DataType
{
DT_NONE = 0,
+ DT_ADDRESS,
DT_BOOL,
- DT_NUMBER,
+ DT_ENUM,
DT_LONG,
- DT_STRING,
- DT_PATH,
+ DT_MBTABLE,
+ DT_NUMBER,
DT_QUAD,
- DT_SORT,
DT_REGEX,
+ DT_SLIST,
+ DT_SORT,
+ DT_STRING,
DT_SYNONYM,
- DT_ADDRESS,
- DT_MBTABLE,
- DT_COMMAND,
};
+// clang-format off
struct VariableTypes
{
char *machine;
char *human;
} types[] = {
- { "DT_NONE", "-none-" },
- { "DT_BOOL", "boolean" },
- { "DT_NUMBER", "number" },
- { "DT_LONG", "number (long)" },
- { "DT_STRING", "string" },
- { "DT_PATH", "path" },
- { "DT_QUAD", "quadoption" },
- { "DT_SORT", "sort order" },
- { "DT_REGEX", "regular expression" },
- { "DT_SYNONYM", NULL },
- { "DT_ADDRESS", "e-mail address" },
- { "DT_MBTABLE", "string" },
- { "DT_COMMAND", "command" },
- { NULL, NULL },
+ { "DT_NONE", "-none-" },
+ { "DT_ADDRESS", "e-mail address" },
+ { "DT_BOOL", "boolean" },
+ { "DT_ENUM", "enumeration" },
+ { "DT_LONG", "number (long)" },
+ { "DT_MBTABLE", "character string" },
+ { "DT_NUMBER", "number" },
+ { "DT_QUAD", "quadoption" },
+ { "DT_REGEX", "regular expression" },
+ { "DT_SLIST", "string list" },
+ { "DT_SORT", "sort order" },
+ { "DT_STRING", "string" },
+ { "DT_SYNONYM", NULL },
+ { NULL, NULL },
};
+// clang-format on
static int buf_to_type(const char *s)
{
strncpy(t, "no", l);
break;
}
+ case DT_ENUM:
+ {
+ if (strcasecmp(s, "MUTT_MBOX") == 0)
+ strncpy(t, "mbox", l);
+ else if (strcasecmp(s, "MUTT_MMDF") == 0)
+ strncpy(t, "MMDF", l);
+ else if (strcasecmp(s, "MUTT_MH") == 0)
+ strncpy(t, "MH", l);
+ else if (strcasecmp(s, "MUTT_MAILDIR") == 0)
+ strncpy(t, "Maildir", l);
+ break;
+ }
case DT_SORT:
{
/* heuristic! */
break;
}
case DT_STRING:
+ case DT_SLIST:
case DT_REGEX:
case DT_ADDRESS:
- case DT_PATH:
- case DT_COMMAND:
case DT_MBTABLE:
{
if (strcmp(s, "0") == 0)
case F_CONF:
{
if (type == DT_STRING || type == DT_REGEX || type == DT_ADDRESS ||
- type == DT_PATH || type == DT_MBTABLE || type == DT_COMMAND)
+ type == DT_MBTABLE || type == DT_SLIST)
{
fprintf(out, "\n# set %s=\"", varname);
conf_print_strval(val, out);
fprintf(out, "\n#\n# Name: %s", varname);
fprintf(out, "\n# Type: %s", type2human(type));
if (type == DT_STRING || type == DT_REGEX || type == DT_ADDRESS ||
- type == DT_PATH || type == DT_MBTABLE || type == DT_COMMAND)
+ type == DT_MBTABLE || type == DT_SLIST)
{
fputs("\n# Default: \"", out);
conf_print_strval(val, out);
fputs(".nf\n", out);
fprintf(out, "Type: %s\n", type2human(type));
if (type == DT_STRING || type == DT_REGEX || type == DT_ADDRESS ||
- type == DT_PATH || type == DT_MBTABLE || type == DT_COMMAND)
+ type == DT_MBTABLE || type == DT_SLIST)
{
fputs("Default: \"", out);
man_print_strval(val, out);
fprintf(out, "</title>\n<literallayout>Type: %s", type2human(type));
if (type == DT_STRING || type == DT_REGEX || type == DT_ADDRESS ||
- type == DT_PATH || type == DT_MBTABLE || type == DT_COMMAND)
+ type == DT_MBTABLE || type == DT_SLIST)
{
if (val && *val)
{
type = buf_to_type(buf);
- /* possibly a "|" or comma */
- s = get_token(buf, sizeof(buf), s);
- if (!s)
- return;
-
- if (strcmp(buf, "|") == 0)
+ while (true)
{
- if (Debug)
- fprintf(stderr, "%s: Expecting <subtype> <comma>.\n", Progname);
- /* ignore subtype and comma */
- s = get_token(buf, sizeof(buf), s);
- if (!s)
- return;
+ /* possibly a "|" or comma */
s = get_token(buf, sizeof(buf), s);
if (!s)
return;
+ if (strcmp(buf, ",") == 0)
+ break;
}
/* option name or IP &address */
{
if (strcmp(buf, "}") == 0)
break;
+ if (strcmp(buf, ",") == 0)
+ break;
strncpy(tmp + strlen(tmp), buf, sizeof(tmp) - strlen(tmp));
} while ((s = get_token(buf, sizeof(buf), s)));