OSDN Git Service

Convert to indentation by spaces
[yash/yash.git] / redir.h
1 /* Yash: yet another shell */
2 /* redir.h: manages file descriptors and provides functions for redirections */
3 /* (C) 2007-2023 magicant */
4
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.
9  * 
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.
14  * 
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/>.  */
17
18
19 #ifndef YASH_REDIR_H
20 #define YASH_REDIR_H
21
22 #include <stddef.h>
23
24
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));
29
30 extern int ttyfd;
31
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);
41
42 typedef struct savefd_T savefd_T;
43 struct redir_T;
44
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);
50
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 */
53
54
55 #endif /* YASH_REDIR_H */
56
57
58 /* vim: set ts=8 sts=4 sw=4 et tw=80: */