cafbd5fa804fe41c08eeca169f334551af429600
[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
196 #if defined NEED_FPURGE_DECL
197 #if !HAVE_DECL_FPURGE
198
199 #if HAVE_FPURGE
200 #  define fpurge _bash_fpurge
201 #endif
202 extern int fpurge __P((FILE *stream));
203
204 #endif /* HAVE_DECL_FPURGE */
205 #endif /* NEED_FPURGE_DECL */
206
207 /* Declarations for functions defined in lib/sh/getcwd.c */
208 #if !defined (HAVE_GETCWD)
209 extern char *getcwd __P((char *, size_t));
210 #endif
211
212 /* Declarations for functions defined in lib/sh/input_avail.c */
213 extern int input_avail __P((int));
214
215 /* Declarations for functions defined in lib/sh/itos.c */
216 extern char *inttostr __P((intmax_t, char *, size_t));
217 extern char *itos __P((intmax_t));
218 extern char *uinttostr __P((uintmax_t, char *, size_t));
219 extern char *uitos __P((uintmax_t));
220
221 /* declarations for functions defined in lib/sh/makepath.c */
222 #define MP_DOTILDE      0x01
223 #define MP_DOCWD        0x02
224 #define MP_RMDOT        0x04
225 #define MP_IGNDOT       0x08
226
227 extern char *sh_makepath __P((const char *, const char *, int));
228
229 /* declarations for functions defined in lib/sh/netconn.c */
230 extern int isnetconn __P((int));
231
232 /* declarations for functions defined in lib/sh/netopen.c */
233 extern int netopen __P((char *));
234
235 /* Declarations for  functions defined in lib/sh/oslib.c */
236
237 #if !defined (HAVE_DUP2) || defined (DUP2_BROKEN)
238 extern int dup2 __P((int, int));
239 #endif
240
241 #if !defined (HAVE_GETDTABLESIZE)
242 extern int getdtablesize __P((void));
243 #endif /* !HAVE_GETDTABLESIZE */
244
245 #if !defined (HAVE_GETHOSTNAME)
246 extern int gethostname __P((char *, int));
247 #endif /* !HAVE_GETHOSTNAME */
248
249 extern int getmaxgroups __P((void));
250 extern long getmaxchild __P((void));
251
252 /* declarations for functions defined in lib/sh/pathcanon.c */
253 #define PATH_CHECKDOTDOT        0x0001
254 #define PATH_CHECKEXISTS        0x0002
255 #define PATH_HARDPATH           0x0004
256 #define PATH_NOALLOC            0x0008
257
258 extern char *sh_canonpath __P((char *, int));
259
260 /* declarations for functions defined in lib/sh/pathphys.c */
261 extern char *sh_physpath __P((char *, int));
262 extern char *sh_realpath __P((const char *, char *));
263
264 /* declarations for functions defined in lib/sh/setlinebuf.c */
265 #ifdef NEED_SH_SETLINEBUF_DECL
266 extern int sh_setlinebuf __P((FILE *));
267 #endif
268
269 /* declarations for functions defined in lib/sh/shaccess.c */
270 extern int sh_eaccess __P((char *, int));
271
272 /* declarations for functions defined in lib/sh/shmatch.c */
273 extern int sh_regmatch __P((const char *, const char *, int));
274
275 /* defines for flags argument to sh_regmatch. */
276 #define SHMAT_SUBEXP            0x001   /* save subexpressions in SH_REMATCH */
277 #define SHMAT_PWARN             0x002   /* print a warning message on invalid regexp */
278
279 /* declarations for functions defined in lib/sh/shquote.c */
280 extern char *sh_single_quote __P((char *));
281 extern char *sh_double_quote __P((char *));
282 extern char *sh_mkdoublequoted __P((const char *, int, int));
283 extern char *sh_un_double_quote __P((char *));
284 extern char *sh_backslash_quote __P((char *));
285 extern char *sh_backslash_quote_for_double_quotes __P((char *));
286 extern int sh_contains_shell_metas __P((char *));
287
288 /* declarations for functions defined in lib/sh/spell.c */
289 extern int spname __P((char *, char *));
290 extern char *dirspell __P((char *));
291
292 /* declarations for functions defined in lib/sh/strcasecmp.c */
293 #if !defined (HAVE_STRCASECMP)
294 extern int strncasecmp __P((const char *, const char *, int));
295 extern int strcasecmp __P((const char *, const char *));
296 #endif /* HAVE_STRCASECMP */
297
298 /* declarations for functions defined in lib/sh/strerror.c */
299 #if !defined (HAVE_STRERROR) && !defined (strerror)
300 extern char *strerror __P((int));
301 #endif
302
303 /* declarations for functions defined in lib/sh/strftime.c */
304 #if !defined (HAVE_STRFTIME) && defined (NEED_STRFTIME_DECL)
305 extern size_t strftime __P((char *, size_t, const char *, const struct tm *));
306 #endif
307
308 /* declarations for functions defined in lib/sh/strindex.c */
309 extern char *strindex __P((const char *, const char *));
310
311 /* declarations for functions and structures defined in lib/sh/stringlist.c */
312
313 /* This is a general-purpose argv-style array struct. */
314 typedef struct _list_of_strings {
315   char **list;
316   int list_size;
317   int list_len;
318 } STRINGLIST;
319
320 typedef int sh_strlist_map_func_t __P((char *));
321
322 extern STRINGLIST *strlist_create __P((int));
323 extern STRINGLIST *strlist_resize __P((STRINGLIST *, int));
324 extern void strlist_flush __P((STRINGLIST *));
325 extern void strlist_dispose __P((STRINGLIST *));
326 extern int strlist_remove __P((STRINGLIST *, char *));
327 extern STRINGLIST *strlist_copy __P((STRINGLIST *));
328 extern STRINGLIST *strlist_merge __P((STRINGLIST *, STRINGLIST *));
329 extern STRINGLIST *strlist_append __P((STRINGLIST *, STRINGLIST *));
330 extern STRINGLIST *strlist_prefix_suffix __P((STRINGLIST *, char *, char *));
331 extern void strlist_print __P((STRINGLIST *, char *));
332 extern void strlist_walk __P((STRINGLIST *, sh_strlist_map_func_t *));
333 extern void strlist_sort __P((STRINGLIST *));
334
335 /* declarations for functions defined in lib/sh/stringvec.c */
336
337 extern char **strvec_create __P((int));
338 extern char **strvec_resize __P((char **, int));
339 extern void strvec_flush __P((char **));
340 extern void strvec_dispose __P((char **));
341 extern int strvec_remove __P((char **, char *));
342 extern int strvec_len __P((char **));
343 extern int strvec_search __P((char **, char *));
344 extern char **strvec_copy __P((char **));
345 extern int strvec_strcmp __P((char **, char **));
346 extern void strvec_sort __P((char **));
347
348 extern char **strvec_from_word_list __P((WORD_LIST *, int, int, int *));
349 extern WORD_LIST *strvec_to_word_list __P((char **, int, int));
350
351 /* declarations for functions defined in lib/sh/strnlen.c */
352 #if !defined (HAVE_STRNLEN)
353 extern size_t strnlen __P((const char *, size_t));
354 #endif
355
356 /* declarations for functions defined in lib/sh/strpbrk.c */
357 #if !defined (HAVE_STRPBRK)
358 extern char *strpbrk __P((const char *, const char *));
359 #endif
360
361 /* declarations for functions defined in lib/sh/strtod.c */
362 #if !defined (HAVE_STRTOD)
363 extern double strtod __P((const char *, char **));
364 #endif
365
366 /* declarations for functions defined in lib/sh/strtol.c */
367 #if !HAVE_DECL_STRTOL
368 extern long strtol __P((const char *, char **, int));
369 #endif
370
371 /* declarations for functions defined in lib/sh/strtoll.c */
372 #if defined (HAVE_LONG_LONG) && !HAVE_DECL_STRTOLL
373 extern long long strtoll __P((const char *, char **, int));
374 #endif
375
376 /* declarations for functions defined in lib/sh/strtoul.c */
377 #if !HAVE_DECL_STRTOUL
378 extern unsigned long strtoul __P((const char *, char **, int));
379 #endif
380
381 /* declarations for functions defined in lib/sh/strtoull.c */
382 #if defined (HAVE_LONG_LONG) && !HAVE_DECL_STRTOULL
383 extern unsigned long long strtoull __P((const char *, char **, int));
384 #endif
385
386 /* declarations for functions defined in lib/sh/strimax.c */
387 #if !HAVE_DECL_STRTOIMAX
388 extern intmax_t strtoimax __P((const char *, char **, int));
389 #endif
390
391 /* declarations for functions defined in lib/sh/strumax.c */
392 #if !HAVE_DECL_STRTOUMAX
393 extern uintmax_t strtoumax __P((const char *, char **, int));
394 #endif
395
396 /* declarations for functions defined in lib/sh/strtrans.c */
397 extern char *ansicstr __P((char *, int, int, int *, int *));
398 extern char *ansic_quote __P((char *, int, int *));
399 extern int ansic_shouldquote __P((const char *));
400 extern char *ansiexpand __P((char *, int, int, int *));
401
402 /* declarations for functions defined in lib/sh/timeval.c.  No prototypes
403    so we don't have to count on having a definition of struct timeval in
404    scope when this file is included. */
405 extern void timeval_to_secs ();
406 extern void print_timeval ();
407
408 /* declarations for functions defined in lib/sh/tmpfile.c */
409 #define MT_USETMPDIR            0x0001
410 #define MT_READWRITE            0x0002
411 #define MT_USERANDOM            0x0004
412
413 extern char *sh_mktmpname __P((char *, int));
414 extern int sh_mktmpfd __P((char *, int, char **));
415 /* extern FILE *sh_mktmpfp __P((char *, int, char **)); */
416
417 /* declarations for functions defined in lib/sh/uconvert.c */
418 extern int uconvert __P((char *, long *, long *));
419
420 /* declarations for functions defined in lib/sh/ufuncs.c */
421 extern unsigned int falarm __P((unsigned int, unsigned int));
422 extern unsigned int fsleep __P((unsigned int, unsigned int));
423
424 /* declarations for functions defined in lib/sh/winsize.c */
425 extern void get_new_window_size __P((int, int *, int *));
426
427 /* declarations for functions defined in lib/sh/xstrchr.c */
428 #undef xstrchr
429 extern char *xstrchr __P((const char *, int));
430
431 /* declarations for functions defined in lib/sh/zcatfd.c */
432 extern int zcatfd __P((int, int, char *));
433
434 /* declarations for functions defined in lib/sh/zgetline.c */
435 extern ssize_t zgetline __P((int, char **, size_t *, int));
436
437 /* declarations for functions defined in lib/sh/zmapfd.c */
438 extern int zmapfd __P((int, char **, char *));
439
440 /* declarations for functions defined in lib/sh/zread.c */
441 extern ssize_t zread __P((int, char *, size_t));
442 extern ssize_t zreadretry __P((int, char *, size_t));
443 extern ssize_t zreadintr __P((int, char *, size_t));
444 extern ssize_t zreadc __P((int, char *));
445 extern ssize_t zreadcintr __P((int, char *));
446 extern void zreset __P((void));
447 extern void zsyncfd __P((int));
448
449 /* declarations for functions defined in lib/sh/zwrite.c */
450 extern int zwrite __P((int, char *, size_t));
451
452 #endif /* _EXTERNS_H_ */