|
Greenbone Vulnerability Management Libraries 22.32.0
|
Simple XML reader. More...
#include "xmlutils.h"#include <assert.h>#include <errno.h>#include <fcntl.h>#include <glib.h>#include <glib/gtypes.h>#include <libxml/parser.h>#include <libxml/tree.h>#include <string.h>#include <time.h>#include <unistd.h>

Go to the source code of this file.
Data Structures | |
| struct | xml_file_iterator_struct |
| Opaque data structure for XML file iterator. More... | |
Macros | |
| #define | G_LOG_DOMAIN "libgvm util" |
| GLib logging domain. | |
| #define | BUFFER_SIZE 1048576 |
| Size of the buffer for reading from the manager. | |
| #define | XML_FILE_BUFFER_SIZE 1048576 |
| #define | XML_FILE_ITERATOR_BUFFER_SIZE 8192 |
| File read buffer size for an XML file iterator. | |
Functions | |
| static entity_t | make_entity (const char *name, const char *text) |
| Create an entity. | |
| entities_t | next_entities (entities_t entities) |
| Return all the entities from an entities_t after the first. | |
| entity_t | first_entity (entities_t entities) |
| Return the first entity from an entities_t. | |
| entity_t | add_entity (entities_t *entities, const char *name, const char *text) |
| Add an XML entity to a tree of entities. | |
| void | free_entity (entity_t entity) |
| Free an entity, recursively. | |
| char * | entity_text (entity_t entity) |
| Get the text an entity. | |
| char * | entity_name (entity_t entity) |
| Get the name an entity. | |
| static int | compare_entity_with_name (gconstpointer entity, gconstpointer name) |
| Compare a given name with the name of a given entity. | |
| entity_t | entity_child (entity_t entity, const char *name) |
| Get a child of an entity. | |
| const char * | entity_attribute (entity_t entity, const char *name) |
| Get an attribute of an entity. | |
| static void | add_attributes (entity_t entity, const gchar **names, const gchar **values) |
| Add attributes from an XML callback to an entity. | |
| static void | ignore_start_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer user_data, GError **error) |
| Handle the start of an OMP XML element. | |
| static void | handle_start_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer user_data, GError **error) |
| Handle the start of an OMP XML element. | |
| void | xml_handle_start_element (context_data_t *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values) |
| Handle the start of an OMP XML element. | |
| static void | ignore_end_element (GMarkupParseContext *context, const gchar *element_name, gpointer user_data, GError **error) |
| Handle the end of an XML element. | |
| static void | handle_end_element (GMarkupParseContext *context, const gchar *element_name, gpointer user_data, GError **error) |
| Handle the end of an XML element. | |
| void | xml_handle_end_element (context_data_t *context, const gchar *element_name) |
| Handle the end of an XML element. | |
| static void | ignore_text (GMarkupParseContext *context, const gchar *text, gsize text_len, gpointer user_data, GError **error) |
| Handle additional text of an XML element. | |
| static void | handle_text (GMarkupParseContext *context, const gchar *text, gsize text_len, gpointer user_data, GError **error) |
| Handle additional text of an XML element. | |
| void | xml_handle_text (context_data_t *context, const gchar *text, gsize text_len) |
| Handle additional text of an XML element. | |
| static void | handle_error (GMarkupParseContext *context, GError *error, gpointer user_data) |
| Handle an OMP XML parsing error. | |
| int | try_read_entity_and_string (gnutls_session_t *session, int timeout, entity_t *entity, GString **string_return) |
| Try read an XML entity tree from the manager. | |
| static int | try_read_string (gnutls_session_t *session, int timeout, GString **string_return) |
| Try read a response from a TLS session. | |
| static int | try_read_string_s (int socket, int timeout, GString **string_return) |
| Try read an XML entity tree from the socket. | |
| static int | try_read_entity_and_string_s (int socket, int timeout, entity_t *entity, GString **string_return) |
| Try read an XML entity tree from the socket. | |
| int | read_entity_and_string (gnutls_session_t *session, entity_t *entity, GString **string_return) |
| Try read an XML entity tree from the manager. | |
| int | read_entity_and_string_c (gvm_connection_t *connection, entity_t *entity, GString **string_return) |
| Try read an XML entity tree from the manager. | |
| int | read_entity_and_text (gnutls_session_t *session, entity_t *entity, char **text) |
| Read an XML entity tree from the manager. | |
| int | read_entity_and_text_c (gvm_connection_t *connection, entity_t *entity, char **text) |
| Read an XML entity tree from the manager. | |
| int | read_text_c (gvm_connection_t *connection, char **text) |
| Read text from the server. | |
| int | read_string (gnutls_session_t *session, GString **string) |
| Read entity and text. Free the entity immediately. | |
| int | read_string_c (gvm_connection_t *connection, GString **string) |
| Read entity and text. Free the entity immediately. | |
| int | try_read_entity (gnutls_session_t *session, int timeout, entity_t *entity) |
| Try read an XML entity tree from the manager. | |
| int | try_read_entity_c (gvm_connection_t *connection, int timeout, entity_t *entity) |
| Try read an XML entity tree from the manager. | |
| int | read_entity (gnutls_session_t *session, entity_t *entity) |
| Read an XML entity tree from the manager. | |
| int | read_entity_s (int socket, entity_t *entity) |
| Read an XML entity tree from the socket. | |
| int | read_entity_c (gvm_connection_t *connection, entity_t *entity) |
| Read an XML entity tree from the manager. | |
| int | parse_entity (const char *string, entity_t *entity) |
| Read an XML entity tree from a string. | |
| static void | foreach_print_entity_to_string (gpointer entity, gpointer string) |
| Print an XML entity for g_slist_foreach to a GString. | |
| static void | foreach_print_attribute_to_string (gpointer name, gpointer value, gpointer string) |
| Print an XML attribute for g_hash_table_foreach to a GString. | |
| void | print_entity_to_string (entity_t entity, GString *string) |
| Print an XML entity tree to a GString, appending it if string is not. | |
| static void | foreach_print_entity (gpointer entity, gpointer stream) |
| Print an XML entity for g_slist_foreach. | |
| static void | foreach_print_attribute (gpointer name, gpointer value, gpointer stream) |
| Print an XML attribute for g_hash_table_foreach. | |
| void | print_entity (FILE *stream, entity_t entity) |
| Print an XML entity. | |
| static void | foreach_print_attribute_format (gpointer name, gpointer value, gpointer none) |
| Print an XML attribute for g_hash_table_foreach to stdout. | |
| void | print_entity_format (entity_t entity, gpointer indent) |
| Print an XML entity to stdout, recursively printing its children. | |
| static gboolean | compare_find_attribute (gpointer key, gpointer value, gpointer attributes2) |
| Look for a key-value pair in a hash table. | |
| int | compare_entities (entity_t entity1, entity_t entity2) |
| Compare two XML entity. | |
| int | xml_count_entities (entities_t entities) |
| Count the number of entities. | |
| void | xml_string_append (GString *xml, const char *format,...) |
| Append formatted escaped XML to a string. | |
| static void | xml_search_handle_start_element (GMarkupParseContext *ctx, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer data, GError **error) |
| Handle the opening tag of an element in an XML search. | |
| int | find_element_in_xml_file (gchar *file_path, gchar *find_element, GHashTable *find_attributes) |
| Tests if an XML file contains an element with given attributes. | |
| int | parse_element (const gchar *string, element_t *element) |
| Read an XML element tree from a string. | |
| void | element_free (element_t element) |
| Free an entire element tree. | |
| const gchar * | element_name (element_t element) |
| Get the name of an element. | |
| static element_t | find_child (element_t element, const gchar *name) |
| Find child in an element. | |
| element_t | element_child (element_t element, const gchar *name) |
| Get a child of an element. | |
| gchar * | element_text (element_t element) |
| Get text of an element. | |
| gchar * | element_attribute (element_t element, const gchar *name) |
| Get an attribute of an element. | |
| element_t | element_first_child (element_t element) |
| Get the first child of an element. | |
| element_t | element_next (element_t element) |
| Get the next sibling of an element. | |
| gchar * | element_to_string (element_t element) |
| Output the XML element as a string. | |
| void | print_element_to_string (element_t element, GString *string) |
| Print an XML element tree to a GString, appending it if string is not. | |
| static void | xml_file_iterator_start_element_ns (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes, int nb_defaulted, const xmlChar **attributes) |
| XML file iterator parser callback for element start. | |
| static void | xml_file_iterator_end_element_ns (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI) |
| XML file iterator parser callback for element end. | |
| static void | xml_file_iterator_internal_subset (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID) |
| XML file iterator parser callback for internal subset declaration. | |
| static void | xml_file_iterator_external_subset (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID) |
| XML file iterator parser callback for external subset declaration. | |
| static int | xml_file_iterator_is_standalone (void *ctx) |
| XML file iterator parser callback for checking if doc is standalone. | |
| static int | xml_file_iterator_has_internal_subset (void *ctx) |
| XML file iterator parser callback for checking if doc has an internal subset. | |
| static int | xml_file_iterator_has_external_subset (void *ctx) |
| XML file iterator parser callback for checking if doc has an external subset. | |
| static xmlParserInputPtr | xml_file_iterator_resolve_entity (void *ctx, const xmlChar *publicId, const xmlChar *systemId) |
| XML file iterator parser callback for resolving an entity. | |
| static xmlEntityPtr | xml_file_iterator_get_entity (void *ctx, const xmlChar *name) |
| XML file iterator parser callback for getting an entity by name. | |
| static xmlEntityPtr | xml_file_iterator_get_parameter_entity (void *ctx, const xmlChar *name) |
| XML file iterator parser callback for getting a parameter entity by name. | |
| static void | xml_file_iterator_entity_decl (void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) |
| XML file iterator parser callback for when an entity definition has been parsed. | |
| static void | xml_file_iterator_attribute_decl (void *ctx, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree) |
| XML file iterator parser callback for when an attribute definition has been parsed. | |
| static void | xml_file_iterator_element_decl (void *ctx, const xmlChar *name, int type, xmlElementContentPtr content) |
| XML file iterator parser callback for when an element definition has been parsed. | |
| static void | xml_file_iterator_notation_decl (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId) |
| XML file iterator parser callback for when a notation definition has been parsed. | |
| static void | xml_file_iterator_unparsed_entity_decl (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName) |
| XML file iterator parser callback for when an unparsed entity declaration has been parsed. | |
| static void | xml_file_iterator_set_document_locator (void *ctx, xmlSAXLocatorPtr loc) |
| XML file iterator parser callback for setting the document locator. | |
| static void | xml_file_iterator_start_document (void *ctx) |
| XML file iterator parser callback at the document start. | |
| static void | xml_file_iterator_end_document (void *ctx) |
| XML file iterator parser callback at the document end. | |
| static void | xml_file_iterator_characters (void *ctx, const xmlChar *ch, int len) |
| XML file iterator parser callback when receiving some chars from the parser. | |
| static void | xml_file_iterator_cdata_block (void *ctx, const xmlChar *ch, int len) |
| XML file iterator parser callback when a cdata block has been parsed. | |
| static void | xml_file_iterator_processing_instruction (void *ctx, const xmlChar *target, const xmlChar *data) |
| XML file iterator parser callback when a processing instruction has been parsed. | |
| static void | xml_file_iterator_comment (void *ctx, const xmlChar *value) |
| XML file iterator parser callback when a comment has been parsed. | |
| static void | xml_file_iterator_init_sax_handler (xmlSAXHandlerPtr hdlr) |
| Initializes a xmlSAXHandler data structure for SAX version 2 parsing, assigning all the XML file iterator callback functions. | |
| xml_file_iterator_t | xml_file_iterator_new (void) |
| Allocates a new, uninitialized XML file iterator. | |
| int | xml_file_iterator_init_from_file_path (xml_file_iterator_t iterator, const char *file_path, int output_depth) |
| Initializes an XML file iterator to read from a given path. | |
| void | xml_file_iterator_free (xml_file_iterator_t iterator) |
| Frees an XML file iterator and all of its internal data structures. | |
| int | xml_file_iterator_rewind (xml_file_iterator_t iterator) |
| Rewinds an XML file iterator by rewinding the file and creating a new XML parser context. | |
| element_t | xml_file_iterator_next (xml_file_iterator_t iterator, gchar **error) |
| Get the next subelement from a XML file iterator. | |
Simple XML reader.
This is a generic XML interface. The key function is read_entity.
There are examples of using this interface in omp.c.
Definition in file xmlutils.c.
| #define BUFFER_SIZE 1048576 |
Size of the buffer for reading from the manager.
Definition at line 37 of file xmlutils.c.
Referenced by try_read_entity_and_string(), try_read_entity_and_string_s(), try_read_string(), and try_read_string_s().
| #define G_LOG_DOMAIN "libgvm util" |
GLib logging domain.
Definition at line 32 of file xmlutils.c.
| #define XML_FILE_BUFFER_SIZE 1048576 |
Definition at line 1931 of file xmlutils.c.
Referenced by find_element_in_xml_file().
| #define XML_FILE_ITERATOR_BUFFER_SIZE 8192 |
File read buffer size for an XML file iterator.
Definition at line 2990 of file xmlutils.c.
Referenced by xml_file_iterator_next().
|
static |
Add attributes from an XML callback to an entity.
| [in] | entity | The entity. |
| [in] | names | List of attribute names. |
| [in] | values | List of attribute values. |
Definition at line 234 of file xmlutils.c.
References entity_s::attributes.
Referenced by handle_start_element().

