xref: /titanic_51/usr/src/lib/libcmd/common/cmdinit.c (revision 5f9878b0212a5bc5924a85d227160bf7f43712f1)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1992-2008 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
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
29 _cmd_init(int argc, char** argv, void* context, const char* catalog, int flags)
30 {
31 	register char*	cp;
32 
33 	if (argc < 0)
34 		return -1;
35 	if (cp = strrchr(argv[0], '/'))
36 		cp++;
37 	else
38 		cp = argv[0];
39 	error_info.id = cp;
40 	if (!error_info.catalog)
41 		error_info.catalog = catalog;
42 	opt_info.index = 0;
43 	if (context)
44 		error_info.flags |= flags;
45 	return 0;
46 }
47 
48 #if __OBSOLETE__ < 20080101
49 
50 #if defined(__EXPORT__)
51 #define extern	__EXPORT__
52 #endif
53 
54 #undef	cmdinit
55 
56 extern void
57 cmdinit(char** argv, void* context, const char* catalog, int flags)
58 {
59 	_cmd_init(0, argv, context, catalog, flags);
60 }
61 
62 #endif
63