1da2e3ebdSchin /***********************************************************************
2da2e3ebdSchin * *
3da2e3ebdSchin * This software is part of the ast package *
4*3e14f97fSRoger A. Faulkner * Copyright (c) 1992-2010 AT&T Intellectual Property *
5da2e3ebdSchin * and is licensed under the *
6da2e3ebdSchin * Common Public License, Version 1.0 *
77c2fbfb3SApril Chin * by AT&T Intellectual Property *
8da2e3ebdSchin * *
9da2e3ebdSchin * A copy of the License is available at *
10da2e3ebdSchin * http://www.opensource.org/licenses/cpl1.0.txt *
11da2e3ebdSchin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
12da2e3ebdSchin * *
13da2e3ebdSchin * Information and Software Systems Research *
14da2e3ebdSchin * AT&T Research *
15da2e3ebdSchin * Florham Park NJ *
16da2e3ebdSchin * *
17da2e3ebdSchin * Glenn Fowler <gsf@research.att.com> *
18da2e3ebdSchin * David Korn <dgk@research.att.com> *
19da2e3ebdSchin * *
20da2e3ebdSchin ***********************************************************************/
21da2e3ebdSchin #pragma prototyped
22da2e3ebdSchin /*
23da2e3ebdSchin * command initialization
24da2e3ebdSchin */
25da2e3ebdSchin
26da2e3ebdSchin #include <cmd.h>
2734f9b3eeSRoland Mainz #include <shcmd.h>
28da2e3ebdSchin
29da2e3ebdSchin int
_cmd_init(int argc,char ** argv,void * context,const char * catalog,int flags)30da2e3ebdSchin _cmd_init(int argc, char** argv, void* context, const char* catalog, int flags)
31da2e3ebdSchin {
32da2e3ebdSchin register char* cp;
33da2e3ebdSchin
3434f9b3eeSRoland Mainz if (argc <= 0)
35da2e3ebdSchin return -1;
3634f9b3eeSRoland Mainz if (context)
3734f9b3eeSRoland Mainz {
3834f9b3eeSRoland Mainz if (flags & ERROR_CALLBACK)
3934f9b3eeSRoland Mainz {
4034f9b3eeSRoland Mainz flags &= ~ERROR_CALLBACK;
4134f9b3eeSRoland Mainz flags |= ERROR_NOTIFY;
4234f9b3eeSRoland Mainz }
4334f9b3eeSRoland Mainz else if (flags & ERROR_NOTIFY)
4434f9b3eeSRoland Mainz {
4534f9b3eeSRoland Mainz ((Shbltin_t*)(context))->notify = 1;
4634f9b3eeSRoland Mainz flags &= ~ERROR_NOTIFY;
4734f9b3eeSRoland Mainz }
4834f9b3eeSRoland Mainz error_info.flags |= flags;
4934f9b3eeSRoland Mainz }
50da2e3ebdSchin if (cp = strrchr(argv[0], '/'))
51da2e3ebdSchin cp++;
52da2e3ebdSchin else
53da2e3ebdSchin cp = argv[0];
54da2e3ebdSchin error_info.id = cp;
55da2e3ebdSchin if (!error_info.catalog)
56da2e3ebdSchin error_info.catalog = catalog;
57da2e3ebdSchin opt_info.index = 0;
58da2e3ebdSchin return 0;
59da2e3ebdSchin }
60da2e3ebdSchin
61da2e3ebdSchin #if __OBSOLETE__ < 20080101
62da2e3ebdSchin
63da2e3ebdSchin #if defined(__EXPORT__)
64da2e3ebdSchin #define extern __EXPORT__
65da2e3ebdSchin #endif
66da2e3ebdSchin
67da2e3ebdSchin #undef cmdinit
68da2e3ebdSchin
69da2e3ebdSchin extern void
cmdinit(char ** argv,void * context,const char * catalog,int flags)70da2e3ebdSchin cmdinit(char** argv, void* context, const char* catalog, int flags)
71da2e3ebdSchin {
72da2e3ebdSchin _cmd_init(0, argv, context, catalog, flags);
73da2e3ebdSchin }
74da2e3ebdSchin
75da2e3ebdSchin #endif
76