1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1992-2012 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                 Eclipse Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *          http://www.eclipse.org/org/documents/epl-v10.html           *
11 *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
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 *                                                                      *
20 ***********************************************************************/
21 #pragma prototyped
22 /*
23  * command initialization
24  */
25 
26 #include <cmd.h>
27 #include <shcmd.h>
28 
29 int
_cmd_init(int argc,char ** argv,Shbltin_t * context,const char * catalog,int flags)30 _cmd_init(int argc, char** argv, Shbltin_t* context, const char* catalog, int flags)
31 {
32 	register char*	cp;
33 
34 	if (argc <= 0)
35 		return -1;
36 	if (context)
37 	{
38 		if (flags & ERROR_CALLBACK)
39 		{
40 			flags &= ~ERROR_CALLBACK;
41 			flags |= ERROR_NOTIFY;
42 		}
43 		else if (flags & ERROR_NOTIFY)
44 		{
45 			context->notify = 1;
46 			flags &= ~ERROR_NOTIFY;
47 		}
48 		error_info.flags |= flags;
49 	}
50 	if (cp = strrchr(argv[0], '/'))
51 		cp++;
52 	else
53 		cp = argv[0];
54 	error_info.id = cp;
55 	if (!error_info.catalog)
56 		error_info.catalog = catalog;
57 	opt_info.index = 0;
58 	return 0;
59 }
60 
61 #if __OBSOLETE__ < 20080101
62 
63 #if defined(__EXPORT__)
64 #define extern	__EXPORT__
65 #endif
66 
67 #undef	cmdinit
68 
69 extern void
cmdinit(char ** argv,Shbltin_t * context,const char * catalog,int flags)70 cmdinit(char** argv, Shbltin_t* context, const char* catalog, int flags)
71 {
72 	_cmd_init(0, argv, context, catalog, flags);
73 }
74 
75 #endif
76