xref: /titanic_50/usr/src/lib/libshell/common/include/path.h (revision 3e14f97f673e8a630f076077de35afdd43dc1587)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1982-2010 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *            http://www.opensource.org/licenses/cpl1.0.txt             *
11 *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
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 
32 #if !defined(SHOPT_SPAWN)
33 #   if _UWIN || _use_spawnveg || !_lib_fork
34 #	define  SHOPT_SPAWN  1
35 #   endif
36 #endif /* !SHOPT_SPAWN */
37 
38 #define PATH_PATH		0001
39 #define PATH_FPATH		0002
40 #define PATH_CDPATH		0004
41 #define PATH_BFPATH		0010
42 #define PATH_SKIP		0020
43 #define PATH_BUILTIN_LIB	0040
44 #define PATH_STD_DIR		0100	/* directory is on  $(getconf PATH) */
45 
46 #define PATH_OFFSET	2		/* path offset for path_join */
47 #define MAXDEPTH	(sizeof(char*)==2?64:1024) /* maximum recursion depth*/
48 
49 /*
50  * path component structure for path searching
51  */
52 typedef struct pathcomp
53 {
54 	struct pathcomp *next;
55 	int		refcount;
56 	dev_t		dev;
57 	ino_t		ino;
58 	time_t		mtime;
59 	char		*name;
60 	char		*lib;
61 	char		*blib;
62 	void		*bltin_lib;
63 	unsigned short	len;
64 	unsigned short	flags;
65 	Shell_t		*shp;
66 } Pathcomp_t;
67 
68 #ifndef ARG_RAW
69     struct argnod;
70 #endif /* !ARG_RAW */
71 
72 /* pathname handling routines */
73 extern void		path_newdir(Pathcomp_t*);
74 extern Pathcomp_t	*path_dirfind(Pathcomp_t*,const char*,int);
75 extern Pathcomp_t	*path_unsetfpath(Pathcomp_t*);
76 extern Pathcomp_t	*path_addpath(Pathcomp_t*,const char*,int);
77 extern Pathcomp_t	*path_dup(Pathcomp_t*);
78 extern void		path_delete(Pathcomp_t*);
79 extern void 		path_alias(Namval_t*,Pathcomp_t*);
80 extern Pathcomp_t 	*path_absolute(const char*, Pathcomp_t*);
81 extern char 		*path_basename(const char*);
82 extern char 		*path_fullname(const char*);
83 extern int 		path_expand(const char*, struct argnod**);
84 extern void 		path_exec(const char*,char*[],struct argnod*);
85 extern pid_t		path_spawn(const char*,char*[],char*[],Pathcomp_t*,int);
86 #if defined(__EXPORT__) && defined(_BLD_DLL) && defined(_BLD_shell)
87 #   define extern __EXPORT__
88 #endif
89 extern int		path_open(const char*,Pathcomp_t*);
90 extern Pathcomp_t 	*path_get(const char*);
91 #undef extern
92 extern char 		*path_pwd(int);
93 extern Pathcomp_t	*path_nextcomp(Pathcomp_t*,const char*,Pathcomp_t*);
94 extern int		path_search(const char*,Pathcomp_t**,int);
95 extern char		*path_relative(const char*);
96 extern int		path_complete(const char*, const char*,struct argnod**);
97 #if SHOPT_BRACEPAT
98     extern int 		path_generate(struct argnod*,struct argnod**);
99 #endif /* SHOPT_BRACEPAT */
100 
101 /* constant strings needed for whence */
102 extern const char e_timeformat[];
103 extern const char e_badtformat[];
104 extern const char e_dot[];
105 extern const char e_pfsh[];
106 extern const char e_pwd[];
107 extern const char e_logout[];
108 extern const char e_alphanum[];
109 extern const char e_mailmsg[];
110 extern const char e_suidprofile[];
111 extern const char e_sysprofile[];
112 extern const char e_traceprompt[];
113 extern const char e_crondir[];
114 #if SHOPT_SUID_EXEC
115     extern const char	e_suidexec[];
116 #endif /* SHOPT_SUID_EXEC */
117 extern const char is_alias[];
118 extern const char is_builtin[];
119 extern const char is_spcbuiltin[];
120 extern const char is_builtver[];
121 extern const char is_reserved[];
122 extern const char is_talias[];
123 extern const char is_xalias[];
124 extern const char is_function[];
125 extern const char is_ufunction[];
126 #ifdef SHELLMAGIC
127     extern const char e_prohibited[];
128 #endif /* SHELLMAGIC */
129 
130 #if SHOPT_ACCT
131 #   include	"FEATURE/acct"
132 #   ifdef	_sys_acct
133 	extern void sh_accinit(void);
134 	extern void sh_accbegin(const char*);
135 	extern void sh_accend(void);
136 	extern void sh_accsusp(void);
137 #   else
138 #	undef	SHOPT_ACCT
139 #   endif	/* _sys_acct */
140 #endif /* SHOPT_ACCT */
141 
142 #endif /*! PATH_OFFSET */
143