ISC DHCP  4.4.3-P1
A reference DHCPv4 and DHCPv6 implementation
data.h File Reference
#include <stdint.h>
#include <stdio.h>

Go to the source code of this file.

Data Structures

struct  string
 
struct  comment
 
union  value
 
struct  element
 
struct  handle
 

Macros

#define TAILQ_HEAD(name, type)
 
#define TAILQ_ENTRY(type)
 
#define TAILQ_CONCAT(head1, head2)
 
#define TAILQ_EMPTY(head)   ((head)->tqh_first == NULL)
 
#define TAILQ_FIRST(head)   ((head)->tqh_first)
 
#define TAILQ_FOREACH(var, head)
 
#define TAILQ_FOREACH_SAFE(var, head, tvar)
 
#define TAILQ_INIT(head)
 
#define TAILQ_INSERT_AFTER(head, listelm, elm)
 
#define TAILQ_INSERT_BEFORE(listelm, elm)
 
#define TAILQ_INSERT_HEAD(head, elm)
 
#define TAILQ_INSERT_TAIL(head, elm)
 
#define TAILQ_LAST(head, headname)    (*(((struct headname *)((head)->tqh_last))->tqh_last))
 
#define TAILQ_NEXT(elm)   ((elm)->next.tqe_next)
 
#define TAILQ_PREV(elm, headname)    (*(((struct headname *)((elm)->next.tqe_prev))->tqh_last))
 
#define TAILQ_REMOVE(head, elm)
 
#define TAILQ_SWAP(head1, head2, type)
 
#define ISC_FALSE   isc_boolean_false
 
#define ISC_TRUE   isc_boolean_true
 
#define ISC_TF(x)   ((x) ? ISC_TRUE : ISC_FALSE)
 
#define ELEMENT_NONE   0
 
#define ELEMENT_INTEGER   1
 
#define ELEMENT_REAL   2
 
#define ELEMENT_BOOLEAN   3
 
#define ELEMENT_NULL   4
 
#define ELEMENT_STRING   5
 
#define ELEMENT_LIST   6
 
#define ELEMENT_MAP   7
 

Enumerations

enum  isc_boolean_t { isc_boolean_false = 0 , isc_boolean_true = 1 }
 

Functions

struct stringallocString (void)
 
struct stringmakeString (int l, const char *s)
 
struct stringmakeStringExt (int l, const char *s, char fmt)
 
struct stringmakeStringArray (int l, const char *s, char fmt)
 
void appendString (struct string *s, const char *a)
 
void concatString (struct string *s, const struct string *a)
 
isc_boolean_t eqString (const struct string *s, const struct string *o)
 
struct stringquote (struct string *)
 
 TAILQ_HEAD (comments, comment)
 
struct commentcreateComment (const char *line)
 
 TAILQ_HEAD (list, element)
 
 TAILQ_HEAD (map, element)
 
int64_t intValue (const struct element *e)
 
double doubleValue (const struct element *e)
 
isc_boolean_t boolValue (const struct element *e)
 
struct stringstringValue (struct element *e)
 
struct list * listValue (struct element *e)
 
struct map * mapValue (struct element *e)
 
struct elementcreate (void)
 
struct elementcreateInt (int64_t i)
 
struct elementcreateDouble (double d)
 
struct elementcreateBool (isc_boolean_t b)
 
struct elementcreateNull (void)
 
struct elementcreateString (const struct string *s)
 
struct elementcreateList (void)
 
struct elementcreateMap (void)
 
void resetInt (struct element *e, int64_t i)
 
void resetDouble (struct element *e, double d)
 
void resetBool (struct element *e, isc_boolean_t b)
 
void resetNull (struct element *e)
 
void resetString (struct element *e, const struct string *s)
 
void resetList (struct element *e)
 
void resetMap (struct element *e)
 
void resetBy (struct element *e, struct element *o)
 
struct elementlistGet (struct element *l, int i)
 
void listSet (struct element *l, struct element *e, int i)
 
void listPush (struct element *l, struct element *e)
 
void listRemove (struct element *l, int i)
 
