]> git.ipfire.org Git - thirdparty/bash.git/blame - input.h
Imported from ../bash-2.05.tar.gz.
[thirdparty/bash.git] / input.h
CommitLineData
726f6388
JA
1/* input.h -- Structures and unions used for reading input. */
2/* Copyright (C) 1993 Free Software Foundation, Inc.
3
4 This file is part of GNU Bash, the Bourne Again SHell.
5
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
9 version.
10
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
14 for more details.
15
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
bb70624e 18 Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
726f6388 19
ccc6cda3
JA
20#if !defined (_INPUT_H_)
21#define _INPUT_H_
726f6388
JA
22
23#include "stdc.h"
24
25/* Function pointers can be declared as (Function *)foo. */
ccc6cda3
JA
26#if !defined (_FUNCTION_DEF)
27# define _FUNCTION_DEF
726f6388
JA
28typedef int Function ();
29typedef void VFunction ();
30typedef char *CPFunction ();
31typedef char **CPPFunction ();
32#endif /* _FUNCTION_DEF */
33
ccc6cda3 34enum stream_type {st_none, st_stdin, st_stream, st_string, st_bstream};
726f6388
JA
35
36#if defined (BUFFERED_INPUT)
726f6388
JA
37
38/* Possible values for b_flag. */
cce855bc
JA
39#undef B_EOF
40#undef B_ERROR /* There are some systems with this define */
41#undef B_UNBUFF
42
28ef6c31
JA
43#define B_EOF 0x01
44#define B_ERROR 0x02
45#define B_UNBUFF 0x04
46#define B_WASBASHINPUT 0x08
726f6388
JA
47
48/* A buffered stream. Like a FILE *, but with our own buffering and
49 synchronization. Look in input.c for the implementation. */
50typedef struct BSTREAM
51{
52 int b_fd;
53 char *b_buffer; /* The buffer that holds characters read. */
cce855bc 54 size_t b_size; /* How big the buffer is. */
726f6388
JA
55 int b_used; /* How much of the buffer we're using, */
56 int b_flag; /* Flag values. */
57 int b_inputp; /* The input pointer, index into b_buffer. */
58} BUFFERED_STREAM;
59
cce855bc 60#if 0
726f6388 61extern BUFFERED_STREAM **buffers;
cce855bc 62#endif
726f6388
JA
63
64extern int default_buffered_input;
65
66#endif /* BUFFERED_INPUT */
67
68typedef union {
69 FILE *file;
70 char *string;
71#if defined (BUFFERED_INPUT)
72 int buffered_fd;
73#endif
74} INPUT_STREAM;
75
76typedef struct {
ccc6cda3 77 enum stream_type type;
726f6388
JA
78 char *name;
79 INPUT_STREAM location;
80 Function *getter;
81 Function *ungetter;
82} BASH_INPUT;
83
84extern BASH_INPUT bash_input;
85
86/* Functions from parse.y. */
87extern void initialize_bash_input __P((void));
d166f048 88extern void init_yy_io __P((Function *, Function *, enum stream_type, char *, INPUT_STREAM));
726f6388
JA
89extern void with_input_from_stdin __P((void));
90extern void with_input_from_string __P((char *, char *));
91extern void with_input_from_stream __P((FILE *, char *));
ccc6cda3
JA
92extern void push_stream __P((int));
93extern void pop_stream __P((void));
94extern int stream_on_stack __P((enum stream_type));
726f6388
JA
95extern char *read_secondary_line __P((int));
96extern int find_reserved_word __P((char *));
97extern char *decode_prompt_string __P((char *));
98extern void gather_here_documents __P((void));
99extern void execute_prompt_command __P((char *));
100
bb70624e
JA
101extern int *save_token_state __P((void));
102extern void restore_token_state __P((int *));
103
ccc6cda3
JA
104/* Functions from input.c */
105extern int getc_with_restart ();
106extern int ungetc_with_restart ();
107
726f6388
JA
108#if defined (BUFFERED_INPUT)
109/* Functions from input.c. */
28ef6c31
JA
110extern int fd_is_bash_input __P((int));
111extern int set_bash_input_fd __P((int));
112extern int save_bash_input __P((int, int));
726f6388
JA
113extern int check_bash_input __P((int));
114extern int duplicate_buffered_stream __P((int, int));
115extern BUFFERED_STREAM *fd_to_buffered_stream __P((int));
cce855bc 116extern BUFFERED_STREAM *set_buffered_stream __P((int, BUFFERED_STREAM *));
726f6388
JA
117extern BUFFERED_STREAM *open_buffered_stream __P((char *));
118extern void free_buffered_stream __P((BUFFERED_STREAM *));
119extern int close_buffered_stream __P((BUFFERED_STREAM *));
120extern int close_buffered_fd __P((int));
121extern int sync_buffered_stream __P((int));
122extern int buffered_getchar __P((void));
123extern int buffered_ungetchar __P((int));
124extern void with_input_from_buffered_stream __P((int, char *));
125#endif /* BUFFERED_INPUT */
126
ccc6cda3 127#endif /* _INPUT_H_ */