diff options
author | Vasilii Chernov <vchernov@inr.ru> | 2016-03-02 10:28:04 +0100 |
---|---|---|
committer | Vasilii Chernov <vchernov@inr.ru> | 2016-03-02 10:28:04 +0100 |
commit | 8e7c95957ee73d6c11ef28f7c0e2319a11103783 (patch) | |
tree | 83df220932b3d88e071eda4c756e485dd48d50e9 /pcilib/tools.h | |
parent | 8719b84a95805d109e21c20f05a0164315e1b38a (diff) | |
parent | 867bddcf7be374221a04b7ae89f93a5f5d703ee6 (diff) | |
download | pcitool-8e7c95957ee73d6c11ef28f7c0e2319a11103783.tar.gz pcitool-8e7c95957ee73d6c11ef28f7c0e2319a11103783.tar.bz2 pcitool-8e7c95957ee73d6c11ef28f7c0e2319a11103783.tar.xz pcitool-8e7c95957ee73d6c11ef28f7c0e2319a11103783.zip |
Merge with http://ufo.kit.edu/ufo/log/csa/pcitool 362 revision
Diffstat (limited to 'pcilib/tools.h')
-rw-r--r-- | pcilib/tools.h | 52 |
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 } |