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