|
Packit |
d7e8d0 |
/* gpgconf.c - GnuPG Made Easy.
|
|
Packit Service |
30b792 |
* Copyright (C) 2007 g10 Code GmbH
|
|
Packit Service |
30b792 |
*
|
|
Packit Service |
30b792 |
* This file is part of GPGME.
|
|
Packit Service |
30b792 |
*
|
|
Packit Service |
30b792 |
* GPGME is free software; you can redistribute it and/or modify it
|
|
Packit Service |
30b792 |
* under the terms of the GNU Lesser General Public License as
|
|
Packit Service |
30b792 |
* published by the Free Software Foundation; either version 2.1 of
|
|
Packit Service |
30b792 |
* the License, or (at your option) any later version.
|
|
Packit Service |
30b792 |
*
|
|
Packit Service |
30b792 |
* GPGME is distributed in the hope that it will be useful, but
|
|
Packit Service |
30b792 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
30b792 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
30b792 |
* Lesser General Public License for more details.
|
|
Packit Service |
30b792 |
*
|
|
Packit Service |
30b792 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
30b792 |
* License along with this program; if not, see <https://gnu.org/licenses/>.
|
|
Packit Service |
30b792 |
* SPDX-License-Identifier: LGPL-2.1-or-later
|
|
Packit Service |
30b792 |
*/
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#if HAVE_CONFIG_H
|
|
Packit |
d7e8d0 |
#include <config.h>
|
|
Packit |
d7e8d0 |
#endif
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include "gpgme.h"
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include "ops.h"
|
|
Packit |
d7e8d0 |
#include "engine.h"
|
|
Packit |
d7e8d0 |
#include "debug.h"
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include "engine-backend.h"
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/* Allocate a new gpgme_conf_arg_t. */
|
|
Packit |
d7e8d0 |
gpgme_error_t
|
|
Packit |
d7e8d0 |
gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p,
|
|
Packit |
d7e8d0 |
gpgme_conf_type_t type, const void *value)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return _gpgme_conf_arg_new (arg_p, type, value);
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/* This also releases all chained argument structures! */
|
|
Packit |
d7e8d0 |
void
|
|
Packit |
d7e8d0 |
gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
_gpgme_conf_arg_release (arg, type);
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/* Register a change for the value of OPT to ARG. */
|
|
Packit |
d7e8d0 |
gpgme_error_t
|
|
Packit |
d7e8d0 |
gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset, gpgme_conf_arg_t arg)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return _gpgme_conf_opt_change (opt, reset, arg);
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/* Public function to release a gpgme_conf_comp list. */
|
|
Packit |
d7e8d0 |
void
|
|
Packit |
d7e8d0 |
gpgme_conf_release (gpgme_conf_comp_t conf)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
_gpgme_conf_release (conf);
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/* Public function to load a configuration list. No
|
|
Packit |
d7e8d0 |
asynchronous interface for now. */
|
|
Packit |
d7e8d0 |
gpgme_error_t
|
|
Packit |
d7e8d0 |
gpgme_op_conf_load (gpgme_ctx_t ctx, gpgme_conf_comp_t *conf_p)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
gpgme_error_t err;
|
|
Packit |
d7e8d0 |
gpgme_protocol_t proto;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
if (!ctx)
|
|
Packit |
d7e8d0 |
return gpg_error (GPG_ERR_INV_VALUE);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
proto = ctx->protocol;
|
|
Packit |
d7e8d0 |
ctx->protocol = GPGME_PROTOCOL_GPGCONF;
|
|
Packit |
d7e8d0 |
err = _gpgme_op_reset (ctx, 1);
|
|
Packit |
d7e8d0 |
if (err)
|
|
Packit |
d7e8d0 |
return err;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
err = _gpgme_engine_op_conf_load (ctx->engine, conf_p);
|
|
Packit |
d7e8d0 |
ctx->protocol = proto;
|
|
Packit |
d7e8d0 |
return err;
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/* This function does not follow chained components! */
|
|
Packit |
d7e8d0 |
gpgme_error_t
|
|
Packit |
d7e8d0 |
gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
gpgme_error_t err;
|
|
Packit |
d7e8d0 |
gpgme_protocol_t proto;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
if (!ctx)
|
|
Packit |
d7e8d0 |
return gpg_error (GPG_ERR_INV_VALUE);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
proto = ctx->protocol;
|
|
Packit |
d7e8d0 |
ctx->protocol = GPGME_PROTOCOL_GPGCONF;
|
|
Packit |
d7e8d0 |
err = _gpgme_op_reset (ctx, 1);
|
|
Packit |
d7e8d0 |
if (err)
|
|
Packit |
d7e8d0 |
return err;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
err = _gpgme_engine_op_conf_save (ctx->engine, comp);
|
|
Packit |
d7e8d0 |
ctx->protocol = proto;
|
|
Packit |
d7e8d0 |
return err;
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
gpgme_error_t
|
|
Packit |
d7e8d0 |
gpgme_op_conf_dir (gpgme_ctx_t ctx, const char *what, char **result)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
gpgme_error_t err;
|
|
Packit |
d7e8d0 |
gpgme_protocol_t proto;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
if (!ctx)
|
|
Packit |
d7e8d0 |
return gpg_error (GPG_ERR_INV_VALUE);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
proto = ctx->protocol;
|
|
Packit |
d7e8d0 |
ctx->protocol = GPGME_PROTOCOL_GPGCONF;
|
|
Packit |
d7e8d0 |
err = _gpgme_op_reset (ctx, 1);
|
|
Packit |
d7e8d0 |
if (err)
|
|
Packit |
d7e8d0 |
return err;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
err = _gpgme_engine_op_conf_dir (ctx->engine, what, result);
|
|
Packit |
d7e8d0 |
ctx->protocol = proto;
|
|
Packit |
d7e8d0 |
return err;
|
|
Packit |
d7e8d0 |
}
|