Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 1 | /* common.h -- extern declarations for functions defined in common.c. */ |
| 2 | |
Chet Ramey | 495aee4 | 2011-11-22 19:11:26 -0500 | [diff] [blame] | 3 | /* Copyright (C) 1993-2010 Free Software Foundation, Inc. |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 4 | |
| 5 | This file is part of GNU Bash, the Bourne Again SHell. |
| 6 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 7 | Bash is free software: you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation, either version 3 of the License, or |
| 10 | (at your option) any later version. |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 11 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 12 | Bash is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 16 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 17 | You should have received a copy of the GNU General Public License |
| 18 | along with Bash. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 20 | |
| 21 | #if !defined (__COMMON_H) |
| 22 | # define __COMMON_H |
| 23 | |
Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 24 | #include "stdc.h" |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 25 | |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 26 | #define ISOPTION(s, c) (s[0] == '-' && !s[2] && s[1] == c) |
| 27 | |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 28 | /* Flag values for parse_and_execute () */ |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 29 | #define SEVAL_NONINT 0x001 |
| 30 | #define SEVAL_INTERACT 0x002 |
| 31 | #define SEVAL_NOHIST 0x004 |
| 32 | #define SEVAL_NOFREE 0x008 |
Jari Aalto | b80f644 | 2004-07-27 13:29:18 +0000 | [diff] [blame] | 33 | #define SEVAL_RESETLINE 0x010 |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 34 | #define SEVAL_PARSEONLY 0x020 |
| 35 | #define SEVAL_NOLONGJMP 0x040 |
Chet Ramey | b64a0e1 | 2014-09-25 08:45:07 -0400 | [diff] [blame] | 36 | #define SEVAL_FUNCDEF 0x080 /* only allow function definitions */ |
| 37 | #define SEVAL_ONECMD 0x100 /* only allow a single command */ |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 38 | |
| 39 | /* Flags for describe_command, shared between type.def and command.def */ |
| 40 | #define CDESC_ALL 0x001 /* type -a */ |
| 41 | #define CDESC_SHORTDESC 0x002 /* command -V */ |
| 42 | #define CDESC_REUSABLE 0x004 /* command -v */ |
| 43 | #define CDESC_TYPE 0x008 /* type -t */ |
| 44 | #define CDESC_PATH_ONLY 0x010 /* type -p */ |
| 45 | #define CDESC_FORCE_PATH 0x020 /* type -ap or type -P */ |
| 46 | #define CDESC_NOFUNCS 0x040 /* type -f */ |
Jari Aalto | 95732b4 | 2005-12-07 14:08:12 +0000 | [diff] [blame] | 47 | #define CDESC_ABSPATH 0x080 /* convert to absolute path, no ./ */ |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 48 | |
| 49 | /* Flags for get_job_by_name */ |
| 50 | #define JM_PREFIX 0x01 /* prefix of job name */ |
| 51 | #define JM_SUBSTRING 0x02 /* substring of job name */ |
| 52 | #define JM_EXACT 0x04 /* match job name exactly */ |
| 53 | #define JM_STOPPED 0x08 /* match stopped jobs only */ |
| 54 | #define JM_FIRSTMATCH 0x10 /* return first matching job */ |
| 55 | |
| 56 | /* Flags for remember_args and value of changed_dollar_vars */ |
| 57 | #define ARGS_NONE 0x0 |
| 58 | #define ARGS_INVOC 0x01 |
| 59 | #define ARGS_FUNC 0x02 |
| 60 | #define ARGS_SETBLTIN 0x04 |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 61 | |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 62 | /* Functions from common.c */ |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 63 | extern void builtin_error __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2))); |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 64 | extern void builtin_warning __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2))); |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 65 | extern void builtin_usage __P((void)); |
| 66 | extern void no_args __P((WORD_LIST *)); |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 67 | extern int no_options __P((WORD_LIST *)); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 68 | |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 69 | /* common error message functions */ |
| 70 | extern void sh_needarg __P((char *)); |
| 71 | extern void sh_neednumarg __P((char *)); |
| 72 | extern void sh_notfound __P((char *)); |
| 73 | extern void sh_invalidopt __P((char *)); |
| 74 | extern void sh_invalidoptname __P((char *)); |
| 75 | extern void sh_invalidid __P((char *)); |
| 76 | extern void sh_invalidnum __P((char *)); |
| 77 | extern void sh_invalidsig __P((char *)); |
| 78 | extern void sh_erange __P((char *, char *)); |
| 79 | extern void sh_badpid __P((char *)); |
| 80 | extern void sh_badjob __P((char *)); |
| 81 | extern void sh_readonly __P((const char *)); |
| 82 | extern void sh_nojobs __P((char *)); |
| 83 | extern void sh_restricted __P((char *)); |
Jari Aalto | b80f644 | 2004-07-27 13:29:18 +0000 | [diff] [blame] | 84 | extern void sh_notbuiltin __P((char *)); |
Jari Aalto | 95732b4 | 2005-12-07 14:08:12 +0000 | [diff] [blame] | 85 | extern void sh_wrerror __P((void)); |
Jari Aalto | 17345e5 | 2009-02-19 22:21:29 +0000 | [diff] [blame] | 86 | extern void sh_ttyerror __P((int)); |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 87 | extern int sh_chkwrite __P((int)); |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 88 | |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 89 | extern char **make_builtin_argv __P((WORD_LIST *, int *)); |
| 90 | extern void remember_args __P((WORD_LIST *, int)); |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 91 | |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 92 | extern int dollar_vars_changed __P((void)); |
| 93 | extern void set_dollar_vars_unchanged __P((void)); |
| 94 | extern void set_dollar_vars_changed __P((void)); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 95 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 96 | extern int get_numeric_arg __P((WORD_LIST *, int, intmax_t *)); |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 97 | extern int get_exitstat __P((WORD_LIST *)); |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 98 | extern int read_octal __P((char *)); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 99 | |
| 100 | /* Keeps track of the current working directory. */ |
| 101 | extern char *the_current_working_directory; |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 102 | extern char *get_working_directory __P((char *)); |
| 103 | extern void set_working_directory __P((char *)); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 104 | |
| 105 | #if defined (JOB_CONTROL) |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 106 | extern int get_job_by_name __P((const char *, int)); |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 107 | extern int get_job_spec __P((WORD_LIST *)); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 108 | #endif |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 109 | extern int display_signal_list __P((WORD_LIST *, int)); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 110 | |
| 111 | /* It's OK to declare a function as returning a Function * without |
| 112 | providing a definition of what a `Function' is. */ |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 113 | extern struct builtin *builtin_address_internal __P((char *, int)); |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 114 | extern sh_builtin_func_t *find_shell_builtin __P((char *)); |
| 115 | extern sh_builtin_func_t *builtin_address __P((char *)); |
| 116 | extern sh_builtin_func_t *find_special_builtin __P((char *)); |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 117 | extern void initialize_shell_builtins __P((void)); |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 118 | |
Jari Aalto | b80f644 | 2004-07-27 13:29:18 +0000 | [diff] [blame] | 119 | /* Functions from exit.def */ |
| 120 | extern void bash_logout __P((void)); |
| 121 | |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 122 | /* Functions from getopts.def */ |
| 123 | extern void getopts_reset __P((int)); |
| 124 | |
Chet Ramey | bbc8b48 | 2015-01-15 10:21:08 -0500 | [diff] [blame] | 125 | /* Functions from read.def */ |
| 126 | extern void read_tty_cleanup __P((void)); |
| 127 | extern int read_tty_modified __P((void)); |
| 128 | |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 129 | /* Functions from set.def */ |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 130 | extern int minus_o_option_value __P((char *)); |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 131 | extern void list_minus_o_opts __P((int, int)); |
Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 132 | extern char **get_minus_o_opts __P((void)); |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 133 | extern int set_minus_o_option __P((int, char *)); |
| 134 | |
| 135 | extern void set_shellopts __P((void)); |
| 136 | extern void parse_shellopts __P((char *)); |
| 137 | extern void initialize_shell_options __P((int)); |
| 138 | |
| 139 | extern void reset_shell_options __P((void)); |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 140 | |
| 141 | /* Functions from shopt.def */ |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 142 | extern void reset_shopt_options __P((void)); |
Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 143 | extern char **get_shopt_options __P((void)); |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 144 | |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 145 | extern int shopt_setopt __P((char *, int)); |
| 146 | extern int shopt_listopt __P((char *, int)); |
| 147 | |
Chet Ramey | 0001803 | 2011-11-21 20:51:19 -0500 | [diff] [blame] | 148 | extern int set_login_shell __P((char *, int)); |
| 149 | |
| 150 | extern void set_bashopts __P((void)); |
| 151 | extern void parse_bashopts __P((char *)); |
| 152 | extern void initialize_bashopts __P((int)); |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 153 | |
Chet Ramey | ac50fba | 2014-02-26 09:36:43 -0500 | [diff] [blame] | 154 | extern void set_compatibility_opts __P((void)); |
| 155 | |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 156 | /* Functions from type.def */ |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 157 | extern int describe_command __P((char *, int)); |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 158 | |
| 159 | /* Functions from setattr.def */ |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 160 | extern int set_or_show_attributes __P((WORD_LIST *, int, int)); |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 161 | extern int show_all_var_attributes __P((int, int)); |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 162 | extern int show_var_attributes __P((SHELL_VAR *, int, int)); |
| 163 | extern int show_name_attributes __P((char *, int)); |
Chet Ramey | ac50fba | 2014-02-26 09:36:43 -0500 | [diff] [blame] | 164 | extern int show_func_attributes __P((char *, int)); |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 165 | extern void set_var_attribute __P((char *, int, int)); |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 166 | |
| 167 | /* Functions from pushd.def */ |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 168 | extern char *get_dirstack_from_string __P((char *)); |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 169 | extern char *get_dirstack_element __P((intmax_t, int)); |
| 170 | extern void set_dirstack_element __P((intmax_t, int, char *)); |
Jari Aalto | 0628567 | 2006-10-10 14:15:34 +0000 | [diff] [blame] | 171 | extern WORD_LIST *get_directory_stack __P((int)); |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 172 | |
| 173 | /* Functions from evalstring.c */ |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 174 | extern int parse_and_execute __P((char *, const char *, int)); |
Chet Ramey | ac50fba | 2014-02-26 09:36:43 -0500 | [diff] [blame] | 175 | extern int evalstring __P((char *, const char *, int)); |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 176 | extern void parse_and_execute_cleanup __P((void)); |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 177 | extern int parse_string __P((char *, const char *, int, char **)); |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 178 | |
| 179 | /* Functions from evalfile.c */ |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 180 | extern int maybe_execute_file __P((const char *, int)); |
Jari Aalto | b80f644 | 2004-07-27 13:29:18 +0000 | [diff] [blame] | 181 | extern int source_file __P((const char *, int)); |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 182 | extern int fc_execute_file __P((const char *)); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 183 | |
| 184 | #endif /* !__COMMON_H */ |