LCOV - code coverage report
Current view: top level - src - gpgconf.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 37 43 86.0 %
Date: 2018-11-15 08:49:49 Functions: 7 7 100.0 %

          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        1271 : gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p,
      37             :                     gpgme_conf_type_t type, const void *value)
      38             : {
      39        1271 :   return _gpgme_conf_arg_new (arg_p, type, value);
      40             : }
      41             : 
      42             : 
      43             : /* This also releases all chained argument structures!  */
      44             : void
      45       14753 : gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type)
      46             : {
      47       14753 :   _gpgme_conf_arg_release (arg, type);
      48       14753 : }
      49             : 
      50             : 
      51             : /* Register a change for the value of OPT to ARG.  */
      52             : gpgme_error_t
      53          42 : gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset, gpgme_conf_arg_t arg)
      54             : {
      55          42 :   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         155 : gpgme_conf_release (gpgme_conf_comp_t conf)
      63             : {
      64         155 :   _gpgme_conf_release (conf);
      65         155 : }
      66             : 
      67             : 
      68             : /* Public function to load a configuration list.  No
      69             :    asynchronous interface for now.  */
      70             : gpgme_error_t
      71          46 : 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          46 :   if (!ctx)
      77           0 :     return gpg_error (GPG_ERR_INV_VALUE);
      78             : 
      79          46 :   proto = ctx->protocol;
      80          46 :   ctx->protocol = GPGME_PROTOCOL_GPGCONF;
      81          46 :   err = _gpgme_op_reset (ctx, 1);
      82          46 :   if (err)
      83           0 :     return err;
      84             : 
      85          46 :   err = _gpgme_engine_op_conf_load (ctx->engine, conf_p);
      86          46 :   ctx->protocol = proto;
      87          46 :   return err;
      88             : }
      89             : 
      90             : 
      91             : /* This function does not follow chained components!  */
      92             : gpgme_error_t
      93         152 : 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         152 :   if (!ctx)
      99           0 :     return gpg_error (GPG_ERR_INV_VALUE);
     100             : 
     101         152 :   proto = ctx->protocol;
     102         152 :   ctx->protocol = GPGME_PROTOCOL_GPGCONF;
     103         152 :   err = _gpgme_op_reset (ctx, 1);
     104         152 :   if (err)
     105           0 :     return err;
     106             : 
     107         152 :   err = _gpgme_engine_op_conf_save (ctx->engine, comp);
     108         152 :   ctx->protocol = proto;
     109         152 :   return err;
     110             : }
     111             : 
     112             : 
     113             : gpgme_error_t
     114           2 : gpgme_op_conf_dir (gpgme_ctx_t ctx, const char *what, char **result)
     115             : {
     116             :   gpgme_error_t err;
     117             :   gpgme_protocol_t proto;
     118             : 
     119           2 :   if (!ctx)
     120           0 :     return gpg_error (GPG_ERR_INV_VALUE);
     121             : 
     122           2 :   proto = ctx->protocol;
     123           2 :   ctx->protocol = GPGME_PROTOCOL_GPGCONF;
     124           2 :   err = _gpgme_op_reset (ctx, 1);
     125           2 :   if (err)
     126           0 :     return err;
     127             : 
     128           2 :   err = _gpgme_engine_op_conf_dir (ctx->engine, what, result);
     129           2 :   ctx->protocol = proto;
     130           2 :   return err;
     131             : }

Generated by: LCOV version 1.13