Move format code to options and cleanup

This commit is contained in:
Olof hagsand 2024-04-16 12:05:36 +02:00
parent 1be158b7be
commit aba5c68fe2
6 changed files with 67 additions and 62 deletions

View file

@ -125,6 +125,42 @@ static const map_str2int yang_regexp_map[] = {
{NULL, -1}
};
/*! Translate between int and string of tree formats
*
* @see enum format_enum
*/
static const map_str2int _FORMATS[] = {
{"xml", FORMAT_XML},
{"text", FORMAT_TEXT},
{"json", FORMAT_JSON},
{"cli", FORMAT_CLI},
{"netconf", FORMAT_NETCONF},
{"default", FORMAT_DEFAULT},
{NULL, -1}
};
/*! Translate from numeric format to string representation
*
* @param[in] showas Format value (see enum format_enum)
* @retval str String value
*/
char *
format_int2str(enum format_enum showas)
{
return (char*)clicon_int2str(_FORMATS, showas);
}
/*! Translate from string to numeric format representation
*
* @param[in] str String value
* @retval enum Format value (see enum format_enum)
*/
enum format_enum
format_str2int(char *str)
{
return clicon_str2int(_FORMATS, str);
}
/*! Debug dump config options
*
* @param[in] h Clixon handle