]>
Commit | Line | Data |
---|---|---|
726f6388 JA |
1 | /* subst.h -- Names of externally visible functions in subst.c. */ |
2 | ||
3 | /* Copyright (C) 1993 Free Software Foundation, Inc. | |
4 | ||
5 | This file is part of GNU Bash, the Bourne Again SHell. | |
6 | ||
7 | Bash is free software; you can redistribute it and/or modify it under | |
8 | the terms of the GNU General Public License as published by the Free | |
9 | Software Foundation; either version 2, or (at your option) any later | |
10 | version. | |
11 | ||
12 | Bash is distributed in the hope that it will be useful, but WITHOUT ANY | |
13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License along | |
18 | with Bash; see the file COPYING. If not, write to the Free Software | |
19 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
20 | ||
21 | #if !defined (_SUBST_H_) | |
22 | #define _SUBST_H_ | |
23 | ||
24 | #include "stdc.h" | |
25 | ||
26 | /* Cons a new string from STRING starting at START and ending at END, | |
27 | not including END. */ | |
28 | extern char *substring __P((char *, int, int)); | |
29 | ||
30 | /* Remove backslashes which are quoting backquotes from STRING. Modifies | |
31 | STRING, and returns a pointer to it. */ | |
32 | extern char * de_backslash __P((char *)); | |
33 | ||
34 | /* Replace instances of \! in a string with !. */ | |
35 | extern void unquote_bang __P((char *)); | |
36 | ||
37 | /* Extract the $( construct in STRING, and return a new string. | |
38 | Start extracting at (SINDEX) as if we had just seen "$(". | |
39 | Make (SINDEX) get the position just after the matching ")". */ | |
40 | extern char *extract_command_subst __P((char *, int *)); | |
41 | ||
42 | /* Extract the $[ construct in STRING, and return a new string. | |
43 | Start extracting at (SINDEX) as if we had just seen "$[". | |
44 | Make (SINDEX) get the position just after the matching "]". */ | |
45 | extern char *extract_arithmetic_subst __P((char *, int *)); | |
46 | ||
47 | #if defined (PROCESS_SUBSTITUTION) | |
48 | /* Extract the <( or >( construct in STRING, and return a new string. | |
49 | Start extracting at (SINDEX) as if we had just seen "<(". | |
50 | Make (SINDEX) get the position just after the matching ")". */ | |
51 | extern char *extract_process_subst __P((char *, char *, int *)); | |
52 | #endif /* PROCESS_SUBSTITUTION */ | |
53 | ||
54 | /* Extract the name of the variable to bind to from the assignment string. */ | |
55 | extern char *assignment_name __P((char *)); | |
56 | ||
57 | /* Return a single string of all the words present in LIST, separating | |
58 | each word with a space. */ | |
59 | extern char *string_list __P((WORD_LIST *)); | |
60 | ||
61 | /* Return a single string of all the words present in LIST, obeying the | |
62 | quoting rules for "$*", to wit: (P1003.2, draft 11, 3.5.2) "If the | |
63 | expansion [of $*] appears within a double quoted string, it expands | |
64 | to a single field with the value of each parameter separated by the | |
65 | first character of the IFS variable, or by a <space> if IFS is unset." */ | |
66 | extern char *string_list_dollar_star __P((WORD_LIST *)); | |
67 | ||
68 | /* Perform quoted null character removal on each element of LIST. | |
69 | This modifies LIST. */ | |
70 | extern void word_list_remove_quoted_nulls __P((WORD_LIST *)); | |
71 | ||
72 | /* This performs word splitting and quoted null character removal on | |
73 | STRING. */ | |
74 | extern WORD_LIST *list_string __P((char *, char *, int)); | |
75 | ||
76 | extern char *get_word_from_string __P((char **, char *, char **)); | |
77 | extern char *strip_trailing_ifs_whitespace __P((char *, char *, int)); | |
78 | ||
79 | /* Given STRING, an assignment string, get the value of the right side | |
80 | of the `=', and bind it to the left side. If EXPAND is true, then | |
81 | perform parameter expansion, command substitution, and arithmetic | |
82 | expansion on the right-hand side. Perform tilde expansion in any | |
83 | case. Do not perform word splitting on the result of expansion. */ | |
84 | extern int do_assignment __P((char *)); | |
85 | extern int do_assignment_no_expand __P((char *)); | |
86 | ||
ccc6cda3 JA |
87 | #if defined (ARRAY_VARS) |
88 | extern SHELL_VAR *do_array_element_assignment __P((char *, char *)); | |
89 | #endif | |
90 | ||
726f6388 JA |
91 | /* Append SOURCE to TARGET at INDEX. SIZE is the current amount |
92 | of space allocated to TARGET. SOURCE can be NULL, in which | |
93 | case nothing happens. Gets rid of SOURCE by free ()ing it. | |
94 | Returns TARGET in case the location has changed. */ | |
95 | extern char *sub_append_string __P((char *, char *, int *, int *)); | |
96 | ||
97 | /* Append the textual representation of NUMBER to TARGET. | |
98 | INDEX and SIZE are as in SUB_APPEND_STRING. */ | |
99 | extern char *sub_append_number __P((int, char *, int *, int *)); | |
100 | ||
101 | /* Return the word list that corresponds to `$*'. */ | |
102 | extern WORD_LIST *list_rest_of_args __P((void)); | |
103 | ||
104 | /* Make a single large string out of the dollar digit variables, | |
105 | and the rest_of_args. If DOLLAR_STAR is 1, then obey the special | |
106 | case of "$*" with respect to IFS. */ | |
107 | extern char *string_rest_of_args __P((int)); | |
108 | ||
ccc6cda3 JA |
109 | extern int number_of_args __P((void)); |
110 | ||
726f6388 JA |
111 | /* Expand STRING by performing parameter expansion, command substitution, |
112 | and arithmetic expansion. Dequote the resulting WORD_LIST before | |
113 | returning it, but do not perform word splitting. The call to | |
114 | remove_quoted_nulls () is in here because word splitting normally | |
115 | takes care of quote removal. */ | |
116 | extern WORD_LIST *expand_string_unsplit __P((char *, int)); | |
117 | ||
118 | /* Expand STRING just as if you were expanding a word. This also returns | |
119 | a list of words. Note that filename globbing is *NOT* done for word | |
120 | or string expansion, just when the shell is expanding a command. This | |
121 | does parameter expansion, command substitution, arithmetic expansion, | |
122 | and word splitting. Dequote the resultant WORD_LIST before returning. */ | |
123 | extern WORD_LIST *expand_string __P((char *, int)); | |
124 | ||
125 | /* De-quoted quoted characters in STRING. */ | |
126 | extern char *dequote_string __P((char *)); | |
127 | ||
128 | /* Expand WORD, performing word splitting on the result. This does | |
129 | parameter expansion, command substitution, arithmetic expansion, | |
130 | word splitting, and quote removal. */ | |
131 | extern WORD_LIST *expand_word __P((WORD_DESC *, int)); | |
132 | ||
133 | /* Expand WORD, but do not perform word splitting on the result. This | |
134 | does parameter expansion, command substitution, arithmetic expansion, | |
135 | and quote removal. */ | |
136 | extern WORD_LIST *expand_word_no_split __P((WORD_DESC *, int)); | |
137 | extern WORD_LIST *expand_word_leave_quoted __P((WORD_DESC *, int)); | |
138 | ||
139 | /* Return the value of a positional parameter. This handles values > 10. */ | |
140 | extern char *get_dollar_var_value __P((int)); | |
141 | ||
ccc6cda3 JA |
142 | /* Quote a string to protect it from word splitting. */ |
143 | extern char *quote_string __P((char *)); | |
144 | ||
726f6388 JA |
145 | /* Perform quote removal on STRING. If QUOTED > 0, assume we are obeying the |
146 | backslash quoting rules for within double quotes. */ | |
147 | extern char *string_quote_removal __P((char *, int)); | |
148 | ||
149 | /* Perform quote removal on word WORD. This allocates and returns a new | |
150 | WORD_DESC *. */ | |
151 | extern WORD_DESC *word_quote_removal __P((WORD_DESC *, int)); | |
152 | ||
153 | /* Perform quote removal on all words in LIST. If QUOTED is non-zero, | |
154 | the members of the list are treated as if they are surrounded by | |
155 | double quotes. Return a new list, or NULL if LIST is NULL. */ | |
156 | extern WORD_LIST *word_list_quote_removal __P((WORD_LIST *, int)); | |
157 | ||
158 | /* This splits a single word into a WORD LIST on $IFS, but only if the word | |
159 | is not quoted. list_string () performs quote removal for us, even if we | |
160 | don't do any splitting. */ | |
161 | extern WORD_LIST *word_split __P((WORD_DESC *)); | |
162 | ||
163 | /* Take the list of words in LIST and do the various substitutions. Return | |
164 | a new list of words which is the expanded list, and without things like | |
165 | variable assignments. */ | |
166 | extern WORD_LIST *expand_words __P((WORD_LIST *)); | |
167 | ||
168 | /* Same as expand_words (), but doesn't hack variable or environment | |
169 | variables. */ | |
170 | extern WORD_LIST *expand_words_no_vars __P((WORD_LIST *)); | |
171 | ||
726f6388 JA |
172 | /* The variable in NAME has just had its state changed. Check to see if it |
173 | is one of the special ones where something special happens. */ | |
174 | extern void stupidly_hack_special_variables __P((char *)); | |
175 | ||
ccc6cda3 JA |
176 | extern char *pat_subst __P((char *, char *, char *, int)); |
177 | ||
178 | extern void unlink_fifo_list __P((void)); | |
179 | ||
180 | #if defined (ARRAY_VARS) | |
181 | extern int array_expand_index __P((char *, int)); | |
182 | extern int valid_array_reference __P((char *)); | |
183 | extern char *get_array_value __P((char *, int)); | |
184 | extern SHELL_VAR *array_variable_part __P((char *, char **, int *)); | |
185 | extern WORD_LIST *list_string_with_quotes __P((char *)); | |
186 | extern char *extract_array_assignment_list __P((char *, int *)); | |
187 | #endif | |
188 | ||
189 | /* The `special variable' functions that get called when a particular | |
190 | variable is set. */ | |
191 | void sv_path (), sv_mail (), sv_ignoreeof (), sv_strict_posix (); | |
192 | void sv_optind (), sv_opterr (), sv_globignore (), sv_locale (); | |
193 | ||
194 | #if defined (READLINE) | |
195 | void sv_terminal (), sv_hostfile (); | |
196 | #endif | |
197 | ||
198 | #if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE) | |
199 | void sv_tz (); | |
200 | #endif | |
201 | ||
202 | #if defined (HISTORY) | |
203 | void sv_histsize (), sv_histignore (), sv_history_control (); | |
204 | # if defined (BANG_HISTORY) | |
205 | void sv_histchars (); | |
206 | # endif | |
207 | #endif /* HISTORY */ | |
208 | ||
209 | /* How to determine the quoted state of the character C. */ | |
210 | #define QUOTED_CHAR(c) ((c) == CTLESC) | |
211 | ||
212 | /* Is the first character of STRING a quoted NULL character? */ | |
213 | #define QUOTED_NULL(string) ((string)[0] == CTLNUL && (string)[1] == '\0') | |
214 | ||
726f6388 | 215 | #endif /* !_SUBST_H_ */ |