xref: /titanic_44/usr/src/lib/libshell/common/include/path.h (revision ee5416c9d7e449233197d5d20bc6b81e4ff091b2)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *           Copyright (c) 1982-2007 AT&T Knowledge Ventures            *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                      by AT&T Knowledge Ventures                      *
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:4096) /* 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 	char		*name;
59 	char		*lib;
60 	char		*blib;
61 	void		*bltin_lib;
62 	unsigned short	len;
63 	unsigned short	flags;
64 	Shell_t		*shp;
65 } Pathcomp_t;
66 
67 #ifndef ARG_RAW
68     struct argnod;
69 #endif /* !ARG_RAW */
70 
71 /* pathname handling routines */
72 extern void		path_newdir(Pathcomp_t*);
73 extern Pathcomp_t	*path_dirfind(Pathcomp_t*,const char*,int);
74 extern Pathcomp_t	*path_unsetfpath(Pathcomp_t*);
75 extern Pathcomp_t	*path_addpath(Pathcomp_t*,const char*,int);
76 extern Pathcomp_t	*path_dup(Pathcomp_t*);
77 extern void		path_delete(Pathcomp_t*);
78 extern void 		path_alias(Namval_t*,Pathcomp_t*);
79 extern Pathcomp_t 	*path_absolute(const char*, Pathcomp_t*);
80 extern char 		*path_basename(const char*);
81 extern char 		*path_fullname(const char*);
82 extern int 		path_expand(const char*, struct argnod**);
83 extern void 		path_exec(const char*,char*[],struct argnod*);
84 extern pid_t		path_spawn(const char*,char*[],char*[],Pathcomp_t*,int);
85 #if defined(__EXPORT__) && defined(_BLD_DLL) && defined(_BLD_shell)
86 #   define extern __EXPORT__
87 #endif
88 extern int		path_open(const char*,Pathcomp_t*);
89 extern Pathcomp_t 	*path_get(const char*);
90 #undef extern
91 extern char 		*path_pwd(int);
92 extern Pathcomp_t	*path_nextcomp(Pathcomp_t*,const char*,Pathcomp_t*);
93 extern int		path_search(const char*,Pathcomp_t*,int);
94 extern char		*path_relative(const char*);
95 extern int		path_complete(const char*, const char*,struct argnod**);
96 #if SHOPT_BRACEPAT
97     extern int 		path_generate(struct argnod*,struct argnod**);
98 #endif /* SHOPT_BRACEPAT */
99 
100 /* constant strings needed for whence */
101 extern const char e_timeformat[];
102 extern const char e_badtformat[];
103 extern const char e_dot[];
104 extern const char e_pfsh[];
105 extern const char e_pwd[];
106 extern const char e_logout[];
107 extern const char e_alphanum[];
108 extern const char e_mailmsg[];
109 extern const char e_suidprofile[];
110 extern const char e_sysprofile[];
111 extern const char e_traceprompt[];
112 extern const char e_crondir[];
113 #if SHOPT_SUID_EXEC
114     extern const char	e_suidexec[];
115 #endif /* SHOPT_SUID_EXEC */
116 extern const char is_alias[];
117 extern const char is_builtin[];
118 extern const char is_builtver[];
119 extern const char is_reserved[];
120 extern const char is_talias[];
121 extern const char is_xalias[];
122 extern const char is_function[];
123 extern const char is_ufunction[];
124 #ifdef SHELLMAGIC
125     extern const char e_prohibited[];
126 #endif /* SHELLMAGIC */
127 
128 #if SHOPT_ACCT
129 #   include	"FEATURE/acct"
130 #   ifdef	_sys_acct
131 	extern void sh_accinit(void);
132 	extern void sh_accbegin(const char*);
133 	extern void sh_accend(void);
134 	extern void sh_accsusp(void);
135 #   else
136 #	undef	SHOPT_ACCT
137 #   endif	/* _sys_acct */
138 #endif /* SHOPT_ACCT */
139 
140 #endif /*! PATH_OFFSET */
141