Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 1 | /* general.h -- defines that everybody likes to use. */ |
| 2 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 3 | /* Copyright (C) 1993-2009 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 | |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 21 | #if !defined (_GENERAL_H_) |
| 22 | #define _GENERAL_H_ |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 23 | |
| 24 | #include "stdc.h" |
| 25 | |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 26 | #include "bashtypes.h" |
Jari Aalto | 95732b4 | 2005-12-07 14:08:12 +0000 | [diff] [blame] | 27 | #include "chartypes.h" |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 28 | |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 29 | #if defined (HAVE_SYS_RESOURCE_H) && defined (RLIMTYPE) |
| 30 | # if defined (HAVE_SYS_TIME_H) |
| 31 | # include <sys/time.h> |
| 32 | # endif |
| 33 | # include <sys/resource.h> |
| 34 | #endif |
| 35 | |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 36 | #if defined (HAVE_STRING_H) |
| 37 | # include <string.h> |
| 38 | #else |
| 39 | # include <strings.h> |
| 40 | #endif /* !HAVE_STRING_H */ |
| 41 | |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 42 | #if defined (HAVE_LIMITS_H) |
| 43 | # include <limits.h> |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 44 | #endif |
| 45 | |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 46 | #include "xmalloc.h" |
| 47 | |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 48 | /* NULL pointer type. */ |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 49 | #if !defined (NULL) |
| 50 | # if defined (__STDC__) |
| 51 | # define NULL ((void *) 0) |
| 52 | # else |
| 53 | # define NULL 0x0 |
| 54 | # endif /* !__STDC__ */ |
| 55 | #endif /* !NULL */ |
| 56 | |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 57 | /* Hardly used anymore */ |
| 58 | #define pointer_to_int(x) (int)((char *)x - (char *)0) |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 59 | |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 60 | #if defined (alpha) && defined (__GNUC__) && !defined (strchr) && !defined (__STDC__) |
| 61 | extern char *strchr (), *strrchr (); |
| 62 | #endif |
| 63 | |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 64 | #if !defined (strcpy) && (defined (HAVE_DECL_STRCPY) && !HAVE_DECL_STRCPY) |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 65 | extern char *strcpy __P((char *, const char *)); |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 66 | #endif |
| 67 | |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 68 | #if !defined (savestring) |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 69 | # define savestring(x) (char *)strcpy (xmalloc (1 + strlen (x)), (x)) |
| 70 | #endif |
| 71 | |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 72 | #ifndef member |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 73 | # define member(c, s) ((c) ? ((char *)xstrchr ((s), (c)) != (char *)NULL) : 0) |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 74 | #endif |
| 75 | |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 76 | #ifndef whitespace |
| 77 | #define whitespace(c) (((c) == ' ') || ((c) == '\t')) |
| 78 | #endif |
| 79 | |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 80 | #ifndef CHAR_MAX |
| 81 | # ifdef __CHAR_UNSIGNED__ |
| 82 | # define CHAR_MAX 0xff |
| 83 | # else |
| 84 | # define CHAR_MAX 0x7f |
| 85 | # endif |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 86 | #endif |
| 87 | |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 88 | #ifndef CHAR_BIT |
| 89 | # define CHAR_BIT 8 |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 90 | #endif |
| 91 | |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 92 | /* Nonzero if the integer type T is signed. */ |
| 93 | #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 94 | |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 95 | /* Bound on length of the string representing an integer value of type T. |
| 96 | Subtract one for the sign bit if T is signed; |
| 97 | 302 / 1000 is log10 (2) rounded up; |
| 98 | add one for integer division truncation; |
| 99 | add one more for a minus sign if t is signed. */ |
| 100 | #define INT_STRLEN_BOUND(t) \ |
| 101 | ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 \ |
| 102 | + 1 + TYPE_SIGNED (t)) |
| 103 | |
Jari Aalto | 28ef6c3 | 2001-04-06 19:14:31 +0000 | [diff] [blame] | 104 | |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 105 | /* Define exactly what a legal shell identifier consists of. */ |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 106 | #define legal_variable_starter(c) (ISALPHA(c) || (c == '_')) |
| 107 | #define legal_variable_char(c) (ISALNUM(c) || c == '_') |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 108 | |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 109 | /* Definitions used in subst.c and by the `read' builtin for field |
| 110 | splitting. */ |
| 111 | #define spctabnl(c) ((c) == ' ' || (c) == '\t' || (c) == '\n') |
| 112 | |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 113 | /* All structs which contain a `next' field should have that field |
| 114 | as the first field in the struct. This means that functions |
| 115 | can be written to handle the general case for linked lists. */ |
| 116 | typedef struct g_list { |
| 117 | struct g_list *next; |
| 118 | } GENERIC_LIST; |
| 119 | |
| 120 | /* Here is a generic structure for associating character strings |
| 121 | with integers. It is used in the parser for shell tokenization. */ |
| 122 | typedef struct { |
| 123 | char *word; |
| 124 | int token; |
| 125 | } STRING_INT_ALIST; |
| 126 | |
| 127 | /* A macro to avoid making an uneccessary function call. */ |
| 128 | #define REVERSE_LIST(list, type) \ |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 129 | ((list && list->next) ? (type)list_reverse ((GENERIC_LIST *)list) \ |
Jari Aalto | 28ef6c3 | 2001-04-06 19:14:31 +0000 | [diff] [blame] | 130 | : (type)(list)) |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 131 | |
| 132 | #if __GNUC__ > 1 |
Jari Aalto | 95732b4 | 2005-12-07 14:08:12 +0000 | [diff] [blame] | 133 | # define FASTCOPY(s, d, n) __builtin_memcpy ((d), (s), (n)) |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 134 | #else /* !__GNUC__ */ |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 135 | # if !defined (HAVE_BCOPY) |
| 136 | # if !defined (HAVE_MEMMOVE) |
Jari Aalto | 95732b4 | 2005-12-07 14:08:12 +0000 | [diff] [blame] | 137 | # define FASTCOPY(s, d, n) memcpy ((d), (s), (n)) |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 138 | # else |
Jari Aalto | 95732b4 | 2005-12-07 14:08:12 +0000 | [diff] [blame] | 139 | # define FASTCOPY(s, d, n) memmove ((d), (s), (n)) |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 140 | # endif /* !HAVE_MEMMOVE */ |
| 141 | # else /* HAVE_BCOPY */ |
Jari Aalto | 95732b4 | 2005-12-07 14:08:12 +0000 | [diff] [blame] | 142 | # define FASTCOPY(s, d, n) bcopy ((s), (d), (n)) |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 143 | # endif /* HAVE_BCOPY */ |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 144 | #endif /* !__GNUC__ */ |
| 145 | |
| 146 | /* String comparisons that possibly save a function call each. */ |
| 147 | #define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0) |
Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 148 | #define STREQN(a, b, n) ((n == 0) ? (1) \ |
| 149 | : ((a)[0] == (b)[0] && strncmp(a, b, n) == 0)) |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 150 | |
| 151 | /* More convenience definitions that possibly save system or libc calls. */ |
| 152 | #define STRLEN(s) (((s) && (s)[0]) ? ((s)[1] ? ((s)[2] ? strlen(s) : 2) : 1) : 0) |
| 153 | #define FREE(s) do { if (s) free (s); } while (0) |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 154 | #define MEMBER(c, s) (((c) && c == (s)[0] && !(s)[1]) || (member(c, s))) |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 155 | |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 156 | /* A fairly hairy macro to check whether an allocated string has more room, |
| 157 | and to resize it using xrealloc if it does not. |
| 158 | STR is the string (char *) |
| 159 | CIND is the current index into the string (int) |
| 160 | ROOM is the amount of additional room we need in the string (int) |
| 161 | CSIZE is the currently-allocated size of STR (int) |
| 162 | SINCR is how much to increment CSIZE before calling xrealloc (int) */ |
| 163 | |
| 164 | #define RESIZE_MALLOCED_BUFFER(str, cind, room, csize, sincr) \ |
| 165 | do { \ |
| 166 | if ((cind) + (room) >= csize) \ |
| 167 | { \ |
| 168 | while ((cind) + (room) >= csize) \ |
| 169 | csize += (sincr); \ |
| 170 | str = xrealloc (str, csize); \ |
| 171 | } \ |
| 172 | } while (0) |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 173 | |
| 174 | /* Function pointers can be declared as (Function *)foo. */ |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 175 | #if !defined (_FUNCTION_DEF) |
| 176 | # define _FUNCTION_DEF |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 177 | typedef int Function (); |
| 178 | typedef void VFunction (); |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 179 | typedef char *CPFunction (); /* no longer used */ |
| 180 | typedef char **CPPFunction (); /* no longer used */ |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 181 | #endif /* _FUNCTION_DEF */ |
| 182 | |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 183 | #ifndef SH_FUNCTION_TYPEDEF |
| 184 | # define SH_FUNCTION_TYPEDEF |
| 185 | |
| 186 | /* Shell function typedefs with prototypes */ |
| 187 | /* `Generic' function pointer typedefs */ |
| 188 | |
| 189 | typedef int sh_intfunc_t __P((int)); |
| 190 | typedef int sh_ivoidfunc_t __P((void)); |
| 191 | typedef int sh_icpfunc_t __P((char *)); |
| 192 | typedef int sh_icppfunc_t __P((char **)); |
| 193 | typedef int sh_iptrfunc_t __P((PTR_T)); |
| 194 | |
| 195 | typedef void sh_voidfunc_t __P((void)); |
| 196 | typedef void sh_vintfunc_t __P((int)); |
| 197 | typedef void sh_vcpfunc_t __P((char *)); |
| 198 | typedef void sh_vcppfunc_t __P((char **)); |
| 199 | typedef void sh_vptrfunc_t __P((PTR_T)); |
| 200 | |
| 201 | typedef int sh_wdesc_func_t __P((WORD_DESC *)); |
| 202 | typedef int sh_wlist_func_t __P((WORD_LIST *)); |
| 203 | |
| 204 | typedef int sh_glist_func_t __P((GENERIC_LIST *)); |
| 205 | |
| 206 | typedef char *sh_string_func_t __P((char *)); /* like savestring, et al. */ |
| 207 | |
| 208 | typedef int sh_msg_func_t __P((const char *, ...)); /* printf(3)-like */ |
| 209 | typedef void sh_vmsg_func_t __P((const char *, ...)); /* printf(3)-like */ |
| 210 | |
| 211 | /* Specific function pointer typedefs. Most of these could be done |
| 212 | with #defines. */ |
| 213 | typedef void sh_sv_func_t __P((char *)); /* sh_vcpfunc_t */ |
| 214 | typedef void sh_free_func_t __P((PTR_T)); /* sh_vptrfunc_t */ |
| 215 | typedef void sh_resetsig_func_t __P((int)); /* sh_vintfunc_t */ |
| 216 | |
| 217 | typedef int sh_ignore_func_t __P((const char *)); /* sh_icpfunc_t */ |
| 218 | |
| 219 | typedef int sh_assign_func_t __P((const char *)); /* sh_icpfunc_t */ |
Jari Aalto | 95732b4 | 2005-12-07 14:08:12 +0000 | [diff] [blame] | 220 | typedef int sh_wassign_func_t __P((WORD_DESC *)); |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 221 | |
| 222 | typedef int sh_builtin_func_t __P((WORD_LIST *)); /* sh_wlist_func_t */ |
| 223 | |
| 224 | #endif /* SH_FUNCTION_TYPEDEF */ |
| 225 | |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 226 | #define NOW ((time_t) time ((time_t *) 0)) |
| 227 | |
| 228 | /* Some defines for calling file status functions. */ |
| 229 | #define FS_EXISTS 0x1 |
| 230 | #define FS_EXECABLE 0x2 |
| 231 | #define FS_EXEC_PREFERRED 0x4 |
| 232 | #define FS_EXEC_ONLY 0x8 |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 233 | #define FS_DIRECTORY 0x10 |
| 234 | #define FS_NODIRS 0x20 |
Jari Aalto | 95732b4 | 2005-12-07 14:08:12 +0000 | [diff] [blame] | 235 | #define FS_READABLE 0x40 |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 236 | |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 237 | /* Default maximum for move_to_high_fd */ |
| 238 | #define HIGH_FD_MAX 256 |
| 239 | |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 240 | /* The type of function passed as the fourth argument to qsort(3). */ |
| 241 | #ifdef __STDC__ |
| 242 | typedef int QSFUNC (const void *, const void *); |
| 243 | #else |
| 244 | typedef int QSFUNC (); |
| 245 | #endif |
| 246 | |
Jari Aalto | 28ef6c3 | 2001-04-06 19:14:31 +0000 | [diff] [blame] | 247 | /* Some useful definitions for Unix pathnames. Argument convention: |
| 248 | x == string, c == character */ |
| 249 | |
| 250 | #if !defined (__CYGWIN__) |
| 251 | # define ABSPATH(x) ((x)[0] == '/') |
| 252 | # define RELPATH(x) ((x)[0] != '/') |
| 253 | #else /* __CYGWIN__ */ |
Jari Aalto | 95732b4 | 2005-12-07 14:08:12 +0000 | [diff] [blame] | 254 | # define ABSPATH(x) (((x)[0] && ISALPHA((unsigned char)(x)[0]) && (x)[1] == ':') || ISDIRSEP((x)[0])) |
| 255 | # define RELPATH(x) (ABSPATH(x) == 0) |
Jari Aalto | 28ef6c3 | 2001-04-06 19:14:31 +0000 | [diff] [blame] | 256 | #endif /* __CYGWIN__ */ |
| 257 | |
| 258 | #define ROOTEDPATH(x) (ABSPATH(x)) |
| 259 | |
| 260 | #define DIRSEP '/' |
Jari Aalto | 95732b4 | 2005-12-07 14:08:12 +0000 | [diff] [blame] | 261 | #if !defined (__CYGWIN__) |
| 262 | # define ISDIRSEP(c) ((c) == '/') |
| 263 | #else |
| 264 | # define ISDIRSEP(c) ((c) == '/' || (c) == '\\') |
| 265 | #endif /* __CYGWIN__ */ |
Jari Aalto | 28ef6c3 | 2001-04-06 19:14:31 +0000 | [diff] [blame] | 266 | #define PATHSEP(c) (ISDIRSEP(c) || (c) == 0) |
| 267 | |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 268 | #if 0 |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 269 | /* Declarations for functions defined in xmalloc.c */ |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 270 | extern PTR_T xmalloc __P((size_t)); |
| 271 | extern PTR_T xrealloc __P((void *, size_t)); |
Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 272 | extern void xfree __P((void *)); |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 273 | #endif |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 274 | |
| 275 | /* Declarations for functions defined in general.c */ |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 276 | extern void posix_initialize __P((int)); |
| 277 | |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 278 | #if defined (RLIMTYPE) |
| 279 | extern RLIMTYPE string_to_rlimtype __P((char *)); |
| 280 | extern void print_rlimtype __P((RLIMTYPE, int)); |
| 281 | #endif |
| 282 | |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 283 | extern int all_digits __P((char *)); |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 284 | extern int legal_number __P((const char *, intmax_t *)); |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 285 | extern int legal_identifier __P((char *)); |
| 286 | extern int check_identifier __P((WORD_DESC *, int)); |
Jari Aalto | b80f644 | 2004-07-27 13:29:18 +0000 | [diff] [blame] | 287 | extern int legal_alias_name __P((char *, int)); |
| 288 | extern int assignment __P((const char *, int)); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 289 | |
Jari Aalto | 28ef6c3 | 2001-04-06 19:14:31 +0000 | [diff] [blame] | 290 | extern int sh_unset_nodelay_mode __P((int)); |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 291 | extern int sh_validfd __P((int)); |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 292 | extern void check_dev_tty __P((void)); |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 293 | extern int move_to_high_fd __P((int, int, int)); |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 294 | extern int check_binary_file __P((char *, int)); |
| 295 | |
| 296 | #ifdef _POSIXSTAT_H_ |
| 297 | extern int same_file __P((char *, char *, struct stat *, struct stat *)); |
| 298 | #endif |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 299 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 300 | extern int sh_openpipe __P((int *)); |
| 301 | extern int sh_closepipe __P((int *)); |
| 302 | |
| 303 | extern int file_exists __P((char *)); |
Jari Aalto | b80f644 | 2004-07-27 13:29:18 +0000 | [diff] [blame] | 304 | extern int file_isdir __P((char *)); |
| 305 | extern int file_iswdir __P((char *)); |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 306 | extern int absolute_pathname __P((const char *)); |
| 307 | extern int absolute_program __P((const char *)); |
Jari Aalto | 95732b4 | 2005-12-07 14:08:12 +0000 | [diff] [blame] | 308 | |
| 309 | extern char *make_absolute __P((char *, char *)); |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 310 | extern char *base_pathname __P((char *)); |
| 311 | extern char *full_pathname __P((char *)); |
| 312 | extern char *polite_directory_format __P((char *)); |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 313 | extern char *trim_pathname __P((char *, int)); |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 314 | |
| 315 | extern char *extract_colon_unit __P((char *, int *)); |
| 316 | |
| 317 | extern void tilde_initialize __P((void)); |
Jari Aalto | 95732b4 | 2005-12-07 14:08:12 +0000 | [diff] [blame] | 318 | extern char *bash_tilde_find_word __P((const char *, int, int *)); |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 319 | extern char *bash_tilde_expand __P((const char *, int)); |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 320 | |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 321 | extern int group_member __P((gid_t)); |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 322 | extern char **get_group_list __P((int *)); |
Jari Aalto | b72432f | 1999-02-19 17:11:39 +0000 | [diff] [blame] | 323 | extern int *get_group_array __P((int *)); |
Jari Aalto | d166f04 | 1997-06-05 14:59:13 +0000 | [diff] [blame] | 324 | |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 325 | #endif /* _GENERAL_H_ */ |