| entity_t add_entity | ( | entities_t * | entities, |
| const char * | name, | ||
| const char * | text ) |
Add an XML entity to a tree of entities.
| [in] | entities | The tree of entities |
| [in] | name | Name of the entity. Copied, copy is freed by free_entity. |
| [in] | text | Text of the entity. Copied, copy is freed by free_entity. |
Definition at line 101 of file xmlutils.c.
References make_entity().
Referenced by handle_start_element().


Compare two XML entity.
| [in] | entity1 | First entity. |
| [in] | entity2 | First entity. |
Definition at line 1765 of file xmlutils.c.
References entity_s::attributes, compare_entities(), compare_find_attribute(), entity_s::entities, entity_s::name, and entity_s::text.
Referenced by compare_entities().


|
static |
Compare a given name with the name of a given entity.
| [in] | entity | Entity. |
| [in] | name | Name. |
Definition at line 179 of file xmlutils.c.
References entity_name().
Referenced by entity_child().


|
static |
Look for a key-value pair in a hash table.
| [in] | key | Key. |
| [in] | value | Value. |
| [in] | attributes2 | The hash table. |
Definition at line 1747 of file xmlutils.c.
Referenced by compare_entities().

| gchar * element_attribute | ( | element_t | element, |
| const gchar * | name ) |
Get an attribute of an element.
| [in] | element | Element. |
| [in] | name | Name of the attribute. |
Definition at line 2162 of file xmlutils.c.
Referenced by Ensure(), Ensure(), and Ensure().

