OpenVAS Scanner 23.23.1
user_agent.c File Reference

Functions to set and get the User-Agent. More...

#include "user_agent.h"
#include "ipc_openvas.h"
#include "plugutils.h"
#include "vendorversion.h"
#include <glib.h>
#include <gvm/base/prefs.h>

Macros

#define G_LOG_DOMAIN   "lib misc"
 GLib logging domain.

Functions

static int send_user_agent_via_ipc (struct ipc_context *ipc_context)
static void user_agent_create (void)
 Create and set the global User-Agent variable.
gchar * user_agent_set (const gchar *ua)
 Set user-agent.
int user_agent_get (struct ipc_context *ipc_context, char **useragent)
 Get user-agent.

Variables

static gchar * user_agent = NULL
 user-agent, or NULL.

Detailed Description

Functions to set and get the User-Agent.

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "lib misc"

GLib logging domain.

Function Documentation

◆ send_user_agent_via_ipc()

int send_user_agent_via_ipc ( struct ipc_context * ipc_context)
static

◆ user_agent_create()

void user_agent_create ( void )
static

Create and set the global User-Agent variable.

@description Gets the User-Agent from the globals_settings.nasl script preferences. If it is not set, it uses the Vendor version. In case that there is no Vendor version, it creates one with a fix string and the nasl library version.

◆ user_agent_get()

int user_agent_get ( struct ipc_context * ipc_context,
char ** useragent )

Get user-agent.

param[in] ipc_context IPC context for sending data to the parent process param[out] useragent the user agent if any set or an empty string.

Returns
0 on success, -1 on error when sending the message, -2 if the context does not exists

◆ user_agent_set()

gchar * user_agent_set ( const gchar * ua)

Set user-agent.

Set the global user agent. This function overwrite the existing UA. Null or empty string are not allowed.

Parameters
[in]uauser-agent to be set.

Return the old User-Agent. It must be free by the caller

Variable Documentation

◆ user_agent

gchar* user_agent = NULL
static

user-agent, or NULL.