NetSurf
generics.h
Go to the documentation of this file.
1/*
2 * Copyright 2010 John-Mark Bell <jmb@netsurf-browser.org>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef NETSURF_UTILS_HTTP_GENERICS_H_
20#define NETSURF_UTILS_HTTP_GENERICS_H_
21
22#include <stdbool.h>
23
24#include "utils/errors.h"
25
26/**
27 * Representation of an item
28 */
29typedef struct http__item {
30 struct http__item *next; /**< Next item in list, or NULL */
31
32 void (*free)(struct http__item *self); /**< Item destructor */
34
35#define HTTP__ITEM_INIT(item, n, f) \
36 ((http__item *) (item))->next = (http__item *) (n); \
37 ((http__item *) (item))->free = (void (*)(http__item *)) (f)
38
39/**
40 * Type of an item parser
41 */
42typedef nserror (*http__itemparser)(const char **input, http__item **item);
43
44
46#define http__item_list_destroy(l) \
47 http___item_list_destroy((http__item *) (l))
48
49nserror http___item_list_parse(const char **input,
50 http__itemparser itemparser, http__item *first,
52#define http__item_list_parse(i, p, f, r) \
53 http___item_list_parse((i), \
54 (http__itemparser) (p), \
55 (http__item *) (f), \
56 (http__item **) (void *) (r))
57
58#endif
static html_css_fetcher_item * items
Definition: css_fetcher.c:65
Error codes.
nserror
Enumeration of error codes.
Definition: errors.h:29
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
void http___item_list_destroy(http__item *list)
Destructor for an item list.
Definition: generics.c:29
nserror(* http__itemparser)(const char **input, http__item **item)
Type of an item parser.
Definition: generics.h:42
struct http__item http__item
Representation of an item.
Representation of an item.
Definition: generics.h:29
void(* free)(struct http__item *self)
Item destructor.
Definition: generics.h:32
struct http__item * next
Next item in list, or NULL.
Definition: generics.h:30