Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 1 | #ifndef OSMOCORE_UTIL_H |
| 2 | #define OSMOCORE_UTIL_H |
| 3 | |
| 4 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
| 5 | |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 6 | #include <stdint.h> |
| 7 | |
| 8 | struct value_string { |
| 9 | unsigned int value; |
| 10 | const char *str; |
| 11 | }; |
| 12 | |
| 13 | const char *get_value_string(const struct value_string *vs, uint32_t val); |
| 14 | int get_string_value(const struct value_string *vs, const char *str); |
| 15 | |
Harald Welte | a73e2f9 | 2010-03-04 10:50:32 +0100 | [diff] [blame] | 16 | char bcd2char(uint8_t bcd); |
| 17 | /* only works for numbers in ascci */ |
| 18 | uint8_t char2bcd(char c); |
Harald Welte | d284cd9 | 2010-03-01 21:58:31 +0100 | [diff] [blame] | 19 | |
Harald Welte | 3eba991 | 2010-07-30 10:37:29 +0200 | [diff] [blame] | 20 | int hexparse(const char *str, uint8_t *b, int max_len); |
Harald Welte | 40481e8 | 2010-07-30 11:40:32 +0200 | [diff] [blame] | 21 | char *hexdump(const unsigned char *buf, int len); |
Harald Welte | dee47cd | 2010-07-30 11:43:30 +0200 | [diff] [blame] | 22 | char *hexdump_nospc(const unsigned char *buf, int len); |
Harald Welte | 3eba991 | 2010-07-30 10:37:29 +0200 | [diff] [blame] | 23 | |
Harald Welte | ec8b450 | 2010-02-20 20:34:29 +0100 | [diff] [blame] | 24 | #endif |