summaryrefslogtreecommitdiffstats
path: root/tools.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/tools.c b/tools.c
index 838172d..4609619 100644
--- a/tools.c
+++ b/tools.c
@@ -3,10 +3,26 @@
#include <unistd.h>
#include <stdint.h>
#include <assert.h>
+#include <ctype.h>
#include <arpa/inet.h>
#include "tools.h"
+int pcilib_isnumber(const char *str) {
+ int i = 0;
+ for (i = 0; str[i]; i++)
+ if (!isdigit(str[i])) return 0;
+ return 1;
+}
+
+int pcilib_isxnumber(const char *str) {
+ int i = 0;
+ for (i = 0; str[i]; i++)
+ if (!isxdigit(str[i])) return 0;
+ return 1;
+}
+
+
uint16_t pcilib_swap16(uint16_t x) {
return (((x<<8)&0xFFFF) | ((x>>8)&0xFFFF));
}