Line data Source code
1 : /* gpgconf.c - GnuPG Made Easy.
2 : Copyright (C) 2007 g10 Code GmbH
3 :
4 : This file is part of GPGME.
5 :
6 : GPGME is free software; you can redistribute it and/or modify it
7 : under the terms of the GNU Lesser General Public License as
8 : published by the Free Software Foundation; either version 2.1 of
9 : the License, or (at your option) any later version.
10 :
11 : GPGME is distributed in the hope that it will be useful, but
12 : WITHOUT ANY WARRANTY; without even the implied warranty of
13 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 : Lesser General Public License for more details.
15 :
16 : You should have received a copy of the GNU Lesser General Public
17 : License along with this program; if not, write to the Free Software
18 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 : 02111-1307, USA. */
20 :
21 : #if HAVE_CONFIG_H
22 : #include <config.h>
23 : #endif
24 :
25 : #include "gpgme.h"
26 :
27 : #include "ops.h"
28 : #include "engine.h"
29 : #include "debug.h"
30 :
31 : #include "engine-backend.h"
32 :
33 :
34 : /* Allocate a new gpgme_conf_arg_t. */
35 : gpgme_error_t
36 0 : gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p,
37 : gpgme_conf_type_t type, const void *value)
38 : {
39 0 : return _gpgme_conf_arg_new (arg_p, type, value);
40 : }
41 :
42 :
43 : /* This also releases all chained argument structures! */
44 : void
45 0 : gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type)
46 : {
47 0 : _gpgme_conf_arg_release (arg, type);
48 0 : }
49 :
50 :
51 : /* Register a change for the value of OPT to ARG. */
52 : gpgme_error_t
53 0 : gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset, gpgme_conf_arg_t arg)
54 : {
55 0 : return _gpgme_conf_opt_change (opt, reset, arg);
56 : }
57 :
58 :
59 :
60 : /* Public function to release a gpgme_conf_comp list. */
61 : void
62 0 : gpgme_conf_release (gpgme_conf_comp_t conf)
63 : {
64 0 : _gpgme_conf_release (conf);
65 0 : }
66 :
67 :
68 : /* Public function to release load a configuration list. No
69 : asynchronous interface for now. */
70 : gpgme_error_t
71 0 : gpgme_op_conf_load (gpgme_ctx_t ctx, gpgme_conf_comp_t *conf_p)
72 : {
73 : gpgme_error_t err;
74 : gpgme_protocol_t proto;
75 :
76 0 : if (!ctx)
77 0 : return gpg_error (GPG_ERR_INV_VALUE);
78 :
79 0 : proto = ctx->protocol;
80 0 : ctx->protocol = GPGME_PROTOCOL_GPGCONF;
81 0 : err = _gpgme_op_reset (ctx, 1);
82 0 : if (err)
83 0 : return err;
84 :
85 0 : err = _gpgme_engine_op_conf_load (ctx->engine, conf_p);
86 0 : ctx->protocol = proto;
87 0 : return err;
88 : }
89 :
90 :
91 : /* This function does not follow chained components! */
92 : gpgme_error_t
93 0 : gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp)
94 : {
95 : gpgme_error_t err;
96 : gpgme_protocol_t proto;
97 :
98 0 : if (!ctx)
99 0 : return gpg_error (GPG_ERR_INV_VALUE);
100 :
101 0 : proto = ctx->protocol;
102 0 : ctx->protocol = GPGME_PROTOCOL_GPGCONF;
103 0 : err = _gpgme_op_reset (ctx, 1);
104 0 : if (err)
105 0 : return err;
106 :
107 0 : err = _gpgme_engine_op_conf_save (ctx->engine, comp);
108 0 : ctx->protocol = proto;
109 0 : return err;
110 : }
111 :
112 :
|