size_t listSize (const struct element *l)
 
void concat (struct element *l, struct element *o)
 
struct elementmapGet (struct element *m, const char *k)
 
void mapSet (struct element *m, struct element *e, const char *k)
 
void mapRemove (struct element *m, const char *k)
 
isc_boolean_t mapContains (const struct element *m, const char *k)
 
size_t mapSize (const struct element *m)
 
void merge (struct element *m, struct element *o)
 
const char * type2name (int t)
 
int name2type (const char *n)
 
void print (FILE *fp, const struct element *e, isc_boolean_t skip, unsigned indent)
 
void printList (FILE *fp, const struct list *l, isc_boolean_t skip, unsigned indent)
 
void printMap (FILE *fp, const struct map *m, isc_boolean_t skip, unsigned indent)
 
void printString (FILE *fp, const struct string *s)
 
isc_boolean_t skip_to_end (const struct element *e)
 
struct elementcopy (struct element *e)
 
struct elementcopyList (struct element *l)
 
struct elementcopyMap (struct element *m)
 
 TAILQ_HEAD (handles, handle)
 
struct handlemapPop (struct element *)
 
void derive (struct handle *, struct handle *)
 
struct stringhexaValue (struct element *)
 
struct elementcreateHexa (struct string *)
 

Macro Definition Documentation

◆ ELEMENT_BOOLEAN

#define ELEMENT_BOOLEAN   3

Definition at line 164 of file data.h.

◆ ELEMENT_INTEGER

#define ELEMENT_INTEGER   1

Definition at line 162 of file data.h.

◆ ELEMENT_LIST

#define ELEMENT_LIST   6

Definition at line 167 of file data.h.

◆ ELEMENT_MAP

#define ELEMENT_MAP   7

Definition at line 168 of file data.h.

◆ ELEMENT_NONE

#define ELEMENT_NONE   0

Definition at line 161 of file data.h.

◆ ELEMENT_NULL

#define ELEMENT_NULL   4

Definition at line 165 of file data.h.

◆ ELEMENT_REAL

#define ELEMENT_REAL   2

Definition at line 163 of file data.h.

◆ ELEMENT_STRING

#define ELEMENT_STRING   5

Definition at line 166 of file data.h.

◆ ISC_FALSE

#define ISC_FALSE   isc_boolean_false

Definition at line 152 of file data.h.

◆ ISC_TF

#define ISC_TF (   x)    ((x) ? ISC_TRUE : ISC_FALSE)

Definition at line 154 of file data.h.

◆ ISC_TRUE

#define ISC_TRUE   isc_boolean_true

Definition at line 153 of file data.h.

◆ TAILQ_CONCAT

#define TAILQ_CONCAT (   head1,
  head2 
)
Value:
do { \
if (!TAILQ_EMPTY(head2)) { \
*(head1)->tqh_last = (head2)->tqh_first; \
(head2)->tqh_first->next.tqe_prev = (head1)->tqh_last; \
(head1)->tqh_last = (head2)->tqh_last; \
TAILQ_INIT((head2)); \
} \
} while (0)
#define TAILQ_EMPTY(head)
Definition: data.h:58

Definition at line 49 of file data.h.

◆ TAILQ_EMPTY

#define TAILQ_EMPTY (   head)    ((head)->tqh_first == NULL)

Definition at line 58 of file data.h.

◆ TAILQ_ENTRY

#define TAILQ_ENTRY (   type)
Value:
struct { \
struct type *tqe_next; /* next element */ \
struct type **tqe_prev; /* address of previous next element */ \
}

Definition at line 40 of file data.h.

◆ TAILQ_FIRST

#define TAILQ_FIRST (   head)    ((head)->tqh_first)

Definition at line 60 of file data.h.

◆ TAILQ_FOREACH

#define TAILQ_FOREACH (   var,
  head 
)
Value:
for ((var) = TAILQ_FIRST((head)); \
(var); \
(var) = TAILQ_NEXT((var)))
#define TAILQ_FIRST(head)
Definition: data.h:60
#define TAILQ_NEXT(elm)
Definition: data.h:115

