17c2fbfb3SApril Chin /*********************************************************************** 27c2fbfb3SApril Chin * * 37c2fbfb3SApril Chin * This software is part of the ast package * 4*3e14f97fSRoger A. Faulkner * Copyright (c) 1985-2010 AT&T Intellectual Property * 57c2fbfb3SApril Chin * and is licensed under the * 67c2fbfb3SApril Chin * Common Public License, Version 1.0 * 77c2fbfb3SApril Chin * by AT&T Intellectual Property * 87c2fbfb3SApril Chin * * 97c2fbfb3SApril Chin * A copy of the License is available at * 107c2fbfb3SApril Chin * http://www.opensource.org/licenses/cpl1.0.txt * 117c2fbfb3SApril Chin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 127c2fbfb3SApril Chin * * 137c2fbfb3SApril Chin * Information and Software Systems Research * 147c2fbfb3SApril Chin * AT&T Research * 157c2fbfb3SApril Chin * Florham Park NJ * 167c2fbfb3SApril Chin * * 177c2fbfb3SApril Chin * Glenn Fowler <gsf@research.att.com> * 187c2fbfb3SApril Chin * David Korn <dgk@research.att.com> * 197c2fbfb3SApril Chin * Phong Vo <kpv@research.att.com> * 207c2fbfb3SApril Chin * * 217c2fbfb3SApril Chin ***********************************************************************/ 227c2fbfb3SApril Chin #pragma prototyped 237c2fbfb3SApril Chin 247c2fbfb3SApril Chin /* 257c2fbfb3SApril Chin * ksh builtin command api 267c2fbfb3SApril Chin */ 277c2fbfb3SApril Chin 287c2fbfb3SApril Chin #ifndef _SHCMD_H 297c2fbfb3SApril Chin #define _SHCMD_H 1 307c2fbfb3SApril Chin 317c2fbfb3SApril Chin #ifndef SH_VERSION 327c2fbfb3SApril Chin # define Shell_t void 337c2fbfb3SApril Chin #endif 347c2fbfb3SApril Chin #ifndef NV_DEFAULT 357c2fbfb3SApril Chin # define Namval_t void 367c2fbfb3SApril Chin #endif 377c2fbfb3SApril Chin #ifndef ERROR_NOTIFY 387c2fbfb3SApril Chin # define ERROR_NOTIFY 1 397c2fbfb3SApril Chin #endif 407c2fbfb3SApril Chin 417c2fbfb3SApril Chin typedef int (*Shbltin_f)(int, char**, void*); 427c2fbfb3SApril Chin 437c2fbfb3SApril Chin #undef Shbltin_t 447c2fbfb3SApril Chin typedef struct Shbltin_s 457c2fbfb3SApril Chin { 467c2fbfb3SApril Chin Shell_t *shp; 477c2fbfb3SApril Chin void *ptr; 487c2fbfb3SApril Chin int version; 497c2fbfb3SApril Chin int (*shrun)(int, char**); 507c2fbfb3SApril Chin int (*shtrap)(const char*, int); 517c2fbfb3SApril Chin void (*shexit)(int); 527c2fbfb3SApril Chin Namval_t *(*shbltin)(const char*, Shbltin_f, void*); 537c2fbfb3SApril Chin unsigned char notify; 547c2fbfb3SApril Chin unsigned char sigset; 557c2fbfb3SApril Chin unsigned char nosfio; 567c2fbfb3SApril Chin Namval_t *bnode; 577c2fbfb3SApril Chin Namval_t *vnode; 587c2fbfb3SApril Chin char *data; 597c2fbfb3SApril Chin int flags; 607c2fbfb3SApril Chin char *(*shgetenv)(const char*); 617c2fbfb3SApril Chin char *(*shsetenv)(const char*); 627c2fbfb3SApril Chin int invariant; 637c2fbfb3SApril Chin } Shbltin_t; 647c2fbfb3SApril Chin 657c2fbfb3SApril Chin #if defined(SH_VERSION) || defined(_SH_PRIVATE) 667c2fbfb3SApril Chin # undef Shell_t 677c2fbfb3SApril Chin # undef Namval_t 687c2fbfb3SApril Chin #else 6934f9b3eeSRoland Mainz # define sh_context(c) ((Shbltin_t*)(c)) 7034f9b3eeSRoland Mainz # define sh_run(c, ac, av) ((c)?(*sh_context(c)->shrun)(ac,av):-1) 7134f9b3eeSRoland Mainz # define sh_system(c,str) ((c)?(*sh_context(c)->shtrap)(str,0):system(str)) 7234f9b3eeSRoland Mainz # define sh_exit(c,n) ((c)?(*sh_context(c)->shexit)(n):exit(n)) 7334f9b3eeSRoland Mainz # define sh_checksig(c) ((c) && sh_context(c)->sigset) 747c2fbfb3SApril Chin # if defined(SFIO_VERSION) || defined(_AST_H) 757c2fbfb3SApril Chin # define LIB_INIT(c) 767c2fbfb3SApril Chin # else 7734f9b3eeSRoland Mainz # define LIB_INIT(c) ((c) && (sh_context(c)->nosfio = 1)) 787c2fbfb3SApril Chin # endif 797c2fbfb3SApril Chin # ifndef _CMD_H 807c2fbfb3SApril Chin # define cmdinit(ac,av,c,cat,flg) do { if((ac)<=0) return(0); \ 8134f9b3eeSRoland Mainz (sh_context(c)->notify = ((flg)&ERROR_NOTIFY)?1:0);} while(0) 827c2fbfb3SApril Chin # endif 837c2fbfb3SApril Chin #endif 847c2fbfb3SApril Chin 857c2fbfb3SApril Chin #if _BLD_ast && defined(__EXPORT__) 867c2fbfb3SApril Chin #define extern __EXPORT__ 877c2fbfb3SApril Chin #endif 887c2fbfb3SApril Chin 897c2fbfb3SApril Chin extern int astintercept(Shbltin_t*, int); 907c2fbfb3SApril Chin 917c2fbfb3SApril Chin #undef extern 927c2fbfb3SApril Chin 937c2fbfb3SApril Chin #endif 94