summaryrefslogtreecommitdiff
path: root/usr/src/lib/libast/common/features/mode.c
blob: ea82970e78721f80ddf91de6e613a12a105f5949 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/***********************************************************************
*                                                                      *
*               This software is part of the ast package               *
*          Copyright (c) 1985-2009 AT&T Intellectual Property          *
*                      and is licensed under the                       *
*                  Common Public License, Version 1.0                  *
*                    by AT&T Intellectual Property                     *
*                                                                      *
*                A copy of the License is available at                 *
*            http://www.opensource.org/licenses/cpl1.0.txt             *
*         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
*                                                                      *
*              Information and Software Systems Research               *
*                            AT&T Research                             *
*                           Florham Park NJ                            *
*                                                                      *
*                 Glenn Fowler <gsf@research.att.com>                  *
*                  David Korn <dgk@research.att.com>                   *
*                   Phong Vo <kpv@research.att.com>                    *
*                                                                      *
***********************************************************************/
#pragma prototyped
/*
 * Glenn Fowler
 * AT&T Research
 *
 * generate mode features
 */

#include "limits.h"

#include "FEATURE/param"

#include <modecanon.h>

int
main()
{
	int	n;
	int	idperm;
	int	idtype;

	idperm = idtype = 1;
#ifndef S_ITYPE
#ifdef	S_IFMT
	printf("#define S_ITYPE(m)	((m)&S_IFMT)\n");
#else
	printf("#define S_ITYPE(m)	((m)&~S_IPERM)\n");
#endif
#endif
#ifdef S_ISBLK
	if (!S_ISBLK(X_IFBLK)) idtype = 0;
#else
#ifdef S_IFBLK
	printf("#define S_ISBLK(m)	(S_ITYPE(m)==S_IFBLK)\n");
#else
	printf("#define S_ISBLK(m)	0\n");
#endif
#endif
#ifdef S_ISCHR
	if (!S_ISCHR(X_IFCHR)) idtype = 0;
#else
#ifdef S_IFCHR
	printf("#define S_ISCHR(m)	(S_ITYPE(m)==S_IFCHR)\n");
#else
	printf("#define S_ISCHR(m)	0\n");
#endif
#endif
#ifdef S_ISCTG
	if (!S_ISCTG(X_IFCTG)) idtype = 0;
#else
#ifdef S_IFCTG
	printf("#define S_ISCTG(m)	(S_ITYPE(m)==S_IFCTG)\n");
#endif
#endif
#ifdef S_ISDIR
	if (!S_ISDIR(X_IFDIR)) idtype = 0;
#else
#ifdef S_IFDIR
	printf("#define S_ISDIR(m)	(S_ITYPE(m)==S_IFDIR)\n");
#else
	printf("#define S_ISDIR(m)	0\n");
#endif
#endif
#ifdef S_ISFIFO
	if (!S_ISFIFO(X_IFIFO)) idtype = 0;
#else
#ifdef S_IFIFO
	printf("#define S_ISFIFO(m)	(S_ITYPE(m)==S_IFIFO)\n");
#else
	printf("#define S_ISFIFO(m)	0\n");
#endif
#endif
#ifdef S_ISLNK
	if (!S_ISLNK(X_IFLNK)) idtype = 0;
#else
#ifdef S_IFLNK
	printf("#define S_ISLNK(m)	(S_ITYPE(m)==S_IFLNK)\n");
#else
	printf("#define S_ISLNK(m)	0\n");
#endif
#endif
#ifdef S_ISREG
	if (!S_ISREG(X_IFREG)) idtype = 0;
#else
#ifdef S_IFREG
	printf("#define S_ISREG(m)	(S_ITYPE(m)==S_IFREG)\n");
#else
	printf("#define S_ISREG(m)	0\n");
#endif
#endif
#ifdef S_ISSOCK
	if (!S_ISSOCK(X_IFSOCK)) idtype = 0;
#else
#ifdef S_IFSOCK
	printf("#define S_ISSOCK(m)	(S_ITYPE(m)==S_IFSOCK)\n");
#endif
#endif
	printf("\n");
#ifndef S_IPERM
	printf("#define S_IPERM		(S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)\n");
#endif
#ifndef S_ISUID
	printf("#define S_ISUID		0%04o\n", X_ISUID);
#else
	if (S_ISUID != X_ISUID) idperm = 0;
#endif
#ifndef S_ISGID
	printf("#define S_ISGID		0%04o\n", X_ISGID);
#else
	if (S_ISGID != X_ISGID) idperm = 0;
#endif
#ifndef S_ISVTX
	printf("#define S_ISVTX		0%04o\n", X_ISVTX);
#else
	if (S_ISVTX != X_ISVTX) idperm = 0;
#endif
#ifndef S_IRUSR
	printf("#define S_IRUSR		0%04o\n", X_IRUSR);
#else
	if (S_IRUSR != X_IRUSR) idperm = 0;
#endif
#ifndef S_IWUSR
	printf("#define S_IWUSR		0%04o\n", X_IWUSR);
#else
	if (S_IWUSR != X_IWUSR) idperm = 0;
#endif
#ifndef S_IXUSR
	printf("#define S_IXUSR		0%04o\n", X_IXUSR);
#else
	if (S_IXUSR != X_IXUSR) idperm = 0;
#endif
#ifndef S_IRGRP
	printf("#define S_IRGRP		0%04o\n", X_IRGRP);
#else
	if (S_IRGRP != X_IRGRP) idperm = 0;
#endif
#ifndef S_IWGRP
	printf("#define S_IWGRP		0%04o\n", X_IWGRP);
#else
	if (S_IWGRP != X_IWGRP) idperm = 0;
#endif
#ifndef S_IXGRP
	printf("#define S_IXGRP		0%04o\n", X_IXGRP);
#else
	if (S_IXGRP != X_IXGRP) idperm = 0;
#endif
#ifndef S_IROTH
	printf("#define S_IROTH		0%04o\n", X_IROTH);
#else
	if (S_IROTH != X_IROTH) idperm = 0;
#endif
#ifndef S_IWOTH
	printf("#define S_IWOTH		0%04o\n", X_IWOTH);
#else
	if (S_IWOTH != X_IWOTH) idperm = 0;
#endif
#ifndef S_IXOTH
	printf("#define S_IXOTH		0%04o\n", X_IXOTH);
#else
	if (S_IXOTH != X_IXOTH) idperm = 0;
#endif
#ifndef S_IRWXU
	printf("#define S_IRWXU		(S_IRUSR|S_IWUSR|S_IXUSR)\n");
#endif
#ifndef S_IRWXG
	printf("#define S_IRWXG		(S_IRGRP|S_IWGRP|S_IXGRP)\n");
#endif
#ifndef S_IRWXO
	printf("#define S_IRWXO		(S_IROTH|S_IWOTH|S_IXOTH)\n");
#endif
	printf("\n");
	if (idperm) printf("#define _S_IDPERM	1\n");
	if (idtype) printf("#define _S_IDTYPE	1\n");
	printf("\n");
#ifdef BUFFERSIZE
	n = BUFFERSIZE;
#else
#ifdef MAXBSIZE
	n = MAXBSIZE;
#else
#ifdef SBUFSIZE
	n = SBUFSIZE;
#else
#ifdef BUFSIZ
	n = BUFSIZ;
#else
	if (sizeof(char*) > 4) n = 8192;
	else if (sizeof(char*) < 4) n = 512;
	else n = 4096;
#endif
#endif
#endif
#endif
	printf("#define BUFFERSIZE	%u\n", n);
	printf("\n");
	return 0;
}