14887Schin /*********************************************************************** 24887Schin * * 34887Schin * This software is part of the ast package * 4*10898Sroland.mainz@nrubsig.org * Copyright (c) 1992-2009 AT&T Intellectual Property * 54887Schin * and is licensed under the * 64887Schin * Common Public License, Version 1.0 * 78462SApril.Chin@Sun.COM * by AT&T Intellectual Property * 84887Schin * * 94887Schin * A copy of the License is available at * 104887Schin * http://www.opensource.org/licenses/cpl1.0.txt * 114887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 124887Schin * * 134887Schin * Information and Software Systems Research * 144887Schin * AT&T Research * 154887Schin * Florham Park NJ * 164887Schin * * 174887Schin * Glenn Fowler <gsf@research.att.com> * 184887Schin * David Korn <dgk@research.att.com> * 194887Schin * * 204887Schin ***********************************************************************/ 214887Schin #pragma prototyped 224887Schin /* 234887Schin * command initialization 244887Schin */ 254887Schin 264887Schin #include <cmd.h> 27*10898Sroland.mainz@nrubsig.org #include <shcmd.h> 284887Schin 294887Schin int 304887Schin _cmd_init(int argc, char** argv, void* context, const char* catalog, int flags) 314887Schin { 324887Schin register char* cp; 334887Schin 34*10898Sroland.mainz@nrubsig.org if (argc <= 0) 354887Schin return -1; 36*10898Sroland.mainz@nrubsig.org if (context) 37*10898Sroland.mainz@nrubsig.org { 38*10898Sroland.mainz@nrubsig.org if (flags & ERROR_CALLBACK) 39*10898Sroland.mainz@nrubsig.org { 40*10898Sroland.mainz@nrubsig.org flags &= ~ERROR_CALLBACK; 41*10898Sroland.mainz@nrubsig.org flags |= ERROR_NOTIFY; 42*10898Sroland.mainz@nrubsig.org } 43*10898Sroland.mainz@nrubsig.org else if (flags & ERROR_NOTIFY) 44*10898Sroland.mainz@nrubsig.org { 45*10898Sroland.mainz@nrubsig.org ((Shbltin_t*)(context))->notify = 1; 46*10898Sroland.mainz@nrubsig.org flags &= ~ERROR_NOTIFY; 47*10898Sroland.mainz@nrubsig.org } 48*10898Sroland.mainz@nrubsig.org error_info.flags |= flags; 49*10898Sroland.mainz@nrubsig.org } 504887Schin if (cp = strrchr(argv[0], '/')) 514887Schin cp++; 524887Schin else 534887Schin cp = argv[0]; 544887Schin error_info.id = cp; 554887Schin if (!error_info.catalog) 564887Schin error_info.catalog = catalog; 574887Schin opt_info.index = 0; 584887Schin return 0; 594887Schin } 604887Schin 614887Schin #if __OBSOLETE__ < 20080101 624887Schin 634887Schin #if defined(__EXPORT__) 644887Schin #define extern __EXPORT__ 654887Schin #endif 664887Schin 674887Schin #undef cmdinit 684887Schin 694887Schin extern void 704887Schin cmdinit(char** argv, void* context, const char* catalog, int flags) 714887Schin { 724887Schin _cmd_init(0, argv, context, catalog, flags); 734887Schin } 744887Schin 754887Schin #endif 76