rpm  5.4.15
Data Structures | Macros | Functions
html-parse.c File Reference
#include "system.h"
#include <assert.h>
#include "html-parse.h"
#include "hash.h"
Include dependency graph for html-parse.c:

Go to the source code of this file.

Data Structures

struct  pool
 

Macros

#define PARAMS(args)   ()
 
#define BOUNDED_TO_ALLOCA(beg, end, place)
 
#define XDIGIT_TO_NUM(x)   ((x) < 'A' ? (x) - '0' : TOUPPER (x) - 'A' + 10)
 
#define countof(array)   (sizeof (array) / sizeof (*(array)))
 
#define POOL_INIT(p, initial_storage, initial_size)
 
#define POOL_GROW(p, increase)
 
#define POOL_APPEND(p, beg, end)
 
#define POOL_APPEND_CHR(p, ch)
 
#define POOL_REWIND(p)   (p)->tail = 0
 
#define POOL_FREE(p)
 
#define GROW_ARRAY(basevar, sizevar, needed_size, resized, type)
 
#define AP_DOWNCASE   1
 
#define AP_PROCESS_ENTITIES   2
 
#define AP_TRIM_BLANKS   4
 
#define FROB(x)
 
#define NAME_CHAR_P(x)
 
#define ADVANCE(p)
 
#define SKIP_WS(p)
 
#define SKIP_NON_WS(p)
 

Functions

static void convert_and_copy (struct pool *pool, const char *beg, const char *end, int flags)
 
static const char * advance_declaration (const char *beg, const char *end)
 
static const char * find_comment_end (const char *beg, const char *end)
 
static int name_allowed (const struct hash_table *ht, const char *b, const char *e)
 
void map_html_tags (const char *text, int size, void(*mapfun)(struct taginfo *, void *), void *maparg, int flags, const struct hash_table *allowed_tags, const struct hash_table *allowed_attributes)
 

Macro Definition Documentation

#define ADVANCE (   p)
Value:
do { \
++p; \
if (p >= end) \
goto finish; \
} while (0)

Definition at line 698 of file html-parse.c.

Referenced by map_html_tags().

#define AP_DOWNCASE   1

Definition at line 287 of file html-parse.c.

Referenced by convert_and_copy(), and map_html_tags().

#define AP_PROCESS_ENTITIES   2

Definition at line 288 of file html-parse.c.

Referenced by convert_and_copy(), and map_html_tags().

#define AP_TRIM_BLANKS   4

Definition at line 289 of file html-parse.c.

Referenced by convert_and_copy(), and map_html_tags().

#define BOUNDED_TO_ALLOCA (   beg,
  end,
  place 
)
Value:
do { \
const char *BTA_beg = (beg); \
int BTA_len = (end) - BTA_beg; \
char **BTA_dest = &(place); \
*BTA_dest = alloca (BTA_len + 1); \
memcpy (*BTA_dest, BTA_beg, BTA_len); \
(*BTA_dest)[BTA_len] = '\0'; \
} while (0)
char * alloca()

Definition at line 108 of file html-parse.c.

Referenced by name_allowed().

#define countof (   array)    (sizeof (array) / sizeof (*(array)))

Definition at line 132 of file html-parse.c.

Referenced by map_html_tags().

#define FROB (   x)
Value:
(remain >= (sizeof (x) - 1) \
&& 0 == memcmp (from, x, sizeof (x) - 1) \
&& (*(from + sizeof (x) - 1) == ';' \
|| remain == sizeof (x) - 1 \
|| !ISALNUM (*(from + sizeof (x) - 1))))
#define ISALNUM(c)
Definition: fnmatch.c:77

Referenced by convert_and_copy().

#define GROW_ARRAY (   basevar,
  sizevar,
  needed_size,
  resized,
  type 
)
Value:
do { \
long ga_needed_size = (needed_size); \
long ga_newsize = (sizevar); \
while (ga_newsize < ga_needed_size) \
ga_newsize <<= 1; \
if (ga_newsize != (sizevar)) \
{ \
if (resized) \
basevar = (type *)xrealloc (basevar, ga_newsize * sizeof (type)); \
else \
{ \
void *ga_new = xmalloc (ga_newsize * sizeof (type)); \
memcpy (ga_new, basevar, (sizevar) * sizeof (type)); \
(basevar) = ga_new; \
resized = 1; \
} \
(sizevar) = ga_newsize; \
} \
} while (0)
const char char type
Definition: bson.h:908
#define xmalloc
Definition: system.h:32
#define xrealloc
Definition: system.h:35

