change strncmp() == 0 to STREQLEN()
[libguestfs.git] / daemon / daemon.h
index 8912840..ac68479 100644 (file)
@@ -164,7 +164,7 @@ extern void reply (xdrproc_t xdrp, char *ret);
  */
 #define RESOLVE_DEVICE(path,fail_stmt)                                 \
   do {                                                                 \
-    if (strncmp ((path), "/dev/", 5) != 0) {                           \
+    if (STRNEQLEN ((path), "/dev/", 5)) {                              \
       reply_with_error ("%s: %s: expecting a device name", __func__, (path)); \
       fail_stmt;                                                       \
     }                                                                  \
@@ -184,7 +184,7 @@ extern void reply (xdrproc_t xdrp, char *ret);
  */
 #define REQUIRE_ROOT_OR_RESOLVE_DEVICE(path,fail_stmt)                 \
   do {                                                                 \
-    if (strncmp ((path), "/dev/", 5) == 0)                             \
+    if (STREQLEN ((path), "/dev/", 5))                         \
       RESOLVE_DEVICE ((path), fail_stmt);                              \
     else {                                                             \
       NEED_ROOT (fail_stmt);                                           \
@@ -234,4 +234,14 @@ extern void reply (xdrproc_t xdrp, char *ret);
 # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
 #endif
 
+#define STREQ(a,b) (strcmp((a),(b)) == 0)
+#define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 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 STRCASEEQLEN(a,b,n) (strncasecmp((a),(b),(n)) == 0)
+#define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0)
+#define STRCASENEQLEN(a,b,n) (strncasecmp((a),(b),(n)) != 0)
+#define STRPREFIX(a,b) (strncmp((a),(b),strlen((b))) == 0)
+
 #endif /* GUESTFSD_DAEMON_H */