summaryrefslogtreecommitdiffstats
path: root/pcilib/tools.h
diff options
context:
space:
mode:
Diffstat (limited to 'pcilib/tools.h')
-rw-r--r--pcilib/tools.h52
1 files changed, 51 insertions, 1 deletions
diff --git a/pcilib/tools.h b/pcilib/tools.h
index 8c525e0..7b4aea0 100644
--- a/pcilib/tools.h
+++ b/pcilib/tools.h
@@ -14,15 +14,65 @@
extern "C" {
#endif
+/**
+ * Check if provided string is a decimal integer
+ * @param[in] str - string to check
+ * @return - 1 if string is a number and 0 - otherwise
+ */
int pcilib_isnumber(const char *str);
+
+/**
+ * Check if provided string is a hexdecimal integer, optionally prefexed with 0x
+ * @param[in] str - string to check
+ * @return - 1 if string is a number and 0 - otherwise
+ */
int pcilib_isxnumber(const char *str);
+
+/**
+ * Check if first \p len bytes of the provided string is a decimal integer
+ * @param[in] str - string to check
+ * @param[in] len - size of the string
+ * @return - 1 if string is a number and 0 - otherwise
+ */
int pcilib_isnumber_n(const char *str, size_t len);
+
+/**
+ * Check if first \p len bytes of the provided string is a hexdecimal integer, optionally prefexed with 0x
+ * @param[in] str - string to check
+ * @param[in] len - size of the string
+ * @return - 1 if string is a number and 0 - otherwise
+ */
int pcilib_isxnumber_n(const char *str, size_t len);
+/**
+ * Change the endianess of the provided number (between big- and little-endian format)
+ * @param[in] x - number in little/big endian format
+ * @return - number in big/little endian format
+ */
uint16_t pcilib_swap16(uint16_t x);
+
+/**
+ * Change the endianess of the provided number (between big- and little-endian format)
+ * @param[in] x - number in little/big endian format
+ * @return - number in big/little endian format
+ */
uint32_t pcilib_swap32(uint32_t x);
+
+/**
+ * Change the endianess of the provided number (between big- and little-endian format)
+ * @param[in] x - number in little/big endian format
+ * @return - number in big/little endian format
+ */
uint64_t pcilib_swap64(uint64_t x);
-void pcilib_swap(void *dst, void *src, size_t size, size_t n);
+
+/**
+ * Change the endianess of the provided array
+ * @param[out] dst - the destination memory region, can be equal to \p src
+ * @param[in] src - the source memory region
+ * @param[in] access - the size of word in bytes (1, 2, 4, or 8)
+ * @param[in] n - the number of words to copy (\p n * \p access bytes are copied).
+ */
+void pcilib_swap(void *dst, void *src, size_t access, size_t n);
#ifdef __cplusplus
}