aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl
diff options
context:
space:
mode:
authorIan Jackson <ian.jackson@eu.citrix.com>2012-04-11 14:14:15 +0100
committerIan Jackson <ian.jackson@eu.citrix.com>2012-04-11 14:14:15 +0100
commit0c713a05544e6e6124c56a1b0c94357f5c427bc6 (patch)
tree3fb0968fc47347f3ef05753e3fff010a8ea32933 /tools/libxl
parent38dfa9fdc0fa5786613e581c636c74da2cc82ca3 (diff)
downloadxen-0c713a05544e6e6124c56a1b0c94357f5c427bc6.tar.gz
xen-0c713a05544e6e6124c56a1b0c94357f5c427bc6.tar.bz2
xen-0c713a05544e6e6124c56a1b0c94357f5c427bc6.zip
libxl: include <ctype.h> and introduce CTYPE helper macro
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl')
-rw-r--r--tools/libxl/libxl_internal.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 95c34f3753..b35421f7b7 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -33,6 +33,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <ctype.h>
#include <sys/mman.h>
#include <sys/poll.h>
@@ -1469,6 +1470,25 @@ static inline void libxl__ctx_unlock(libxl_ctx *ctx) {
} while(0)
+/*
+ * int CTYPE(ISFOO, char c);
+ * int CTYPE(toupper, char c);
+ * int CTYPE(tolower, char c);
+ *
+ * This is necessary because passing a simple char to a ctype.h
+ * is forbidden. ctype.h macros take ints derived from _unsigned_ chars.
+ *
+ * If you have a char which might be EOF then you should already have
+ * it in an int representing an unsigned char, and you can use the
+ * <ctype.h> macros directly. This generally happens only with values
+ * from fgetc et al.
+ *
+ * For any value known to be a character (eg, anything that came from
+ * a char[]), use CTYPE.
+ */
+#define CTYPE(isfoo,c) (isfoo((unsigned char)(c)))
+
+
#endif
/*