Get a child of an element.
| [in] | element | Element. |
| [in] | name | Name of the child. |
Definition at line 2086 of file xmlutils.c.
References find_child().
Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), and Ensure().


Get the first child of an element.
| [in] | element | Element. |
Definition at line 2210 of file xmlutils.c.
Referenced by Ensure(), and print_element_to_string().

| void element_free | ( | element_t | element | ) |
Free an entire element tree.
Beware that this frees the entire tree that element is part of, including any ancestors.
| [in] | element | Element. |
Definition at line 2035 of file xmlutils.c.
Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), xml_file_iterator_free(), and xml_file_iterator_rewind().

| const gchar * element_name | ( | element_t | element | ) |
Get the name of an element.
| [in] | element | Element. |
Definition at line 2052 of file xmlutils.c.
Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), handle_end_element(), handle_start_element(), ignore_end_element(), ignore_start_element(), print_element_to_string(), xml_handle_end_element(), xml_handle_start_element(), and xml_search_handle_start_element().

Get the next sibling of an element.
| [in] | element | Element. |
Definition at line 2230 of file xmlutils.c.
Referenced by Ensure(), and print_element_to_string().

| gchar * element_text | ( | element_t | element | ) |
Get text of an element.
If element is not NULL then the return is guaranteed to be a string. So if the caller has NULL checked element then there is no need for the caller to NULL check the return.
| [in] | element | Element. |
Definition at line 2137 of file xmlutils.c.
Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), and print_element_to_string().

| gchar * element_to_string | ( | element_t | element | ) |
Output the XML element as a string.
The generated XML string will include namespace definitions from ancestor elements.
| [in] | element | The element to output as a string. |
Definition at line 2253 of file xmlutils.c.
| const char * entity_attribute | ( | entity_t | entity, |
| const char * | name ) |
Get an attribute of an entity.
| [in] | entity | Entity. |
| [in] | name | Name of the attribute. |
Definition at line 216 of file xmlutils.c.
References entity_s::attributes.
Referenced by check_response_c(), Ensure(), gmp_authenticate_info_ext(), gmp_authenticate_info_ext_c(), gmp_check_response(), gmp_get_report_ext(), gmp_get_tasks_ext(), gmp_ping(), gmp_ping_c(), gmp_read_create_response(), gmp_resume_task_report_c(), gmp_start_task_report_c(), osp_check_feed(), osp_delete_scan(), osp_get_performance_ext(), osp_get_scan_pop(), osp_get_scan_status_ext(), osp_get_scanner_details(), osp_get_vts_feed_info(), osp_get_vts_version(), osp_start_scan(), osp_start_scan_ext(), and osp_stop_scan().

Get a child of an entity.
| [in] | entity | Entity. |
| [in] | name | Name of the child. |
Definition at line 193 of file xmlutils.c.
References compare_entity_with_name(), and entity_s::entities.
Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), gmp_authenticate_info_ext(), gmp_authenticate_info_ext_c(), gmp_ping_c(), gmp_resume_task_report(), gmp_resume_task_report_c(), gmp_start_task_report(), gmp_start_task_report_c(), gmp_task_status(), osp_check_feed(), osp_get_scan_pop(), osp_get_scan_status_ext(), osp_get_scanner_details(), osp_get_version(), osp_get_vts_feed_info(), and osp_get_vts_version().


| char * entity_name | ( | entity_t | entity | ) |
Get the name an entity.
| [in] | entity | Entity. |
Definition at line 161 of file xmlutils.c.
References entity_s::name.
Referenced by compare_entity_with_name(), Ensure(), Ensure(), Ensure(), Ensure(), and Ensure().

| char * entity_text | ( | entity_t | entity | ) |
Get the text an entity.
| [in] | entity | Entity. |
Definition at line 145 of file xmlutils.c.
References entity_s::text.
Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), gmp_authenticate_info_ext(), gmp_authenticate_info_ext_c(), gmp_ping_c(), gmp_resume_task_report(), gmp_resume_task_report_c(), gmp_start_task_report(), gmp_start_task_report_c(), gmp_task_status(), osp_check_feed(), osp_get_performance_ext(), osp_get_scanner_details(), and osp_get_version().

