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

GVM GMP layer: GET commands. More...

#include "gmp_get.h"
#include "gmp_base.h"
#include "manage_acl.h"
#include <stdlib.h>
#include <string.h>

Macros

#define G_LOG_DOMAIN   "md gmp"
 GLib log domain.
 

Functions

void get_data_parse_attributes (get_data_t *data, const gchar *type, const gchar **attribute_names, const gchar **attribute_values)
 Parse attributes for a GET command. More...
 
int init_get (gchar *command, get_data_t *get, const gchar *setting_name, int *first)
 Init for a GET handler. More...
 
int get_next (iterator_t *resources, get_data_t *get, int *first, int *count, int(*init)(iterator_t *, const get_data_t *))
 Iterate a GET iterator. More...
 
int send_get_start (const char *type, int(*write_to_client)(const char *, void *), void *write_to_client_data)
 Send start of GET response. More...
 
int send_get_common (const char *type, get_data_t *get, iterator_t *iterator, int(*write_to_client)(const char *, void *), void *write_to_client_data, int writable, int in_use)
 Send common part of GET response for a single resource. More...
 
int buffer_get_filter_xml (GString *msg, const char *type, const get_data_t *get, const char *filter_term, const char *extra_xml)
 Write data of a GET command filter to a string buffer as XML. More...
 
static int send_get_end_internal (const char *type, get_data_t *get, int get_counts, int count, int filtered, int full, int(*write_to_client)(const char *, void *), void *write_to_client_data)
 Send end of GET response. More...
 
int send_get_end (const char *type, get_data_t *get, int count, int filtered, int full, int(*write_to_client)(const char *, void *), void *write_to_client_data)
 Send end of GET response. More...
 
int send_get_end_no_counts (const char *type, get_data_t *get, int(*write_to_client)(const char *, void *), void *write_to_client_data)
 Send end of GET response, skipping result counts. More...
 

Detailed Description

GVM GMP layer: GET commands.

Common GET command code for the GVM GMP layer.

Function Documentation

◆ buffer_get_filter_xml()

int buffer_get_filter_xml ( GString *  msg,
const char *  type,
const get_data_t get,
const char *  filter_term,
const char *  extra_xml 
)

Write data of a GET command filter to a string buffer as XML.

Parameters
[in]msgThe string buffer to write to.
[in]typeThe filtered type.
[in]getGET data.
[in]filter_termFilter term.
[in]extra_xmlExtra XML to include in the FILTER element.
Returns
Always 0.

◆ get_data_parse_attributes()

void get_data_parse_attributes ( get_data_t data,
const gchar *  type,
const gchar **  attribute_names,
const gchar **  attribute_values 
)

Parse attributes for a GET command.

Parameters
[in]dataGET operation data.
[in]typeResource type.
[in]attribute_namesXML attribute names.
[in]attribute_valuesXML attribute values.

◆ get_next()

int get_next ( iterator_t resources,
get_data_t get,
int *  first,
int *  count,
int(*)(iterator_t *, const get_data_t *)  init 
)

Iterate a GET iterator.

If the user requested to start at an offset from the first result, but the result set was empty, then reset the iterator to start from the first result.

Parameters
[in]resourcesResource iterator.
[in]getGET command data.
[out]firstFirst. Number of first item to get.
[out]countCount.
[in]initInit function, to reset the iterator.
Returns
What to do next: 0 continue, 1 end, -1 fail.

◆ init_get()

int init_get ( gchar *  command,
get_data_t get,
const gchar *  setting_name,
int *  first 
)

Init for a GET handler.

Parameters
[in]commandGMP command name.
[in]getGET data.
[in]setting_nameType name for setting.
[out]firstFirst result, from filter.
Returns
0 success, -1 error.

◆ send_get_common()

int send_get_common ( const char *  type,
get_data_t get,
iterator_t iterator,
int(*)(const char *, void *)  write_to_client,
void *  write_to_client_data,
int  writable,
int  in_use 
)

Send common part of GET response for a single resource.

Parameters
[in]typeType.
[in]getGET data.
[in]iteratorIterator.
[in]write_to_clientFunction that sends to clients.
[in]write_to_client_dataData for write_to_client.
[in]writableWhether the resource is writable.
[in]in_useWhether the resource is in use.
Returns
0 success, 1 send error.

◆ send_get_end()

int send_get_end ( const char *  type,
get_data_t get,
int  count,
int  filtered,
int  full,
int(*)(const char *, void *)  write_to_client,
void *  write_to_client_data 
)

Send end of GET response.

Parameters
[in]typeType.
[in]getGET data.
[in]countPage count.
[in]filteredFiltered count.
[in]fullFull count.
[in]write_to_clientFunction that sends to clients.
[in]write_to_client_dataData for write_to_client.
Returns
0 success, 1 sending to client failed, 2 failed to allocate filter term.

◆ send_get_end_internal()

static int send_get_end_internal ( const char *  type,
get_data_t get,
int  get_counts,
int  count,
int  filtered,
int  full,
int(*)(const char *, void *)  write_to_client,
void *  write_to_client_data 
)
static

Send end of GET response.

Parameters
[in]typeType.
[in]getGET data.
[in]get_countsInclude counts.
[in]countPage count.
[in]filteredFiltered count.
[in]fullFull count.
[in]write_to_clientFunction that sends to clients.
[in]write_to_client_dataData for write_to_client.
Returns
0 success, 1 sending to client failed, 2 failed to allocate filter term.

◆ send_get_end_no_counts()

int send_get_end_no_counts ( const char *  type,
get_data_t get,
int(*)(const char *, void *)  write_to_client,
void *  write_to_client_data 
)

Send end of GET response, skipping result counts.

Parameters
[in]typeType.
[in]getGET data.
[in]write_to_clientFunction that sends to clients.
[in]write_to_client_dataData for write_to_client.
Returns
0 success, 1 sending to client failed, 2 failed to allocate filter term.

◆ send_get_start()

int send_get_start ( const char *  type,
int(*)(const char *, void *)  write_to_client,
void *  write_to_client_data 
)

Send start of GET response.

Parameters
[in]typeType.
[in]write_to_clientFunction that sends to clients.
[in]write_to_client_dataData for write_to_client.
Returns
0 success, 1 send to client failed.