-
Notifications
You must be signed in to change notification settings - Fork 38
/
parsley.h
87 lines (68 loc) · 1.99 KB
/
parsley.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef PARSLEY_H_INCLUDED
#define PARSLEY_H_INCLUDED
#define PARSLEY_BUF_SIZE 1024
#include <stdbool.h>
#include <libxslt/xslt.h>
#include <libxslt/xsltInternals.h>
#include <libxslt/transform.h>
#include <json/json.h>
#include "parsed_xpath.h"
static int parsley_debug_mode = 0;
static char* last_parsley_error;
typedef struct __compiled_parsley {
xsltStylesheetPtr stylesheet;
char* error;
} compiled_parsley;
typedef struct __parsed_parsley {
xmlDocPtr xml;
char *error;
compiled_parsley *parsley;
} parsed_parsley;
typedef compiled_parsley * parsleyPtr;
typedef parsed_parsley * parsedParsleyPtr;
typedef struct __key_node {
char* name;
char* use;
struct __key_node * next;
} key_node;
typedef key_node * keyPtr;
typedef struct __parsley_context {
xmlNsPtr ns;
xmlNodePtr node;
struct json_object * json;
char* tag;
pxpathPtr filter;
pxpathPtr expr;
bool magic;
bool array;
bool string;
int flags; //bitmask over following enum
struct __parsley_context * parent;
struct __parsley_context *child;
struct __parsley_context *next;
} parsley_context;
enum {
PARSLEY_OPTIONAL = 1,
PARSLEY_BANG = 2
};
enum {
PARSLEY_OPTIONS_HTML = 1,
PARSLEY_OPTIONS_PRUNE = 2,
PARSLEY_OPTIONS_ALLOW_NET = 4,
PARSLEY_OPTIONS_ALLOW_LOCAL = 8,
PARSLEY_OPTIONS_COLLATE = 16,
PARSLEY_OPTIONS_SGWRAP = 32,
PARSLEY_OPTIONS_FORCE_UTF8 = 64
};
typedef parsley_context * contextPtr;
void parsed_parsley_free(parsedParsleyPtr);
void killDefaultNS(xmlDocPtr doc);
void parsley_free(parsleyPtr);
parsleyPtr parsley_compile(char* parsley, char* incl);
parsedParsleyPtr parsley_parse_file(parsleyPtr parsley, char* file, int flags);
parsedParsleyPtr parsley_parse_string(parsleyPtr parsley, char* string, size_t size, char* base_uri, int flags);
parsedParsleyPtr parsley_parse_doc(parsleyPtr, xmlDocPtr, int);
void parsleyXsltError(void * ctx, const char * msg, ...);
void parsley_set_user_agent(char const *agent);
static contextPtr parsley_parsing_context;
#endif