LCOV - code coverage report
Current view: top level - src - spawn.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 25 0.0 %
Date: 2016-12-01 18:45:36 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /* spawn.c - Run an arbitrary command with callbacks.
       2             :    Copyright (C) 2014 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             : #include <stdlib.h>
      25             : 
      26             : #include "gpgme.h"
      27             : #include "debug.h"
      28             : #include "context.h"
      29             : #include "util.h"
      30             : #include "ops.h"
      31             : 
      32             : 
      33             : static gpgme_error_t
      34           0 : spawn_start (gpgme_ctx_t ctx, int synchronous,
      35             :              const char *file, const char *argv[],
      36             :              gpgme_data_t datain,
      37             :              gpgme_data_t dataout, gpgme_data_t dataerr,
      38             :              unsigned int flags)
      39             : {
      40             :   gpgme_error_t err;
      41             :   const char *tmp_argv[2];
      42             : 
      43           0 :   if (ctx->protocol != GPGME_PROTOCOL_SPAWN)
      44           0 :     return gpg_error (GPG_ERR_UNSUPPORTED_PROTOCOL);
      45             : 
      46           0 :   err = _gpgme_op_reset (ctx, synchronous);
      47           0 :   if (err)
      48           0 :     return err;
      49             : 
      50           0 :   if (!argv)
      51             :     {
      52           0 :       tmp_argv[0] = _gpgme_get_basename (file);
      53           0 :       tmp_argv[1] = NULL;
      54           0 :       argv = tmp_argv;
      55             :     }
      56             : 
      57           0 :   return _gpgme_engine_op_spawn (ctx->engine, file, argv,
      58             :                                  datain, dataout, dataerr, flags);
      59             : }
      60             : 
      61             : 
      62             : /* Run the command FILE with the arguments in ARGV.  Connect stdin to
      63             :    DATAIN, stdout to DATAOUT, and STDERR to DATAERR.  If one the data
      64             :    streams is NULL, connect to /dev/null instead.  */
      65             : gpgme_error_t
      66           0 : gpgme_op_spawn_start (gpgme_ctx_t ctx, const char *file, const char *argv[],
      67             :                       gpgme_data_t datain,
      68             :                       gpgme_data_t dataout, gpgme_data_t dataerr,
      69             :                       unsigned int flags)
      70             : {
      71             :   gpgme_error_t err;
      72             : 
      73           0 :   TRACE_BEG2 (DEBUG_CTX, "gpgme_op_spawn_start", ctx, "file=(%s) flaggs=%x",
      74             :               file, flags);
      75             : 
      76           0 :   if (!ctx)
      77           0 :     return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
      78             : 
      79           0 :   err = spawn_start (ctx, 0, file, argv, datain, dataout, dataerr, flags);
      80           0 :   return err;
      81             : }
      82             : 
      83             : 
      84             : /* Run the command FILE with the arguments in ARGV.  Connect stdin to
      85             :    DATAIN, stdout to DATAOUT, and STDERR to DATAERR.  If one the data
      86             :    streams is NULL, connect to /dev/null instead.  Synchronous
      87             :    variant. */
      88             : gpgme_error_t
      89           0 : gpgme_op_spawn (gpgme_ctx_t ctx, const char *file, const char *argv[],
      90             :                 gpgme_data_t datain,
      91             :                 gpgme_data_t dataout, gpgme_data_t dataerr,
      92             :                 unsigned int flags)
      93             : {
      94             :   gpgme_error_t err;
      95             : 
      96           0 :   TRACE_BEG2 (DEBUG_CTX, "gpgme_op_spawn", ctx, "file=(%s) flags=%x",
      97             :               file, flags);
      98           0 :   if (!ctx)
      99           0 :     return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
     100             : 
     101           0 :   err = spawn_start (ctx, 1, file, argv, datain, dataout, dataerr, flags);
     102             : 
     103           0 :   if (!err)
     104           0 :     err = _gpgme_wait_one (ctx);
     105           0 :   return TRACE_ERR (err);
     106             : }

Generated by: LCOV version 1.11