Find child in an element.
| [in] | element | Element. |
| [in] | name | Name of child. |
Definition at line 2069 of file xmlutils.c.
Referenced by element_child().

| int find_element_in_xml_file | ( | gchar * | file_path, |
| gchar * | find_element, | ||
| GHashTable * | find_attributes ) |
Tests if an XML file contains an element with given attributes.
| [in] | file_path | Path of the XML file. |
| [in] | find_element | Name of the element to find. |
| [in] | find_attributes | GHashTable of attributes to find. |
Definition at line 1942 of file xmlutils.c.
References xml_search_data_t::find_attributes, xml_search_data_t::find_element, xml_search_data_t::found, XML_FILE_BUFFER_SIZE, and xml_search_handle_start_element().

| entity_t first_entity | ( | entities_t | entities | ) |
Return the first entity from an entities_t.
| [in] | entities | The list of entities. |
Definition at line 82 of file xmlutils.c.
Referenced by Ensure(), and xml_count_entities().

|
static |
Print an XML attribute for g_hash_table_foreach.
| [in] | name | The attribute name. |
| [in] | value | The attribute value. |
| [in] | stream | The stream to which to print. |
Definition at line 1651 of file xmlutils.c.
Referenced by print_entity().

|
static |
Print an XML attribute for g_hash_table_foreach to stdout.
| [in] | name | The attribute name. |
| [in] | value | The attribute value. |
| [in] | none | (ignored). |
Definition at line 1688 of file xmlutils.c.
Referenced by print_entity_format().

|
static |
Print an XML attribute for g_hash_table_foreach to a GString.
| [in] | name | The attribute name. |
| [in] | value | The attribute value. |
| [in] | string | The string to which to print. |
Definition at line 1598 of file xmlutils.c.
Referenced by print_entity_to_string().

|
static |
Print an XML entity for g_slist_foreach.
| [in] | entity | The entity, as a gpointer. |
| [in] | stream | The stream to which to print, as a gpointer. |
Definition at line 1638 of file xmlutils.c.
References print_entity().
Referenced by print_entity().


|
static |
Print an XML entity for g_slist_foreach to a GString.
| [in] | entity | The entity, as a gpointer. |
| [in] | string | The stream to which to print, as a gpointer. |
Definition at line 1585 of file xmlutils.c.
References print_entity_to_string().
Referenced by print_entity_to_string().


| void free_entity | ( | entity_t | entity | ) |
Free an entity, recursively.
| [in] | entity | The entity, can be NULL. |
Definition at line 115 of file xmlutils.c.
References entity_s::attributes, entity_s::entities, free_entity(), entity_s::name, and entity_s::text.
Referenced by check_response_c(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), free_entity(), gmp_authenticate(), gmp_authenticate_info_ext(), gmp_authenticate_info_ext_c(), gmp_check_response(), gmp_delete_config_ext(), gmp_delete_lsc_credential_ext(), gmp_delete_port_list_ext(), gmp_delete_report(), gmp_delete_target_ext(), gmp_delete_task(), gmp_delete_task_ext(), gmp_get_report_ext(), gmp_get_tasks_ext(), gmp_modify_task_file(), gmp_ping(), gmp_ping_c(), gmp_read_create_response(), gmp_resume_task_report(), gmp_resume_task_report_c(), gmp_start_task_report(), gmp_start_task_report_c(), gmp_stop_task(), osp_check_feed(), osp_delete_scan(), osp_get_performance_ext(), osp_get_scan_pop(), osp_get_scan_status_ext(), osp_get_scanner_details(), osp_get_version(), osp_get_vts_feed_info(), osp_get_vts_version(), osp_start_scan(), osp_start_scan_ext(), osp_stop_scan(), parse_entity(), read_string(), try_read_entity_and_string(), and try_read_entity_and_string_s().

|
static |
Handle the end of an XML element.
| [in] | context | Parser context. |
| [in] | element_name | XML element name. |
| [in] | user_data | Dummy parameter. |
| [in] | error | Error parameter. |
Definition at line 366 of file xmlutils.c.
References context_data_t::current, context_data_t::done, element_name(), and context_data_t::first.
Referenced by parse_entity(), try_read_entity_and_string(), try_read_entity_and_string_s(), and xml_handle_end_element().


|
static |
Handle an OMP XML parsing error.
| [in] | context | Parser context. |
| [in] | error | The error. |
| [in] | user_data | Dummy parameter. |
Definition at line 477 of file xmlutils.c.
Referenced by parse_entity(), try_read_entity_and_string(), and try_read_entity_and_string_s().

|
static |
Handle the start of an OMP XML element.
| [in] | context | Parser context. |
| [in] | element_name | XML element name. |
| [in] | attribute_names | XML attribute name. |
| [in] | attribute_values | XML attribute values. |
| [in] | user_data | Dummy parameter. |
| [in] | error | Error parameter. |
Definition at line 290 of file xmlutils.c.
References add_attributes(), add_entity(), context_data_t::current, element_name(), entity_s::entities, and context_data_t::first.
Referenced by parse_entity(), try_read_entity_and_string(), try_read_entity_and_string_s(), and xml_handle_start_element().


|
static |
Handle additional text of an XML element.
| [in] | context | Parser context. |
| [in] | text | The text. |
| [in] | text_len | Length of the text. |
| [in] | user_data | Dummy parameter. |
| [in] | error | Error parameter. |
Definition at line 437 of file xmlutils.c.
References context_data_t::current, and entity_s::text.
Referenced by parse_entity(), try_read_entity_and_string(), try_read_entity_and_string_s(), and xml_handle_text().

|
static |
Handle the end of an XML element.
| [in] | context | Parser context. |
| [in] | element_name | XML element name. |
| [in] | user_data | Dummy parameter. |
| [in] | error | Error parameter. |
Definition at line 343 of file xmlutils.c.
References context_data_t::current, context_data_t::done, and element_name().
Referenced by try_read_entity_and_string(), and try_read_entity_and_string_s().


|
static |
Handle the start of an OMP XML element.
| [in] | context | Parser context. |
| [in] | element_name | XML element name. |
| [in] | attribute_names | XML attribute name. |
| [in] | attribute_values | XML attribute values. |
| [in] | user_data | Dummy parameter. |
| [in] | error | Error parameter. |
Definition at line 263 of file xmlutils.c.
References context_data_t::current, and element_name().
Referenced by try_read_entity_and_string(), and try_read_entity_and_string_s().


