From 7cd4b6aeee3693463b03608a31cf53f21152c2e8 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 9 Nov 2009 19:50:22 +0100 Subject: [PATCH] define STREQ, STRNEQ, STREQLEN, STRCASEQ, etc. * src/guestfs.h: Define STREQ and company. * daemon/daemon.h: Likewise. * hivex/hivex.h: Likewise. --- daemon/daemon.h | 10 ++++++++++ hivex/hivex.h | 10 ++++++++++ src/guestfs.h | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/daemon/daemon.h b/daemon/daemon.h index 8912840..3f4c480 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -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 */ diff --git a/hivex/hivex.h b/hivex/hivex.h index 14bdcc5..be7feee 100644 --- a/hivex/hivex.h +++ b/hivex/hivex.h @@ -73,6 +73,16 @@ typedef enum hive_type hive_type; #define HIVEX_OPEN_DEBUG 2 #define HIVEX_OPEN_MSGLVL_MASK 3 +#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) + extern hive_h *hivex_open (const char *filename, int flags); extern int hivex_close (hive_h *h); extern hive_node_h hivex_root (hive_h *h); diff --git a/src/guestfs.h b/src/guestfs.h index 35f995d..e89f744 100644 --- a/src/guestfs.h +++ b/src/guestfs.h @@ -30,6 +30,16 @@ extern "C" { #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) + typedef struct guestfs_h guestfs_h; /* Connection management. */ -- 1.8.3.1