KLone APIs | Modules | Data Structures | File List | Data Fields | Globals

vars.h File Reference

Go to the source code of this file.


Typedefs

typedef vars_s vars_t
typedef int(* vars_cb_t )(var_t *, void *)

Enumerations

enum  { VARS_FLAG_NONE = 0, VARS_FLAG_FOREIGN = 1 << 0 }

Functions

int vars_create (vars_t **pvs)
int vars_free (vars_t *vs)
int vars_set_flags (vars_t *vs, int flags)
int vars_add (vars_t *vs, var_t *v)
int vars_del (vars_t *vs, var_t *v)
int vars_add_strvar (vars_t *vs, const char *str)
int vars_add_urlvar (vars_t *vs, const char *cstr, var_t **v)
var_tvars_getn (vars_t *vs, size_t n)
size_t vars_count (vars_t *vs)
size_t vars_countn (vars_t *vs, const char *name)
void vars_foreach (vars_t *vs, int(*foreach)(var_t *, void *), void *arg)
var_tvars_get (vars_t *vs, const char *name)
const char * vars_get_value (vars_t *vs, const char *name)
int vars_get_value_i (vars_t *vs, const char *name)
u_string_t * vars_get_value_s (vars_t *vs, const char *name)
var_tvars_geti (vars_t *vs, const char *name, size_t ith)
const char * vars_geti_value (vars_t *vs, const char *name, size_t ith)
int vars_geti_value_i (vars_t *vs, const char *name, size_t ith)
u_string_t * vars_geti_value_s (vars_t *vs, const char *name, size_t ith)

Typedef Documentation

typedef int(* vars_cb_t)(var_t*, void*)
 

Definition at line 29 of file vars.h.

typedef struct vars_s vars_t
 

Definition at line 27 of file vars.h.


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
VARS_FLAG_NONE 
VARS_FLAG_FOREIGN 

Definition at line 21 of file vars.h.


Function Documentation

int vars_add vars_t vs,
var_t v
 

Definition at line 108 of file vars.c.

int vars_add_strvar vars_t vs,
const char *  str
 

Definition at line 290 of file vars.c.

int vars_add_urlvar vars_t vs,
const char *  cstr,
var_t **  pv
 

Add an URL variable.

Parse the "name=value" string cstr, url-decode name and value and push it into vs. The variable is returned at *v.

Parameters:
vs variables' list where the variable is pushed
cstr URL string to parse
v the generated variable as a value-result argument
Returns:
0 if successful, non-zero on error

Definition at line 212 of file vars.c.

size_t vars_count vars_t vs  ) 
 

Count the number of variables.

Return a the number of variables in a list

Parameters:
vs variable list
Returns:
the number of elements in vs

Definition at line 164 of file vars.c.

size_t vars_countn vars_t vs,
const char *  name
 

Count the number of variables with given name.

Return a the number of variables in a list with given name name

Parameters:
vs variable list
name name of the variables to count
Returns:
the number of elements in vs whose name is name

Definition at line 182 of file vars.c.

int vars_create vars_t **  pvs  ) 
 

Definition at line 53 of file vars.c.

int vars_del vars_t vs,
var_t v
 

Definition at line 120 of file vars.c.

void vars_foreach vars_t vs,
int(*  cb)(var_t *, void *),
void *  arg
 

Execute a function on a list of variables.

Execute function cb with optional arguments arg on all variables in list vs

Parameters:
vs variable list
cb function to be called on each variable (see prototype)
arg argument to cb
Returns:
nothing

Definition at line 517 of file vars.c.

int vars_free vars_t vs  ) 
 

Definition at line 84 of file vars.c.

var_t* vars_get vars_t vs,
const char *  var_name
 

Get a variable with given name.

Return a var_t object with name name in list vs.

Parameters:
vs variable list
var_name variable name
Returns:
  • the var_t object found
  • NULL if there's no variable called var_name in vs

Definition at line 371 of file vars.c.

const char* vars_get_value vars_t vs,
const char *  name
 

Get the value of the variable with given name.

Return the string value of the variable with name name in list vs.

Parameters:
vs variable list that is scanned
name variable name to search
Returns:
  • the value string corresponding to name
  • NULL if no value could be found

Definition at line 496 of file vars.c.

int vars_get_value_i vars_t vs,
const char *  name
 

Get the integer value of a variable with a given name.

Return the integer value of the variable with name name in list vs.

Parameters:
vs variable list
name variable name
Returns:
  • the integer value of name
  • 0 if no value could be found

Definition at line 448 of file vars.c.

u_string_t* vars_get_value_s vars_t vs,
const char *  name
 

Get u_string_t value of a variable.

Return an u_string_t containing the value of variable with name in variable list vs.

Parameters:
vs variable list
name name of variable
Returns:
the variable value (may be NULL)

Definition at line 39 of file vars.c.

var_t* vars_geti vars_t vs,
const char *  var_name,
size_t  i
 

Get i-th variable with given name.

Return the var_t object at index i with name var_name in list vs.

Parameters:
vs variable list
var_name variable name
i index
Returns:
  • the var_t object found
  • NULL if there's no i-th variable called var_name in vs

Definition at line 337 of file vars.c.

const char* vars_geti_value vars_t vs,
const char *  name,
size_t  ith
 

Get the value of the variable at a given index.

Return the string value of the variable with name name and index ith in list vs.

Parameters:
vs variable list that is scanned
name variable name to search
ith index of the searched variable
Returns:
  • the value string corresponding to name at i-th position
  • NULL if no value could be found

Definition at line 471 of file vars.c.

int vars_geti_value_i vars_t vs,
const char *  name,
size_t  ith
 

Get the integer value of a variable with a given name and index.

Get the integer value of the variable with name name and index ith in list vs.

Parameters:
vs variable list
name variable name
ith index
Returns:
  • the integer value of name
  • 0 if no value could be found

Definition at line 394 of file vars.c.

u_string_t* vars_geti_value_s vars_t vs,
const char *  name,
size_t  ith
 

Get u_string_t value of i-th variable.

Return an u_string_t containing the value of i-th variable with name in variable list vs.

Parameters:
vs variable list
name name of variable
ith index
Returns:
the variable value (may be NULL)

Definition at line 421 of file vars.c.

var_t* vars_getn vars_t vs,
size_t  i
 

Get ith variable.

Return the var_t at index i in list vs.

Parameters:
vs variable list
i index
Returns:
the ith variable or NULL if there's no ith var in vs

Definition at line 143 of file vars.c.

int vars_set_flags vars_t vs,
int  flags
 

Definition at line 73 of file vars.c.