xref: /titanic_44/usr/src/lib/libast/common/features/mode.c (revision 726fad2a65f16c200a03969c29cb5c86c2d427db)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1985-2010 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 *                   Phong Vo <kpv@research.att.com>                    *
20 *                                                                      *
21 ***********************************************************************/
22 #pragma prototyped
23 /*
24  * Glenn Fowler
25  * AT&T Research
26  *
27  * generate mode features
28  */
29 
30 #include "limits.h"
31 
32 #include "FEATURE/param"
33 
34 #include <modecanon.h>
35 
36 int
37 main()
38 {
39 	int	n;
40 	int	idperm;
41 	int	idtype;
42 
43 	idperm = idtype = 1;
44 #ifndef S_ITYPE
45 #ifdef	S_IFMT
46 	printf("#define S_ITYPE(m)	((m)&S_IFMT)\n");
47 #else
48 	printf("#define S_ITYPE(m)	((m)&~S_IPERM)\n");
49 #endif
50 #endif
51 #ifdef S_ISBLK
52 	if (!S_ISBLK(X_IFBLK)) idtype = 0;
53 #else
54 #ifdef S_IFBLK
55 	printf("#define S_ISBLK(m)	(S_ITYPE(m)==S_IFBLK)\n");
56 #else
57 	printf("#define S_ISBLK(m)	0\n");
58 #endif
59 #endif
60 #ifdef S_ISCHR
61 	if (!S_ISCHR(X_IFCHR)) idtype = 0;
62 #else
63 #ifdef S_IFCHR
64 	printf("#define S_ISCHR(m)	(S_ITYPE(m)==S_IFCHR)\n");
65 #else
66 	printf("#define S_ISCHR(m)	0\n");
67 #endif
68 #endif
69 #ifdef S_ISCTG
70 	if (!S_ISCTG(X_IFCTG)) idtype = 0;
71 #else
72 #ifdef S_IFCTG
73 	printf("#define S_ISCTG(m)	(S_ITYPE(m)==S_IFCTG)\n");
74 #endif
75 #endif
76 #ifdef S_ISDIR
77 	if (!S_ISDIR(X_IFDIR)) idtype = 0;
78 #else
79 #ifdef S_IFDIR
80 	printf("#define S_ISDIR(m)	(S_ITYPE(m)==S_IFDIR)\n");
81 #else
82 	printf("#define S_ISDIR(m)	0\n");
83 #endif
84 #endif
85 #ifdef S_ISFIFO
86 	if (!S_ISFIFO(X_IFIFO)) idtype = 0;
87 #else
88 #ifdef S_IFIFO
89 	printf("#define S_ISFIFO(m)	(S_ITYPE(m)==S_IFIFO)\n");
90 #else
91 	printf("#define S_ISFIFO(m)	0\n");
92 #endif
93 #endif
94 #ifdef S_ISLNK
95 	if (!S_ISLNK(X_IFLNK)) idtype = 0;
96 #else
97 #ifdef S_IFLNK
98 	printf("#define S_ISLNK(m)	(S_ITYPE(m)==S_IFLNK)\n");
99 #else
100 	printf("#define S_ISLNK(m)	0\n");
101 #endif
102 #endif
103 #ifdef S_ISREG
104 	if (!S_ISREG(X_IFREG)) idtype = 0;
105 #else
106 #ifdef S_IFREG
107 	printf("#define S_ISREG(m)	(S_ITYPE(m)==S_IFREG)\n");
108 #else
109 	printf("#define S_ISREG(m)	0\n");
110 #endif
111 #endif
112 #ifdef S_ISSOCK
113 	if (!S_ISSOCK(X_IFSOCK)) idtype = 0;
114 #else
115 #ifdef S_IFSOCK
116 	printf("#define S_ISSOCK(m)	(S_ITYPE(m)==S_IFSOCK)\n");
117 #endif
118 #endif
119 	printf("\n");
120 #ifndef S_IPERM
121 	printf("#define S_IPERM		(S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)\n");
122 #endif
123 #ifndef S_ISUID
124 	printf("#define S_ISUID		0%04o\n", X_ISUID);
125 #else
126 	if (S_ISUID != X_ISUID) idperm = 0;
127 #endif
128 #ifndef S_ISGID
129 	printf("#define S_ISGID		0%04o\n", X_ISGID);
130 #else
131 	if (S_ISGID != X_ISGID) idperm = 0;
132 #endif
133 #ifndef S_ISVTX
134 	printf("#define S_ISVTX		0%04o\n", X_ISVTX);
135 #else
136 	if (S_ISVTX != X_ISVTX) idperm = 0;
137 #endif
138 #ifndef S_IRUSR
139 	printf("#define S_IRUSR		0%04o\n", X_IRUSR);
140 #else
141 	if (S_IRUSR != X_IRUSR) idperm = 0;
142 #endif
143 #ifndef S_IWUSR
144 	printf("#define S_IWUSR		0%04o\n", X_IWUSR);
145 #else
146 	if (S_IWUSR != X_IWUSR) idperm = 0;
147 #endif
148 #ifndef S_IXUSR
149 	printf("#define S_IXUSR		0%04o\n", X_IXUSR);
150 #else
151 	if (S_IXUSR != X_IXUSR) idperm = 0;
152 #endif
153 #ifndef S_IRGRP
154 	printf("#define S_IRGRP		0%04o\n", X_IRGRP);
155 #else
156 	if (S_IRGRP != X_IRGRP) idperm = 0;
157 #endif
158 #ifndef S_IWGRP
159 	printf("#define S_IWGRP		0%04o\n", X_IWGRP);
160 #else
161 	if (S_IWGRP != X_IWGRP) idperm = 0;
162 #endif
163 #ifndef S_IXGRP
164 	printf("#define S_IXGRP		0%04o\n", X_IXGRP);
165 #else
166 	if (S_IXGRP != X_IXGRP) idperm = 0;
167 #endif
168 #ifndef S_IROTH
169 	printf("#define S_IROTH		0%04o\n", X_IROTH);
170 #else
171 	if (S_IROTH != X_IROTH) idperm = 0;
172 #endif
173 #ifndef S_IWOTH
174 	printf("#define S_IWOTH		0%04o\n", X_IWOTH);
175 #else
176 	if (S_IWOTH != X_IWOTH) idperm = 0;
177 #endif
178 #ifndef S_IXOTH
179 	printf("#define S_IXOTH		0%04o\n", X_IXOTH);
180 #else
181 	if (S_IXOTH != X_IXOTH) idperm = 0;
182 #endif
183 #ifndef S_IRWXU
184 	printf("#define S_IRWXU		(S_IRUSR|S_IWUSR|S_IXUSR)\n");
185 #endif
186 #ifndef S_IRWXG
187 	printf("#define S_IRWXG		(S_IRGRP|S_IWGRP|S_IXGRP)\n");
188 #endif
189 #ifndef S_IRWXO
190 	printf("#define S_IRWXO		(S_IROTH|S_IWOTH|S_IXOTH)\n");
191 #endif
192 	printf("\n");
193 	if (idperm) printf("#define _S_IDPERM	1\n");
194 	if (idtype) printf("#define _S_IDTYPE	1\n");
195 	printf("\n");
196 #ifdef BUFFERSIZE
197 	n = BUFFERSIZE;
198 #else
199 #ifdef MAXBSIZE
200 	n = MAXBSIZE;
201 #else
202 #ifdef SBUFSIZE
203 	n = SBUFSIZE;
204 #else
205 #ifdef BUFSIZ
206 	n = BUFSIZ;
207 #else
208 	if (sizeof(char*) > 4) n = 8192;
209 	else if (sizeof(char*) < 4) n = 512;
210 	else n = 4096;
211 #endif
212 #endif
213 #endif
214 #endif
215 	printf("#define BUFFERSIZE	%u\n", n);
216 	printf("\n");
217 	return 0;
218 }
219