1/*********************************************************************** 2* * 3* This software is part of the ast package * 4* Copyright (c) 1985-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* Glenn Fowler <gsf@research.att.com> * 18* David Korn <dgk@research.att.com> * 19* Phong Vo <kpv@research.att.com> * 20* * 21***********************************************************************/ 22#pragma prototyped 23 24/* 25 * ksh builtin command api 26 */ 27 28#ifndef _SHCMD_H 29#define _SHCMD_H 1 30 31#define SH_PLUGIN_VERSION AST_PLUGIN_VERSION(20100528L) 32 33#if __STDC__ 34#define SHLIB(m) unsigned long plugin_version(void) { return SH_PLUGIN_VERSION; } 35#else 36#define SHLIB(m) unsigned long plugin_version() { return SH_PLUGIN_VERSION; } 37#endif 38 39#ifndef SH_VERSION 40# define Shell_t void 41#endif 42#ifndef NV_DEFAULT 43# define Namval_t void 44#endif 45#ifndef ERROR_NOTIFY 46# define ERROR_NOTIFY 1 47#endif 48 49typedef int (*Shbltin_f)(int, char**, void*); 50 51#undef Shbltin_t 52typedef struct Shbltin_s 53{ 54 Shell_t *shp; 55 void *ptr; 56 int version; 57 int (*shrun)(int, char**); 58 int (*shtrap)(const char*, int); 59 void (*shexit)(int); 60 Namval_t *(*shbltin)(const char*, Shbltin_f, void*); 61 unsigned char notify; 62 unsigned char sigset; 63 unsigned char nosfio; 64 Namval_t *bnode; 65 Namval_t *vnode; 66 char *data; 67 int flags; 68 char *(*shgetenv)(const char*); 69 char *(*shsetenv)(const char*); 70 int invariant; 71} Shbltin_t; 72 73#if defined(SH_VERSION) || defined(_SH_PRIVATE) 74# undef Shell_t 75# undef Namval_t 76#else 77# define sh_context(c) ((Shbltin_t*)(c)) 78# define sh_run(c, ac, av) ((c)?(*sh_context(c)->shrun)(ac,av):-1) 79# define sh_system(c,str) ((c)?(*sh_context(c)->shtrap)(str,0):system(str)) 80# define sh_exit(c,n) ((c)?(*sh_context(c)->shexit)(n):exit(n)) 81# define sh_checksig(c) ((c) && sh_context(c)->sigset) 82# define sh_builtin(c,n,f,p) ((c)?(*sh_context(c)->shbltin)(n,(Shbltin_f)(f),(void*)(p)):0) 83# if defined(SFIO_VERSION) || defined(_AST_H) 84# define LIB_INIT(c) 85# else 86# define LIB_INIT(c) ((c) && (sh_context(c)->nosfio = 1)) 87# endif 88# ifndef _CMD_H 89# define cmdinit(ac,av,c,cat,flg) do { if((ac)<=0) return(0); \ 90 (sh_context(c)->notify = ((flg)&ERROR_NOTIFY)?1:0);} while(0) 91# endif 92#endif 93 94#if _BLD_ast && defined(__EXPORT__) 95#define extern __EXPORT__ 96#endif 97 98extern int astintercept(Shbltin_t*, int); 99 100#undef extern 101 102#endif 103