]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tools: add is_idchar() to tell if a char may belong to an identifier
authorWilly Tarreau <w@1wt.eu>
Fri, 14 Feb 2020 17:25:17 +0000 (18:25 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 14 Feb 2020 18:02:06 +0000 (19:02 +0100)
This function will simply be used to find the end of config identifiers
(proxies, servers, ACLs, sample fetches, converters, etc).

include/common/standard.h

index 69d760dd8bfbc4f494744b512d9a1af037eb55c4..da2efcfbb6b37b66e761be1f053b60612a3f55ea 100644 (file)
@@ -372,6 +372,16 @@ extern const char *invalid_domainchar(const char *name);
  */
 extern const char *invalid_prefix_char(const char *name);
 
+/* returns true if <c> 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 <str> to a locally allocated struct sockaddr_storage *, and a
  * port range consisting in two integers. The low and high end are always set