/* Copyright (C) 2019-2022 Greenbone AG
 *
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

#ifndef _GVMD_MANAGE_CONFIGS_H
#define _GVMD_MANAGE_CONFIGS_H

#include "manage_resources_types.h"
#include "manage_get.h"
#include "manage_preferences.h"

preference_t *
get_nvt_preference_by_id (const char *,
                          const char *,
                          const char *,
                          const char *,
                          const char *);

/**
 * @brief An NVT selector.
 */
typedef struct
{
  char *name;           ///< Name of NVT selector.
  char *type;           ///< Name of NVT selector.
  int include;          ///< Whether family/NVT is included or excluded.
  char *family_or_nvt;  ///< Family or NVT that this selector selects.
} nvt_selector_t;

int
create_config (const char*, const char*, int, const char*, int, const array_t*,
               const array_t*, const char*, config_t*, char**);

int
copy_config (const char*, const char*, const char *, const char *, config_t*);

int
delete_config (const char*, int);

gboolean
find_config_with_permission (const char*, config_t*, const char *);

char *
config_uuid (config_t);

char *
config_nvt_timeout (config_t, const char *);

int
config_predefined_uuid (const gchar *);

void
init_user_config_iterator (iterator_t*, config_t, int, int, const char*);

int
init_config_iterator (iterator_t*, get_data_t*);

const char*
config_iterator_nvt_selector (iterator_t*);

int
config_iterator_nvt_count (iterator_t*);

int
config_iterator_family_count (iterator_t*);

int
config_iterator_nvts_growing (iterator_t*);

int
config_iterator_families_growing (iterator_t*);

const char*
config_iterator_usage_type (iterator_t*);

int
config_iterator_predefined (iterator_t*);

char*
config_nvt_selector (config_t);

int
config_in_use (config_t);

int
config_writable (config_t);

int
config_count (const get_data_t *);

int
trash_config_in_use (config_t);

int
trash_config_writable (config_t);

int
trash_config_readable_uuid (const gchar *);

int
config_families_growing (config_t);

int
config_nvts_growing (config_t);

int
manage_modify_config_start (const char *, config_t *);

void
manage_modify_config_cancel ();

void
manage_modify_config_commit ();

int
manage_set_config_preference (config_t, const char*, const char*, const char*);

void
init_config_preference_iterator (iterator_t *, config_t);

const char*
config_preference_iterator_name (iterator_t *);

const char*
config_preference_iterator_value (iterator_t *);

const char*
config_preference_iterator_type (iterator_t *);

const char*
config_preference_iterator_default (iterator_t *);

int
manage_set_config (config_t, const char*, const char *);

int
manage_set_config_nvts (config_t, const char*, GPtrArray*);

int
manage_set_config_families (config_t, GPtrArray*, GPtrArray*, GPtrArray*, int,
                            gchar **);

gboolean
configs_feed_dir_exists ();

void
manage_sync_configs ();

int
manage_rebuild_configs ();

gboolean
should_sync_configs ();

gboolean
scanner_type_requires_config (int scanner_type);

void
get_nvt_oids_from_config (config_t, GSList **);

void
get_nvt_oids_from_config_uuid (const gchar *, GSList **);

#endif /* not _GVMD_MANAGE_CONFIGS_H */
