\doxysection{include/osmocom/core/bitvec.h File Reference}
\label{bitvec_8h}\index{include/osmocom/core/bitvec.h@{include/osmocom/core/bitvec.h}}
{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/defs.\+h$>$}\newline
{\ttfamily \#include $<$stdbool.\+h$>$}\newline
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ bitvec}
\begin{DoxyCompactList}\small\item\em structure describing a bit vector \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \textbf{ bit\+\_\+value} \{ \newline
\textbf{ ZERO} = 0
, \newline
\textbf{ ONE} = 1
, \newline
\textbf{ L} = 2
, \newline
\textbf{ H} = 3
 \}
\begin{DoxyCompactList}\small\item\em A single GSM bit. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
enum \textbf{ bit\+\_\+value} \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+pos} (const struct \textbf{ bitvec} $\ast$bv, unsigned int bitnr)
\begin{DoxyCompactList}\small\item\em check if the bit is 0 or 1 for a given position inside a bitvec \end{DoxyCompactList}\item 
enum \textbf{ bit\+\_\+value} \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+pos\+\_\+high} (const struct \textbf{ bitvec} $\ast$bv, unsigned int bitnr)
\begin{DoxyCompactList}\small\item\em check if the bit is L or H for a given position inside a bitvec \end{DoxyCompactList}\item 
unsigned int \textbf{ bitvec\+\_\+get\+\_\+nth\+\_\+set\+\_\+bit} (const struct \textbf{ bitvec} $\ast$bv, unsigned int \textbf{ n})
\begin{DoxyCompactList}\small\item\em get the Nth set bit inside the bit vector \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+set\+\_\+bit\+\_\+pos} (struct \textbf{ bitvec} $\ast$bv, unsigned int bitnr, enum \textbf{ bit\+\_\+value} bit)
\begin{DoxyCompactList}\small\item\em set a bit at given position in a bit vector \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+set\+\_\+bit} (struct \textbf{ bitvec} $\ast$bv, enum \textbf{ bit\+\_\+value} bit)
\begin{DoxyCompactList}\small\item\em set the next bit inside a bitvec \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+high} (struct \textbf{ bitvec} $\ast$bv)
\begin{DoxyCompactList}\small\item\em get the next bit (low/high) inside a bitvec \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+set\+\_\+bits} (struct \textbf{ bitvec} $\ast$bv, const enum \textbf{ bit\+\_\+value} $\ast$bits, unsigned int count)
\begin{DoxyCompactList}\small\item\em set multiple bits (based on array of bitvals) at current pos \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+set\+\_\+u64} (struct \textbf{ bitvec} $\ast$bv, uint64\+\_\+t v, uint8\+\_\+t num\+\_\+bits, bool use\+\_\+lh)
\begin{DoxyCompactList}\small\item\em set multiple bits (based on numeric value) at current pos. \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+set\+\_\+uint} (struct \textbf{ bitvec} $\ast$bv, unsigned int ui, unsigned int num\+\_\+bits)
\begin{DoxyCompactList}\small\item\em set multiple bits (based on numeric value) at current pos. \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+get\+\_\+uint} (struct \textbf{ bitvec} $\ast$bv, unsigned int num\+\_\+bits)
\begin{DoxyCompactList}\small\item\em get multiple bits (based on numeric value) from current pos \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+find\+\_\+bit\+\_\+pos} (const struct \textbf{ bitvec} $\ast$bv, unsigned int \textbf{ n}, enum \textbf{ bit\+\_\+value} val)
\begin{DoxyCompactList}\small\item\em find first bit set in bit vector \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+spare\+\_\+padding} (struct \textbf{ bitvec} $\ast$bv, unsigned int up\+\_\+to\+\_\+bit)
\begin{DoxyCompactList}\small\item\em pad all remaining bits up to a given bit number \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+get\+\_\+bytes} (struct \textbf{ bitvec} $\ast$bv, uint8\+\_\+t $\ast$bytes, unsigned int count)
\begin{DoxyCompactList}\small\item\em get multiple bytes from current pos Assumes MSB first encoding. \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+set\+\_\+bytes} (struct \textbf{ bitvec} $\ast$bv, const uint8\+\_\+t $\ast$bytes, unsigned int count)
\begin{DoxyCompactList}\small\item\em set multiple bytes at current pos Assumes MSB first encoding. \end{DoxyCompactList}\item 
struct \textbf{ bitvec} $\ast$ \textbf{ bitvec\+\_\+alloc} (unsigned int size, void $\ast$ctx)
\begin{DoxyCompactList}\small\item\em Allocate a bit vector. \end{DoxyCompactList}\item 
void \textbf{ bitvec\+\_\+free} (struct \textbf{ bitvec} $\ast$bv)
\begin{DoxyCompactList}\small\item\em Free a bit vector (release its memory) \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+unhex} (struct \textbf{ bitvec} $\ast$bv, const char $\ast$src)
\begin{DoxyCompactList}\small\item\em read hexadecimap string into a bit vector \end{DoxyCompactList}\item 
unsigned int \textbf{ bitvec\+\_\+pack} (const struct \textbf{ bitvec} $\ast$bv, uint8\+\_\+t $\ast$\textbf{ buffer})
\begin{DoxyCompactList}\small\item\em Export a bit vector to a buffer. \end{DoxyCompactList}\item 
unsigned int \textbf{ bitvec\+\_\+unpack} (struct \textbf{ bitvec} $\ast$bv, const uint8\+\_\+t $\ast$\textbf{ buffer})
\begin{DoxyCompactList}\small\item\em Copy buffer of unpacked bits into bit vector. \end{DoxyCompactList}\item 
uint64\+\_\+t \textbf{ bitvec\+\_\+read\+\_\+field} (struct \textbf{ bitvec} $\ast$bv, unsigned int $\ast$read\+\_\+index, unsigned int \textbf{ len})
\begin{DoxyCompactList}\small\item\em read part of the vector \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+write\+\_\+field} (struct \textbf{ bitvec} $\ast$bv, unsigned int $\ast$write\+\_\+index, uint64\+\_\+t val, unsigned int \textbf{ len})
\begin{DoxyCompactList}\small\item\em write into the vector \end{DoxyCompactList}\item 
int \textbf{ bitvec\+\_\+fill} (struct \textbf{ bitvec} $\ast$bv, unsigned int num\+\_\+bits, enum \textbf{ bit\+\_\+value} fill)
\begin{DoxyCompactList}\small\item\em fill num\+\_\+bits with \textbackslash{}fill starting from the current position \end{DoxyCompactList}\item 
char \textbf{ bit\+\_\+value\+\_\+to\+\_\+char} (enum \textbf{ bit\+\_\+value} v)
\begin{DoxyCompactList}\small\item\em convert enum to corresponding character \end{DoxyCompactList}\item 
void \textbf{ bitvec\+\_\+to\+\_\+string\+\_\+r} (const struct \textbf{ bitvec} $\ast$bv, char $\ast$str)
\begin{DoxyCompactList}\small\item\em prints bit vector to provided string It\textquotesingle{}s caller\textquotesingle{}s responsibility to ensure that we won\textquotesingle{}t shoot him in the foot\+: the provided buffer should be at lest cur\+\_\+bit + 1 bytes long \end{DoxyCompactList}\item 
void \textbf{ bitvec\+\_\+zero} (struct \textbf{ bitvec} $\ast$bv)
\begin{DoxyCompactList}\small\item\em force bit vector to all 0 and current bit to the beginnig of the vector \end{DoxyCompactList}\item 
unsigned \textbf{ bitvec\+\_\+rl} (const struct \textbf{ bitvec} $\ast$bv, bool b)
\begin{DoxyCompactList}\small\item\em Return number (bits) of uninterrupted bit run in vector starting from the MSB. \end{DoxyCompactList}\item 
unsigned \textbf{ bitvec\+\_\+rl\+\_\+curbit} (struct \textbf{ bitvec} $\ast$bv, bool b, unsigned int max\+\_\+bits)
\begin{DoxyCompactList}\small\item\em Return number (bits) of uninterrupted bit run in vector starting from the current bit. \end{DoxyCompactList}\item 
void \textbf{ bitvec\+\_\+shiftl} (struct \textbf{ bitvec} $\ast$bv, unsigned int \textbf{ n})
\item 
int16\+\_\+t \textbf{ bitvec\+\_\+get\+\_\+int16\+\_\+msb} (const struct \textbf{ bitvec} $\ast$bv, unsigned int num\+\_\+bits)
\begin{DoxyCompactList}\small\item\em get multiple bits (num\+\_\+bits) from beginning of vector (MSB side) \end{DoxyCompactList}\item 
unsigned int \textbf{ bitvec\+\_\+add\+\_\+array} (struct \textbf{ bitvec} $\ast$bv, const uint32\+\_\+t $\ast$array, unsigned int array\+\_\+len, bool dry\+\_\+run, unsigned int num\+\_\+bits)
\begin{DoxyCompactList}\small\item\em Add given array to bitvec. \end{DoxyCompactList}\item 
static unsigned int \textbf{ bitvec\+\_\+used\+\_\+bytes} (const struct \textbf{ bitvec} $\ast$bv)
\begin{DoxyCompactList}\small\item\em Return the number of bytes used within the bit vector. \end{DoxyCompactList}\item 
static unsigned int \textbf{ bitvec\+\_\+tailroom\+\_\+bits} (const struct \textbf{ bitvec} $\ast$bv)
\begin{DoxyCompactList}\small\item\em Return the tailroom in number of unused bits remaining in the bit-\/vector. \end{DoxyCompactList}\end{DoxyCompactItemize}
