From: Willy Tarreau Date: Fri, 14 Feb 2020 17:25:17 +0000 (+0100) Subject: MINOR: tools: add is_idchar() to tell if a char may belong to an identifier X-Git-Tag: v2.2-dev3~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36f586b6944fc40c1e2ecdae85e2df552d3d1fee;p=thirdparty%2Fhaproxy.git MINOR: tools: add is_idchar() to tell if a char may belong to an identifier This function will simply be used to find the end of config identifiers (proxies, servers, ACLs, sample fetches, converters, etc). --- diff --git a/include/common/standard.h b/include/common/standard.h index 69d760dd8b..da2efcfbb6 100644 --- a/include/common/standard.h +++ b/include/common/standard.h @@ -372,6 +372,16 @@ extern const char *invalid_domainchar(const char *name); */ extern const char *invalid_prefix_char(const char *name); +/* returns true if is an identifier character, that is, a digit, a letter, + * or '-', '_', ':' or '.'. This is usable for proxy names, server names, ACL + * names, sample fetch names, and converter names. + */ +static inline int is_idchar(char c) +{ + return isalnum((int)(unsigned char)c) || + c == '.' || c == '_' || c == '-' || c == ':'; +} + /* * converts to a locally allocated struct sockaddr_storage *, and a * port range consisting in two integers. The low and high end are always set