xref: /titanic_44/usr/src/lib/libcmd/common/cmdinit.c (revision 55553f719b521a0bb4deab6efc944cd30c1a56aa)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *           Copyright (c) 1992-2007 AT&T Knowledge Ventures            *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                      by AT&T Knowledge Ventures                      *
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 *                                                                      *
20 ***********************************************************************/
21 #pragma prototyped
22 /*
23  * command initialization
24  */
25 
26 #include <cmd.h>
27 
28 int	_cmd_quit = 0;
29 
30 int
31 _cmd_init(int argc, char** argv, void* context, const char* catalog, int flags)
32 {
33 	register char*	cp;
34 
35 	if (argc < 0)
36 	{
37 		_cmd_quit = 1;
38 		return -1;
39 	}
40 	_cmd_quit = 0;
41 	if (cp = strrchr(argv[0], '/'))
42 		cp++;
43 	else
44 		cp = argv[0];
45 	error_info.id = cp;
46 	if (!error_info.catalog)
47 		error_info.catalog = catalog;
48 	opt_info.index = 0;
49 	if (context)
50 		error_info.flags |= flags;
51 	return 0;
52 }
53 
54 #if __OBSOLETE__ < 20080101
55 
56 #if defined(__EXPORT__)
57 #define extern	__EXPORT__
58 #endif
59 
60 #undef	cmdinit
61 
62 extern void
63 cmdinit(char** argv, void* context, const char* catalog, int flags)
64 {
65 	_cmd_init(0, argv, context, catalog, flags);
66 }
67 
68 #endif
69