1/*********************************************************************** 2* * 3* This software is part of the ast package * 4* Copyright (c) 1982-2011 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#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 */ 53typedef 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 *blib; 63 void *bltin_lib; 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 */ 74extern void path_newdir(Shell_t*,Pathcomp_t*); 75extern Pathcomp_t *path_dirfind(Pathcomp_t*,const char*,int); 76extern Pathcomp_t *path_unsetfpath(Shell_t*); 77extern Pathcomp_t *path_addpath(Shell_t*,Pathcomp_t*,const char*,int); 78extern Pathcomp_t *path_dup(Pathcomp_t*); 79extern void path_delete(Pathcomp_t*); 80extern void path_alias(Namval_t*,Pathcomp_t*); 81extern Pathcomp_t *path_absolute(Shell_t*, const char*, Pathcomp_t*); 82extern char *path_basename(const char*); 83extern char *path_fullname(Shell_t*,const char*); 84extern int path_expand(Shell_t*,const char*, struct argnod**); 85extern void path_exec(Shell_t*,const char*,char*[],struct argnod*); 86extern 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 90extern int path_open(Shell_t*,const char*,Pathcomp_t*); 91extern Pathcomp_t *path_get(Shell_t*,const char*); 92#undef extern 93extern char *path_pwd(Shell_t*,int); 94extern Pathcomp_t *path_nextcomp(Shell_t*,Pathcomp_t*,const char*,Pathcomp_t*); 95extern int path_search(Shell_t*,const char*,Pathcomp_t**,int); 96extern char *path_relative(Shell_t*,const char*); 97extern 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#if SHOPT_PFSH 102 extern int path_xattr(Shell_t*, const char*, char*); 103#endif /* SHOPT_PFSH */ 104 105/* constant strings needed for whence */ 106extern const char e_timeformat[]; 107extern const char e_badtformat[]; 108extern const char e_dot[]; 109extern const char e_funload[]; 110extern const char e_pfsh[]; 111extern const char e_pwd[]; 112extern const char e_logout[]; 113extern const char e_alphanum[]; 114extern const char e_mailmsg[]; 115extern const char e_suidprofile[]; 116extern const char e_sysprofile[]; 117extern const char e_traceprompt[]; 118extern const char e_crondir[]; 119#if SHOPT_SUID_EXEC 120 extern const char e_suidexec[]; 121#endif /* SHOPT_SUID_EXEC */ 122extern const char is_alias[]; 123extern const char is_builtin[]; 124extern const char is_spcbuiltin[]; 125extern const char is_builtver[]; 126extern const char is_reserved[]; 127extern const char is_talias[]; 128extern const char is_xalias[]; 129extern const char is_function[]; 130extern const char is_ufunction[]; 131#ifdef SHELLMAGIC 132 extern const char e_prohibited[]; 133#endif /* SHELLMAGIC */ 134 135#if SHOPT_ACCT 136# include "FEATURE/acct" 137# ifdef _sys_acct 138 extern void sh_accinit(void); 139 extern void sh_accbegin(const char*); 140 extern void sh_accend(void); 141 extern void sh_accsusp(void); 142# else 143# undef SHOPT_ACCT 144# endif /* _sys_acct */ 145#endif /* SHOPT_ACCT */ 146 147#endif /*! PATH_OFFSET */ 148