|
Greenbone Vulnerability Management Libraries
10.0.0
|
Headers for simple XML reader. More...


Go to the source code of this file.
Data Structures | |
| struct | context_data_t |
| XML context. More... | |
| struct | entity_s |
| XML element. More... | |
| struct | xml_search_data_t |
| Data for xml search functions. More... | |
Typedefs | |
| typedef GSList * | entities_t |
| Entities. More... | |
| typedef struct entity_s * | entity_t |
Functions | |
| void | xml_handle_start_element (context_data_t *, const gchar *, const gchar **, const gchar **) |
| Handle the start of an OMP XML element. More... | |
| void | xml_handle_end_element (context_data_t *, const gchar *) |
| Handle the end of an XML element. More... | |
| void | xml_handle_text (context_data_t *, const gchar *, gsize) |
| Handle additional text of an XML element. More... | |
| entities_t | next_entities (entities_t) |
| Return all the entities from an entities_t after the first. More... | |
| entity_t | first_entity (entities_t) |
| Return the first entity from an entities_t. More... | |
| entity_t | add_entity (entities_t *, const char *, const char *) |
| Add an XML entity to a tree of entities. More... | |
| int | compare_entities (entity_t, entity_t) |
| Compare two XML entity. More... | |
| entity_t | entity_child (entity_t, const char *) |
| Get a child of an entity. More... | |
| const char * | entity_attribute (entity_t, const char *) |
| Get an attribute of an entity. More... | |
| char * | entity_name (entity_t entity) |
| Get the name an entity. More... | |
| char * | entity_text (entity_t entity) |
| Get the text an entity. More... | |
| void | free_entity (entity_t) |
| Free an entity, recursively. More... | |
| void | print_entity (FILE *, entity_t) |
| Print an XML entity. More... | |
| void | print_entity_format (entity_t, gpointer indentation) |
| Print an XML entity to stdout, recursively printing its children. More... | |
| int | try_read_entity_and_string (gnutls_session_t *, int, entity_t *, GString **) |
| Try read an XML entity tree from the manager. More... | |
| int | read_entity_and_string (gnutls_session_t *, entity_t *, GString **) |
| Try read an XML entity tree from the manager. More... | |
| int | read_entity_and_string_c (gvm_connection_t *, entity_t *, GString **) |
| Try read an XML entity tree from the manager. More... | |
| int | read_entity_and_text (gnutls_session_t *, entity_t *, char **) |
| Read an XML entity tree from the manager. More... | |
| int | read_entity_and_text_c (gvm_connection_t *, entity_t *, char **) |
| Read an XML entity tree from the manager. More... | |
| int | try_read_entity (gnutls_session_t *, int, entity_t *) |
| Try read an XML entity tree from the manager. More... | |
| int | try_read_entity_c (gvm_connection_t *, int, entity_t *) |
| Try read an XML entity tree from the manager. More... | |
| int | read_entity (gnutls_session_t *, entity_t *) |
| Read an XML entity tree from the manager. More... | |
| int | read_entity_s (int, entity_t *) |
| Read an XML entity tree from the socket. More... | |
| int | read_entity_c (gvm_connection_t *, entity_t *) |
| Read an XML entity tree from the manager. More... | |
| int | read_string (gnutls_session_t *, GString **) |
| Read entity and text. Free the entity immediately. More... | |
| int | read_string_c (gvm_connection_t *, GString **) |
| Read entity and text. Free the entity immediately. More... | |
| int | parse_entity (const char *, entity_t *) |
| Read an XML entity tree from a string. More... | |
| void | print_entity_to_string (entity_t entity, GString *string) |
| Print an XML entity tree to a GString, appending it if string is not. More... | |
| int | xml_count_entities (entities_t) |
| Count the number of entities. More... | |
| void | xml_string_append (GString *, const char *,...) |
| Append formatted escaped XML to a string. More... | |
| int | find_element_in_xml_file (gchar *, gchar *, GHashTable *) |
| Tests if an XML file contains an element with given attributes. More... | |
Headers for simple XML reader.
Definition in file xmlutils.h.
| typedef GSList* entities_t |
Entities.
Definition at line 60 of file xmlutils.h.
Definition at line 72 of file xmlutils.h.
| 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 113 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 1346 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().


| 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 228 of file xmlutils.c.
References entity_s::attributes.
Referenced by gmp_authenticate_info_ext(), gmp_authenticate_info_ext_c(), gmp_check_response(), gmp_check_response_c(), 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_delete_scan(), osp_get_scan(), osp_get_scanner_details(), osp_start_scan(), and osp_stop_scan().

Get a child of an entity.
| [in] | entity | Entity. |
| [in] | name | Name of the child. |
Definition at line 205 of file xmlutils.c.
References compare_entity_with_name(), and entity_s::entities.
Referenced by 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_get_scan(), osp_get_scanner_details(), and osp_get_version().


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

| char* entity_text | ( | entity_t | entity | ) |
Get the text an entity.
| [in] | entity | Entity. |
Definition at line 157 of file xmlutils.c.
References entity_s::text.
Referenced by 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_get_scanner_details(), and osp_get_version().

| 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 1525 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 94 of file xmlutils.c.
Referenced by xml_count_entities().

| void free_entity | ( | entity_t | entity | ) |
Free an entity, recursively.
| [in] | entity | The entity, can be NULL. |
Definition at line 127 of file xmlutils.c.
References entity_s::attributes, entity_s::entities, free_entity(), entity_s::name, and entity_s::text.
Referenced by free_entity(), gmp_authenticate(), gmp_authenticate_info_ext(), gmp_authenticate_info_ext_c(), gmp_check_response(), gmp_check_response_c(), 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_delete_scan(), osp_get_scan(), osp_get_scanner_details(), osp_get_version(), osp_start_scan(), osp_stop_scan(), parse_entity(), read_string(), read_string_c(), try_read_entity_and_string(), and try_read_entity_and_string_s().


| 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 79 of file xmlutils.c.
Referenced by osp_get_scanner_details(), and xml_count_entities().

| 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 1099 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().

| 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 1244 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 1287 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 (will be created if NULL). |
Definition at line 1197 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().


| 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 1057 of file xmlutils.c.
References try_read_entity().
Referenced by gmp_check_response(), and gmp_read_create_response().


| 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 880 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 900 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 923 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 954 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 1085 of file xmlutils.c.
References try_read_entity_c().
Referenced by gmp_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 1071 of file xmlutils.c.
References try_read_entity_and_string_s().

| 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 982 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 1002 of file xmlutils.c.
References free_entity(), and read_entity_and_string_c().

| 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 1024 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 442 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(), and handle_text().
Referenced by read_entity_and_string(), read_entity_and_string_c(), try_read_entity(), 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 1040 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().


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

| 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 364 of file xmlutils.c.
References 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 311 of file xmlutils.c.
References 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 406 of file xmlutils.c.
References handle_text().

| 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 1432 of file xmlutils.c.
Referenced by gmp_get_system_reports_ext().
