1 /* Yash: yet another shell */
2 /* redir.h: manages file descriptors and provides functions for redirections */
3 /* (C) 2007-2023 magicant */
5 /* This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 extern int xclose(int fd);
26 extern int xdup2(int oldfd, int newfd);
27 extern _Bool write_all(int fd, const void *data, size_t size)
28 __attribute__((nonnull));
32 extern void init_shellfds(void);
33 extern void add_shellfd(int fd);
34 extern void remove_shellfd(int fd);
35 extern _Bool is_shellfd(int fd)
36 __attribute__((pure));
37 extern void clear_shellfds(_Bool leavefds);
38 extern int copy_as_shellfd(int fd);
39 extern int move_to_shellfd(int fd);
40 extern void open_ttyfd(void);
42 typedef struct savefd_T savefd_T;
45 extern _Bool open_redirections(const struct redir_T *r, savefd_T **save)
46 __attribute__((nonnull(2)));
47 extern void undo_redirections(savefd_T *save);
48 extern void clear_savefd(savefd_T *save);
49 extern void maybe_redirect_stdin_to_devnull(void);
51 #define PIPE_IN 0 /* index of the reading end of a pipe */
52 #define PIPE_OUT 1 /* index of the writing end of a pipe */
55 #endif /* YASH_REDIR_H */
58 /* vim: set ts=8 sts=4 sw=4 et tw=80: */