|
static |
Handle additional text of an XML element.
| [in] | context | Parser context. |
| [in] | text | The text. |
| [in] | text_len | Length of the text. |
| [in] | user_data | Dummy parameter. |
| [in] | error | Error parameter. |
Definition at line 417 of file xmlutils.c.
Referenced by try_read_entity_and_string(), and try_read_entity_and_string_s().

|
static |
Create an entity.
| [in] | name | Name of the entity. Copied, freed by free_entity. |
| [in] | text | Text of the entity. Copied, freed by free_entity. |
Definition at line 48 of file xmlutils.c.
References entity_s::attributes, entity_s::entities, entity_s::name, and entity_s::text.
Referenced by add_entity().

| entities_t next_entities | ( | entities_t | entities | ) |
Return all the entities from an entities_t after the first.
| [in] | entities | The list of entities. |
Definition at line 67 of file xmlutils.c.
Referenced by Ensure(), osp_get_scanner_details(), and xml_count_entities().

| int parse_element | ( | const gchar * | string, |
| element_t * | element ) |
Read an XML element tree from a string.
Caller must not free string until caller is finished using element.
| [in] | string | Input string. |
| [out] | element | Location for parsed element tree, or NULL if not required. If given, set to NULL on failure. Free with element_free. |
Definition at line 2003 of file xmlutils.c.
Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), and Ensure().

| int parse_entity | ( | const char * | string, |
| entity_t * | entity ) |
Read an XML entity tree from a string.
| [in] | string | Input string. |
| [out] | entity | Pointer to an entity tree. |
Definition at line 1511 of file xmlutils.c.
References context_data_t::current, context_data_t::done, context_data_t::first, free_entity(), handle_end_element(), handle_error(), handle_start_element(), and handle_text().
Referenced by Ensure(), Ensure(), Ensure(), Ensure(), Ensure(), and Ensure().


| void print_element_to_string | ( | element_t | element, |
| GString * | string ) |
Print an XML element tree to a GString, appending it if string is not.
empty.
| [in] | element | Element tree to print to string. |
| [in,out] | string | String to write to. |
Definition at line 2280 of file xmlutils.c.
References element_first_child(), element_name(), element_next(), element_text(), and print_element_to_string().
Referenced by Ensure(), and print_element_to_string().


| void print_entity | ( | FILE * | stream, |
| entity_t | entity ) |
Print an XML entity.
| [in] | entity | The entity. |
| [in] | stream | The stream to which to print. |
Definition at line 1663 of file xmlutils.c.
References entity_s::attributes, entity_s::entities, foreach_print_attribute(), foreach_print_entity(), entity_s::name, and entity_s::text.
Referenced by foreach_print_entity().


| void print_entity_format | ( | entity_t | entity, |
| gpointer | indent ) |
Print an XML entity to stdout, recursively printing its children.
Does very basic indentation for pretty printing.
This function is used as the (callback) GFunc in g_slist_foreach.
| [in] | entity | The entity. |
| [in] | indent | Indentation level, indentation width is 2 spaces. Use GINT_TO_POINTER to convert a integer value when passing this parameter. |
Definition at line 1706 of file xmlutils.c.
References entity_s::attributes, entity_s::entities, foreach_print_attribute_format(), entity_s::name, print_entity_format(), and entity_s::text.
Referenced by print_entity_format().


| void print_entity_to_string | ( | entity_t | entity, |
| GString * | string ) |
Print an XML entity tree to a GString, appending it if string is not.
empty.
| [in] | entity | Entity tree to print to string. |
| [in,out] | string | String to write to. |
Definition at line 1616 of file xmlutils.c.
References entity_s::attributes, entity_s::entities, foreach_print_attribute_to_string(), foreach_print_entity_to_string(), entity_s::name, and entity_s::text.
Referenced by foreach_print_entity_to_string(), and osp_get_scan_pop().


| int read_entity | ( | gnutls_session_t * | session, |
| entity_t * | entity ) |
Read an XML entity tree from the manager.
| [in] | session | Pointer to GNUTLS session. |
| [out] | entity | Pointer to an entity tree. |
Definition at line 1469 of file xmlutils.c.
References try_read_entity().
Referenced by gmp_check_response(), gmp_read_create_response(), and osp_send_command().


| int read_entity_and_string | ( | gnutls_session_t * | session, |
| entity_t * | entity, | ||
| GString ** | string_return ) |
Try read an XML entity tree from the manager.
| [in] | session | Pointer to GNUTLS session. |
| [out] | entity | Pointer to an entity tree. |
| [out] | string_return | An optional return location for the text read from the session. If NULL then it simply remains NULL. If a pointer to NULL then it points to a freshly allocated GString on successful return. Otherwise it points to an existing GString onto which the text is appended. |
Definition at line 1262 of file xmlutils.c.
References try_read_entity_and_string().
Referenced by read_entity_and_text(), and read_string().


| int read_entity_and_string_c | ( | gvm_connection_t * | connection, |
| entity_t * | entity, | ||
| GString ** | string_return ) |
Try read an XML entity tree from the manager.
| [in] | connection | Connection. |
| [out] | entity | Pointer to an entity tree. |
| [out] | string_return | An optional return location for the text read from the session. If NULL then it simply remains NULL. If a pointer to NULL then it points to a freshly allocated GString on successful return. Otherwise it points to an existing GString onto which the text is appended. |
Definition at line 1282 of file xmlutils.c.
References gvm_connection_t::session, gvm_connection_t::socket, gvm_connection_t::tls, try_read_entity_and_string(), and try_read_entity_and_string_s().
Referenced by read_entity_and_text_c(), and read_string_c().


| int read_entity_and_text | ( | gnutls_session_t * | session, |
| entity_t * | entity, | ||
| char ** | text ) |
Read an XML entity tree from the manager.
| [in] | session | Pointer to GNUTLS session. |
| [out] | entity | Pointer to an entity tree. |
| [out] | text | A pointer to a pointer, at which to store the address of a newly allocated string holding the text read from the session, if the text is required, else NULL. |
Definition at line 1305 of file xmlutils.c.
References read_entity_and_string().

| int read_entity_and_text_c | ( | gvm_connection_t * | connection, |
| entity_t * | entity, | ||
| char ** | text ) |
Read an XML entity tree from the manager.
| [in] | connection | Connection. |
| [out] | entity | Entity tree. |
| [out] | text | A pointer to a pointer, at which to store the address of a newly allocated string holding the text read from the session, if the text is required, else NULL. |
Definition at line 1336 of file xmlutils.c.
References read_entity_and_string_c().

