Greenbone Vulnerability Manager  22.4.0~dev1
Macros | Functions
gmp_base.c File Reference

GVM GMP layer: Base facilities. More...

#include "gmp_base.h"
#include "manage.h"
#include <stdlib.h>
#include <string.h>
#include <gvm/base/strings.h>

Macros

#define G_LOG_DOMAIN   "md gmp"
 GLib log domain.
 

Functions

int find_attribute (const gchar **attribute_names, const gchar **attribute_values, const char *attribute_name, const gchar **attribute_value)
 Find an attribute in a parser callback list of attributes. More...
 
int append_attribute (const gchar **attribute_names, const gchar **attribute_values, const char *attribute_name, gchar **string)
 Find an attribute in a parser callback list of attributes and append. More...
 
void buffer_xml_append_printf (GString *buffer, const char *format,...)
 Format XML into a buffer. More...
 
gboolean send_to_client (const char *msg, int(*user_send_to_client)(const char *, void *), void *user_send_to_client_data)
 Send a response message to the client. More...
 
gboolean send_find_error_to_client (const char *command, const char *type, const char *id, gmp_parser_t *gmp_parser)
 Send an XML find error response message to the client. More...
 
void error_send_to_client (GError **error)
 Set an out of space parse error on a GError. More...
 
void internal_error_send_to_client (GError **error)
 Set an internal error on a GError. More...
 
static void log_event_internal (const char *type, const char *type_name, const char *id, const char *action, int fail)
 Creates a log event entry for a resource action. More...
 
void log_event (const char *type, const char *type_name, const char *id, const char *action)
 Creates a log event entry for a resource action. More...
 
void log_event_fail (const char *type, const char *type_name, const char *id, const char *action)
 Creates a log event failure entry for a resource action. More...
 

Detailed Description

GVM GMP layer: Base facilities.

GMP base facilities used by all modules, but not exported for users of the GMP layer (i.e. gmpd.c).

Function Documentation

◆ append_attribute()

int append_attribute ( const gchar **  attribute_names,
const gchar **  attribute_values,
const char *  attribute_name,
gchar **  string 
)

Find an attribute in a parser callback list of attributes and append.

it to a string using gvm_append_string.

Parameters
[in]attribute_namesList of names.
[in]attribute_valuesList of values.
[in]attribute_nameName of sought attribute.
[out]stringString to append attribute value to, if found.
Returns
1 if found and appended, else 0.

◆ buffer_xml_append_printf()

void buffer_xml_append_printf ( GString *  buffer,
const char *  format,
  ... 
)

Format XML into a buffer.

Parameters
[in]bufferBuffer.
[in]formatFormat string for XML.
[in]...Arguments for format string.

◆ error_send_to_client()

void error_send_to_client ( GError **  error)

Set an out of space parse error on a GError.

Parameters
[out]errorThe error.

◆ find_attribute()

int find_attribute ( const gchar **  attribute_names,
const gchar **  attribute_values,
const char *  attribute_name,
const gchar **  attribute_value 
)

Find an attribute in a parser callback list of attributes.

Parameters
[in]attribute_namesList of names.
[in]attribute_valuesList of values.
[in]attribute_nameName of sought attribute.
[out]attribute_valueAttribute value return.
Returns
1 if found, else 0.

◆ internal_error_send_to_client()

void internal_error_send_to_client ( GError **  error)

Set an internal error on a GError.

Parameters
[out]errorThe error.

◆ log_event()

void log_event ( const char *  type,
const char *  type_name,
const char *  id,
const char *  action 
)

Creates a log event entry for a resource action.

Parameters
[in]typeResource type.
[in]type_nameResource type name.
[in]idResource id.
[in]actionAction done.

◆ log_event_fail()

void log_event_fail ( const char *  type,
const char *  type_name,
const char *  id,
const char *  action 
)

Creates a log event failure entry for a resource action.

Parameters
[in]typeResource type.
[in]type_nameResource type name.
[in]idResource id.
[in]actionAction done.

◆ log_event_internal()

static void log_event_internal ( const char *  type,
const char *  type_name,
const char *  id,
const char *  action,
int  fail 
)
static

Creates a log event entry for a resource action.

Parameters
[in]typeResource type.
[in]type_nameResource type name.
[in]idResource id.
[in]actionAction done.
[in]failWhether it is a fail event.

◆ send_find_error_to_client()

gboolean send_find_error_to_client ( const char *  command,
const char *  type,
const char *  id,
gmp_parser_t gmp_parser 
)

Send an XML find error response message to the client.

Parameters
[in]commandCommand name.
[in]typeResource type.
[in]idResource ID.
[in]gmp_parserGMP Parser.
Returns
TRUE if out of space in to_client, else FALSE.

◆ send_to_client()

gboolean send_to_client ( const char *  msg,
int(*)(const char *, void *)  user_send_to_client,
void *  user_send_to_client_data 
)

Send a response message to the client.

Parameters
[in]msgThe message, a string.
[in]user_send_to_clientFunction to send to client.
[in]user_send_to_client_dataArgument to user_send_to_client.
Returns
TRUE if send to client failed, else FALSE.