| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | /* general.h -- defines that everybody likes to use. */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-12 13:36:28 +00:00
										 |  |  | /* Copyright (C) 1993-2009 Free Software Foundation, Inc.
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |    This file is part of GNU Bash, the Bourne Again SHell. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-12 13:36:28 +00:00
										 |  |  |    Bash is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  |    it under the terms of the GNU General Public License as published by | 
					
						
							|  |  |  |    the Free Software Foundation, either version 3 of the License, or | 
					
						
							|  |  |  |    (at your option) any later version. | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-12 13:36:28 +00:00
										 |  |  |    Bash is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |    GNU General Public License for more details. | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-12 13:36:28 +00:00
										 |  |  |    You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |    along with Bash.  If not, see <http://www.gnu.org/licenses/>.
 | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | #if !defined (_GENERAL_H_)
 | 
					
						
							|  |  |  | #define _GENERAL_H_
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "stdc.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-06-05 14:59:13 +00:00
										 |  |  | #include "bashtypes.h"
 | 
					
						
							| 
									
										
										
										
											2005-12-07 14:08:12 +00:00
										 |  |  | #include "chartypes.h"
 | 
					
						
							| 
									
										
										
										
											1997-06-05 14:59:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-04-17 19:52:44 +00:00
										 |  |  | #if defined (HAVE_SYS_RESOURCE_H) && defined (RLIMTYPE)
 | 
					
						
							|  |  |  | #  if defined (HAVE_SYS_TIME_H)
 | 
					
						
							|  |  |  | #    include <sys/time.h>
 | 
					
						
							|  |  |  | #  endif
 | 
					
						
							|  |  |  | #  include <sys/resource.h>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-06-05 14:59:13 +00:00
										 |  |  | #if defined (HAVE_STRING_H)
 | 
					
						
							|  |  |  | #  include <string.h>
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #  include <strings.h>
 | 
					
						
							|  |  |  | #endif /* !HAVE_STRING_H */
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  | #if defined (HAVE_LIMITS_H)
 | 
					
						
							|  |  |  | #  include <limits.h>
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  | #include "xmalloc.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | /* NULL pointer type. */ | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | #if !defined (NULL)
 | 
					
						
							|  |  |  | #  if defined (__STDC__)
 | 
					
						
							|  |  |  | #    define NULL ((void *) 0)
 | 
					
						
							|  |  |  | #  else
 | 
					
						
							|  |  |  | #    define NULL 0x0
 | 
					
						
							|  |  |  | #  endif /* !__STDC__ */
 | 
					
						
							|  |  |  | #endif /* !NULL */
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-07-17 14:10:11 +00:00
										 |  |  | /* Hardly used anymore */ | 
					
						
							|  |  |  | #define pointer_to_int(x)	(int)((char *)x - (char *)0)
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | #if defined (alpha) && defined (__GNUC__) && !defined (strchr) && !defined (__STDC__)
 | 
					
						
							|  |  |  | extern char *strchr (), *strrchr (); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-07-17 14:10:11 +00:00
										 |  |  | #if !defined (strcpy) && (defined (HAVE_DECL_STRCPY) && !HAVE_DECL_STRCPY)
 | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  | extern char *strcpy __P((char *, const char *)); | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | #if !defined (savestring)
 | 
					
						
							|  |  |  | #  define savestring(x) (char *)strcpy (xmalloc (1 + strlen (x)), (x))
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | #ifndef member
 | 
					
						
							| 
									
										
										
										
											2011-11-21 20:51:19 -05:00
										 |  |  | #  define member(c, s) ((c) ? ((char *)mbschr ((s), (c)) != (char *)NULL) : 0)
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | #ifndef whitespace
 | 
					
						
							|  |  |  | #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  | #ifndef CHAR_MAX
 | 
					
						
							|  |  |  | #  ifdef __CHAR_UNSIGNED__
 | 
					
						
							|  |  |  | #    define CHAR_MAX	0xff
 | 
					
						
							|  |  |  | #  else
 | 
					
						
							|  |  |  | #    define CHAR_MAX	0x7f
 | 
					
						
							|  |  |  | #  endif
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  | #ifndef CHAR_BIT
 | 
					
						
							|  |  |  | #  define CHAR_BIT 8
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  | /* Nonzero if the integer type T is signed.  */ | 
					
						
							|  |  |  | #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Bound on length of the string representing an integer value of type T.
 | 
					
						
							|  |  |  |    Subtract one for the sign bit if T is signed; | 
					
						
							|  |  |  |    302 / 1000 is log10 (2) rounded up; | 
					
						
							|  |  |  |    add one for integer division truncation; | 
					
						
							|  |  |  |    add one more for a minus sign if t is signed.  */ | 
					
						
							|  |  |  | #define INT_STRLEN_BOUND(t) \
 | 
					
						
							|  |  |  |   ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 \ | 
					
						
							|  |  |  |    + 1 + TYPE_SIGNED (t)) | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-06 19:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | /* Define exactly what a legal shell identifier consists of. */ | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  | #define legal_variable_starter(c) (ISALPHA(c) || (c == '_'))
 | 
					
						
							|  |  |  | #define legal_variable_char(c)	(ISALNUM(c) || c == '_')
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | /* Definitions used in subst.c and by the `read' builtin for field
 | 
					
						
							|  |  |  |    splitting. */ | 
					
						
							|  |  |  | #define spctabnl(c)	((c) == ' ' || (c) == '\t' || (c) == '\n')
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* All structs which contain a `next' field should have that field
 | 
					
						
							|  |  |  |    as the first field in the struct.  This means that functions | 
					
						
							|  |  |  |    can be written to handle the general case for linked lists. */ | 
					
						
							|  |  |  | typedef struct g_list { | 
					
						
							|  |  |  |   struct g_list *next; | 
					
						
							|  |  |  | } GENERIC_LIST; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Here is a generic structure for associating character strings
 | 
					
						
							|  |  |  |    with integers.  It is used in the parser for shell tokenization. */ | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  |   char *word; | 
					
						
							|  |  |  |   int token; | 
					
						
							|  |  |  | } STRING_INT_ALIST; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-26 09:36:43 -05:00
										 |  |  | /* A macro to avoid making an unneccessary function call. */ | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | #define REVERSE_LIST(list, type) \
 | 
					
						
							| 
									
										
										
										
											2002-07-17 14:10:11 +00:00
										 |  |  |   ((list && list->next) ? (type)list_reverse ((GENERIC_LIST *)list) \ | 
					
						
							| 
									
										
										
										
											2001-04-06 19:14:31 +00:00
										 |  |  | 			: (type)(list)) | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #if __GNUC__ > 1
 | 
					
						
							| 
									
										
										
										
											2005-12-07 14:08:12 +00:00
										 |  |  | #  define FASTCOPY(s, d, n)  __builtin_memcpy ((d), (s), (n))
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | #else /* !__GNUC__ */
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | #  if !defined (HAVE_BCOPY)
 | 
					
						
							|  |  |  | #    if !defined (HAVE_MEMMOVE)
 | 
					
						
							| 
									
										
										
										
											2005-12-07 14:08:12 +00:00
										 |  |  | #      define FASTCOPY(s, d, n)  memcpy ((d), (s), (n))
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | #    else
 | 
					
						
							| 
									
										
										
										
											2005-12-07 14:08:12 +00:00
										 |  |  | #      define FASTCOPY(s, d, n)  memmove ((d), (s), (n))
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | #    endif /* !HAVE_MEMMOVE */
 | 
					
						
							|  |  |  | #  else /* HAVE_BCOPY */
 | 
					
						
							| 
									
										
										
										
											2005-12-07 14:08:12 +00:00
										 |  |  | #    define FASTCOPY(s, d, n)  bcopy ((s), (d), (n))
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | #  endif /* HAVE_BCOPY */
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | #endif /* !__GNUC__ */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* String comparisons that possibly save a function call each. */ | 
					
						
							|  |  |  | #define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)
 | 
					
						
							| 
									
										
										
										
											2000-03-17 21:46:59 +00:00
										 |  |  | #define STREQN(a, b, n) ((n == 0) ? (1) \
 | 
					
						
							|  |  |  | 				  : ((a)[0] == (b)[0] && strncmp(a, b, n) == 0)) | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* More convenience definitions that possibly save system or libc calls. */ | 
					
						
							|  |  |  | #define STRLEN(s) (((s) && (s)[0]) ? ((s)[1] ? ((s)[2] ? strlen(s) : 2) : 1) : 0)
 | 
					
						
							|  |  |  | #define FREE(s)  do { if (s) free (s); } while (0)
 | 
					
						
							| 
									
										
										
										
											1998-04-17 19:52:44 +00:00
										 |  |  | #define MEMBER(c, s) (((c) && c == (s)[0] && !(s)[1]) || (member(c, s)))
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | /* A fairly hairy macro to check whether an allocated string has more room,
 | 
					
						
							|  |  |  |    and to resize it using xrealloc if it does not. | 
					
						
							|  |  |  |    STR is the string (char *) | 
					
						
							|  |  |  |    CIND is the current index into the string (int) | 
					
						
							|  |  |  |    ROOM is the amount of additional room we need in the string (int) | 
					
						
							|  |  |  |    CSIZE is the currently-allocated size of STR (int) | 
					
						
							|  |  |  |    SINCR is how much to increment CSIZE before calling xrealloc (int) */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define RESIZE_MALLOCED_BUFFER(str, cind, room, csize, sincr) \
 | 
					
						
							|  |  |  |   do { \ | 
					
						
							|  |  |  |     if ((cind) + (room) >= csize) \ | 
					
						
							|  |  |  |       { \ | 
					
						
							|  |  |  | 	while ((cind) + (room) >= csize) \ | 
					
						
							|  |  |  | 	  csize += (sincr); \ | 
					
						
							|  |  |  | 	str = xrealloc (str, csize); \ | 
					
						
							|  |  |  |       } \ | 
					
						
							|  |  |  |   } while (0) | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Function pointers can be declared as (Function *)foo. */ | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | #if !defined (_FUNCTION_DEF)
 | 
					
						
							|  |  |  | #  define _FUNCTION_DEF
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | typedef int Function (); | 
					
						
							|  |  |  | typedef void VFunction (); | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  | typedef char *CPFunction ();		/* no longer used */ | 
					
						
							|  |  |  | typedef char **CPPFunction ();		/* no longer used */ | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | #endif /* _FUNCTION_DEF */
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  | #ifndef SH_FUNCTION_TYPEDEF
 | 
					
						
							|  |  |  | #  define SH_FUNCTION_TYPEDEF
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Shell function typedefs with prototypes */ | 
					
						
							|  |  |  | /* `Generic' function pointer typedefs */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef int sh_intfunc_t __P((int)); | 
					
						
							|  |  |  | typedef int sh_ivoidfunc_t __P((void)); | 
					
						
							|  |  |  | typedef int sh_icpfunc_t __P((char *)); | 
					
						
							|  |  |  | typedef int sh_icppfunc_t __P((char **)); | 
					
						
							|  |  |  | typedef int sh_iptrfunc_t __P((PTR_T)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef void sh_voidfunc_t __P((void)); | 
					
						
							|  |  |  | typedef void sh_vintfunc_t __P((int)); | 
					
						
							|  |  |  | typedef void sh_vcpfunc_t __P((char *)); | 
					
						
							|  |  |  | typedef void sh_vcppfunc_t __P((char **)); | 
					
						
							|  |  |  | typedef void sh_vptrfunc_t __P((PTR_T)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef int sh_wdesc_func_t __P((WORD_DESC *)); | 
					
						
							|  |  |  | typedef int sh_wlist_func_t __P((WORD_LIST *)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef int sh_glist_func_t __P((GENERIC_LIST *)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef char *sh_string_func_t __P((char *));	/* like savestring, et al. */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef int sh_msg_func_t __P((const char *, ...));	/* printf(3)-like */ | 
					
						
							|  |  |  | typedef void sh_vmsg_func_t __P((const char *, ...));	/* printf(3)-like */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Specific function pointer typedefs.  Most of these could be done
 | 
					
						
							|  |  |  |    with #defines. */ | 
					
						
							|  |  |  | typedef void sh_sv_func_t __P((char *));	/* sh_vcpfunc_t */ | 
					
						
							|  |  |  | typedef void sh_free_func_t __P((PTR_T));	/* sh_vptrfunc_t */ | 
					
						
							|  |  |  | typedef void sh_resetsig_func_t __P((int));	/* sh_vintfunc_t */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef int sh_ignore_func_t __P((const char *));	/* sh_icpfunc_t */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-22 19:11:26 -05:00
										 |  |  | typedef int sh_assign_func_t __P((const char *)); | 
					
						
							|  |  |  | typedef int sh_wassign_func_t __P((WORD_DESC *, int)); | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | typedef int sh_builtin_func_t __P((WORD_LIST *)); /* sh_wlist_func_t */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* SH_FUNCTION_TYPEDEF */
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | #define NOW	((time_t) time ((time_t *) 0))
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Some defines for calling file status functions. */ | 
					
						
							|  |  |  | #define FS_EXISTS	  0x1
 | 
					
						
							|  |  |  | #define FS_EXECABLE	  0x2
 | 
					
						
							|  |  |  | #define FS_EXEC_PREFERRED 0x4
 | 
					
						
							|  |  |  | #define FS_EXEC_ONLY	  0x8
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | #define FS_DIRECTORY	  0x10
 | 
					
						
							|  |  |  | #define FS_NODIRS	  0x20
 | 
					
						
							| 
									
										
										
										
											2005-12-07 14:08:12 +00:00
										 |  |  | #define FS_READABLE	  0x40
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-07-17 14:10:11 +00:00
										 |  |  | /* Default maximum for move_to_high_fd */ | 
					
						
							|  |  |  | #define HIGH_FD_MAX	256
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  | /* The type of function passed as the fourth argument to qsort(3). */ | 
					
						
							|  |  |  | #ifdef __STDC__
 | 
					
						
							|  |  |  | typedef int QSFUNC (const void *, const void *); | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | typedef int QSFUNC (); | 
					
						
							|  |  |  | #endif 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-06 19:14:31 +00:00
										 |  |  | /* Some useful definitions for Unix pathnames.  Argument convention:
 | 
					
						
							|  |  |  |    x == string, c == character */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if !defined (__CYGWIN__)
 | 
					
						
							|  |  |  | #  define ABSPATH(x)	((x)[0] == '/')
 | 
					
						
							|  |  |  | #  define RELPATH(x)	((x)[0] != '/')
 | 
					
						
							|  |  |  | #else /* __CYGWIN__ */
 | 
					
						
							| 
									
										
										
										
											2005-12-07 14:08:12 +00:00
										 |  |  | #  define ABSPATH(x)	(((x)[0] && ISALPHA((unsigned char)(x)[0]) && (x)[1] == ':') || ISDIRSEP((x)[0]))
 | 
					
						
							|  |  |  | #  define RELPATH(x)	(ABSPATH(x) == 0)
 | 
					
						
							| 
									
										
										
										
											2001-04-06 19:14:31 +00:00
										 |  |  | #endif /* __CYGWIN__ */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define ROOTEDPATH(x)	(ABSPATH(x))
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define DIRSEP	'/'
 | 
					
						
							| 
									
										
										
										
											2005-12-07 14:08:12 +00:00
										 |  |  | #if !defined (__CYGWIN__)
 | 
					
						
							|  |  |  | #  define ISDIRSEP(c)	((c) == '/')
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #  define ISDIRSEP(c)	((c) == '/' || (c) == '\\')
 | 
					
						
							|  |  |  | #endif /* __CYGWIN__ */
 | 
					
						
							| 
									
										
										
										
											2001-04-06 19:14:31 +00:00
										 |  |  | #define PATHSEP(c)	(ISDIRSEP(c) || (c) == 0)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  | #if 0
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | /* Declarations for functions defined in xmalloc.c */ | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  | extern PTR_T xmalloc __P((size_t)); | 
					
						
							|  |  |  | extern PTR_T xrealloc __P((void *, size_t)); | 
					
						
							| 
									
										
										
										
											2000-03-17 21:46:59 +00:00
										 |  |  | extern void xfree __P((void *)); | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | /* Declarations for functions defined in general.c */ | 
					
						
							|  |  |  | extern void posix_initialize __P((int)); | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | #if defined (RLIMTYPE)
 | 
					
						
							|  |  |  | extern RLIMTYPE string_to_rlimtype __P((char *)); | 
					
						
							|  |  |  | extern void print_rlimtype __P((RLIMTYPE, int)); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | extern int all_digits __P((char *)); | 
					
						
							| 
									
										
										
										
											2009-01-12 13:36:28 +00:00
										 |  |  | extern int legal_number __P((const char *, intmax_t *)); | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | extern int legal_identifier __P((char *)); | 
					
						
							|  |  |  | extern int check_identifier __P((WORD_DESC *, int)); | 
					
						
							| 
									
										
										
										
											2004-07-27 13:29:18 +00:00
										 |  |  | extern int legal_alias_name __P((char *, int)); | 
					
						
							|  |  |  | extern int assignment __P((const char *, int)); | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-06 19:14:31 +00:00
										 |  |  | extern int sh_unset_nodelay_mode __P((int)); | 
					
						
							| 
									
										
										
										
											2002-07-17 14:10:11 +00:00
										 |  |  | extern int sh_validfd __P((int)); | 
					
						
							| 
									
										
										
										
											2011-11-22 19:11:26 -05:00
										 |  |  | extern int fd_ispipe __P((int)); | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | extern void check_dev_tty __P((void)); | 
					
						
							| 
									
										
										
										
											1997-06-05 14:59:13 +00:00
										 |  |  | extern int move_to_high_fd __P((int, int, int)); | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  | extern int check_binary_file __P((char *, int)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef _POSIXSTAT_H_
 | 
					
						
							|  |  |  | extern int same_file __P((char *, char *, struct stat *, struct stat *)); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-12 13:36:28 +00:00
										 |  |  | extern int sh_openpipe __P((int *)); | 
					
						
							|  |  |  | extern int sh_closepipe __P((int *)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern int file_exists __P((char *)); | 
					
						
							| 
									
										
										
										
											2004-07-27 13:29:18 +00:00
										 |  |  | extern int file_isdir __P((char  *)); | 
					
						
							|  |  |  | extern int file_iswdir __P((char  *)); | 
					
						
							| 
									
										
										
										
											2014-02-26 09:36:43 -05:00
										 |  |  | extern int path_dot_or_dotdot __P((const char *)); | 
					
						
							| 
									
										
										
										
											2001-11-13 17:56:06 +00:00
										 |  |  | extern int absolute_pathname __P((const char *)); | 
					
						
							|  |  |  | extern int absolute_program __P((const char *)); | 
					
						
							| 
									
										
										
										
											2005-12-07 14:08:12 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | extern char *make_absolute __P((char *, char *)); | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | extern char *base_pathname __P((char *)); | 
					
						
							|  |  |  | extern char *full_pathname __P((char *)); | 
					
						
							|  |  |  | extern char *polite_directory_format __P((char *)); | 
					
						
							| 
									
										
										
										
											2009-01-12 13:36:28 +00:00
										 |  |  | extern char *trim_pathname __P((char *, int)); | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | extern char *extract_colon_unit __P((char *, int *)); | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | extern void tilde_initialize __P((void)); | 
					
						
							| 
									
										
										
										
											2005-12-07 14:08:12 +00:00
										 |  |  | extern char *bash_tilde_find_word __P((const char *, int, int *)); | 
					
						
							| 
									
										
										
										
											2002-07-17 14:10:11 +00:00
										 |  |  | extern char *bash_tilde_expand __P((const char *, int)); | 
					
						
							| 
									
										
										
										
											1996-08-26 18:22:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-06-05 14:59:13 +00:00
										 |  |  | extern int group_member __P((gid_t)); | 
					
						
							|  |  |  | extern char **get_group_list __P((int *)); | 
					
						
							| 
									
										
										
										
											1999-02-19 17:11:39 +00:00
										 |  |  | extern int *get_group_array __P((int *)); | 
					
						
							| 
									
										
										
										
											1997-06-05 14:59:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1996-12-23 17:02:34 +00:00
										 |  |  | #endif	/* _GENERAL_H_ */
 |