kernel: remove unused utsname_set_machine()
[unleashed.git] / usr / src / lib / libcmd / sparc / include / ast / cmd.h
blobe064222a77e98dff464dad79dde558dc7da9ee2b
2 /* : : generated by proto : : */
3 /***********************************************************************
4 * *
5 * This software is part of the ast package *
6 * Copyright (c) 1992-2010 AT&T Intellectual Property *
7 * and is licensed under the *
8 * Common Public License, Version 1.0 *
9 * by AT&T Intellectual Property *
10 * *
11 * A copy of the License is available at *
12 * http://www.opensource.org/licenses/cpl1.0.txt *
13 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
14 * *
15 * Information and Software Systems Research *
16 * AT&T Research *
17 * Florham Park NJ *
18 * *
19 * Glenn Fowler <gsf@research.att.com> *
20 * David Korn <dgk@research.att.com> *
21 * *
22 ***********************************************************************/
25 * AT&T Research
27 * builtin cmd definitions
30 #ifndef _CMD_H
31 #if !defined(__PROTO__)
32 #include <prototyped.h>
33 #endif
34 #if !defined(__LINKAGE__)
35 #define __LINKAGE__ /* 2004-08-11 transition */
36 #endif
38 #define _CMD_H
40 #include <ast.h>
41 #include <error.h>
42 #include <stak.h>
43 #include <shcmd.h>
45 #define cmdinit _cmd_init
47 #define ERROR_CALLBACK ERROR_SET
49 #if _BLD_cmd && defined(__EXPORT__)
50 #undef __MANGLE__
51 #define __MANGLE__ __LINKAGE__ __EXPORT__
52 #endif
54 #include <cmdext.h>
56 #undef __MANGLE__
57 #define __MANGLE__ __LINKAGE__
59 #if defined(CMD_BUILTIN) && !defined(CMD_STANDALONE)
60 #define CMD_STANDALONE CMD_BUILTIN
61 #endif
63 #ifdef CMD_STANDALONE
65 #define CMD_CONTEXT(c) ((Shbltin_t*)0)
67 #if CMD_DYNAMIC
69 #include <dlldefs.h>
71 #else
73 extern __MANGLE__ int CMD_STANDALONE __PROTO__((int, char**, __V_*));
75 #endif
77 #ifndef CMD_BUILTIN
80 * command initialization
83 static int
84 cmdinit __PARAM__((int argc, register char** argv, __V_* context, const char* catalog, int flags), (argc, argv, context, catalog, flags)) __OTORP__(int argc; register char** argv; __V_* context; const char* catalog; int flags;){
85 register char* cp;
86 register char* pp;
88 if (cp = strrchr(argv[0], '/'))
89 cp++;
90 else
91 cp = argv[0];
92 if (pp = strrchr(cp, '_'))
93 cp = pp + 1;
94 error_info.id = cp;
95 if (!error_info.catalog)
96 error_info.catalog = (char*)catalog;
97 opt_info.index = 0;
98 if (context)
99 error_info.flags |= flags & ~(ERROR_CALLBACK|ERROR_NOTIFY);
100 return 0;
103 #endif
106 main __PARAM__((int argc, char** argv), (argc, argv)) __OTORP__(int argc; char** argv;){
107 #if CMD_DYNAMIC
108 register char* s;
109 register char* t;
110 __V_* dll;
111 Shbltin_f fun;
112 char buf[64];
114 if (s = strrchr(argv[0], '/'))
115 s++;
116 else if (!(s = argv[0]))
117 return 127;
118 if ((t = strrchr(s, '_')) && *++t)
119 s = t;
120 buf[0] = '_';
121 buf[1] = 'b';
122 buf[2] = '_';
123 strncpy(buf + 3, s, sizeof(buf) - 4);
124 buf[sizeof(buf) - 1] = 0;
125 if (t = strchr(buf, '.'))
126 *t = 0;
127 for (;;)
129 if (dll = dlopen(NiL, RTLD_LAZY))
131 if (fun = (Shbltin_f)dlsym(dll, buf + 1))
132 break;
133 if (fun = (Shbltin_f)dlsym(dll, buf))
134 break;
136 if (dll = dllplug(NiL, "cmd", NiL, RTLD_LAZY, NiL, 0))
138 if (fun = (Shbltin_f)dlsym(dll, buf + 1))
139 break;
140 if (fun = (Shbltin_f)dlsym(dll, buf))
141 break;
143 return 127;
145 return (*fun)(argc, argv, NiL);
146 #else
147 return CMD_STANDALONE(argc, argv, NiL);
148 #endif
151 #else
153 #undef cmdinit
154 #ifdef _MSC_VER
155 #define CMD_CONTEXT(p) ((Shbltin_t*)(p))
156 #define cmdinit(a,b,c,d,e) do{if(_cmd_init(a,b,c,d,e))return -1;}while(0)
157 #else
158 #define CMD_CONTEXT(p) (((p)&&((Shbltin_t*)(p))->version>=20071012&&((Shbltin_t*)(p))->version<20350101)?((Shbltin_t*)(p)):0)
159 #define cmdinit(a,b,c,d,e) do{if((c)&&!CMD_CONTEXT(c))c=0;if(_cmd_init(a,b,c,d,e))return -1;}while(0)
160 #endif
162 #if _BLD_cmd && defined(__EXPORT__)
163 #undef __MANGLE__
164 #define __MANGLE__ __LINKAGE__ __EXPORT__
165 #endif
167 extern __MANGLE__ int _cmd_init __PROTO__((int, char**, __V_*, const char*, int));
169 #undef __MANGLE__
170 #define __MANGLE__ __LINKAGE__
172 #endif
174 #endif