return -1;
}
}
- else if ((*col = mutt_getvaluebyname(s, Colors)) == -1)
+ else if ((*col = mutt_map_get_value(s, Colors)) == -1)
{
snprintf(err->data, err->dsize, _("%s: no such color"), s);
return -1;
mutt_extract_token(buf, s, 0);
- object = mutt_getvaluebyname(buf->data, Fields);
+ object = mutt_map_get_value(buf->data, Fields);
if (object == -1)
{
snprintf(err->data, err->dsize, _("%s: no such object"), buf->data);
mutt_extract_token(buf, s, 0);
- *o = mutt_getvaluebyname(buf->data, ComposeFields);
+ *o = mutt_map_get_value(buf->data, ComposeFields);
if (*o == -1)
{
snprintf(err->data, err->dsize, _("%s: no such object"), buf->data);
return (-1);
}
}
- else if ((*o = mutt_getvaluebyname(buf->data, Fields)) == -1)
+ else if ((*o = mutt_map_get_value(buf->data, Fields)) == -1)
{
snprintf(err->data, err->dsize, _("%s: no such object"), buf->data);
return -1;
mutt_mktemp(t, sizeof(t));
funcs = km_get_table(menu);
- desc = mutt_getnamebyvalue(menu, Menus);
+ desc = mutt_map_get_name(menu, Menus);
if (!desc)
desc = _("<UNKNOWN>");
flags |= SORT_LAST;
}
- i = mutt_getvaluebyname(s, map);
+ i = mutt_map_get_value(s, map);
if (i == -1)
{
snprintf(err->data, err->dsize, _("%s: unknown sorting method"), s);
if (query || *s->dptr != '=')
{
- p = mutt_getnamebyvalue(*((short *) MuttVars[idx].data) & SORT_MASK, map);
+ p = mutt_map_get_name(*((short *) MuttVars[idx].data) & SORT_MASK, map);
snprintf(err->data, err->dsize, "%s=%s%s%s", MuttVars[idx].option,
(*((short *) MuttVars[idx].data) & SORT_REVERSE) ? "reverse-" : "",
map = SortMethods;
break;
}
- p = mutt_getnamebyvalue(*((short *) MuttVars[idx].data) & SORT_MASK, map);
+ p = mutt_map_get_name(*((short *) MuttVars[idx].data) & SORT_MASK, map);
snprintf(tmp, sizeof(tmp), "%s%s%s",
(*((short *) MuttVars[idx].data) & SORT_REVERSE) ? "reverse-" : "",
(*((short *) MuttVars[idx].data) & SORT_LAST) ? "last-" : "", p);
c = *t;
*t = '\0';
- n = mutt_getvaluebyname(s, KeyNames);
+ n = mutt_map_get_value(s, KeyNames);
if (n != -1)
{
s = t;
_("Binding '%s' will alias '%s' Before, try: 'bind %s %s "
"noop' "
"https://neomutt.org/guide/configuration.html#bind-warnings"),
- old_binding, new_binding, mutt_getnamebyvalue(menu, Menus), new_binding);
+ old_binding, new_binding, mutt_map_get_name(menu, Menus), new_binding);
}
else
{
_("Binding '%s' will alias '%s' Before, try: 'bind %s %s "
"noop' "
"https://neomutt.org/guide/configuration.html#bind-warnings"),
- old_binding, new_binding, mutt_getnamebyvalue(menu, Menus), new_binding);
+ old_binding, new_binding, mutt_map_get_name(menu, Menus), new_binding);
}
retval = -2;
}
static char buf[10];
const char *p = NULL;
- if ((p = mutt_getnamebyvalue(c, KeyNames)))
+ if ((p = mutt_map_get_name(c, KeyNames)))
return p;
if (c < 256 && c > -128 && iscntrl((unsigned char) c))
if (q)
*q = '\0';
- menu[i] = mutt_getvaluebyname(p, Menus);
+ menu[i] = mutt_map_get_value(p, Menus);
if (menu[i] == -1)
{
snprintf(err->data, err->dsize, _("%s: no such menu"), p);
{
snprintf(err->data, err->dsize,
_("Function '%s' not available for menu '%s'"), func,
- mutt_getnamebyvalue(menu, Menus));
+ mutt_map_get_name(menu, Menus));
}
return -1; /* Couldn't find an existing function with this name */
}
*
* Map a string to a constant and vice versa.
*
- * | Function | Description
- * | :-------------------- | :-------------------------------
- * | mutt_getnamebyvalue() | Lookup a string for a constant
- * | mutt_getvaluebyname() | Lookup the constant for a string
+ * | Function | Description
+ * | :------------------- | :-------------------------------
+ * | mutt_map_get_name() | Lookup a string for a constant
+ * | mutt_map_get_value() | Lookup the constant for a string
*/
#include "mapping.h"
#include "string2.h"
/**
- * mutt_getnamebyvalue - Lookup a string for a constant
+ * mutt_map_get_name - Lookup a string for a constant
* @param val ID to locate in map
* @param map NULL-terminated map of strings and constants
* @retval str String matching ID
* @retval NULL ID not found
*/
-const char *mutt_getnamebyvalue(int val, const struct Mapping *map)
+const char *mutt_map_get_name(int val, const struct Mapping *map)
{
for (int i = 0; map[i].name; i++)
if (map[i].value == val)
}
/**
- * mutt_getvaluebyname - Lookup the constant for a string
+ * mutt_map_get_value - Lookup the constant for a string
* @param name String to locate in map
* @param map NULL-terminated map of strings and constants
* @retval num ID matching string
* @retval -1 String not found
*/
-int mutt_getvaluebyname(const char *name, const struct Mapping *map)
+int mutt_map_get_value(const char *name, const struct Mapping *map)
{
for (int i = 0; map[i].name; i++)
if (mutt_strcasecmp(map[i].name, name) == 0)
int value;
};
-const char *mutt_getnamebyvalue(int val, const struct Mapping *map);
-int mutt_getvaluebyname(const char *name, const struct Mapping *map);
+const char *mutt_map_get_name(int val, const struct Mapping *map);
+int mutt_map_get_value(const char *name, const struct Mapping *map);
#endif /* _MUTT_MAPPING_H */
{
snprintf(buf, buflen, "%s%s%s", (method & SORT_REVERSE) ? "reverse-" : "",
(method & SORT_LAST) ? "last-" : "",
- mutt_getnamebyvalue(method & SORT_MASK, SortMethods));
+ mutt_map_get_name(method & SORT_MASK, SortMethods));
return buf;
}
for (t = sbuf; *t; t++)
*t = tolower(*t);
- i = mutt_getvaluebyname(sbuf, UrlMap);
+ i = mutt_map_get_value(sbuf, UrlMap);
if (i == -1)
return U_UNKNOWN;
else
if (u->scheme == U_UNKNOWN)
return -1;
- snprintf(dest, len, "%s:", mutt_getnamebyvalue(u->scheme, UrlMap));
+ snprintf(dest, len, "%s:", mutt_map_get_name(u->scheme, UrlMap));
if (u->host)
{