libosmocore 0.9.6-23.20170220git32ee5af8.fc42
Osmocom core library
Loading...
Searching...
No Matches
utils.h File Reference
#include <osmocom/core/backtrace.h>
#include <osmocom/core/talloc.h>
#include <stdint.h>
#include <stdio.h>

Go to the source code of this file.

Data Structures

struct  value_string
 A mapping between human-readable string and numeric value. More...
 

Macros

#define ARRAY_SIZE(x)
 Determine number of elements in an array of static size.
 
#define OSMO_MAX(a, b)
 Return the maximum of two specified values.
 
#define OSMO_MIN(a, b)
 Return the minimum of two specified values.
 
#define OSMO_STRINGIFY(x)
 Stringify the contents of a macro, e.g. a port number.
 
#define OSMO_VALUE_STRING(x)
 Make a value_string entry from an enum value name.
 
#define osmo_static_assert(exp, name)
 
#define OSMO_SNPRINTF_RET(ret, rem, offset, len)
 
#define OSMO_ASSERT(exp)
 

Functions

const char * get_value_string (const struct value_string *vs, uint32_t val)
 get human-readable string for given value
 
const char * get_value_string_or_null (const struct value_string *vs, uint32_t val)
 get human-readable string or NULL for given value
 
int get_string_value (const struct value_string *vs, const char *str)
 get numeric value for given human-readable string
 
char osmo_bcd2char (uint8_t bcd)
 Convert BCD-encoded digit into printable character.
 
uint8_t osmo_char2bcd (char c)
 Convert number in ASCII to BCD value.
 
int osmo_hexparse (const char *str, uint8_t *b, int max_len)
 Parse a string containing hexadecimal digits.
 
char * osmo_ubit_dump (const uint8_t *bits, unsigned int len)
 Convert a sequence of unpacked bits to ASCII string.
 
char * osmo_hexdump (const unsigned char *buf, int len)
 Convert binary sequence to hexadecimal ASCII string.
 
char * osmo_hexdump_nospc (const unsigned char *buf, int len)
 Convert binary sequence to hexadecimal ASCII string.
 
char * osmo_osmo_hexdump_nospc (const unsigned char *buf, int len) __attribute__((__deprecated__))
 
void osmo_str2lower (char *out, const char *in)
 Convert an entire string to lower case.
 
void osmo_str2upper (char *out, const char *in)
 Convert an entire string to upper case.
 
static void osmo_talloc_replace_string (void *ctx, char **dst, const char *newstr)
 
int osmo_constant_time_cmp (const uint8_t *exp, const uint8_t *rel, const int count)
 Wishful thinking to generate a constant time compare.
 
uint64_t osmo_decode_big_endian (const uint8_t *data, size_t data_len)
 Generic retrieval of 1..8 bytes as big-endian uint64_t.
 
uint8_t * osmo_encode_big_endian (uint64_t value, size_t data_len)
 Generic big-endian encoding of big endian number up to 64bit.
 
size_t osmo_strlcpy (char *dst, const char *src, size_t siz)
 Copy a C-string into a sized buffer.