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