1 /* input.h -- Structures and unions used for reading input. */
2 /* Copyright (C) 1993 Free Software Foundation, Inc.
4 This file is part of GNU Bash, the Bourne Again SHell.
6 Bash is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License along
17 with Bash; see the file COPYING. If not, write to the Free Software
18 Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
20 #if !defined (_INPUT_H_)
25 /* Function pointers can be declared as (Function *)foo. */
26 #if !defined (_FUNCTION_DEF)
27 # define _FUNCTION_DEF
28 typedef int Function ();
29 typedef void VFunction ();
30 typedef char *CPFunction ();
31 typedef char **CPPFunction ();
32 #endif /* _FUNCTION_DEF */
34 enum stream_type {st_none, st_stdin, st_stream, st_string, st_bstream};
36 #if defined (BUFFERED_INPUT)
38 /* Possible values for b_flag. */
40 #undef B_ERROR /* There are some systems with this define */
47 /* A buffered stream. Like a FILE *, but with our own buffering and
48 synchronization. Look in input.c for the implementation. */
49 typedef struct BSTREAM
52 char *b_buffer; /* The buffer that holds characters read. */
53 size_t b_size; /* How big the buffer is. */
54 int b_used; /* How much of the buffer we're using, */
55 int b_flag; /* Flag values. */
56 int b_inputp; /* The input pointer, index into b_buffer. */
60 extern BUFFERED_STREAM **buffers;
63 extern int default_buffered_input;
65 #endif /* BUFFERED_INPUT */
70 #if defined (BUFFERED_INPUT)
76 enum stream_type type;
78 INPUT_STREAM location;
83 extern BASH_INPUT bash_input;
85 /* Functions from parse.y. */
86 extern void initialize_bash_input __P((void));
87 extern void init_yy_io __P((Function *, Function *, enum stream_type, char *, INPUT_STREAM));
88 extern void with_input_from_stdin __P((void));
89 extern void with_input_from_string __P((char *, char *));
90 extern void with_input_from_stream __P((FILE *, char *));
91 extern void push_stream __P((int));
92 extern void pop_stream __P((void));
93 extern int stream_on_stack __P((enum stream_type));
94 extern char *read_secondary_line __P((int));
95 extern int find_reserved_word __P((char *));
96 extern char *decode_prompt_string __P((char *));
97 extern void gather_here_documents __P((void));
98 extern void execute_prompt_command __P((char *));
100 extern int *save_token_state __P((void));
101 extern void restore_token_state __P((int *));
103 /* Functions from input.c */
104 extern int getc_with_restart ();
105 extern int ungetc_with_restart ();
107 #if defined (BUFFERED_INPUT)
108 /* Functions from input.c. */
109 extern int check_bash_input __P((int));
110 extern int duplicate_buffered_stream __P((int, int));
111 extern BUFFERED_STREAM *fd_to_buffered_stream __P((int));
112 extern BUFFERED_STREAM *set_buffered_stream __P((int, BUFFERED_STREAM *));
113 extern BUFFERED_STREAM *open_buffered_stream __P((char *));
114 extern void free_buffered_stream __P((BUFFERED_STREAM *));
115 extern int close_buffered_stream __P((BUFFERED_STREAM *));
116 extern int close_buffered_fd __P((int));
117 extern int sync_buffered_stream __P((int));
118 extern int buffered_getchar __P((void));
119 extern int buffered_ungetchar __P((int));
120 extern void with_input_from_buffered_stream __P((int, char *));
121 #endif /* BUFFERED_INPUT */
123 #endif /* _INPUT_H_ */