xref: /onnv-gate/usr/src/lib/libshell/common/include/path.h (revision 12068:08a39a083754)
14887Schin /***********************************************************************
24887Schin *                                                                      *
34887Schin *               This software is part of the ast package               *
4*12068SRoger.Faulkner@Oracle.COM *          Copyright (c) 1982-2010 AT&T Intellectual Property          *
54887Schin *                      and is licensed under the                       *
64887Schin *                  Common Public License, Version 1.0                  *
78462SApril.Chin@Sun.COM *                    by AT&T Intellectual Property                     *
84887Schin *                                                                      *
94887Schin *                A copy of the License is available at                 *
104887Schin *            http://www.opensource.org/licenses/cpl1.0.txt             *
114887Schin *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
124887Schin *                                                                      *
134887Schin *              Information and Software Systems Research               *
144887Schin *                            AT&T Research                             *
154887Schin *                           Florham Park NJ                            *
164887Schin *                                                                      *
174887Schin *                  David Korn <dgk@research.att.com>                   *
184887Schin *                                                                      *
194887Schin ***********************************************************************/
204887Schin #pragma prototyped
214887Schin #ifndef PATH_OFFSET
224887Schin 
234887Schin /*
244887Schin  *	UNIX shell path handling interface
254887Schin  *	Written by David Korn
264887Schin  *	These are the definitions for the lexical analyzer
274887Schin  */
284887Schin 
294887Schin #include	"FEATURE/options"
304887Schin #include	<nval.h>
314887Schin 
324887Schin #if !defined(SHOPT_SPAWN)
334887Schin #   if _UWIN || _use_spawnveg || !_lib_fork
344887Schin #	define  SHOPT_SPAWN  1
354887Schin #   endif
364887Schin #endif /* !SHOPT_SPAWN */
374887Schin 
384887Schin #define PATH_PATH		0001
394887Schin #define PATH_FPATH		0002
404887Schin #define PATH_CDPATH		0004
414887Schin #define PATH_BFPATH		0010
424887Schin #define PATH_SKIP		0020
434887Schin #define PATH_BUILTIN_LIB	0040
444887Schin #define PATH_STD_DIR		0100	/* directory is on  $(getconf PATH) */
454887Schin 
464887Schin #define PATH_OFFSET	2		/* path offset for path_join */
4710898Sroland.mainz@nrubsig.org #define MAXDEPTH	(sizeof(char*)==2?64:1024) /* maximum recursion depth*/
484887Schin 
494887Schin /*
504887Schin  * path component structure for path searching
514887Schin  */
524887Schin typedef struct pathcomp
534887Schin {
544887Schin 	struct pathcomp *next;
554887Schin 	int		refcount;
564887Schin 	dev_t		dev;
574887Schin 	ino_t		ino;
588462SApril.Chin@Sun.COM 	time_t		mtime;
594887Schin 	char		*name;
604887Schin 	char		*lib;
614887Schin 	char		*blib;
624887Schin 	void		*bltin_lib;
634887Schin 	unsigned short	len;
644887Schin 	unsigned short	flags;
654887Schin 	Shell_t		*shp;
664887Schin } Pathcomp_t;
674887Schin 
684887Schin #ifndef ARG_RAW
694887Schin     struct argnod;
704887Schin #endif /* !ARG_RAW */
714887Schin 
724887Schin /* pathname handling routines */
734887Schin extern void		path_newdir(Pathcomp_t*);
744887Schin extern Pathcomp_t	*path_dirfind(Pathcomp_t*,const char*,int);
754887Schin extern Pathcomp_t	*path_unsetfpath(Pathcomp_t*);
764887Schin extern Pathcomp_t	*path_addpath(Pathcomp_t*,const char*,int);
774887Schin extern Pathcomp_t	*path_dup(Pathcomp_t*);
784887Schin extern void		path_delete(Pathcomp_t*);
794887Schin extern void 		path_alias(Namval_t*,Pathcomp_t*);
804887Schin extern Pathcomp_t 	*path_absolute(const char*, Pathcomp_t*);
814887Schin extern char 		*path_basename(const char*);
824887Schin extern char 		*path_fullname(const char*);
834887Schin extern int 		path_expand(const char*, struct argnod**);
844887Schin extern void 		path_exec(const char*,char*[],struct argnod*);
854887Schin extern pid_t		path_spawn(const char*,char*[],char*[],Pathcomp_t*,int);
864887Schin #if defined(__EXPORT__) && defined(_BLD_DLL) && defined(_BLD_shell)
874887Schin #   define extern __EXPORT__
884887Schin #endif
894887Schin extern int		path_open(const char*,Pathcomp_t*);
904887Schin extern Pathcomp_t 	*path_get(const char*);
914887Schin #undef extern
924887Schin extern char 		*path_pwd(int);
934887Schin extern Pathcomp_t	*path_nextcomp(Pathcomp_t*,const char*,Pathcomp_t*);
948462SApril.Chin@Sun.COM extern int		path_search(const char*,Pathcomp_t**,int);
954887Schin extern char		*path_relative(const char*);
964887Schin extern int		path_complete(const char*, const char*,struct argnod**);
974887Schin #if SHOPT_BRACEPAT
984887Schin     extern int 		path_generate(struct argnod*,struct argnod**);
994887Schin #endif /* SHOPT_BRACEPAT */
1004887Schin 
1014887Schin /* constant strings needed for whence */
1024887Schin extern const char e_timeformat[];
1034887Schin extern const char e_badtformat[];
1044887Schin extern const char e_dot[];
1054887Schin extern const char e_pfsh[];
1064887Schin extern const char e_pwd[];
1074887Schin extern const char e_logout[];
1084887Schin extern const char e_alphanum[];
1094887Schin extern const char e_mailmsg[];
1104887Schin extern const char e_suidprofile[];
1114887Schin extern const char e_sysprofile[];
1124887Schin extern const char e_traceprompt[];
1134887Schin extern const char e_crondir[];
1144887Schin #if SHOPT_SUID_EXEC
1154887Schin     extern const char	e_suidexec[];
1164887Schin #endif /* SHOPT_SUID_EXEC */
1174887Schin extern const char is_alias[];
1184887Schin extern const char is_builtin[];
1198462SApril.Chin@Sun.COM extern const char is_spcbuiltin[];
1204887Schin extern const char is_builtver[];
1214887Schin extern const char is_reserved[];
1224887Schin extern const char is_talias[];
1234887Schin extern const char is_xalias[];
1244887Schin extern const char is_function[];
1254887Schin extern const char is_ufunction[];
1264887Schin #ifdef SHELLMAGIC
1274887Schin     extern const char e_prohibited[];
1284887Schin #endif /* SHELLMAGIC */
1294887Schin 
1304887Schin #if SHOPT_ACCT
1314887Schin #   include	"FEATURE/acct"
1324887Schin #   ifdef	_sys_acct
1334887Schin 	extern void sh_accinit(void);
1344887Schin 	extern void sh_accbegin(const char*);
1354887Schin 	extern void sh_accend(void);
1364887Schin 	extern void sh_accsusp(void);
1374887Schin #   else
1384887Schin #	undef	SHOPT_ACCT
1394887Schin #   endif	/* _sys_acct */
1404887Schin #endif /* SHOPT_ACCT */
1414887Schin 
1424887Schin #endif /*! PATH_OFFSET */
143