diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2018-10-21 16:23:23 +0300 |
---|---|---|
committer | Jari Vetoniemi <mailroxas@gmail.com> | 2018-10-21 16:23:23 +0300 |
commit | 75f9922f6d3c1e5bbbe7b90ca170392cc0f5efbc (patch) | |
tree | d79e445e87ae9a55e146c6c3b46fef6f238d23e7 /src/util.h | |
parent | d81411896f140981400e4fbf4aafacdbabad96cd (diff) |
Refactor io utils, add *-address-rw tools
Namespace io_ stuff into mem_io_ to be less likely to collision with
anything else. Add io-stream utility for working with streams instead of
direct buffers. Add address-rw tools for simple memory read/write, where
regions aren't needed.
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -2,6 +2,18 @@ #include <err.h> +static inline bool +is_hex(const char *str) +{ + return (strlen(str) > 2 && str[0] == '0' && str[1] == 'x'); +} + +static inline unsigned long long int +hexdecstrtoull(const char *str, char **endptr) +{ + return strtoull(str, endptr, (is_hex(str) ? 16 : 10)); +} + struct region { size_t start, end, offset; }; |