Definition at line 62 of file data.h.

◆ TAILQ_FOREACH_SAFE

#define TAILQ_FOREACH_SAFE (   var,
  head,
  tvar 
)
Value:
for ((var) = TAILQ_FIRST((head)); \
(var) && ((tvar) = TAILQ_NEXT((var)), 1); \
(var) = (tvar))

Definition at line 67 of file data.h.

◆ TAILQ_HEAD

#define TAILQ_HEAD (   name,
  type 
)
Value:
struct name { \
struct type *tqh_first; /* first element */ \
struct type **tqh_last; /* addr of last next element */ \
}

Definition at line 34 of file data.h.

◆ TAILQ_INIT

#define TAILQ_INIT (   head)
Value:
do { \
TAILQ_FIRST((head)) = NULL; \
(head)->tqh_last = &TAILQ_FIRST((head)); \
} while (0)

Definition at line 72 of file data.h.

◆ TAILQ_INSERT_AFTER

#define TAILQ_INSERT_AFTER (   head,
  listelm,
  elm 
)
Value:
do { \
if ((TAILQ_NEXT((elm)) = TAILQ_NEXT((listelm))) != NULL) \
TAILQ_NEXT((elm))->next.tqe_prev = \
&TAILQ_NEXT((elm)); \
else { \
(head)->tqh_last = &TAILQ_NEXT((elm)); \
} \
TAILQ_NEXT((listelm)) = (elm); \
(elm)->next.tqe_prev = &TAILQ_NEXT((listelm)); \
} while (0)

Definition at line 77 of file data.h.

◆ TAILQ_INSERT_BEFORE

#define TAILQ_INSERT_BEFORE (   listelm,
  elm 
)
Value:
do { \
(elm)->next.tqe_prev = (listelm)->next.tqe_prev; \
TAILQ_NEXT((elm)) = (listelm); \
*(listelm)->next.tqe_prev = (elm); \
(listelm)->next.tqe_prev = &TAILQ_NEXT((elm)); \
} while (0)

Definition at line 88 of file data.h.

◆ TAILQ_INSERT_HEAD

#define TAILQ_INSERT_HEAD (   head,
  elm 
)
Value:
do { \
if ((TAILQ_NEXT((elm)) = TAILQ_FIRST((head))) != NULL) \
TAILQ_FIRST((head))->next.tqe_prev = \
&TAILQ_NEXT((elm)); \
else \
(head)->tqh_last = &TAILQ_NEXT((elm)); \
TAILQ_FIRST((head)) = (elm); \
(elm)->next.tqe_prev = &TAILQ_FIRST((head)); \
} while (0)

Definition at line 95 of file data.h.

◆ TAILQ_INSERT_TAIL

#define TAILQ_INSERT_TAIL (   head,
  elm 
)
Value:
do { \
TAILQ_NEXT((elm)) = NULL; \
(elm)->next.tqe_prev = (head)->tqh_last; \
*(head)->tqh_last = (elm); \
(head)->tqh_last = &TAILQ_NEXT((elm)); \
} while (0)

Definition at line 105 of file data.h.

◆ TAILQ_LAST

#define TAILQ_LAST (   head,
  headname 
)     (*(((struct headname *)((head)->tqh_last))->tqh_last))

Definition at line 112 of file data.h.

◆ TAILQ_NEXT

#define TAILQ_NEXT (   elm)    ((elm)->next.tqe_next)

Definition at line 115 of file data.h.

◆ TAILQ_PREV

#define TAILQ_PREV (   elm,
  headname 
)     (*(((struct headname *)((elm)->next.tqe_prev))->tqh_last))

Definition at line 117 of file data.h.

◆ TAILQ_REMOVE

#define TAILQ_REMOVE (   head,
  elm 
)
Value:
do { \
if ((TAILQ_NEXT((elm))) != NULL) \
TAILQ_NEXT((elm))->next.tqe_prev = \
(elm)->next.tqe_prev; \
else \
(head)->tqh_last = (elm)->next.tqe_prev; \
*(elm)->next.tqe_prev = TAILQ_NEXT((elm)); \
(elm)->next.tqe_next = (void *)-1; \
(elm)->next.tqe_prev = (void *)-1; \
} while (0)

