utils.c File Reference
General-purpose utility functions
`#include <stdbool.h>`
`#include <string.h>`
`#include <stdint.h>`
`#include <errno.h>`
`#include <stdio.h>`
`#include <inttypes.h>`
`#include <osmocom/core/utils.h>`
`#include <osmocom/core/bit64gen.h>`
`#include "../config.h"`
`#include <ctype.h>`

## Macros

#define | BACKSLASH_CASE(c, repr)

## Functions

const char * | get_value_string (const struct value_string *vs, uint32_t val)
| get human-readable string for given value More...
const char * | get_value_string_or_null (const struct value_string *vs, uint32_t val)
| get human-readable string or NULL for given value More...
int | get_string_value (const struct value_string *vs, const char *str)
| get numeric value for given human-readable string More...
char | osmo_bcd2char (uint8_t bcd)
| Convert BCD-encoded digit into printable character. More...
uint8_t | osmo_char2bcd (char c)
| Convert number in ASCII to BCD value. More...
int | osmo_hexparse (const char *str, uint8_t *b, int max_len)
| Parse a string containing hexadecimal digits. More...
static char * | _osmo_hexdump (const unsigned char *buf, int len, char *delim)
char * | osmo_ubit_dump (const uint8_t *bits, unsigned int len)
| Convert a sequence of unpacked bits to ASCII string. More...
char * | osmo_hexdump (const unsigned char *buf, int len)
| Convert binary sequence to hexadecimal ASCII string. More...
char * | osmo_hexdump_nospc (const unsigned char *buf, int len)
| Convert binary sequence to hexadecimal ASCII string. More...
char * | osmo_osmo_hexdump_nospc (const unsigned char *buf, int len) __attribute__((__deprecated__))
char | alias ("osmo_hexdump_nospc")))
void | osmo_str2lower (char *out, const char *in)
| Convert an entire string to lower case. More...
void | osmo_str2upper (char *out, const char *in)
| Convert an entire string to upper case. More...
int | osmo_constant_time_cmp (const uint8_t *exp, const uint8_t *rel, const int count)
| Wishful thinking to generate a constant time compare. More...
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. More...
uint8_t * | osmo_encode_big_endian (uint64_t value, size_t data_len)
| Generic big-endian encoding of big endian number up to 64bit. More...
size_t | osmo_strlcpy (char *dst, const char *src, size_t siz)
| Copy a C-string into a sized buffer. More...
bool | osmo_is_hexstr (const char *str, int min_digits, int max_digits, bool require_even)
| Validate that a given string is a hex string within given size limits. More...
bool | osmo_separated_identifiers_valid (const char *str, const char *sep_chars)
| Determine if a given identifier is valid, i.e. More...
bool | osmo_identifier_valid (const char *str)
| Determine if a given identifier is valid, i.e. More...
const char * | osmo_escape_str_buf (const char *str, int in_len, char *buf, size_t bufsize)
| Return the string with all non-printable characters escaped. More...
const char * | osmo_escape_str (const char *str, int in_len)
| Return the string with all non-printable characters escaped. More...
const char * | osmo_quote_str_buf (const char *str, int in_len, char *buf, size_t bufsize)
| Like osmo_escape_str(), but returns double-quotes around a string, or "NULL" for a NULL string. More...
const char * | osmo_quote_str (const char *str, int in_len)
uint32_t | osmo_isqrt32 (uint32_t x)
| perform an integer square root operation on unsigned 32bit integer. More...

## Variables

static char | namebuf [255]
static char | hexd_buff [4096]
static const char | hex_chars [] = "0123456789abcdef"

## Macro Definition Documentation

## BACKSLASH_CASE

#define BACKSLASH_CASE | ( |  | c,
|  |  | repr
| ) |  |

Value:
case c: \
if (out_pos > out_len-2) \
goto done; \
out[out_pos++] = '\\'; \
out[out_pos++] = repr; \
break