|
Packit Service |
82fcde |
/* Capture output from a subprocess.
|
|
Packit Service |
82fcde |
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library; if not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifndef SUPPORT_CAPTURE_SUBPROCESS_H
|
|
Packit Service |
82fcde |
#define SUPPORT_CAPTURE_SUBPROCESS_H
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <support/xmemstream.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
struct support_capture_subprocess
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
struct xmemstream out;
|
|
Packit Service |
82fcde |
struct xmemstream err;
|
|
Packit Service |
82fcde |
int status;
|
|
Packit Service |
82fcde |
};
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Invoke CALLBACK (CLOSURE) in a subprocess and capture standard
|
|
Packit Service |
82fcde |
output, standard error, and the exit status. The out.buffer and
|
|
Packit Service |
82fcde |
err.buffer members in the result are null-terminated strings which
|
|
Packit Service |
82fcde |
can be examined by the caller (out.out and err.out are NULL). */
|
|
Packit Service |
82fcde |
struct support_capture_subprocess support_capture_subprocess
|
|
Packit Service |
82fcde |
(void (*callback) (void *), void *closure);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Deallocate the subprocess data captured by
|
|
Packit Service |
82fcde |
support_capture_subprocess. */
|
|
Packit Service |
82fcde |
void support_capture_subprocess_free (struct support_capture_subprocess *);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
enum support_capture_allow
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
/* No output is allowed. */
|
|
Packit Service |
82fcde |
sc_allow_none = 0x01,
|
|
Packit Service |
82fcde |
/* Output to stdout is permitted. */
|
|
Packit Service |
82fcde |
sc_allow_stdout = 0x02,
|
|
Packit Service |
82fcde |
/* Output to standard error is permitted. */
|
|
Packit Service |
82fcde |
sc_allow_stderr = 0x04,
|
|
Packit Service |
82fcde |
};
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Check that the subprocess exited with STATUS and that only the
|
|
Packit Service |
82fcde |
allowed outputs happened. ALLOWED is a combination of
|
|
Packit Service |
82fcde |
support_capture_allow flags. Report errors under the CONTEXT
|
|
Packit Service |
82fcde |
message. */
|
|
Packit Service |
82fcde |
void support_capture_subprocess_check (struct support_capture_subprocess *,
|
|
Packit Service |
82fcde |
const char *context, int status,
|
|
Packit Service |
82fcde |
int allowed)
|
|
Packit Service |
82fcde |
__attribute__ ((nonnull (1, 2)));
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#endif /* SUPPORT_CAPTURE_SUBPROCESS_H */
|