diff options
Diffstat (limited to 'tools.c')
-rw-r--r-- | tools.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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)); } |