2 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015,
4 Ben Kibbey <bjk@luxsci.net>
6 This file is part of pwmd.
8 Pwmd is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 (at your option) any later version.
13 Pwmd is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with Pwmd. If not, see <http://www.gnu.org/licenses/>.
24 #include <libxml/tree.h>
25 #include <libxml/parser.h>
26 #include <libxml/xpath.h>
28 #include "util-misc.h"
30 #include "util-string.h"
34 struct slist_s
*list
; // The list of elements to be returned
35 char *target
; // Placeholder for the current elements target
36 struct string_s
*prefix
; // Previous elements in the path.
37 int recurse
; // Recurse into children of the current element
38 int root_only
; // List only root elements.
39 unsigned depth
; // Current recursion level
40 unsigned flags
; // To determine which list flags too append
44 XML_CMD_NONE
, // No special processing in xml_find_elements()
57 struct xml_request_s
{
58 xmlDocPtr doc
; // The document this request belongs to
59 xml_command_t cmd
; // For special processing in xml_find_elements()
60 char **args
; // The arguments passed to a command
61 unsigned depth
; // Current depth of recursion
62 void *data
; // Pointer for command data (LIST)
65 gpg_error_t
xml_new_request (struct client_s
*client
, const char *line
,
66 xml_command_t cmd
, struct xml_request_s
**result
);
67 void xml_free_request (struct xml_request_s
*);
68 gpg_error_t
xml_new_root_element (struct client_s
*, xmlDocPtr doc
, char *name
);
69 xmlDocPtr
xml_new_document (void);
70 int xml_valid_element (xmlChar
* element
);
71 xmlNodePtr
xml_find_elements (struct client_s
*client
,
72 struct xml_request_s
*req
, xmlNodePtr node
,
74 int xml_valid_element_path (char **path
, int content
);
75 xmlNodePtr
xml_find_text_node (xmlNodePtr node
);
76 gpg_error_t
xml_create_path_list (struct client_s
*, xmlDocPtr doc
, xmlNodePtr
,
77 struct element_list_s
*elements
, char *path
,
79 void xml_free_element_list (struct element_list_s
*);
80 gpg_error_t
xml_recurse_xpath_nodeset (struct client_s
*, xmlDocPtr doc
,
81 xmlNodeSetPtr nodes
, xmlChar
* value
,
82 xmlBufferPtr
* result
, int,
84 gpg_error_t
xml_add_attribute (struct client_s
*, xmlNodePtr node
,
85 const char *name
, const char *value
);
86 xmlChar
*xml_attribute_value (xmlNodePtr n
, xmlChar
* attr
);
87 gpg_error_t
xml_delete_attribute (struct client_s
*, xmlNodePtr n
,
88 const xmlChar
* name
);
89 gpg_error_t
xml_validate_import (struct client_s
*, xmlNodePtr
);
90 xmlNodePtr
xml_find_element (struct client_s
*, xmlNodePtr node
,
91 const char *element
, gpg_error_t
*);
92 gpg_error_t
xml_update_element_mtime (struct client_s
*, xmlNodePtr n
);
93 gpg_error_t
xml_parse_doc (const char *xml
, size_t len
, xmlDocPtr
*doc
);
94 xmlNodePtr
xml_resolve_path (struct client_s
*client
, xmlDocPtr doc
,
95 xmlChar
*path
, char ***result
, gpg_error_t
*rc
);
96 gpg_error_t
xml_validate_target (struct client_s
*, xmlDocPtr doc
,
97 const char *src
, xmlNodePtr dst
);
98 gpg_error_t
xml_check_recursion (struct client_s
*client
,
99 struct xml_request_s
*req
);
100 int xml_valid_attribute (const char *str
);
101 int xml_valid_attribute_value (const char *str
);
102 gpg_error_t
xml_is_element_owner (struct client_s
*, xmlNodePtr
);
103 gpg_error_t
xml_unlink_node (struct client_s
*, xmlNodePtr
);
104 xmlNodePtr
xml_create_element_path (struct client_s
*client
,
105 struct xml_request_s
*req
, xmlNodePtr node
,
106 char **path
, gpg_error_t
*rc
);
107 int xml_reserved_attribute (const char *);