Definition at line 120 of file data.h.

◆ TAILQ_SWAP

#define TAILQ_SWAP (   head1,
  head2,
  type 
)
Value:
do { \
struct type *swap_first = (head1)->tqh_first; \
struct type **swap_last = (head1)->tqh_last; \
(head1)->tqh_first = (head2)->tqh_first; \
(head1)->tqh_last = (head2)->tqh_last; \
(head2)->tqh_first = swap_first; \
(head2)->tqh_last = swap_last; \
if ((swap_first = (head1)->tqh_first) != NULL) \
swap_first->next.tqe_prev = &(head1)->tqh_first; \
else \
(head1)->tqh_last = &(head1)->tqh_first; \
if ((swap_first = (head2)->tqh_first) != NULL) \
swap_first->next.tqe_prev = &(head2)->tqh_first; \
else \
(head2)->tqh_last = &(head2)->tqh_first; \
} while (0)

Definition at line 131 of file data.h.

Enumeration Type Documentation

◆ isc_boolean_t

Enumerator
isc_boolean_false 
isc_boolean_true 

Definition at line 150 of file data.h.

Function Documentation

◆ allocString()

struct string* allocString ( void  )

Definition at line 32 of file data.c.

◆ appendString()

void appendString ( struct string s,
const char *  a 
)

Definition at line 311 of file data.c.

◆ boolValue()

isc_boolean_t boolValue ( const struct element e)

Definition at line 399 of file data.c.

◆ concat()

void concat ( struct element l,
struct element o 
)

Definition at line 748 of file data.c.

◆ concatString()

void concatString ( struct string s,
const struct string a 
)

Definition at line 330 of file data.c.

◆ copy()

struct element* copy ( struct element e)

Definition at line 1115 of file data.c.

◆ copyList()

struct element* copyList ( struct element l)

Definition at line 1162 of file data.c.

◆ copyMap()

struct element* copyMap ( struct element m)

Definition at line 1174 of file data.c.

◆ create()

struct element* create ( void  )

Definition at line 432 of file data.c.

◆ createBool()

struct element* createBool ( isc_boolean_t  b)

Definition at line 469 of file data.c.

◆ createComment()

struct comment* createComment ( const char *  line)

Definition at line 367 of file data.c.

◆ createDouble()

struct element* createDouble ( double  d)

Definition at line 457 of file data.c.

◆ createHexa()

struct element* createHexa ( struct string h)

Definition at line 1249 of file data.c.

◆ createInt()

struct element* createInt ( int64_t  i)

Definition at line 445 of file data.c.

◆ createList()

struct element* createList ( void  )

Definition at line 504 of file data.c.

◆ createMap()

struct element* createMap ( void  )

Definition at line 516 of file data.c.

◆ createNull()

struct element* createNull ( void  )

Definition at line 481 of file data.c.

◆ createString()

struct element* createString ( const struct string s)

Definition at line 492 of file data.c.

◆ derive()

void derive ( struct handle src,
struct handle dst 
)

Definition at line 1212 of file data.c.

◆ doubleValue()

double doubleValue ( const struct element e)

Definition at line 391 of file data.c.

◆ eqString()

isc_boolean_t eqString ( const struct string s,
const struct string o 
)

Definition at line 343 of file data.c.

◆ hexaValue()

struct string* hexaValue ( struct element s)

Definition at line 1234 of file data.c.

◆ intValue()

int64_t intValue ( const struct element e)

Definition at line 383 of file data.c.

◆ listGet()

struct element* listGet ( struct element l,
int  i 
)

Definition at line 646 of file data.c.

◆ listPush()

void listPush ( struct element l,
struct element e 
)

Definition at line 697 of file data.c.

◆ listRemove()

void listRemove ( struct element l,
int  i 
)

Definition at line 707 of file data.c.

◆ listSet()

