OSDN Git Service

yash2: redir: +redirect_stdin_to_devnull
[yash/yash.git] / redir.h
1 /* Yash: yet another shell */
2 /* redir.h: manages file descriptors and provides functions for redirections */
3 /* © 2007-2008 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 REDIR_H
20 #define REDIR_H
21
22 #include <stdbool.h>
23 #include <stdio.h>
24
25 extern int xclose(int fd);
26 extern int xdup2(int oldfd, int newfd);
27
28 extern bool is_stdin_redirected;
29 extern int ttyfd;
30
31 extern void init_shellfds(void);
32 extern void clear_shellfds(void);
33 extern int copy_as_shellfd(int fd);
34 extern FILE *reopen_with_shellfd(FILE *f, const char *mode);
35 extern void open_ttyfd(void);
36
37 typedef struct savefd_T savefd_T;
38 struct redir_T;
39
40 extern bool open_redirections(const struct redir_T *r, struct savefd_T **save);
41 extern void undo_redirections(savefd_T *save);
42 extern void clear_savefd(savefd_T *save);
43 extern void redirect_stdin_to_devnull(void);
44
45
46 #endif /* REDIR_H */
47
48
49 /* vim: set ts=8 sts=4 sw=4 noet: */