Do not include the removed file status-table.h
[gpgme.git] / src / gpgconf.c
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
30 #ifdef ENABLE_GPGCONF
31 /* engine-gpgconf.c.  */
32 gpgme_error_t _gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p,
33                                   gpgme_conf_type_t type, const void *value);
34 void _gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type);
35 gpgme_error_t _gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset,
36                                       gpgme_conf_arg_t arg);
37 void _gpgme_conf_release (gpgme_conf_comp_t conf);
38 gpgme_error_t _gpgme_conf_load (void *engine, gpgme_conf_comp_t *conf_p);
39 gpgme_error_t gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp);
40
41 #endif
42
43 \f
44 /* Allocate a new gpgme_conf_arg_t.  */
45 gpgme_error_t
46 gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p,
47                     gpgme_conf_type_t type, const void *value)
48 {
49 #ifdef ENABLE_GPGCONF
50   return _gpgme_conf_arg_new (arg_p, type, value);
51 #else
52   return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
53 #endif
54 }
55
56
57 /* This also releases all chained argument structures!  */
58 void
59 gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type)
60 {
61 #ifdef ENABLE_GPGCONF
62   _gpgme_conf_arg_release (arg, type);
63 #endif
64 }
65
66
67 /* Register a change for the value of OPT to ARG.  */
68 gpgme_error_t
69 gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset, gpgme_conf_arg_t arg)
70 {
71 #ifdef ENABLE_GPGCONF
72   return _gpgme_conf_opt_change (opt, reset, arg);
73 #else
74   return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
75 #endif
76 }
77
78
79
80 /* Public function to release a gpgme_conf_comp list.  */
81 void
82 gpgme_conf_release (gpgme_conf_comp_t conf)
83 {
84 #ifdef ENABLE_GPGCONF
85   _gpgme_conf_release (conf);
86 #endif
87 }
88
89
90 /* Public function to release load a configuration list.  No
91    asynchronous interface for now.  */
92 gpgme_error_t
93 gpgme_op_conf_load (gpgme_ctx_t ctx, gpgme_conf_comp_t *conf_p)
94 {
95 #ifdef ENABLE_GPGCONF
96   gpgme_error_t err;
97   gpgme_protocol_t proto;
98
99   if (!ctx)
100     return gpg_error (GPG_ERR_INV_VALUE);
101
102   proto = ctx->protocol;
103   ctx->protocol = GPGME_PROTOCOL_GPGCONF;
104   err = _gpgme_op_reset (ctx, 1);
105   if (err)
106     return err;
107
108   err = _gpgme_engine_op_conf_load (ctx->engine, conf_p);
109   ctx->protocol = proto;
110   return err;
111 #else
112   return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
113 #endif
114 }
115
116
117 /* This function does not follow chained components!  */
118 gpgme_error_t
119 gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp)
120 {
121 #ifdef ENABLE_GPGCONF
122   gpgme_error_t err;
123   gpgme_protocol_t proto;
124
125   if (!ctx)
126     return gpg_error (GPG_ERR_INV_VALUE);
127
128   proto = ctx->protocol;
129   ctx->protocol = GPGME_PROTOCOL_GPGCONF;
130   err = _gpgme_op_reset (ctx, 1);
131   if (err)
132     return err;
133
134   err = _gpgme_engine_op_conf_save (ctx->engine, comp);
135   ctx->protocol = proto;
136   return err;
137 #else
138   return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
139 #endif
140 }
141
142