| int read_entity_c | ( | gvm_connection_t * | connection, |
| entity_t * | entity ) |
Read an XML entity tree from the manager.
| [in] | connection | Connection. |
| [out] | entity | Pointer to an entity tree. |
Definition at line 1497 of file xmlutils.c.
References try_read_entity_c().
Referenced by check_response_c(), gmp_resume_task_report_c(), and gmp_start_task_report_c().


| int read_entity_s | ( | int | socket, |
| entity_t * | entity ) |
Read an XML entity tree from the socket.
| [in] | socket | Socket to read from. |
| [out] | entity | Pointer to an entity tree. |
Definition at line 1483 of file xmlutils.c.
References try_read_entity_and_string_s().
Referenced by osp_send_command().


| int read_string | ( | gnutls_session_t * | session, |
| GString ** | string ) |
Read entity and text. Free the entity immediately.
| [in] | session | Pointer to GNUTLS session to read from. |
| [out] | string | Return location for the string. |
Definition at line 1400 of file xmlutils.c.
References free_entity(), and read_entity_and_string().

| int read_string_c | ( | gvm_connection_t * | connection, |
| GString ** | string ) |
Read entity and text. Free the entity immediately.
| [in] | connection | Connection. |
| [out] | string | Return location for the string. |
Definition at line 1420 of file xmlutils.c.
References read_entity_and_string_c().

| int read_text_c | ( | gvm_connection_t * | connection, |
| char ** | text ) |
Read text from the server.
| [in] | connection | Connection. |
| [out] | text | A pointer to a pointer, at which to store the address of a newly allocated string holding the text read from the session. |
Definition at line 1366 of file xmlutils.c.
References gvm_connection_t::session, gvm_connection_t::socket, gvm_connection_t::tls, try_read_string(), and try_read_string_s().
Referenced by osp_send_command_str().


| int try_read_entity | ( | gnutls_session_t * | session, |
| int | timeout, | ||
| entity_t * | entity ) |
Try read an XML entity tree from the manager.
| [in] | session | Pointer to GNUTLS session. |
| [in] | timeout | Server idle time before giving up, in seconds. 0 to wait forever. |
| [out] | entity | Pointer to an entity tree. |
Definition at line 1436 of file xmlutils.c.
References try_read_entity_and_string().
Referenced by gmp_authenticate_info_ext(), gmp_get_report_ext(), gmp_get_tasks_ext(), gmp_ping(), and read_entity().


| int try_read_entity_and_string | ( | gnutls_session_t * | session, |
| int | timeout, | ||
| entity_t * | entity, | ||
| GString ** | string_return ) |
Try read an XML entity tree from the manager.
| [in] | session | Pointer to GNUTLS session. |
| [in] | timeout | Server idle time before giving up, in seconds. 0 to wait forever. |
| [out] | entity | Pointer to an entity tree. |
| [out] | string_return | An optional return location for the text read from the session. If NULL then it simply remains NULL. If a pointer to NULL then it points to a freshly allocated GString on successful return. Otherwise it points to an existing GString onto which the text is appended. |
Definition at line 501 of file xmlutils.c.
References BUFFER_SIZE, context_data_t::current, context_data_t::done, context_data_t::first, free_entity(), handle_end_element(), handle_error(), handle_start_element(), handle_text(), ignore_end_element(), ignore_start_element(), and ignore_text().
Referenced by read_entity_and_string(), read_entity_and_string_c(), try_read_entity(), and try_read_entity_c().


|
static |
Try read an XML entity tree from the socket.
| [in] | socket | Socket to read from. |
| [in] | timeout | Server idle time before giving up, in seconds. 0 to wait forever. |
| [out] | entity | Pointer to an entity tree. |
| [out] | string_return | An optional return location for the text read from the session. If NULL then it simply remains NULL. If a pointer to NULL then it points to a freshly allocated GString on successful return. Otherwise it points to an existing GString onto which the text is appended. |
Definition at line 1030 of file xmlutils.c.
References BUFFER_SIZE, context_data_t::current, context_data_t::done, context_data_t::first, free_entity(), handle_end_element(), handle_error(), handle_start_element(), handle_text(), ignore_end_element(), ignore_start_element(), and ignore_text().
Referenced by read_entity_and_string_c(), read_entity_s(), and try_read_entity_c().


| int try_read_entity_c | ( | gvm_connection_t * | connection, |
| int | timeout, | ||
| entity_t * | entity ) |
Try read an XML entity tree from the manager.
| [in] | connection | Connection. |
| [in] | timeout | Server idle time before giving up, in seconds. 0 to wait forever. |
| [out] | entity | Pointer to an entity tree. |
Definition at line 1452 of file xmlutils.c.
References gvm_connection_t::session, gvm_connection_t::socket, gvm_connection_t::tls, try_read_entity_and_string(), and try_read_entity_and_string_s().
Referenced by gmp_authenticate_info_ext_c(), gmp_ping_c(), and read_entity_c().


|
static |
Try read a response from a TLS session.
| [in] | session | Pointer to GNUTLS session. |
| [in] | timeout | Server idle time before giving up, in seconds. 0 to wait forever. |
| [out] | string_return | An optional return location for the text read from the session. |
If string_return is NULL then it simply remains NULL. If it is pointer to NULL then it points to a freshly allocated GString on successful return. Otherwise it must point to an existing GString onto which the text is appended.
Definition at line 752 of file xmlutils.c.
References BUFFER_SIZE.
Referenced by read_text_c().

|
static |
Try read an XML entity tree from the socket.
| [in] | socket | Socket to read from. |
| [in] | timeout | Server idle time before giving up, in seconds. 0 to wait forever. |
| [out] | string_return | An optional return location for the text read from the socket. If NULL then it simply remains NULL. If a pointer to NULL then it points to a freshly allocated GString on successful return. Otherwise it points to an existing GString onto which the text is appended. |
Definition at line 900 of file xmlutils.c.
References BUFFER_SIZE.
Referenced by read_text_c().

| int xml_count_entities | ( | entities_t | entities | ) |
Count the number of entities.
| [in] | entities | Entities. |
Definition at line 1830 of file xmlutils.c.
References first_entity(), and next_entities().

