xref: /illumos-gate/usr/src/contrib/ast/src/cmd/ksh93/include/path.h (revision b30d193948be5a7794d7ae3ba0ed9c2f72c88e0f)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1982-2012 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                 Eclipse Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *          http://www.eclipse.org/org/documents/epl-v10.html           *
11 *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                  David Korn <dgk@research.att.com>                   *
18 *                                                                      *
19 ***********************************************************************/
20 #pragma prototyped
21 #ifndef PATH_OFFSET
22 
23 /*
24  *	UNIX shell path handling interface
25  *	Written by David Korn
26  *	These are the definitions for the lexical analyzer
27  */
28 
29 #include	"FEATURE/options"
30 #include	<nval.h>
31 #include	"defs.h"
32 
33 #if !defined(SHOPT_SPAWN)
34 #   if _UWIN || _use_spawnveg || !_lib_fork
35 #	define  SHOPT_SPAWN  1
36 #   endif
37 #endif /* !SHOPT_SPAWN */
38 
39 #define PATH_PATH		0001
40 #define PATH_FPATH		0002
41 #define PATH_CDPATH		0004
42 #define PATH_BFPATH		0010
43 #define PATH_SKIP		0020
44 #define PATH_BUILTIN_LIB	0040
45 #define PATH_STD_DIR		0100	/* directory is on  $(getconf PATH) */
46 
47 #define PATH_OFFSET	2		/* path offset for path_join */
48 #define MAXDEPTH	(sizeof(char*)==2?64:1024) /* maximum recursion depth*/
49 
50 /*
51  * path component structure for path searching
52  */
53 typedef struct pathcomp
54 {
55 	struct pathcomp *next;
56 	int		refcount;
57 	dev_t		dev;
58 	ino_t		ino;
59 	time_t		mtime;
60 	char		*name;
61 	char		*lib;
62 	char		*bbuf;
63 	char		*blib;
64 	unsigned short	len;
65 	unsigned short	flags;
66 	Shell_t		*shp;
67 } Pathcomp_t;
68 
69 #ifndef ARG_RAW
70     struct argnod;
71 #endif /* !ARG_RAW */
72 
73 /* pathname handling routines */
74 extern void		path_newdir(Shell_t*,Pathcomp_t*);
75 extern Pathcomp_t	*path_dirfind(Pathcomp_t*,const char*,int);
76 extern Pathcomp_t	*path_unsetfpath(Shell_t*);
77 extern Pathcomp_t	*path_addpath(Shell_t*,Pathcomp_t*,const char*,int);
78 extern Pathcomp_t	*path_dup(Pathcomp_t*);
79 extern void		path_delete(Pathcomp_t*);
80 extern void 		path_alias(Namval_t*,Pathcomp_t*);
81 extern Pathcomp_t 	*path_absolute(Shell_t*, const char*, Pathcomp_t*);
82 extern char 		*path_basename(const char*);
83 extern char 		*path_fullname(Shell_t*,const char*);
84 extern int 		path_expand(Shell_t*,const char*, struct argnod**);
85 extern void 		path_exec(Shell_t*,const char*,char*[],struct argnod*);
86 extern pid_t		path_spawn(Shell_t*,const char*,char*[],char*[],Pathcomp_t*,int);
87 #if defined(__EXPORT__) && defined(_BLD_DLL) && defined(_BLD_shell)
88 #   define extern __EXPORT__
89 #endif
90 extern int		path_open(Shell_t*,const char*,Pathcomp_t*);
91 extern Pathcomp_t 	*path_get(Shell_t*,const char*);
92 #undef extern
93 extern char 		*path_pwd(Shell_t*,int);
94 extern Pathcomp_t	*path_nextcomp(Shell_t*,Pathcomp_t*,const char*,Pathcomp_t*);
95 extern int		path_search(Shell_t*,const char*,Pathcomp_t**,int);
96 extern char		*path_relative(Shell_t*,const char*);
97 extern int		path_complete(Shell_t*,const char*, const char*,struct argnod**);
98 #if SHOPT_BRACEPAT
99     extern int 		path_generate(Shell_t*,struct argnod*,struct argnod**);
100 #endif /* SHOPT_BRACEPAT */
101     extern int		path_xattr(Shell_t*, const char*, char*);
102 
103 /* builtin/plugin routines */
104 extern int		sh_addlib(Shell_t*,void*,char*,Pathcomp_t*);
105 extern Shbltin_f	sh_getlib(Shell_t*,char*,Pathcomp_t*);
106 
107 /* constant strings needed for whence */
108 extern const char e_timeformat[];
109 extern const char e_badtformat[];
110 extern const char e_dot[];
111 extern const char e_funload[];
112 extern const char e_pfsh[];
113 extern const char e_pwd[];
114 extern const char e_logout[];
115 extern const char e_alphanum[];
116 extern const char e_mailmsg[];
117 extern const char e_suidprofile[];
118 extern const char e_sysprofile[];
119 extern const char e_traceprompt[];
120 extern const char e_crondir[];
121 #if SHOPT_SUID_EXEC
122     extern const char	e_suidexec[];
123 #endif /* SHOPT_SUID_EXEC */
124 extern const char is_alias[];
125 extern const char is_builtin[];
126 extern const char is_spcbuiltin[];
127 extern const char is_builtver[];
128 extern const char is_reserved[];
129 extern const char is_talias[];
130 extern const char is_xalias[];
131 extern const char is_function[];
132 extern const char is_ufunction[];
133 #ifdef SHELLMAGIC
134     extern const char e_prohibited[];
135 #endif /* SHELLMAGIC */
136 
137 #if SHOPT_ACCT
138 #   include	"FEATURE/acct"
139 #   ifdef	_sys_acct
140 	extern void sh_accinit(void);
141 	extern void sh_accbegin(const char*);
142 	extern void sh_accend(void);
143 	extern void sh_accsusp(void);
144 #   else
145 #	undef	SHOPT_ACCT
146 #   endif	/* _sys_acct */
147 #endif /* SHOPT_ACCT */
148 
149 #endif /*! PATH_OFFSET */
150