Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

Header Manipulation
[Dynamic page interfaces]


Functions

int field_set (field_t *, const char *name, const char *value)
 Set a field.
int field_set_from_line (field_t *, const char *line)
 Set a field from a line.
const char * field_get_name (field_t *f)
 Get the name of a field.
const char * field_get_value (field_t *f)
 Get the value of a field.
int field_create (const char *name, const char *value, field_t **pf)
 Create a field.
int field_free (field_t *f)
 Free a field.
int header_set_field (header_t *h, const char *name, const char *value)
 Set the value of a field in a header.
int header_clear (header_t *h)
 Clear a header.
size_t header_field_count (header_t *h)
 Count fields in a header.
field_theader_get_fieldn (header_t *h, size_t idx)
 Get ith field in a header.
field_theader_get_field (header_t *h, const char *name)
 Get a field given a name.
const char * header_get_field_value (header_t *h, const char *name)
 Get field value.
int header_del_field (header_t *h, field_t *f)
 Delete a field from a header.
int header_add_field (header_t *h, field_t *f)
 Add a field to a header.

Function Documentation

int field_set field_t f,
const char *  name,
const char *  value
 

Set field f to have name and value.

Parameters:
f field object
name field name
value field value
Returns:
0 if successful, non-zero on error

Definition at line 34 of file field.c.

References field_s::name, and field_s::value.

Referenced by field_set_from_line(), and header_set_field().

int field_set_from_line field_t f,
const char *  ln
 

Set the name and value of field f. Name and value must be separated by ":".

Parameters:
f field object
ln line
Returns:
0 if successful, non-zero on error

Definition at line 74 of file field.c.

References field_set().

const char * field_get_name field_t f  ) 
 

Return the string value of field f.

Parameters:
f field object
Returns:
the (null-terminated) string corresponding to the field name

Definition at line 112 of file field.c.

References field_s::name.

const char * field_get_value field_t f  ) 
 

Return the string value of field f.

Parameters:
f field object
Returns:
the (null-terminated) string corresponding to the field value

Definition at line 129 of file field.c.

References field_s::value.

Referenced by header_get_field_value().

int field_create const char *  name,
const char *  value,
field_t **  pf
 

Create a field from name and value into *pf.

Parameters:
name field name
value field value
pf address of field pointer
Returns:
0 if successful, non-zero on error

Definition at line 148 of file field.c.

References field_free(), field_s::name, and field_s::value.

Referenced by header_set_field(), response_redirect(), and response_set_cookie().

int field_free field_t f  ) 
 

Free field f.

Parameters:
f field object
Returns:
0, always

Definition at line 183 of file field.c.

References field_s::name, and field_s::value.

Referenced by field_create(), header_clear(), header_set_field(), response_del_field(), and response_set_cookie().

int header_set_field header_t h,
const char *  name,
const char *  value
 

Set the value of field name to value in header h.

Parameters:
h header object
name name of the field
value value of the field
Returns:
0 if successful, non-zero on error

Definition at line 29 of file header.c.

References field_create(), field_free(), field_set(), header_add_field(), and header_get_field().

Referenced by response_set_content_encoding(), response_set_content_length(), response_set_content_type(), response_set_date(), response_set_field(), and response_set_last_modified().

int header_clear header_t h  ) 
 

Clear all items in header h.

Parameters:
h header object
Returns:
0 if successful, non-zero on error

Definition at line 62 of file header.c.

References field_free(), header_t::fields, and header_del_field().

size_t header_field_count header_t h  ) 
 

Return the number of fields in header h.

Parameters:
h header object
Returns:
the number of fields found in h

Definition at line 88 of file header.c.

References header_t::nfields.

field_t* header_get_fieldn header_t h,
size_t  idx
 

Return the field_t object at index idx in header h.

Parameters:
h header object
idx index
Returns:
the pointer to the field or NULL if no field could be found

Definition at line 106 of file header.c.

References header_t::fields, and header_t::nfields.

field_t* header_get_field header_t h,
const char *  name
 

Return the first matching field_t object with name name in header h

Parameters:
h header object
name name of the field to be searched
Returns:
  • the field string corresponding to name
  • NULL if no field could be found

Definition at line 138 of file header.c.

References header_t::fields, and field_s::name.

Referenced by header_get_field_value(), header_set_field(), request_get_field(), and response_del_field().

const char* header_get_field_value header_t h,
const char *  name
 

Return a string representation of the field with name name in header h

Parameters:
h header object
name name of the field
Returns:
  • the field string corresponding to name
  • NULL if no field could be found

Definition at line 166 of file header.c.

References field_get_value(), and header_get_field().

Referenced by request_get_field_value().

int header_del_field header_t h,
field_t f
 

Delete the supplied field f in header h.

Parameters:
h header object
f field to be deleted
Returns:
0 on success, non-zero otherwise

Definition at line 189 of file header.c.

References header_t::fields, and header_t::nfields.

Referenced by header_clear(), and response_del_field().

int header_add_field header_t h,
field_t f
 

Add a field f to header h.

Parameters:
h header object
f field to be added
Returns:
0 on success, non-zero otherwise

Definition at line 211 of file header.c.

References header_t::fields, and header_t::nfields.

Referenced by header_set_field(), response_redirect(), and response_set_cookie().