1 /* externs.h -- extern function declarations which do not appear in their
4 /* Copyright (C) 1993-2020 Free Software Foundation, Inc.
6 This file is part of GNU Bush, the Bourne Again SHell.
8 Bush 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.
13 Bush 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.
18 You should have received a copy of the GNU General Public License
19 along with Bush. If not, see <http://www.gnu.org/licenses/>.
22 /* Make sure that this is included *after* config.h! */
24 #if !defined (_EXTERNS_H_)
29 /* Functions from expr.c. */
30 #define EXP_EXPANDED 0x01
32 extern intmax_t evalexp
PARAMS((char *, int, int *));
34 /* Functions from print_cmd.c. */
35 #define FUNC_MULTILINE 0x01
36 #define FUNC_EXTERNAL 0x02
38 extern char *make_command_string
PARAMS((COMMAND
*));
39 extern char *named_function_string
PARAMS((char *, COMMAND
*, int));
41 extern void print_command
PARAMS((COMMAND
*));
42 extern void print_simple_command
PARAMS((SIMPLE_COM
*));
43 extern void print_word_list
PARAMS((WORD_LIST
*, char *));
45 /* debugger support */
46 extern void print_for_command_head
PARAMS((FOR_COM
*));
47 #if defined (SELECT_COMMAND)
48 extern void print_select_command_head
PARAMS((SELECT_COM
*));
50 extern void print_case_command_head
PARAMS((CASE_COM
*));
51 #if defined (DPAREN_ARITHMETIC)
52 extern void print_arith_command
PARAMS((WORD_LIST
*));
54 #if defined (COND_COMMAND)
55 extern void print_cond_command
PARAMS((COND_COM
*));
59 extern void xtrace_init
PARAMS((void));
60 #ifdef NEED_XTRACE_SET_DECL
61 extern void xtrace_set
PARAMS((int, FILE *));
63 extern void xtrace_fdchk
PARAMS((int));
64 extern void xtrace_reset
PARAMS((void));
65 extern char *indirection_level_string
PARAMS((void));
66 extern void xtrace_print_assignment
PARAMS((char *, char *, int, int));
67 extern void xtrace_print_word_list
PARAMS((WORD_LIST
*, int));
68 extern void xtrace_print_for_command_head
PARAMS((FOR_COM
*));
69 #if defined (SELECT_COMMAND)
70 extern void xtrace_print_select_command_head
PARAMS((SELECT_COM
*));
72 extern void xtrace_print_case_command_head
PARAMS((CASE_COM
*));
73 #if defined (DPAREN_ARITHMETIC)
74 extern void xtrace_print_arith_cmd
PARAMS((WORD_LIST
*));
76 #if defined (COND_COMMAND)
77 extern void xtrace_print_cond_term
PARAMS((int, int, WORD_DESC
*, char *, char *));
80 /* Functions from shell.c. */
81 extern void exit_shell
PARAMS((int)) __attribute__((__noreturn__
));
82 extern void sh_exit
PARAMS((int)) __attribute__((__noreturn__
));
83 extern void subshell_exit
PARAMS((int)) __attribute__((__noreturn__
));
84 extern void set_exit_status
PARAMS((int));
85 extern void disable_priv_mode
PARAMS((void));
86 extern void unbind_args
PARAMS((void));
88 #if defined (RESTRICTED_SHELL)
89 extern int shell_is_restricted
PARAMS((char *));
90 extern int maybe_make_restricted
PARAMS((char *));
93 extern void unset_bush_input
PARAMS((int));
94 extern void get_current_user_info
PARAMS((void));
96 /* Functions from eval.c. */
97 extern int reader_loop
PARAMS((void));
98 extern int pretty_print_loop
PARAMS((void));
99 extern int parse_command
PARAMS((void));
100 extern int read_command
PARAMS((void));
102 /* Functions from braces.c. */
103 #if defined (BRACE_EXPANSION)
104 extern char **brace_expand
PARAMS((char *));
107 /* Miscellaneous functions from parse.y */
108 extern int yyparse
PARAMS((void));
109 extern int return_EOF
PARAMS((void));
110 extern void push_token
PARAMS((int));
111 extern char *xparse_dolparen
PARAMS((char *, char *, int *, int));
112 extern void reset_parser
PARAMS((void));
113 extern void reset_readahead_token
PARAMS((void));
114 extern WORD_LIST
*parse_string_to_word_list
PARAMS((char *, int, const char *));
116 extern int parser_will_prompt
PARAMS((void));
117 extern int parser_in_command_position
PARAMS((void));
119 extern void free_pushed_string_input
PARAMS((void));
121 extern int parser_expanding_alias
PARAMS((void));
122 extern void parser_save_alias
PARAMS((void));
123 extern void parser_restore_alias
PARAMS((void));
125 extern void clear_shell_input_line
PARAMS((void));
127 extern char *decode_prompt_string
PARAMS((char *));
129 extern int get_current_prompt_level
PARAMS((void));
130 extern void set_current_prompt_level
PARAMS((int));
132 #if defined (HISTORY)
133 extern char *history_delimiting_chars
PARAMS((const char *));
136 /* Declarations for functions defined in locale.c */
137 extern void set_default_locale
PARAMS((void));
138 extern void set_default_locale_vars
PARAMS((void));
139 extern int set_locale_var
PARAMS((char *, char *));
140 extern int set_lang
PARAMS((char *, char *));
141 extern void set_default_lang
PARAMS((void));
142 extern char *get_locale_var
PARAMS((char *));
143 extern char *localetrans
PARAMS((char *, int, int *));
144 extern char *mk_msgstr
PARAMS((char *, int *));
145 extern char *localeexpand
PARAMS((char *, int, int, int, int *));
146 #ifndef locale_decpoint
147 extern int locale_decpoint
PARAMS((void));
150 /* Declarations for functions defined in list.c. */
151 extern void list_walk
PARAMS((GENERIC_LIST
*, sh_glist_func_t
*));
152 extern void wlist_walk
PARAMS((WORD_LIST
*, sh_icpfunc_t
*));
153 extern GENERIC_LIST
*list_reverse ();
154 extern int list_length ();
155 extern GENERIC_LIST
*list_append ();
156 extern GENERIC_LIST
*list_remove ();
158 /* Declarations for functions defined in stringlib.c */
159 extern int find_string_in_alist
PARAMS((char *, STRING_INT_ALIST
*, int));
160 extern char *find_token_in_alist
PARAMS((int, STRING_INT_ALIST
*, int));
161 extern int find_index_in_alist
PARAMS((char *, STRING_INT_ALIST
*, int));
163 extern char *substring
PARAMS((const char *, int, int));
164 extern char *strsub
PARAMS((char *, char *, char *, int));
165 extern char *strcreplace
PARAMS((char *, int, const char *, int));
166 extern void strip_leading
PARAMS((char *));
167 extern void strip_trailing
PARAMS((char *, int, int));
168 extern void xbcopy
PARAMS((char *, char *, int));
170 /* Functions from version.c. */
171 extern char *shell_version_string
PARAMS((void));
172 extern void show_shell_version
PARAMS((int));
174 /* Functions from the bush library, lib/sh/libsh.a. These should really
175 go into a separate include file. */
177 /* declarations for functions defined in lib/sh/casemod.c */
178 extern char *sh_modcase
PARAMS((const char *, char *, int));
180 /* Defines for flags argument to sh_modcase. These need to agree with what's
181 in lib/sh/casemode.c */
182 #define CASE_LOWER 0x0001
183 #define CASE_UPPER 0x0002
184 #define CASE_CAPITALIZE 0x0004
185 #define CASE_UNCAP 0x0008
186 #define CASE_TOGGLE 0x0010
187 #define CASE_TOGGLEALL 0x0020
188 #define CASE_UPFIRST 0x0040
189 #define CASE_LOWFIRST 0x0080
191 #define CASE_USEWORDS 0x1000
193 /* declarations for functions defined in lib/sh/clktck.c */
194 extern long get_clk_tck
PARAMS((void));
196 /* declarations for functions defined in lib/sh/clock.c */
197 extern void clock_t_to_secs ();
198 extern void print_clock_t ();
200 /* Declarations for functions defined in lib/sh/dprintf.c */
201 #if !defined (HAVE_DPRINTF)
202 extern void dprintf
PARAMS((int, const char *, ...)) __attribute__((__format__ (printf
, 2, 3)));
205 /* Declarations for functions defined in lib/sh/fmtulong.c */
206 #define FL_PREFIX 0x01 /* add 0x, 0X, or 0 prefix as appropriate */
207 #define FL_ADDBASE 0x02 /* add base# prefix to converted value */
208 #define FL_HEXUPPER 0x04 /* use uppercase when converting to hex */
209 #define FL_UNSIGNED 0x08 /* don't add any sign */
211 extern char *fmtulong
PARAMS((unsigned long int, int, char *, size_t, int));
213 /* Declarations for functions defined in lib/sh/fmtulong.c */
214 #if defined (HAVE_LONG_LONG)
215 extern char *fmtullong
PARAMS((unsigned long long int, int, char *, size_t, int));
218 /* Declarations for functions defined in lib/sh/fmtumax.c */
219 extern char *fmtumax
PARAMS((uintmax_t, int, char *, size_t, int));
221 /* Declarations for functions defined in lib/sh/fnxform.c */
222 extern char *fnx_fromfs
PARAMS((char *, size_t));
223 extern char *fnx_tofs
PARAMS((char *, size_t));
225 /* Declarations for functions defined in lib/sh/fpurge.c */
227 #if defined NEED_FPURGE_DECL
228 #if !HAVE_DECL_FPURGE
231 # define fpurge _bush_fpurge
233 extern int fpurge
PARAMS((FILE *stream
));
235 #endif /* HAVE_DECL_FPURGE */
236 #endif /* NEED_FPURGE_DECL */
238 /* Declarations for functions defined in lib/sh/getcwd.c */
239 #if !defined (HAVE_GETCWD)
240 extern char *getcwd
PARAMS((char *, size_t));
243 /* Declarations for functions defined in lib/sh/input_avail.c */
244 extern int input_avail
PARAMS((int));
246 /* Declarations for functions defined in lib/sh/itos.c */
247 extern char *inttostr
PARAMS((intmax_t, char *, size_t));
248 extern char *itos
PARAMS((intmax_t));
249 extern char *mitos
PARAMS((intmax_t));
250 extern char *uinttostr
PARAMS((uintmax_t, char *, size_t));
251 extern char *uitos
PARAMS((uintmax_t));
253 /* declarations for functions defined in lib/sh/makepath.c */
254 #define MP_DOTILDE 0x01
255 #define MP_DOCWD 0x02
256 #define MP_RMDOT 0x04
257 #define MP_IGNDOT 0x08
259 extern char *sh_makepath
PARAMS((const char *, const char *, int));
261 /* declarations for functions defined in lib/sh/mbscasecmp.c */
262 #if !defined (HAVE_MBSCASECMP)
263 extern char *mbscasecmp
PARAMS((const char *, const char *));
266 /* declarations for functions defined in lib/sh/mbschr.c */
267 #if !defined (HAVE_MBSCHR)
268 extern char *mbschr
PARAMS((const char *, int));
271 /* declarations for functions defined in lib/sh/mbscmp.c */
272 #if !defined (HAVE_MBSCMP)
273 extern char *mbscmp
PARAMS((const char *, const char *));
276 /* declarations for functions defined in lib/sh/netconn.c */
277 extern int isnetconn
PARAMS((int));
279 /* declarations for functions defined in lib/sh/netopen.c */
280 extern int netopen
PARAMS((char *));
282 /* Declarations for functions defined in lib/sh/oslib.c */
284 #if !defined (HAVE_DUP2) || defined (DUP2_BROKEN)
285 extern int dup2
PARAMS((int, int));
288 #if !defined (HAVE_GETDTABLESIZE)
289 extern int getdtablesize
PARAMS((void));
290 #endif /* !HAVE_GETDTABLESIZE */
292 #if !defined (HAVE_GETHOSTNAME)
293 extern int gethostname
PARAMS((char *, int));
294 #endif /* !HAVE_GETHOSTNAME */
296 extern int getmaxgroups
PARAMS((void));
297 extern long getmaxchild
PARAMS((void));
299 /* declarations for functions defined in lib/sh/pathcanon.c */
300 #define PATH_CHECKDOTDOT 0x0001
301 #define PATH_CHECKEXISTS 0x0002
302 #define PATH_HARDPATH 0x0004
303 #define PATH_NOALLOC 0x0008
305 extern char *sh_canonpath
PARAMS((char *, int));
307 /* declarations for functions defined in lib/sh/pathphys.c */
308 extern char *sh_physpath
PARAMS((char *, int));
309 extern char *sh_realpath
PARAMS((const char *, char *));
311 /* declarations for functions defined in lib/sh/random.c */
312 extern int brand
PARAMS((void));
313 extern void sbrand
PARAMS((unsigned long)); /* set bush random number generator. */
314 extern void seedrand
PARAMS((void)); /* seed generator randomly */
315 extern void seedrand32
PARAMS((void));
316 extern u_bits32_t get_urandom32
PARAMS((void));
318 /* declarations for functions defined in lib/sh/setlinebuf.c */
319 #ifdef NEED_SH_SETLINEBUF_DECL
320 extern int sh_setlinebuf
PARAMS((FILE *));
323 /* declarations for functions defined in lib/sh/shaccess.c */
324 extern int sh_eaccess
PARAMS((const char *, int));
326 /* declarations for functions defined in lib/sh/shmatch.c */
327 extern int sh_regmatch
PARAMS((const char *, const char *, int));
329 /* defines for flags argument to sh_regmatch. */
330 #define SHMAT_SUBEXP 0x001 /* save subexpressions in SH_REMATCH */
331 #define SHMAT_PWARN 0x002 /* print a warning message on invalid regexp */
333 /* declarations for functions defined in lib/sh/shmbchar.c */
334 extern size_t mbstrlen
PARAMS((const char *));
335 extern char *mbsmbchar
PARAMS((const char *));
336 extern int sh_mbsnlen
PARAMS((const char *, size_t, int));
338 /* declarations for functions defined in lib/sh/shquote.c */
339 extern char *sh_single_quote
PARAMS((const char *));
340 extern char *sh_double_quote
PARAMS((const char *));
341 extern char *sh_mkdoublequoted
PARAMS((const char *, int, int));
342 extern char *sh_un_double_quote
PARAMS((char *));
343 extern char *sh_backslash_quote
PARAMS((char *, const char *, int));
344 extern char *sh_backslash_quote_for_double_quotes
PARAMS((char *));
345 extern char *sh_quote_reusable
PARAMS((char *, int));
346 extern int sh_contains_shell_metas
PARAMS((const char *));
347 extern int sh_contains_quotes
PARAMS((const char *));
349 /* declarations for functions defined in lib/sh/spell.c */
350 extern int spname
PARAMS((char *, char *));
351 extern char *dirspell
PARAMS((char *));
353 /* declarations for functions defined in lib/sh/strcasecmp.c */
354 #if !defined (HAVE_STRCASECMP)
355 extern int strncasecmp
PARAMS((const char *, const char *, size_t));
356 extern int strcasecmp
PARAMS((const char *, const char *));
357 #endif /* HAVE_STRCASECMP */
359 /* declarations for functions defined in lib/sh/strcasestr.c */
360 #if ! HAVE_STRCASESTR
361 extern char *strcasestr
PARAMS((const char *, const char *));
364 /* declarations for functions defined in lib/sh/strchrnul.c */
366 extern char *strchrnul
PARAMS((const char *, int));
369 /* declarations for functions defined in lib/sh/strerror.c */
370 #if !defined (HAVE_STRERROR) && !defined (strerror)
371 extern char *strerror
PARAMS((int));
374 /* declarations for functions defined in lib/sh/strftime.c */
375 #if !defined (HAVE_STRFTIME) && defined (NEED_STRFTIME_DECL)
376 extern size_t strftime
PARAMS((char *, size_t, const char *, const struct tm
*));
379 /* declarations for functions and structures defined in lib/sh/stringlist.c */
381 /* This is a general-purpose argv-style array struct. */
382 typedef struct _list_of_strings
{
388 typedef int sh_strlist_map_func_t
PARAMS((char *));
390 extern STRINGLIST
*strlist_create
PARAMS((int));
391 extern STRINGLIST
*strlist_resize
PARAMS((STRINGLIST
*, int));
392 extern void strlist_flush
PARAMS((STRINGLIST
*));
393 extern void strlist_dispose
PARAMS((STRINGLIST
*));
394 extern int strlist_remove
PARAMS((STRINGLIST
*, char *));
395 extern STRINGLIST
*strlist_copy
PARAMS((STRINGLIST
*));
396 extern STRINGLIST
*strlist_merge
PARAMS((STRINGLIST
*, STRINGLIST
*));
397 extern STRINGLIST
*strlist_append
PARAMS((STRINGLIST
*, STRINGLIST
*));
398 extern STRINGLIST
*strlist_prefix_suffix
PARAMS((STRINGLIST
*, char *, char *));
399 extern void strlist_print
PARAMS((STRINGLIST
*, char *));
400 extern void strlist_walk
PARAMS((STRINGLIST
*, sh_strlist_map_func_t
*));
401 extern void strlist_sort
PARAMS((STRINGLIST
*));
403 /* declarations for functions defined in lib/sh/stringvec.c */
405 extern char **strvec_create
PARAMS((int));
406 extern char **strvec_resize
PARAMS((char **, int));
407 extern char **strvec_mcreate
PARAMS((int));
408 extern char **strvec_mresize
PARAMS((char **, int));
409 extern void strvec_flush
PARAMS((char **));
410 extern void strvec_dispose
PARAMS((char **));
411 extern int strvec_remove
PARAMS((char **, char *));
412 extern int strvec_len
PARAMS((char **));
413 extern int strvec_search
PARAMS((char **, char *));
414 extern char **strvec_copy
PARAMS((char **));
415 extern int strvec_posixcmp
PARAMS((char **, char **));
416 extern int strvec_strcmp
PARAMS((char **, char **));
417 extern void strvec_sort
PARAMS((char **, int));
419 extern char **strvec_from_word_list
PARAMS((WORD_LIST
*, int, int, int *));
420 extern WORD_LIST
*strvec_to_word_list
PARAMS((char **, int, int));
422 /* declarations for functions defined in lib/sh/strnlen.c */
423 #if !defined (HAVE_STRNLEN)
424 extern size_t strnlen
PARAMS((const char *, size_t));
427 /* declarations for functions defined in lib/sh/strpbrk.c */
428 #if !defined (HAVE_STRPBRK)
429 extern char *strpbrk
PARAMS((const char *, const char *));
432 /* declarations for functions defined in lib/sh/strtod.c */
433 #if !defined (HAVE_STRTOD)
434 extern double strtod
PARAMS((const char *, char **));
437 /* declarations for functions defined in lib/sh/strtol.c */
438 #if !HAVE_DECL_STRTOL
439 extern long strtol
PARAMS((const char *, char **, int));
442 /* declarations for functions defined in lib/sh/strtoll.c */
443 #if defined (HAVE_LONG_LONG) && !HAVE_DECL_STRTOLL
444 extern long long strtoll
PARAMS((const char *, char **, int));
447 /* declarations for functions defined in lib/sh/strtoul.c */
448 #if !HAVE_DECL_STRTOUL
449 extern unsigned long strtoul
PARAMS((const char *, char **, int));
452 /* declarations for functions defined in lib/sh/strtoull.c */
453 #if defined (HAVE_LONG_LONG) && !HAVE_DECL_STRTOULL
454 extern unsigned long long strtoull
PARAMS((const char *, char **, int));
457 /* declarations for functions defined in lib/sh/strimax.c */
458 #if !HAVE_DECL_STRTOIMAX
459 extern intmax_t strtoimax
PARAMS((const char *, char **, int));
462 /* declarations for functions defined in lib/sh/strumax.c */
463 #if !HAVE_DECL_STRTOUMAX
464 extern uintmax_t strtoumax
PARAMS((const char *, char **, int));
467 /* declarations for functions defined in lib/sh/strtrans.c */
468 extern char *ansicstr
PARAMS((char *, int, int, int *, int *));
469 extern char *ansic_quote
PARAMS((char *, int, int *));
470 extern int ansic_shouldquote
PARAMS((const char *));
471 extern char *ansiexpand
PARAMS((char *, int, int, int *));
473 /* declarations for functions defined in lib/sh/timeval.c. No prototypes
474 so we don't have to count on having a definition of struct timeval in
475 scope when this file is included. */
476 extern void timeval_to_secs ();
477 extern void print_timeval ();
479 /* declarations for functions defined in lib/sh/tmpfile.c */
480 #define MT_USETMPDIR 0x0001
481 #define MT_READWRITE 0x0002
482 #define MT_USERANDOM 0x0004
483 #define MT_TEMPLATE 0x0008
485 extern char *sh_mktmpname
PARAMS((char *, int));
486 extern int sh_mktmpfd
PARAMS((char *, int, char **));
487 /* extern FILE *sh_mktmpfp PARAMS((char *, int, char **)); */
488 extern char *sh_mktmpdir
PARAMS((char *, int));
490 /* declarations for functions defined in lib/sh/uconvert.c */
491 extern int uconvert
PARAMS((char *, long *, long *, char **));
493 /* declarations for functions defined in lib/sh/ufuncs.c */
494 extern unsigned int falarm
PARAMS((unsigned int, unsigned int));
495 extern unsigned int fsleep
PARAMS((unsigned int, unsigned int));
497 /* declarations for functions defined in lib/sh/unicode.c */
498 extern int u32cconv
PARAMS((unsigned long, char *));
499 extern void u32reset
PARAMS((void));
501 /* declarations for functions defined in lib/sh/utf8.c */
502 extern char *utf8_mbschr
PARAMS((const char *, int));
503 extern int utf8_mbscmp
PARAMS((const char *, const char *));
504 extern char *utf8_mbsmbchar
PARAMS((const char *));
505 extern int utf8_mbsnlen
PARAMS((const char *, size_t, int));
506 extern int utf8_mblen
PARAMS((const char *, size_t));
507 extern size_t utf8_mbstrlen
PARAMS((const char *));
509 /* declarations for functions defined in lib/sh/wcsnwidth.c */
510 #if defined (HANDLE_MULTIBYTE)
511 extern int wcsnwidth
PARAMS((const wchar_t *, size_t, int));
514 /* declarations for functions defined in lib/sh/winsize.c */
515 extern void get_new_window_size
PARAMS((int, int *, int *));
517 /* declarations for functions defined in lib/sh/zcatfd.c */
518 extern int zcatfd
PARAMS((int, int, char *));
520 /* declarations for functions defined in lib/sh/zgetline.c */
521 extern ssize_t zgetline
PARAMS((int, char **, size_t *, int, int));
523 /* declarations for functions defined in lib/sh/zmapfd.c */
524 extern int zmapfd
PARAMS((int, char **, char *));
526 /* declarations for functions defined in lib/sh/zread.c */
527 extern ssize_t zread
PARAMS((int, char *, size_t));
528 extern ssize_t zreadretry
PARAMS((int, char *, size_t));
529 extern ssize_t zreadintr
PARAMS((int, char *, size_t));
530 extern ssize_t zreadc
PARAMS((int, char *));
531 extern ssize_t zreadcintr
PARAMS((int, char *));
532 extern ssize_t zreadn
PARAMS((int, char *, size_t));
533 extern void zreset
PARAMS((void));
534 extern void zsyncfd
PARAMS((int));
536 /* declarations for functions defined in lib/sh/zwrite.c */
537 extern int zwrite
PARAMS((int, char *, size_t));
539 /* declarations for functions defined in lib/glob/gmisc.c */
540 extern int match_pattern_char
PARAMS((char *, char *, int));
541 extern int umatchlen
PARAMS((char *, size_t));
543 #if defined (HANDLE_MULTIBYTE)
544 extern int match_pattern_wchar
PARAMS((wchar_t *, wchar_t *, int));
545 extern int wmatchlen
PARAMS((wchar_t *, size_t));
548 #endif /* _EXTERNS_H_ */