1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
25 * ksh builtin command api
35 # define Namval_t void
38 # define ERROR_NOTIFY 1
41 typedef int (*Shbltin_f
)(int, char**, void*);
44 typedef struct Shbltin_s
49 int (*shrun
)(int, char**);
50 int (*shtrap
)(const char*, int);
52 Namval_t
*(*shbltin
)(const char*, Shbltin_f
, void*);
60 char *(*shgetenv
)(const char*);
61 char *(*shsetenv
)(const char*);
65 #if defined(SH_VERSION) || defined(_SH_PRIVATE)
69 # define sh_context(c) ((Shbltin_t*)(c))
70 # define sh_run(c, ac, av) ((c)?(*sh_context(c)->shrun)(ac,av):-1)
71 # define sh_system(c,str) ((c)?(*sh_context(c)->shtrap)(str,0):system(str))
72 # define sh_exit(c,n) ((c)?(*sh_context(c)->shexit)(n):exit(n))
73 # define sh_checksig(c) ((c) && sh_context(c)->sigset)
74 # if defined(SFIO_VERSION) || defined(_AST_H)
77 # define LIB_INIT(c) ((c) && (sh_context(c)->nosfio = 1))
80 # define cmdinit(ac,av,c,cat,flg) do { if((ac)<=0) return(0); \
81 (sh_context(c)->notify = ((flg)&ERROR_NOTIFY)?1:0);} while(0)
85 #if _BLD_ast && defined(__EXPORT__)
86 #define extern __EXPORT__
89 extern int astintercept(Shbltin_t
*, int);