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