#include "svn_types.h"
#include "svn_error.h"
#include "private/svn_token.h"
#include "svn_private_config.h"
const char *
svn_token__to_word(const svn_token_map_t *map,
int value)
{
for (; map->str != NULL; ++map)
if (map->val == value)
return map->str;
SVN_ERR_MALFUNCTION_NO_RETURN();
}
int
svn_token__from_word_strict(const svn_token_map_t *map,
const char *word)
{
int value = svn_token__from_word(map, word);
if (value == SVN_TOKEN_UNKNOWN)
SVN_ERR_MALFUNCTION_NO_RETURN();
return value;
}
svn_error_t *
svn_token__from_word_err(int *value,
const svn_token_map_t *map,
const char *word)
{
*value = svn_token__from_word(map, word);
if (*value == SVN_TOKEN_UNKNOWN)
return svn_error_createf(SVN_ERR_BAD_TOKEN, NULL,
_("Token '%s' is unrecognized"),
word);
return SVN_NO_ERROR;
}
int
svn_token__from_word(const svn_token_map_t *map,
const char *word)
{
if (word == NULL)
return SVN_TOKEN_UNKNOWN;
for (; map->str != NULL; ++map)
if (strcmp(map->str, word) == 0)
return map->val;
return SVN_TOKEN_UNKNOWN;
}
int
svn_token__from_mem(const svn_token_map_t *map,
const char *word,
apr_size_t len)
{
for (; map->str != NULL; ++map)
if (strncmp(map->str, word, len) == 0 && map->str[len] == '\0')
return map->val;
return SVN_TOKEN_UNKNOWN;
}