blob: 93cefbe69ec8380ca41b9245debcda2d330c6cbb [file] [log] [blame]
Harald Welteec8b4502010-02-20 20:34:29 +01001#ifndef OSMOCORE_UTIL_H
2#define OSMOCORE_UTIL_H
3
4#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
5
Harald Welted284cd92010-03-01 21:58:31 +01006#include <stdint.h>
7
8struct value_string {
9 unsigned int value;
10 const char *str;
11};
12
13const char *get_value_string(const struct value_string *vs, uint32_t val);
14int get_string_value(const struct value_string *vs, const char *str);
15
Harald Weltea73e2f92010-03-04 10:50:32 +010016char bcd2char(uint8_t bcd);
17/* only works for numbers in ascci */
18uint8_t char2bcd(char c);
Harald Welted284cd92010-03-01 21:58:31 +010019
Harald Welte3eba9912010-07-30 10:37:29 +020020int hexparse(const char *str, uint8_t *b, int max_len);
Harald Welte40481e82010-07-30 11:40:32 +020021char *hexdump(const unsigned char *buf, int len);
Harald Weltedee47cd2010-07-30 11:43:30 +020022char *hexdump_nospc(const unsigned char *buf, int len);
Harald Welte3eba9912010-07-30 10:37:29 +020023
Holger Hans Peter Freyther52c07ca2011-01-16 17:37:27 +010024#define static_assert(exp, name) typedef int dummy##name [(exp) ? 1 : -1];
25
Harald Welteec8b4502010-02-20 20:34:29 +010026#endif