netcf's internal.h already had some of the other STR*() macros that
are in libvirt, but was missing some. A couple of the macros now use
the gnulib variants of strcase* functions, so the appropriate module
is added to bootstrap.conf and the #include is added to internal.h.
---
 bootstrap.conf |  3 ++-
 src/internal.h | 23 ++++++++++++++++-------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/bootstrap.conf b/bootstrap.conf
index 4503015..74bbd7e 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -1,6 +1,6 @@
 # Bootstrap configuration.
 
-# Copyright (C) 2010-2014 Red Hat, Inc.
+# Copyright (C) 2010-2015 Red Hat, Inc.
 
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -21,6 +21,7 @@
 gnulib_modules='
 arpa_inet
 c-ctype
+c-strcase
 close
 configmake
 getopt-posix
diff --git a/src/internal.h b/src/internal.h
index 8783262..4e5a508 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -26,6 +26,7 @@
 #include <config.h>
 #include "netcf.h"
 #include "datadir.h"
+# include "c-strcase.h"
 
 #include <string.h>
 #include <stdarg.h>
@@ -95,13 +96,21 @@
 #define MEMZERO(ptr, n) memset((ptr), 0, (n) * sizeof(*(ptr)));
 
 /* String equality tests, suggested by Jim Meyering. */
-#define STREQ(a,b) (strcmp((a),(b)) == 0)
-#define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0)
-#define STRCASEEQLEN(a,b,n) (strncasecmp((a),(b),(n)) == 0)
-#define STRNEQ(a,b) (strcmp((a),(b)) != 0)
-#define STRCASENEQ(a,b) (strcasecmp((a),(b)) != 0)
-#define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0)
-#define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0)
+# define STREQ(a, b) (strcmp(a, b) == 0)
+# define STRCASEEQ(a, b) (c_strcasecmp(a, b) == 0)
+# define STRNEQ(a, b) (strcmp(a, b) != 0)
+# define STRCASENEQ(a, b) (c_strcasecmp(a, b) != 0)
+# define STREQLEN(a, b, n) (strncmp(a, b, n) == 0)
+# define STRCASEEQLEN(a, b, n) (c_strncasecmp(a, b, n) == 0)
+# define STRNEQLEN(a, b, n) (strncmp(a, b, n) != 0)
+# define STRCASENEQLEN(a, b, n) (c_strncasecmp(a, b, n) != 0)
+# define STRPREFIX(a, b) (strncmp(a, b, strlen(b)) == 0)
+# define STRSKIP(a, b) (STRPREFIX(a, b) ? (a) + strlen(b) : NULL)
+
+# define STREQ_NULLABLE(a, b)                           \
+    ((a) ? (b) && STREQ((a) ? (a) : "", (b) ? (b) : "") : !(b))
+# define STRNEQ_NULLABLE(a, b)                          \
+    ((a) ? !(b) || STRNEQ((a) ? (a) : "", (b) ? (b) : "") : !!(b))
 
 #define ERR_COND(cond, ncf, err) \
     if (cond) (ncf)->errcode = (NETCF_##err)
-- 
2.1.0

_______________________________________________
netcf-devel mailing list
netcf-devel@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/netcf-devel

Reply via email to