Definition at line 267 of file html-parse.c.

Referenced by map_html_tags().

#define NAME_CHAR_P (   x)
Value:
((x) > 32 && (x) < 127 \
&& (x) != '=' && (x) != '>' && (x) != '/')

Definition at line 446 of file html-parse.c.

Referenced by advance_declaration(), and map_html_tags().

#define PARAMS (   args)    ()

Definition at line 101 of file html-parse.c.

#define POOL_APPEND (   p,
  beg,
  end 
)
Value:
do { \
const char *PA_beg = (beg); \
int PA_size = (end) - PA_beg; \
POOL_GROW (p, PA_size); \
memcpy ((p)->contents + (p)->tail, PA_beg, PA_size); \
(p)->tail += PA_size; \
} while (0)
#define POOL_GROW(p, increase)
Definition: html-parse.c:212

Definition at line 219 of file html-parse.c.

Referenced by convert_and_copy().

#define POOL_APPEND_CHR (   p,
  ch 
)
Value:
do { \
char PAC_char = (ch); \
POOL_GROW (p, 1); \
(p)->contents[(p)->tail++] = PAC_char; \
} while (0)
#define POOL_GROW(p, increase)
Definition: html-parse.c:212

Definition at line 230 of file html-parse.c.

Referenced by convert_and_copy().

#define POOL_FREE (   p)
Value:
do { \
struct pool *P = p; \
if (P->resized) \
xfree (P->contents); \
P->contents = P->orig_contents; \
P->size = P->orig_size; \
P->tail = 0; \
P->resized = 0; \
} while (0)
#define xfree
Definition: system.h:38

Definition at line 245 of file html-parse.c.

Referenced by map_html_tags().

#define POOL_GROW (   p,
  increase 
)
Value:
GROW_ARRAY ((p)->contents, (p)->size, (p)->tail + (increase), \
(p)->resized, char)
#define GROW_ARRAY(basevar, sizevar, needed_size, resized, type)
Definition: html-parse.c:267
const char const char size_t size
Definition: bson.h:895

Definition at line 212 of file html-parse.c.

Referenced by convert_and_copy().

#define POOL_INIT (   p,
  initial_storage,
  initial_size 
)
Value:
do { \
struct pool *P = (p); \
P->contents = (initial_storage); \
P->size = (initial_size); \
P->tail = 0; \
P->resized = 0; \
P->orig_contents = P->contents; \
P->orig_size = P->size; \
} while (0)
char * contents
Definition: html-parse.c:184

Definition at line 199 of file html-parse.c.

Referenced by map_html_tags().

#define POOL_REWIND (   p)    (p)->tail = 0

Definition at line 237 of file html-parse.c.

Referenced by map_html_tags().

#define SKIP_NON_WS (   p)
Value:
do { \
while (!ISSPACE (*p)) { \
ADVANCE (p); \
} \
} while (0)
#define ISSPACE(c)
Definition: fnmatch.c:82
#define ADVANCE(p)
Definition: html-parse.c:698

Definition at line 714 of file html-parse.c.

#define SKIP_WS (   p)
Value:
do { \
while (ISSPACE (*p)) { \
ADVANCE (p); \
} \
} while (0)
#define ISSPACE(c)
Definition: fnmatch.c:82
#define ADVANCE(p)
Definition: html-parse.c:698

Definition at line 706 of file html-parse.c.

Referenced by map_html_tags().

#define XDIGIT_TO_NUM (   x)    ((x) < 'A' ? (x) - '0' : TOUPPER (x) - 'A' + 10)

Definition at line 120 of file html-parse.c.

Referenced by convert_and_copy().

Function Documentation

static const char* advance_declaration ( const char *  beg,
const char *  end 
)
static

Definition at line 473 of file html-parse.c.

References NAME_CHAR_P.

Referenced by map_html_tags().

static void convert_and_copy ( struct pool pool,
const char *  beg,
const char *  end,
int  flags 
)
static
static const char* find_comment_end ( const char *  beg,
const char *  end 
)
static

Definition at line 638 of file html-parse.c.

Referenced by map_html_tags().

void map_html_tags ( const char *  text,
int  size,
void(*)(struct taginfo *, void *)  mapfun,
void *  maparg,
int  flags,
const struct hash_table *  allowed_tags,
const struct hash_table *  allowed_attributes 
)
static int name_allowed ( const struct hash_table *  ht,
const char *  b,
const char *  e 
)
static

Definition at line 686 of file html-parse.c.

References BOUNDED_TO_ALLOCA.

Referenced by map_html_tags().