NetSurf
Data Structures | Macros | Typedefs | Functions
generics.h File Reference
#include <stdbool.h>
#include "utils/errors.h"
Include dependency graph for generics.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  http__item
 Representation of an item. More...
 

Macros

#define HTTP__ITEM_INIT(item, n, f)
 
#define http__item_list_destroy(l)    http___item_list_destroy((http__item *) (l))
 
#define http__item_list_parse(i, p, f, r)
 

Typedefs

typedef struct http__item http__item
 Representation of an item. More...
 
typedef nserror(* http__itemparser) (const char **input, http__item **item)
 Type of an item parser. More...
 

Functions

void http___item_list_destroy (http__item *list)
 Destructor for an item list. More...
 
nserror http___item_list_parse (const char **input, http__itemparser itemparser, http__item *first, http__item **items)
 Parse a list of items. More...
 

Macro Definition Documentation

◆ HTTP__ITEM_INIT

#define HTTP__ITEM_INIT (   item,
  n,
 
)
Value:
((http__item *) (item))->next = (http__item *) (n); \
((http__item *) (item))->free = (void (*)(http__item *)) (f)
Representation of an item.
Definition: generics.h:29

Definition at line 35 of file generics.h.

◆ http__item_list_destroy

#define http__item_list_destroy (   l)     http___item_list_destroy((http__item *) (l))

Definition at line 46 of file generics.h.

◆ http__item_list_parse

#define http__item_list_parse (   i,
  p,
  f,
 
)
Value:
(http__item *) (f), \
(http__item **) (void *) (r))
nserror http___item_list_parse(const char **input, http__itemparser itemparser, http__item *first, http__item **items)
Parse a list of items.
Definition: generics.c:55
nserror(* http__itemparser)(const char **input, http__item **item)
Type of an item parser.
Definition: generics.h:42

Definition at line 52 of file generics.h.

Typedef Documentation

◆ http__item

typedef struct http__item http__item

Representation of an item.

◆ http__itemparser

typedef nserror(* http__itemparser) (const char **input, http__item **item)

Type of an item parser.

Definition at line 42 of file generics.h.

Function Documentation

◆ http___item_list_destroy()

void http___item_list_destroy ( http__item list)

Destructor for an item list.

Parameters
listList to destroy

Definition at line 29 of file generics.c.

References http__item::free, and http__item::next.

◆ http___item_list_parse()

nserror http___item_list_parse ( const char **  input,
http__itemparser  itemparser,
http__item first,
http__item **  items 
)

Parse a list of items.

Parameters
inputPointer to current input byte. Updated on exit.
itemparserPointer to function to parse list items
firstPointer to first item, or NULL.
itemsPointer to location to receive on-heap parameter list.
Returns
NSERROR_OK on success, NSERROR_NOMEM on memory exhaustion, NSERROR_NOT_FOUND if no items could be parsed

The returned list is owned by the caller

Note
Ownership of the first item is passed to this function.

Definition at line 55 of file generics.c.

References http__item_list_destroy, http__skip_LWS(), items, http__item::next, NSERROR_NOT_FOUND, and NSERROR_OK.

Here is the call graph for this function: