LCOV - code coverage report
Current view: top level - common - asshelp2.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 12 91.7 %
Date: 2016-09-12 13:01:59 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* asshelp2.c - More helper functions for Assuan
       2             :  * Copyright (C) 2012 Free Software Foundation, Inc.
       3             :  *
       4             :  * This file is part of GnuPG.
       5             :  *
       6             :  * This file is free software; you can redistribute it and/or modify
       7             :  * it under the terms of either
       8             :  *
       9             :  *   - the GNU Lesser General Public License as published by the Free
      10             :  *     Software Foundation; either version 3 of the License, or (at
      11             :  *     your option) any later version.
      12             :  *
      13             :  * or
      14             :  *
      15             :  *   - the GNU General Public License as published by the Free
      16             :  *     Software Foundation; either version 2 of the License, or (at
      17             :  *     your option) any later version.
      18             :  *
      19             :  * or both in parallel, as here.
      20             :  *
      21             :  * This file is distributed in the hope that it will be useful,
      22             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      23             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      24             :  * GNU General Public License for more details.
      25             :  *
      26             :  * You should have received a copy of the GNU General Public License
      27             :  * along with this program; if not, see <http://www.gnu.org/licenses/>.
      28             :  */
      29             : 
      30             : #include <config.h>
      31             : #include <stdio.h>
      32             : #include <stdlib.h>
      33             : #include <string.h>
      34             : #include <errno.h>
      35             : #include <assuan.h>
      36             : 
      37             : #include "util.h"
      38             : #include "asshelp.h"
      39             : 
      40             : /* Helper function to print an assuan status line using a printf
      41             :    format string.  */
      42             : gpg_error_t
      43         661 : vprint_assuan_status (assuan_context_t ctx,
      44             :                       const char *keyword,
      45             :                       const char *format, va_list arg_ptr)
      46             : {
      47             :   int rc;
      48             :   char *buf;
      49             : 
      50         661 :   rc = gpgrt_vasprintf (&buf, format, arg_ptr);
      51         661 :   if (rc < 0)
      52           0 :     return gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
      53         661 :   rc = assuan_write_status (ctx, keyword, buf);
      54         661 :   xfree (buf);
      55         661 :   return rc;
      56             : }
      57             : 
      58             : 
      59             : /* Helper function to print an assuan status line using a printf
      60             :    format string.  */
      61             : gpg_error_t
      62         262 : print_assuan_status (assuan_context_t ctx,
      63             :                      const char *keyword,
      64             :                      const char *format, ...)
      65             : {
      66             :   va_list arg_ptr;
      67             :   gpg_error_t err;
      68             : 
      69         262 :   va_start (arg_ptr, format);
      70         262 :   err = vprint_assuan_status (ctx, keyword, format, arg_ptr);
      71         262 :   va_end (arg_ptr);
      72         262 :   return err;
      73             : }

Generated by: LCOV version 1.11