void listSet ( struct element l,
struct element e,
int  i 
)

Definition at line 669 of file data.c.

◆ listSize()

size_t listSize ( const struct element l)

Definition at line 730 of file data.c.

◆ listValue()

struct list* listValue ( struct element e)

Definition at line 416 of file data.c.

◆ makeString()

struct string* makeString ( int  l,
const char *  s 
)

Definition at line 44 of file data.c.

◆ makeStringArray()

struct string* makeStringArray ( int  l,
const char *  s,
char  fmt 
)

Definition at line 268 of file data.c.

◆ makeStringExt()

struct string* makeStringExt ( int  l,
const char *  s,
char  fmt 
)

Definition at line 64 of file data.c.

◆ mapContains()

isc_boolean_t mapContains ( const struct element m,
const char *  k 
)

Definition at line 811 of file data.c.

◆ mapGet()

struct element* mapGet ( struct element m,
const char *  k 
)

Definition at line 759 of file data.c.

◆ mapPop()

struct handle* mapPop ( struct element m)

Definition at line 1186 of file data.c.

◆ mapRemove()

void mapRemove ( struct element m,
const char *  k 
)

Definition at line 792 of file data.c.

◆ mapSet()

void mapSet ( struct element m,
struct element e,
const char *  k 
)

Definition at line 777 of file data.c.

◆ mapSize()

size_t mapSize ( const struct element m)

Definition at line 829 of file data.c.

◆ mapValue()

struct map* mapValue ( struct element e)

Definition at line 424 of file data.c.

◆ merge()

void merge ( struct element m,
struct element o 
)

Definition at line 847 of file data.c.

◆ name2type()

int name2type ( const char *  n)

Definition at line 895 of file data.c.

◆ print()

void print ( FILE *  fp,
const struct element e,
isc_boolean_t  skip,
unsigned  indent 
)

Definition at line 919 of file data.c.

◆ printList()

void printList ( FILE *  fp,
const struct list *  l,
isc_boolean_t  skip,
unsigned  indent 
)

Definition at line 970 of file data.c.

◆ printMap()

void printMap ( FILE *  fp,
const struct map *  m,
isc_boolean_t  skip,
unsigned  indent 
)

Definition at line 1014 of file data.c.

◆ printString()

void printString ( FILE *  fp,
const struct string s 
)

Definition at line 1059 of file data.c.

◆ quote()

struct string* quote ( struct string s)

Definition at line 356 of file data.c.

◆ resetBool()

void resetBool ( struct element e,
isc_boolean_t  b 
)

Definition at line 557 of file data.c.

◆ resetBy()

void resetBy ( struct element e,
struct element o 
)

Definition at line 605 of file data.c.

◆ resetDouble()

void resetDouble ( struct element e,
double  d 
)

Definition at line 547 of file data.c.

◆ resetInt()

void resetInt ( struct element e,
int64_t  i 
)

Definition at line 537 of file data.c.

◆ resetList()

void resetList ( struct element e)

Definition at line 585 of file data.c.

◆ resetMap()

void resetMap ( struct element e)

Definition at line 595 of file data.c.

◆ resetNull()

void resetNull ( struct element e)

Definition at line 566 of file data.c.

◆ resetString()

void resetString ( struct element e,
const struct string s 
)

Definition at line 575 of file data.c.

◆ skip_to_end()

isc_boolean_t skip_to_end ( const struct element e)

Definition at line 1104 of file data.c.

◆ stringValue()

struct string* stringValue ( struct element e)

Definition at line 408 of file data.c.

◆ TAILQ_HEAD() [1/4]

TAILQ_HEAD ( comments  ,
comment   
)

◆ TAILQ_HEAD() [2/4]

TAILQ_HEAD ( handles  ,
handle   
)

◆ TAILQ_HEAD() [3/4]

TAILQ_HEAD ( list  ,
element   
)

◆ TAILQ_HEAD() [4/4]

TAILQ_HEAD ( map  ,
element   
)

◆ type2name()

const char* type2name ( int  t)

Definition at line 867 of file data.c.