|
static |
XML file iterator parser callback for when an attribute definition has been parsed.
This is just a wrapper for the libXML xmlSAX2AttributeDecl getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
| [in] | name | the name of the element |
| [in] | fullname | the attribute name |
| [in] | type | the attribute type |
| [in] | def | the type of default value |
| [in] | defaultValue | the attribute default value |
| [in] | tree | the tree of enumerated value set |
Definition at line 2615 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

|
static |
XML file iterator parser callback when a cdata block has been parsed.
This is just a wrapper for the libXML xmlSAX2CDataBlock getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
| [in] | ch | The cdata content |
| [in] | len | the block length |
Definition at line 2768 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

|
static |
XML file iterator parser callback when receiving some chars from the parser.
This is just a wrapper for the libXML xmlSAX2Characters getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
| [in] | ch | a xmlChar string |
| [in] | len | the number of xmlChar |
Definition at line 2750 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

|
static |
XML file iterator parser callback when a comment has been parsed.
This is just a wrapper for the libXML xmlSAX2Comment getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
| [in] | value | the comment content |
Definition at line 2803 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

|
static |
XML file iterator parser callback for when an element definition has been parsed.
This is just a wrapper for the libXML xmlSAX2ElementDecl getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
| [in] | name | the element name |
| [in] | type | the element type |
| [in] | def | the type of default value |
| [in] | defaultValue | the attribute default value |
| [in] | content | the element value tree |
Definition at line 2640 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

|
static |
XML file iterator parser callback at the document end.
This is just a wrapper for the libXML xmlSAX2EndDocument getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
Definition at line 2732 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

|
static |
XML file iterator parser callback for element end.
This uses xmlSAX2EndElementNs to finish parsing the element to the document in the libXML parser context of the iterator. If the element is at the output tree depth defined in the iterator then it is removed from the document and added to the element queue of the iterator.
| [in] | ctx | parser context data / iterator data structure |
| [in] | localname | the local name of the element |
| [in] | prefix | the element namespace prefix if available |
| [in] | URI | the element namespace name if available |
Definition at line 2390 of file xmlutils.c.
References xml_file_iterator_struct::element_queue, xml_file_iterator_struct::output_depth, xml_file_iterator_struct::parser_ctxt, and xml_file_iterator_struct::stack_depth.
Referenced by xml_file_iterator_init_sax_handler().

|
static |
XML file iterator parser callback for when an entity definition has been parsed.
This is just a wrapper for the libXML xmlSAX2EntityDecl getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
| [in] | name | the entity name |
| [in] | type | the entity type |
| [in] | publicId | The public ID of the entity |
| [in] | systemId | The system ID of the entity |
| [in] | content | the entity value (without processing) |
Definition at line 2590 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

|
static |
XML file iterator parser callback for external subset declaration.
This is just a wrapper for the libXML xmlSAX2ExternalSubset getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
| [in] | name | the root element name |
| [in] | ExternalID | the external ID |
| [in] | SystemID | the SYSTEM ID (e.g. filename or URL) |
Definition at line 2457 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

| void xml_file_iterator_free | ( | xml_file_iterator_t | iterator | ) |
Frees an XML file iterator and all of its internal data structures.
| [in] | iterator | The XML file iterator to free. |
Definition at line 2919 of file xmlutils.c.
References element_free(), xml_file_iterator_struct::element_queue, xml_file_iterator_struct::file, xml_file_iterator_struct::file_path, and xml_file_iterator_struct::parser_ctxt.
Referenced by Ensure(), Ensure(), and Ensure().


|
static |
XML file iterator parser callback for getting an entity by name.
This is just a wrapper for the libXML xmlSAX2GetEntity getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
| [in] | name | The entity name |
Definition at line 2550 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

|
static |
XML file iterator parser callback for getting a parameter entity by name.
This is just a wrapper for the libXML xmlSAX2GetParameterEntity getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
| [in] | name | The entity name |
Definition at line 2569 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

|
static |
XML file iterator parser callback for checking if doc has an external subset.
This is just a wrapper for the libXML xmlSAX2HasExternalSubset getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
Definition at line 2512 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

|
static |
XML file iterator parser callback for checking if doc has an internal subset.
This is just a wrapper for the libXML xmlSAX2HasInternalSubset getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
Definition at line 2494 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

| int xml_file_iterator_init_from_file_path | ( | xml_file_iterator_t | iterator, |
| const char * | file_path, | ||
| int | output_depth ) |
Initializes an XML file iterator to read from a given path.
| [in] | iterator | Pointer to the iterator to initialize. |
| [in] | file_path | Path to the file to read from. |
| [in] | output_depth | XML tree depth at which to return elements. |
Definition at line 2876 of file xmlutils.c.
References xml_file_iterator_struct::element_queue, xml_file_iterator_struct::file, xml_file_iterator_struct::file_path, xml_file_iterator_struct::initialized, xml_file_iterator_struct::output_depth, xml_file_iterator_struct::parser_ctxt, xml_file_iterator_struct::sax_handler, xml_file_iterator_struct::stack_depth, and xml_file_iterator_init_sax_handler().
Referenced by Ensure(), Ensure(), and Ensure().


|
static |
Initializes a xmlSAXHandler data structure for SAX version 2 parsing, assigning all the XML file iterator callback functions.
| [in] | hdlr | The xmlSAXHandler to initialize |
Definition at line 2816 of file xmlutils.c.
References xml_file_iterator_attribute_decl(), xml_file_iterator_cdata_block(), xml_file_iterator_characters(), xml_file_iterator_comment(), xml_file_iterator_element_decl(), xml_file_iterator_end_document(), xml_file_iterator_end_element_ns(), xml_file_iterator_entity_decl(), xml_file_iterator_external_subset(), xml_file_iterator_get_entity(), xml_file_iterator_get_parameter_entity(), xml_file_iterator_has_external_subset(), xml_file_iterator_has_internal_subset(), xml_file_iterator_internal_subset(), xml_file_iterator_is_standalone(), xml_file_iterator_notation_decl(), xml_file_iterator_processing_instruction(), xml_file_iterator_resolve_entity(), xml_file_iterator_set_document_locator(), xml_file_iterator_start_document(), xml_file_iterator_start_element_ns(), and xml_file_iterator_unparsed_entity_decl().
Referenced by xml_file_iterator_init_from_file_path().


|
static |
XML file iterator parser callback for internal subset declaration.
This is just a wrapper for the libXML xmlSAX2InternalSubset getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
| [in] | name | the root element name |
| [in] | ExternalID | the external ID |
| [in] | SystemID | the SYSTEM ID (e.g. filename or URL) |
Definition at line 2437 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

