2 * Copyright (C) 2001-2017 Colin Watson.
4 * This file is part of libpipeline.
6 * libpipeline is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
11 * libpipeline 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 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with libpipeline; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22 #ifndef PIPELINE_PRIVATE_H
23 #define PIPELINE_PRIVATE_H
28 #define OK 0 /* success */
29 #define FAIL 1 /* usage or syntax error */
30 #define FATAL 2 /* operational error */
32 extern char *appendstr (char *, ...)
33 PIPELINE_ATTR_SENTINEL PIPELINE_ATTR_WARN_UNUSED_RESULT;
35 extern void init_debug (void);
36 extern int debug_level;
37 extern void debug (const char *message, ...)
38 PIPELINE_ATTR_FORMAT_PRINTF (1, 2);
40 #if defined(HAVE_SETENV) && !defined(HAVE_CLEARENV)
41 extern int clearenv (void);
59 int discard_err; /* discard stderr? */
63 int env_max; /* size of allocated array */
64 struct pipecmd_env *env;
65 pipecmd_function_type *pre_exec_func;
66 pipecmd_function_type *pre_exec_free_func;
69 struct pipecmd_process {
71 int argv_max; /* size of allocated array */
74 struct pipecmd_function {
75 pipecmd_function_type *func;
76 pipecmd_function_free_type *free_func;
79 struct pipecmd_sequence {
82 struct pipecmd **commands;
87 enum pipeline_redirect {
95 int commands_max; /* size of allocated array */
98 int *statuses; /* -1 until command exits */
100 /* REDIRECT_NONE for no redirection; REDIRECT_FD for redirection
101 * from/to file descriptor; REDIRECT_FILE_NAME for redirection
104 enum pipeline_redirect redirect_in, redirect_out;
106 /* If non-negative, these contain caller-supplied file descriptors
107 * for the input and output of the whole pipeline. If negative,
108 * pipeline_start() will create pipes and store the input writing
109 * half and the output reading half in infd and outfd as
112 int want_in, want_out;
114 /* If non-NULL, these contain files to open and use as the input and
115 * output of the whole pipeline. These are only used if want_in or
116 * want_out respectively is zero. The value of using these rather
117 * than simply opening the files before starting the pipeline is
118 * that the files will be opened with the same privileges under
119 * which the pipeline is being run.
121 char *want_infile, *want_outfile;
123 /* See above. Default to -1. The caller should consider these
128 /* Set by pipeline_get_infile() and pipeline_get_outfile()
129 * respectively. Default to NULL.
131 FILE *infile, *outfile;
133 /* Set by pipeline_connect() to record that this pipeline reads its
134 * input from another pipeline. Defaults to NULL.
136 struct pipeline *source;
138 /* Private buffer for use by read/peek functions. */
140 size_t buflen, bufmax;
142 /* The last line returned by readline/peekline. Private. */
145 /* The amount of data at the end of buffer which has been
146 * read-ahead, either by an explicit peek or by readline/peekline
147 * reading a block at a time to save work. Private.
151 /* If set, ignore SIGINT and SIGQUIT while the pipeline is running,
152 * like system(). Defaults to 1.
157 #endif /* PIPELINE_PRIVATE_H */