Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  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 "utils/errors.h"
  23.  
  24. /**
  25.  * Representation of an item
  26.  */
  27. typedef struct http__item {
  28.         struct http__item *next;                /**< Next item in list, or NULL */
  29.  
  30.         void (*free)(struct http__item *self);  /**< Item destructor */
  31. } http__item;
  32.  
  33. #define HTTP__ITEM_INIT(item, n, f) \
  34.                 ((http__item *) (item))->next = (http__item *) (n); \
  35.                 ((http__item *) (item))->free = (void (*)(http__item *)) (f)
  36.  
  37. /**
  38.  * Type of an item parser
  39.  */
  40. typedef nserror (*http__itemparser)(const char **input, http__item **item);
  41.  
  42.  
  43. void http___item_list_destroy(http__item *list);
  44. #define http__item_list_destroy(l) \
  45.                 http___item_list_destroy((http__item *) (l))
  46.  
  47. nserror http___item_list_parse(const char **input,
  48.                 http__itemparser itemparser, http__item *first,
  49.                 http__item **items);
  50. #define http__item_list_parse(i, p, f, r) \
  51.                 http___item_list_parse((i), \
  52.                                 (http__itemparser) (p), \
  53.                                 (http__item *) (f), \
  54.                                 (http__item **) (void *) (r))
  55.  
  56. #endif
  57.