+static int addr_from_string (struct option_t* dst, const char* val,
+ char* errbuf __attribute__ ((unused)), ssize_t errlen __attribute__ ((unused))) {
+ if (!dst)
+ return (0);
+ address_list_wipe((address_t**) dst->data);
+ if (val && *val)
+ *((address_t**) dst->data) = rfc822_parse_adrlist (NULL, val);
+ return (1);
+}
+
+static struct {
+ unsigned short type;
+ void (*opt_tostr) (char* dst, ssize_t dstlen, struct option_t* option);
+ int (*opt_fromstr) (struct option_t* dst, const char* val,
+ char* errbuf, ssize_t errlen);
+} FuncTable[] = {
+ { 0, NULL, NULL }, /* there's no DT_ type with 0 */
+ { DT_BOOL, bool_to_string, bool_from_string },
+ { DT_NUM, num_to_string, num_from_string },
+ { DT_STR, str_to_string, str_from_string },
+ { DT_PATH, str_to_string, path_from_string },
+ { DT_QUAD, quad_to_string, quad_from_string },
+ { DT_SORT, sort_to_string, sort_from_string },
+ { DT_RX, rx_to_string, rx_from_string },
+ { DT_MAGIC, magic_to_string, magic_from_string },
+ /* synonyms should be resolved already so we don't need this
+ * but must define it as DT_ is used for indexing */
+ { DT_SYN, NULL, NULL },
+ { DT_ADDR, addr_to_string, addr_from_string },
+};
+
+
+int mutt_option_value (const char* val, char* dst, ssize_t dstlen) {
+ struct option_t* option = NULL;
+ char* tmp = NULL, *t = NULL;
+ ssize_t l = 0;
+
+ if (!(option = hash_find (ConfigOptions, val))) {
+ *dst = '\0';
+ return (0);
+ }
+ tmp = p_new(char, dstlen+1);
+ FuncTable[DTYPE(option->type)].opt_tostr (tmp, dstlen, option);
+
+ /* as we get things of type $var=value and don't want to bloat the
+ * above "just" for expansion, we do the stripping here */
+ t = strchr (tmp, '=');
+ t++;
+ l = m_strlen(t);
+ if (l >= 2) {
+ if (t[l-1] == '"' && *t == '"') {
+ t[l-1] = '\0';
+ t++;