1079e727257a80aa2b4da89f13fa7aaa889f0e27
[platform/upstream/bash.git] / externs.h
1 /* externs.h -- extern function declarations which do not appear in their
2    own header file. */
3
4 /* Copyright (C) 1993-2009 Free Software Foundation, Inc.
5
6    This file is part of GNU Bash, the Bourne Again SHell.
7
8    Bash is free software: you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation, either version 3 of the License, or
11    (at your option) any later version.
12
13    Bash is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with Bash.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 /* Make sure that this is included *after* config.h! */
23
24 #if !defined (_EXTERNS_H_)
25 #  define _EXTERNS_H_
26
27 #include "stdc.h"
28
29 /* Functions from expr.c. */
30 extern intmax_t evalexp __P((char *, int *));
31
32 /* Functions from print_cmd.c. */
33 #define FUNC_MULTILINE  0x01
34 #define FUNC_EXTERNAL   0x02
35
36 extern char *make_command_string __P((COMMAND *));
37 extern char *named_function_string __P((char *, COMMAND *, int));
38
39 extern void print_command __P((COMMAND *));
40 extern void print_simple_command __P((SIMPLE_COM *));
41 extern void print_word_list __P((WORD_LIST *, char *));
42
43 /* debugger support */
44 extern void print_for_command_head __P((FOR_COM *));
45 #if defined (SELECT_COMMAND)
46 extern void print_select_command_head __P((SELECT_COM *));
47 #endif
48 extern void print_case_command_head __P((CASE_COM *));
49 #if defined (DPAREN_ARITHMETIC)
50 extern void print_arith_command __P((WORD_LIST *));
51 #endif
52 #if defined (COND_COMMAND)
53 extern void print_cond_command __P((COND_COM *));
54 #endif
55
56 /* set -x support */
57 extern char *indirection_level_string __P((void));
58 extern void xtrace_print_assignment __P((char *, char *, int, int));
59 extern void xtrace_print_word_list __P((WORD_LIST *, int));
60 extern void xtrace_print_for_command_head __P((FOR_COM *));
61 #if defined (SELECT_COMMAND)
62 extern void xtrace_print_select_command_head __P((SELECT_COM *));
63 #endif
64 extern void xtrace_print_case_command_head __P((CASE_COM *));
65 #if defined (DPAREN_ARITHMETIC)
66 extern void xtrace_print_arith_cmd __P((WORD_LIST *));
67 #endif
68 #if defined (COND_COMMAND)
69 extern void xtrace_print_cond_term __P((int, int, WORD_DESC *, char *, char *));
70 #endif
71
72 /* Functions from shell.c. */
73 extern void exit_shell __P((int)) __attribute__((__noreturn__));
74 extern void sh_exit __P((int)) __attribute__((__noreturn__));
75 extern void disable_priv_mode __P((void));
76 extern void unbind_args __P((void));
77
78 #if defined (RESTRICTED_SHELL)
79 extern int shell_is_restricted __P((char *));
80 extern int maybe_make_restricted __P((char *));
81 #endif
82
83 extern void unset_bash_input __P((int));
84 extern void get_current_user_info __P((void));
85
86 /* Functions from eval.c. */
87 extern int reader_loop __P((void));
88 extern int parse_command __P((void));
89 extern int read_command __P((void));
90
91 /* Functions from braces.c. */
92 #if defined (BRACE_EXPANSION)
93 extern char **brace_expand __P((char *));
94 #endif
95
96 /* Miscellaneous functions from parse.y */
97 extern int yyparse __P((void));
98 extern int return_EOF __P((void));
99 extern char *xparse_dolparen __P((char *, char *, int *, int));
100 extern void reset_parser __P((void));
101 extern WORD_LIST *parse_string_to_word_list __P((char *, int, const char *));
102
103 extern void free_pushed_string_input __P((void));
104
105 extern char *decode_prompt_string __P((char *));
106
107 extern int get_current_prompt_level __P((void));
108 extern void set_current_prompt_level __P((int));
109
110 #if defined (HISTORY)
111 extern char *history_delimiting_chars __P((void));
112 #endif
113
114 /* Declarations for functions defined in locale.c */
115 extern void set_default_locale __P((void));
116 extern void set_default_locale_vars __P((void));
117 extern int set_locale_var __P((char *, char *));
118 extern int set_lang __P((char *, char *));
119 extern void set_default_lang __P((void));
120 extern char *get_locale_var __P((char *));
121 extern char *localetrans __P((char *, int, int *));
122 extern char *mk_msgstr __P((char *, int *));
123 extern char *localeexpand __P((char *, int, int, int, int *));
124
125 /* Declarations for functions defined in list.c. */
126 extern void list_walk __P((GENERIC_LIST *, sh_glist_func_t *));
127 extern void wlist_walk __P((WORD_LIST *, sh_icpfunc_t *));
128 extern GENERIC_LIST *list_reverse ();
129 extern int list_length ();
130 extern GENERIC_LIST *list_append ();
131 extern GENERIC_LIST *list_remove ();
132
133 /* Declarations for functions defined in stringlib.c */
134 extern int find_string_in_alist __P((char *, STRING_INT_ALIST *, int));
135 extern char *find_token_in_alist __P((int, STRING_INT_ALIST *, int));
136 extern int find_index_in_alist __P((char *, STRING_INT_ALIST *, int));
137
138 extern char *substring __P((char *, int, int));
139 extern char *strsub __P((char *, char *, char *, int));
140 extern char *strcreplace __P((char *, int, char *, int));
141 extern void strip_leading __P((char *));
142 extern void strip_trailing __P((char *, int, int));
143 extern void xbcopy __P((char *, char *, int));
144
145 /* Functions from version.c. */
146 extern char *shell_version_string __P((void));
147 extern void show_shell_version __P((int));
148
149 /* Functions from the bash library, lib/sh/libsh.a.  These should really
150    go into a separate include file. */
151
152 /* declarations for functions defined in lib/sh/casemod.c */
153 extern char *sh_modcase __P((const char *, char *, int));
154
155 /* Defines for flags argument to sh_modcase.  These need to agree with what's
156    in lib/sh/casemode.c */
157 #define CASE_LOWER      0x0001
158 #define CASE_UPPER      0x0002
159 #define CASE_CAPITALIZE 0x0004
160 #define CASE_UNCAP      0x0008
161 #define CASE_TOGGLE     0x0010
162 #define CASE_TOGGLEALL  0x0020
163 #define CASE_UPFIRST    0x0040
164 #define CASE_LOWFIRST   0x0080
165
166 #define CASE_USEWORDS   0x1000
167
168 /* declarations for functions defined in lib/sh/clktck.c */
169 extern long get_clk_tck __P((void));
170
171 /* declarations for functions defined in lib/sh/clock.c */
172 extern void clock_t_to_secs ();
173 extern void print_clock_t ();
174
175 /* Declarations for functions defined in lib/sh/fdprintf.c */
176 extern void fdprintf __P((int, const char *, ...))  __attribute__((__format__ (printf, 2, 3)));
177
178 /* Declarations for functions defined in lib/sh/fmtulong.c */
179 #define FL_PREFIX     0x01    /* add 0x, 0X, or 0 prefix as appropriate */
180 #define FL_ADDBASE    0x02    /* add base# prefix to converted value */
181 #define FL_HEXUPPER   0x04    /* use uppercase when converting to hex */
182 #define FL_UNSIGNED   0x08    /* don't add any sign */
183
184 extern char *fmtulong __P((unsigned long int, int, char *, size_t, int));
185
186 /* Declarations for functions defined in lib/sh/fmtulong.c */
187 #if defined (HAVE_LONG_LONG)
188 extern char *fmtullong __P((unsigned long long int, int, char *, size_t, int));
189 #endif
190
191 /* Declarations for functions defined in lib/sh/fmtumax.c */
192 extern char *fmtumax __P((uintmax_t, int, char *, size_t, int));
193
194 /* Declarations for functions defined in lib/sh/fpurge.c */
195 #if !HAVE_DECL_FPURGE
196
197 #if HAVE_FPURGE
198 #  define fpurge _bash_fpurge
199 #endif
200 extern int fpurge __P((FILE *stream));
201
202 #endif /* HAVE_DECL_FPURGE */
203
204
205 /* Declarations for functions defined in lib/sh/getcwd.c */
206 #if !defined (HAVE_GETCWD)
207 extern char *getcwd __P((char *, size_t));
208 #endif
209
210 /* Declarations for functions defined in lib/sh/input_avail.c */
211 extern int input_avail __P((int));
212
213 /* Declarations for functions defined in lib/sh/itos.c */
214 extern char *inttostr __P((intmax_t, char *, size_t));
215 extern char *itos __P((intmax_t));
216 extern char *uinttostr __P((uintmax_t, char *, size_t));
217 extern char *uitos __P((uintmax_t));
218
219 /* declarations for functions defined in lib/sh/makepath.c */
220 #define MP_DOTILDE      0x01
221 #define MP_DOCWD        0x02
222 #define MP_RMDOT        0x04
223 #define MP_IGNDOT       0x08
224
225 extern char *sh_makepath __P((const char *, const char *, int));
226
227 /* declarations for functions defined in lib/sh/netconn.c */
228 extern int isnetconn __P((int));
229
230 /* declarations for functions defined in lib/sh/netopen.c */
231 extern int netopen __P((char *));
232
233 /* Declarations for  functions defined in lib/sh/oslib.c */
234
235 #if !defined (HAVE_DUP2) || defined (DUP2_BROKEN)
236 extern int dup2 __P((int, int));
237 #endif
238
239 #if !defined (HAVE_GETDTABLESIZE)
240 extern int getdtablesize __P((void));
241 #endif /* !HAVE_GETDTABLESIZE */
242
243 #if !defined (HAVE_GETHOSTNAME)
244 extern int gethostname __P((char *, int));
245 #endif /* !HAVE_GETHOSTNAME */
246
247 extern int getmaxgroups __P((void));
248 extern long getmaxchild __P((void));
249
250 /* declarations for functions defined in lib/sh/pathcanon.c */
251 #define PATH_CHECKDOTDOT        0x0001
252 #define PATH_CHECKEXISTS        0x0002
253 #define PATH_HARDPATH           0x0004
254 #define PATH_NOALLOC            0x0008
255
256 extern char *sh_canonpath __P((char *, int));
257
258 /* declarations for functions defined in lib/sh/pathphys.c */
259 extern char *sh_physpath __P((char *, int));
260 extern char *sh_realpath __P((const char *, char *));
261
262 /* declarations for functions defined in lib/sh/setlinebuf.c */
263 #ifdef NEED_SH_SETLINEBUF_DECL
264 extern int sh_setlinebuf __P((FILE *));
265 #endif
266
267 /* declarations for functions defined in lib/sh/shaccess.c */
268 extern int sh_eaccess __P((char *, int));
269
270 /* declarations for functions defined in lib/sh/shmatch.c */
271 extern int sh_regmatch __P((const char *, const char *, int));
272
273 /* defines for flags argument to sh_regmatch. */
274 #define SHMAT_SUBEXP            0x001   /* save subexpressions in SH_REMATCH */
275 #define SHMAT_PWARN             0x002   /* print a warning message on invalid regexp */
276
277 /* declarations for functions defined in lib/sh/shquote.c */
278 extern char *sh_single_quote __P((char *));
279 extern char *sh_double_quote __P((char *));
280 extern char *sh_mkdoublequoted __P((const char *, int, int));
281 extern char *sh_un_double_quote __P((char *));
282 extern char *sh_backslash_quote __P((char *));
283 extern char *sh_backslash_quote_for_double_quotes __P((char *));
284 extern int sh_contains_shell_metas __P((char *));
285
286 /* declarations for functions defined in lib/sh/spell.c */
287 extern int spname __P((char *, char *));
288 extern char *dirspell __P((char *));
289
290 /* declarations for functions defined in lib/sh/strcasecmp.c */
291 #if !defined (HAVE_STRCASECMP)
292 extern int strncasecmp __P((const char *, const char *, int));
293 extern int strcasecmp __P((const char *, const char *));
294 #endif /* HAVE_STRCASECMP */
295
296 /* declarations for functions defined in lib/sh/strerror.c */
297 #if !defined (HAVE_STRERROR) && !defined (strerror)
298 extern char *strerror __P((int));
299 #endif
300
301 /* declarations for functions defined in lib/sh/strftime.c */
302 #if !defined (HAVE_STRFTIME) && defined (NEED_STRFTIME_DECL)
303 extern size_t strftime __P((char *, size_t, const char *, const struct tm *));
304 #endif
305
306 /* declarations for functions defined in lib/sh/strindex.c */
307 extern char *strindex __P((const char *, const char *));
308
309 /* declarations for functions and structures defined in lib/sh/stringlist.c */
310
311 /* This is a general-purpose argv-style array struct. */
312 typedef struct _list_of_strings {
313   char **list;
314   int list_size;
315   int list_len;
316 } STRINGLIST;
317
318 typedef int sh_strlist_map_func_t __P((char *));
319
320 extern STRINGLIST *strlist_create __P((int));
321 extern STRINGLIST *strlist_resize __P((STRINGLIST *, int));
322 extern void strlist_flush __P((STRINGLIST *));
323 extern void strlist_dispose __P((STRINGLIST *));
324 extern int strlist_remove __P((STRINGLIST *, char *));
325 extern STRINGLIST *strlist_copy __P((STRINGLIST *));
326 extern STRINGLIST *strlist_merge __P((STRINGLIST *, STRINGLIST *));
327 extern STRINGLIST *strlist_append __P((STRINGLIST *, STRINGLIST *));
328 extern STRINGLIST *strlist_prefix_suffix __P((STRINGLIST *, char *, char *));
329 extern void strlist_print __P((STRINGLIST *, char *));
330 extern void strlist_walk __P((STRINGLIST *, sh_strlist_map_func_t *));
331 extern void strlist_sort __P((STRINGLIST *));
332
333 /* declarations for functions defined in lib/sh/stringvec.c */
334
335 extern char **strvec_create __P((int));
336 extern char **strvec_resize __P((char **, int));
337 extern void strvec_flush __P((char **));
338 extern void strvec_dispose __P((char **));
339 extern int strvec_remove __P((char **, char *));
340 extern int strvec_len __P((char **));
341 extern int strvec_search __P((char **, char *));
342 extern char **strvec_copy __P((char **));
343 extern int strvec_strcmp __P((char **, char **));
344 extern void strvec_sort __P((char **));
345
346 extern char **strvec_from_word_list __P((WORD_LIST *, int, int, int *));
347 extern WORD_LIST *strvec_to_word_list __P((char **, int, int));
348
349 /* declarations for functions defined in lib/sh/strnlen.c */
350 #if !defined (HAVE_STRNLEN)
351 extern size_t strnlen __P((const char *, size_t));
352 #endif
353
354 /* declarations for functions defined in lib/sh/strpbrk.c */
355 #if !defined (HAVE_STRPBRK)
356 extern char *strpbrk __P((const char *, const char *));
357 #endif
358
359 /* declarations for functions defined in lib/sh/strtod.c */
360 #if !defined (HAVE_STRTOD)
361 extern double strtod __P((const char *, char **));
362 #endif
363
364 /* declarations for functions defined in lib/sh/strtol.c */
365 #if !HAVE_DECL_STRTOL
366 extern long strtol __P((const char *, char **, int));
367 #endif
368
369 /* declarations for functions defined in lib/sh/strtoll.c */
370 #if defined (HAVE_LONG_LONG) && !HAVE_DECL_STRTOLL
371 extern long long strtoll __P((const char *, char **, int));
372 #endif
373
374 /* declarations for functions defined in lib/sh/strtoul.c */
375 #if !HAVE_DECL_STRTOUL
376 extern unsigned long strtoul __P((const char *, char **, int));
377 #endif
378
379 /* declarations for functions defined in lib/sh/strtoull.c */
380 #if defined (HAVE_LONG_LONG) && !HAVE_DECL_STRTOULL
381 extern unsigned long long strtoull __P((const char *, char **, int));
382 #endif
383
384 /* declarations for functions defined in lib/sh/strimax.c */
385 #if !HAVE_DECL_STRTOIMAX
386 extern intmax_t strtoimax __P((const char *, char **, int));
387 #endif
388
389 /* declarations for functions defined in lib/sh/strumax.c */
390 #if !HAVE_DECL_STRTOUMAX
391 extern uintmax_t strtoumax __P((const char *, char **, int));
392 #endif
393
394 /* declarations for functions defined in lib/sh/strtrans.c */
395 extern char *ansicstr __P((char *, int, int, int *, int *));
396 extern char *ansic_quote __P((char *, int, int *));
397 extern int ansic_shouldquote __P((const char *));
398 extern char *ansiexpand __P((char *, int, int, int *));
399
400 /* declarations for functions defined in lib/sh/timeval.c.  No prototypes
401    so we don't have to count on having a definition of struct timeval in
402    scope when this file is included. */
403 extern void timeval_to_secs ();
404 extern void print_timeval ();
405
406 /* declarations for functions defined in lib/sh/tmpfile.c */
407 #define MT_USETMPDIR            0x0001
408 #define MT_READWRITE            0x0002
409 #define MT_USERANDOM            0x0004
410
411 extern char *sh_mktmpname __P((char *, int));
412 extern int sh_mktmpfd __P((char *, int, char **));
413 /* extern FILE *sh_mktmpfp __P((char *, int, char **)); */
414
415 /* declarations for functions defined in lib/sh/uconvert.c */
416 extern int uconvert __P((char *, long *, long *));
417
418 /* declarations for functions defined in lib/sh/ufuncs.c */
419 extern unsigned int falarm __P((unsigned int, unsigned int));
420 extern unsigned int fsleep __P((unsigned int, unsigned int));
421
422 /* declarations for functions defined in lib/sh/winsize.c */
423 extern void get_new_window_size __P((int, int *, int *));
424
425 /* declarations for functions defined in lib/sh/xstrchr.c */
426 #undef xstrchr
427 extern char *xstrchr __P((const char *, int));
428
429 /* declarations for functions defined in lib/sh/zcatfd.c */
430 extern int zcatfd __P((int, int, char *));
431
432 /* declarations for functions defined in lib/sh/zgetline.c */
433 extern ssize_t zgetline __P((int, char **, size_t *, int));
434
435 /* declarations for functions defined in lib/sh/zmapfd.c */
436 extern int zmapfd __P((int, char **, char *));
437
438 /* declarations for functions defined in lib/sh/zread.c */
439 extern ssize_t zread __P((int, char *, size_t));
440 extern ssize_t zreadretry __P((int, char *, size_t));
441 extern ssize_t zreadintr __P((int, char *, size_t));
442 extern ssize_t zreadc __P((int, char *));
443 extern ssize_t zreadcintr __P((int, char *));
444 extern void zreset __P((void));
445 extern void zsyncfd __P((int));
446
447 /* declarations for functions defined in lib/sh/zwrite.c */
448 extern int zwrite __P((int, char *, size_t));
449
450 #endif /* _EXTERNS_H_ */