|
static |
XML file iterator parser callback for checking if doc is standalone.
This is just a wrapper for the libXML xmlSAX2IsStandalone getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
Definition at line 2476 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

| xml_file_iterator_t xml_file_iterator_new | ( | void | ) |
Allocates a new, uninitialized XML file iterator.
Free with xml_file_iterator_free.
Definition at line 2859 of file xmlutils.c.
Referenced by Ensure(), Ensure(), and Ensure().

| element_t xml_file_iterator_next | ( | xml_file_iterator_t | iterator, |
| gchar ** | error ) |
Get the next subelement from a XML file iterator.
| [in] | iterator | The XML file iterator to get the element from. |
| [out] | error | Error message output, set to NULL on success / EOF |
Definition at line 3002 of file xmlutils.c.
References xml_file_iterator_struct::element_queue, xml_file_iterator_struct::file, xml_file_iterator_struct::initialized, xml_file_iterator_struct::parser_ctxt, and XML_FILE_ITERATOR_BUFFER_SIZE.
Referenced by Ensure(), Ensure(), and Ensure().

|
static |
XML file iterator parser callback for when a notation definition has been parsed.
This is just a wrapper for the libXML xmlSAX2NotationDecl getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
| [in] | name | The name of the notation |
| [in] | publicId | The public ID of the entity |
| [in] | systemId | The system ID of the entity |
Definition at line 2660 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

|
static |
XML file iterator parser callback when a processing instruction has been parsed.
This is just a wrapper for the libXML xmlSAX2ProcessingInstruction getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
| [in] | target | The target name |
| [in] | data | the PI data |
Definition at line 2786 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

|
static |
XML file iterator parser callback for resolving an entity.
This is just a wrapper for the libXML xmlSAX2ResolveEntity getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
| [in] | publicId | The public ID of the entity |
| [in] | systemId | The systemID of the entity |
Definition at line 2531 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

| int xml_file_iterator_rewind | ( | xml_file_iterator_t | iterator | ) |
Rewinds an XML file iterator by rewinding the file and creating a new XML parser context.
| [in] | iterator | The XML file iterator to rewind. |
Definition at line 2956 of file xmlutils.c.
References element_free(), xml_file_iterator_struct::element_queue, xml_file_iterator_struct::file, xml_file_iterator_struct::file_path, xml_file_iterator_struct::parser_ctxt, xml_file_iterator_struct::sax_handler, and xml_file_iterator_struct::stack_depth.
Referenced by Ensure().


|
static |
XML file iterator parser callback for setting the document locator.
This is just a wrapper for the libXML xmlSAX2SetDocumentLocator getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
| [in] | loc | A SAX Locator |
Definition at line 2702 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

|
static |
XML file iterator parser callback at the document start.
This is just a wrapper for the libXML xmlSAX2StartDocument getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
Definition at line 2717 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

|
static |
XML file iterator parser callback for element start.
This is just a wrapper for the libXML xmlSAX2StartElementNs getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
| [in] | localname | the local name of the element |
| [in] | prefix | the element namespace prefix if available |
| [in] | URI | the element namespace name if available |
| [in] | nb_namespaces | number of namespace definitions on that node |
| [in] | namespaces | pointer to the array of prefix/URI pairs namespace definitions |
| [in] | nb_attributes | the number of attributes on that node |
| [in] | nb_defaulted | the number of defaulted attributes |
| [in] | attributes | pointer to the array of (localname/prefix/URI/value/end) attribute values |
Definition at line 2361 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt, and xml_file_iterator_struct::stack_depth.
Referenced by xml_file_iterator_init_sax_handler().

|
static |
XML file iterator parser callback for when an unparsed entity declaration has been parsed.
This is just a wrapper for the libXML xmlSAX2UnparsedEntityDecl getting the libXML parser context from the iterator struct passed as user data.
| [in] | ctx | parser context data / iterator data structure |
| [in] | name | The name of the notation |
| [in] | publicId | The public ID of the entity |
| [in] | systemId | The system ID of the entity |
| [in] | notationName | The name of the notation |
Definition at line 2682 of file xmlutils.c.
References xml_file_iterator_struct::parser_ctxt.
Referenced by xml_file_iterator_init_sax_handler().

| void xml_handle_end_element | ( | context_data_t * | context, |
| const gchar * | element_name ) |
Handle the end of an XML element.
| [in] | context | Parser context. |
| [in] | element_name | XML element name. |
Definition at line 402 of file xmlutils.c.
References element_name(), and handle_end_element().

| void xml_handle_start_element | ( | context_data_t * | context, |
| const gchar * | element_name, | ||
| const gchar ** | attribute_names, | ||
| const gchar ** | attribute_values ) |
Handle the start of an OMP XML element.
| [in] | context | Parser context. |
| [in] | element_name | XML element name. |
| [in] | attribute_names | XML attribute name. |
| [in] | attribute_values | XML attribute values. |
Definition at line 326 of file xmlutils.c.
References element_name(), and handle_start_element().

| void xml_handle_text | ( | context_data_t * | context, |
| const gchar * | text, | ||
| gsize | text_len ) |
Handle additional text of an XML element.
| [in] | context | Parser context. |
| [in] | text | The text. |
| [in] | text_len | Length of the text. |
Definition at line 464 of file xmlutils.c.
References handle_text().

|
static |
Handle the opening tag of an element in an XML search.
| [in] | ctx | The parse context. |
| [in] | element_name | The name of the element. |
| [in] | attribute_names | NULL-terminated array of attribute names. |
| [in] | attribute_values | NULL-terminated array of attribute values. |
| [in] | data | The search data struct. |
| [out] | error | Pointer to error output location. |
Definition at line 1874 of file xmlutils.c.
References element_name(), xml_search_data_t::find_attributes, xml_search_data_t::find_element, and xml_search_data_t::found.
Referenced by find_element_in_xml_file().


| void xml_string_append | ( | GString * | xml, |
| const char * | format, | ||
| ... ) |
Append formatted escaped XML to a string.
| [in] | xml | XML string. |
| [in] | format | Format string. |
| [in] | ... | Arguments for format string. |
Definition at line 1849 of file xmlutils.c.
Referenced by credential_append_as_xml(), gmp_get_system_reports_ext(), osp_start_scan_ext(), target_append_as_xml(), vt_group_append_as_xml(), vt_single_append_as_xml(), and vt_value_append_as_xml().
