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