OpenVAS Libraries  9.0.1
xml.h
Go to the documentation of this file.
1 /* openvase-libraries/omp/xml
2  * $Id$
3  * Description: Headers for simple XML reader.
4  *
5  * Authors:
6  * Matthew Mundell <matt@mundell.ukfsn.org>
7  *
8  * Copyright:
9  * Copyright (C) 2009 Greenbone Networks GmbH
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25 
26 #ifndef _OPENVAS_LIBRARIES_XML_H
27 #define _OPENVAS_LIBRARIES_XML_H
28 
29 #include <glib.h>
30 #include <gnutls/gnutls.h>
31 #include <stdio.h>
32 
33 #include "../misc/openvas_server.h"
34 
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #if 0
39 }
40 #endif
41 #endif
42 
43 typedef GSList *entities_t;
44 
48 struct entity_s
49 {
50  char *name;
51  char *text;
52  GHashTable *attributes;
54 };
55 typedef struct entity_s *entity_t;
56 
60 typedef struct {
61  int found;
62  int done;
63  gchar *find_element;
64  GHashTable *find_attributes;
66 
68 
69 entity_t first_entity (entities_t);
70 
71 entity_t add_entity (entities_t *, const char *, const char *);
72 
73 int compare_entities (entity_t, entity_t);
74 
75 entity_t entity_child (entity_t, const char *);
76 
77 const char *entity_attribute (entity_t, const char *);
78 
79 char *entity_name (entity_t entity);
80 
81 char *entity_text (entity_t entity);
82 
83 void free_entity (entity_t);
84 
85 void print_entity (FILE *, entity_t);
86 
87 void print_entity_format (entity_t, gpointer indentation);
88 
89 int try_read_entity_and_string (gnutls_session_t *, int, entity_t *,
90  GString **);
91 
93  GString **);
94 
95 int read_entity_and_string (gnutls_session_t *, entity_t *, GString **);
96 
97 int read_entity_and_string_c (openvas_connection_t *, entity_t *, GString **);
98 
99 int read_entity_and_text (gnutls_session_t *, entity_t *, char **);
100 
101 int read_entity_and_text_c (openvas_connection_t *, entity_t *, char **);
102 
103 int try_read_entity (gnutls_session_t *, int, entity_t *);
104 
105 int try_read_entity_c (openvas_connection_t *, int, entity_t *);
106 
107 int read_entity (gnutls_session_t *, entity_t *);
108 
109 int read_entity_c (openvas_connection_t *, entity_t *);
110 
111 int read_string (gnutls_session_t *, GString **);
112 
113 int read_string_c (openvas_connection_t *, GString **);
114 
115 int parse_entity (const char *, entity_t *);
116 
117 void print_entity_to_string (entity_t entity, GString * string);
118 
120 
121 void xml_string_append (GString *, const char *, ...);
122 
123 /* XML file utilities */
124 
125 int find_element_in_xml_file (gchar *, gchar *, GHashTable*);
126 
127 #if 0
128 {
129 #endif
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif /* not _OPENVAS_LIBRARIES_XML_H */
const char * entity_attribute(entity_t, const char *)
Get an attribute of an entity.
Definition: xml.c:241
Data for xml search functions.
Definition: xml.h:60
GHashTable * attributes
Attributes.
Definition: xml.h:52
int parse_entity(const char *, entity_t *)
Read an XML entity tree from a string.
Definition: xml.c:1020
entity_t entity_child(entity_t, const char *)
Get a child of an entity.
Definition: xml.c:220
int compare_entities(entity_t, entity_t)
Compare two XML entity.
Definition: xml.c:1267
int try_read_entity_c(openvas_connection_t *, int, entity_t *)
Try read an XML entity tree from the manager.
Definition: xml.c:977
int read_entity_and_text(gnutls_session_t *, entity_t *, char **)
Read an XML entity tree from the manager.
Definition: xml.c:859
int read_entity_and_string(gnutls_session_t *, entity_t *, GString **)
Try read an XML entity tree from the manager.
Definition: xml.c:819
int read_string(gnutls_session_t *, GString **)
Read entity and text. Free the entity immediately.
Definition: xml.c:919
char * entity_text(entity_t entity)
Get the text an entity.
Definition: xml.c:178
int read_entity_and_text_c(openvas_connection_t *, entity_t *, char **)
Read an XML entity tree from the manager.
Definition: xml.c:891
entities_t next_entities(entities_t)
Return all the entities from an entities_t after the first.
Definition: xml.c:100
int done
Definition: xml.h:62
void print_entity_to_string(entity_t entity, GString *string)
Print an XML entity tree to a GString, appending it if string is not.
Definition: xml.c:1118
Connection.
Definition: openvas_server.h:58
void print_entity(FILE *, entity_t)
Print an XML entity.
Definition: xml.c:1165
int read_string_c(openvas_connection_t *, GString **)
Read entity and text. Free the entity immediately.
Definition: xml.c:939
GHashTable * find_attributes
Definition: xml.h:64
XML element.
Definition: xml.h:48
int try_read_entity(gnutls_session_t *, int, entity_t *)
Try read an XML entity tree from the manager.
Definition: xml.c:961
entities_t entities
Children.
Definition: xml.h:53
void xml_string_append(GString *, const char *,...)
Append formatted escaped XML to a string.
Definition: xml.c:1354
int read_entity_c(openvas_connection_t *, entity_t *)
Read an XML entity tree from the manager.
Definition: xml.c:1006
entity_t add_entity(entities_t *, const char *, const char *)
Add an XML entity to a tree of entities.
Definition: xml.c:134
struct entity_s * entity_t
Definition: xml.h:55
int try_read_entity_and_string(gnutls_session_t *, int, entity_t *, GString **)
Try read an XML entity tree from the manager.
Definition: xml.c:410
int read_entity_and_string_c(openvas_connection_t *, entity_t *, GString **)
Try read an XML entity tree from the manager.
Definition: xml.c:840
char * name
Name.
Definition: xml.h:50
int find_element_in_xml_file(gchar *, gchar *, GHashTable *)
Tests if an XML file contains an element with given attributes.
Definition: xml.c:1451
int try_read_entity_and_string_c(openvas_connection_t *, int, entity_t *, GString **)
Try read an XML entity tree from the manager.
Definition: xml.c:617
int read_entity(gnutls_session_t *, entity_t *)
Read an XML entity tree from the manager.
Definition: xml.c:992
GSList * entities_t
Definition: xml.h:43
gchar * find_element
Definition: xml.h:63
void print_entity_format(entity_t, gpointer indentation)
Print an XML entity to stdout, recusively printing its children.
Definition: xml.c:1208
entity_t first_entity(entities_t)
Return the first entity from an entities_t.
Definition: xml.c:115
int found
Definition: xml.h:61
void free_entity(entity_t)
Free an entity, recursively.
Definition: xml.c:148
char * entity_name(entity_t entity)
Get the name an entity.
Definition: xml.c:191
char * text
Text.
Definition: xml.h:51
int xml_count_entities(entities_t)
Count the number of entities.
Definition: xml.c:1333