|
|
1.1 root 1: :
2: #
3: # mkhdr hdr [ genhdr ] [ cc [ ccflags ] ]
4: #
5: # @(#)mkhdr (ulysses!gsf) 01/31/91
6: #
7: case $# in
8: 0) echo "Usage: $0 hdr [ genhdr ] [ cc [ ccflags ] ]" >&2; exit 1 ;;
9: esac
10: hdr=$1
11: shift
12: case $1 in
13: "") genhdr= ;;
14: *) genhdr=$1 ;;
15: esac
16: case $# in
17: 0) ;;
18: *) shift ;;
19: esac
20: cc=${1-cc}
21: case $# in
22: 0) ;;
23: *) shift ;;
24: esac
25: tmp=x.$$
26: trap 'code=$?; rm -f $tmp.?; exit $code' 0 1 2 3
27: case $hdr in
28: align) case $genhdr in
29: "") echo "$0: $hdr: genhdr arg required" >&2; exit 1 ;;
30: esac
31: cat <<!
32: /*
33: * AT&T Bell Laboratories
34: * alignment and pointer pun definitions
35: * : : generated by $0 and $genhdr : :
36: */
37:
38: #ifndef __ALIGN_H__
39: #define __ALIGN_H__
40:
41: !
42: $genhdr $hdr || exit 1
43: cat <<!
44: #endif
45: !
46: ;;
47: dirent) case $genhdr in
48: "") echo "$0: $hdr: genhdr arg required" >&2; exit 1 ;;
49: esac
50: cat<<!
51: /*
52: * AT&T Bell Laboratories
53: * directory stream access definitions
54: *
55: * #include <sys/types.h>
56: * #include <dirent.h>
57: *
58: * : : generated by $0 and $genhdr : :
59: */
60:
61: #ifndef __DIRENT_H__
62:
63: #include <lcldirent.h>
64:
65: #ifndef __DIRENT_H__
66: #define __DIRENT_H__
67: #endif
68:
69: !
70: $genhdr $hdr || exit 1
71: for i in "" "#ifndef d_ino
72: #define d_ino d_fileno
73: #endif" "#ifndef d_fileno
74: #define d_fileno d_ino
75: #endif"
76: do cat > $tmp.c <<!
77: #include <sys/types.h>
78: #include <lcldirent.h>
79: #ifdef _lcl_dirent
80: static struct dirent dir;
81: #else
82: #include <sys/dir.h>
83: static struct direct dir;
84: #endif
85: $i
86: int n1 = sizeof(dir.d_ino);
87: int n2 = sizeof(dir.d_fileno);
88: !
89: if $cc -I. ${1+"$@"} -c $tmp.c >/dev/null 2>&1
90: then break
91: fi
92: done
93: nl=
94: case $i in
95: ?*) nl=1
96: echo "$i"
97: ;;
98: esac
99: cat > $tmp.c <<!
100: #include <sys/types.h>
101: #include <lcldirent.h>
102: #ifdef _lcl_dirent
103: static struct dirent dir;
104: #else
105: #include <sys/dir.h>
106: static struct direct dir;
107: #endif
108: int n1 = sizeof(dir.d_namlen);
109: !
110: if $cc -I. ${1+"$@"} -c $tmp.c >/dev/null 2>&1
111: then nl=1
112: echo "#define _dir_namlen 1 /* dirent.d_namlen */"
113: fi
114: case $nl in
115: ?*) echo ;;
116: esac
117: cat <<!
118: #ifndef _lcl_dirent
119:
120: #ifdef _dir_sys
121:
122: #include <sys/dir.h>
123:
124: #else
125:
126: #undef _dir_rewinddir
127:
128: #define DIRSIZ 14
129:
130: struct direct
131: {
132: short d_ino;
133: char d_name[DIRSIZ];
134: };
135:
136: #endif
137:
138: #ifdef _dir_rewinddir
139:
140: /*
141: * variable length directory entry format
142: */
143:
144: #define _dir_variable
145:
146: #ifndef dirent
147: #define dirent direct
148: #endif
149:
150: #else
151:
152: /*
153: * fixed length directory entry format
154: */
155:
156: #define _dir_fixed
157:
158: #ifndef DIRSIZ
159: #define DIRSIZ 14 /* maximum entry link length */
160: #endif
161:
162: #ifndef MAXNAMLEN
163: #define MAXNAMLEN DIRSIZ /* maximum filename length */
164: #endif
165:
166: #ifdef _dir_getdents
167:
168: struct dirent /* data from local getdents() */
169: {
170: long d_ino; /* file number of entry */
171: long d_off; /* entry seek offset */
172: unsigned short d_reclen; /* length of this record */
173: char d_name[1]; /* link name */
174: };
175:
176: #else
177:
178: #ifndef _dir_namlen
179: #define _dir_namlen 1
180: #endif
181:
182: struct dirent /* data from readdir() */
183: {
184: long d_fileno; /* file number of entry */
185: unsigned short d_reclen; /* length of this record */
186: unsigned short d_namlen; /* strlen(d_name) */
187: char d_name[1]; /* link name */
188: };
189:
190: #endif
191:
192: typedef struct
193: {
194: int dd_fd; /* file descriptor */
195: int dd_loc; /* offset in block */
196: int dd_size; /* amount of valid data */
197: char* dd_buf; /* directory block */
198: } DIR; /* stream data from opendir() */
199:
200: extern DIR* opendir();
201: extern struct dirent* readdir();
202: extern long telldir();
203: extern void seekdir();
204: extern void closedir();
205:
206: #if !_dir_local
207: #define rewinddir(dirp) seekdir(dirp,0L)
208: #endif
209:
210: #endif
211:
212: #endif
213:
214: #if _dir_namlen
215: #define DIRNAMLEN(d) ((d)->d_namlen)
216: #else
217: #define DIRNAMLEN(d) strlen((d)->d_name)
218: #endif
219:
220: #endif
221: !
222: ;;
223: fsinfo) case $genhdr in
224: "") echo "$0: $hdr: genhdr arg required" >&2; exit 1 ;;
225: esac
226: cat <<!
227: /*
228: * AT&T Bell Laboratories
229: * file system user interface definitions
230: * : : generated by $0 and $genhdr : :
231: */
232:
233: #ifndef __FSINFO_H__
234: #define __FSINFO_H__
235:
236: #ifndef __LCLPARAM_H__
237: #ifndef S_IFMT
238: #ifndef TM_DEFAULT
239: #include <sys/types.h>
240: #endif
241: #include <sys/stat.h>
242: #endif
243: #endif
244: !
245: nl=
246: for i in blocks blksize
247: do cat > $tmp.c <<!
248: #include <sys/types.h>
249: #include <sys/stat.h>
250: static struct stat st;
251: int bytes = sizeof(st.st_$i);
252: !
253: if $cc ${1+"$@"} -c $tmp.c >/dev/null 2>&1
254: then case $nl in
255: "") nl=1
256: echo
257: ;;
258: esac
259: echo "#define stat_$i 1 /* struct stat has st_$i */"
260: fi
261: done
262: cat > $tmp.c <<!
263: #include <sys/types.h>
264: #include <sys/stat.h>
265: #ifndef major
266: #include <sys/param.h>
267: #ifndef major
268: #include <sys/sysmacros.h>
269: #endif
270: "#ifndef major" =
271: #ifdef major
272: "#define major(x)" = major((x))
273: #else
274: "#define major(x)" = ((int)(((unsigned)(x)>>8)&0377))
275: #endif
276: "#endif" =
277: "#ifndef minor" =
278: #ifdef minor
279: "#define minor(x)" = minor((x))
280: #else
281: "#define minor(x)" = ((int)((x)&0377))
282: #endif
283: "#endif" =
284: "#ifndef makedev" =
285: #ifdef makedev
286: "#define makedev(x,y)" = makedev((x),(y))
287: #else
288: "#define makedev(x,y)" = ((dev_t)((((x)&0377)<<8)|((y)&0377)))
289: #endif
290: "#endif" =
291: #endif
292: !
293: if $cc ${1+"$@"} -E $tmp.c > $tmp.i 2>/dev/null
294: then sed -e '/"#/!d' -e 's/.*#/#/' -e 's/"[^=]*=//' $tmp.i
295: else cat <<!
296:
297: #ifndef major
298: #define major(x) ((int)(((unsigned)(x)>>8)&0377))
299: #endif
300: #ifndef minor
301: #define minor(x) ((int)((x)&0377))
302: #endif
303: #ifndef makedev
304: #define makedev(x,y) ((dev_t)((((x)&0377)<<8)|((y)&0377)))
305: #endif
306: !
307: fi
308: echo
309: $genhdr $hdr || exit 1
310: cat <<!
311: #endif
312: !
313: ;;
314: lclparam)
315: HDR=LCLPARAM
316: cat <<!
317: /*
318: * AT&T Bell Laboratories
319: * <sys/param.h> + <sys/types.h> + <sys/stat.h>
320: * : : generated by $0 : :
321: */
322:
323: #ifndef __${HDR}_H__
324: #define __${HDR}_H__
325:
326: !
327: for i in "#include <sys/param.h>" "#include <sys/param.h>
328: #ifndef S_IFDIR
329: #include <sys/stat.h>
330: #endif" "#include <sys/param.h>
331: #ifndef S_IFDIR
332: #include <sys/types.h>
333: #include <sys/stat.h>
334: #endif" "#ifndef S_IFDIR
335: #include <sys/types.h>
336: #include <sys/stat.h>
337: #endif"
338: do echo "$i
339: struct stat V_stat_V;
340: F_stat_F() { V_stat_V.st_mode = 0; }" > $tmp.c
341: if $cc ${1+"$@"} -c $tmp.c >/dev/null 2>&1
342: then echo "$i"
343: break
344: fi
345: done
346: cat <<!
347:
348: #endif
349: !
350: ;;
351: lcl*) lcl=`echo $hdr | sed -e 's/lcl//'`
352: HDR=`echo $hdr | tr '[a-z]' '[A-Z]'`
353: cat <<!
354: /*
355: * AT&T Bell Laboratories
356: * untrusted local <$lcl.h>
357: * : : generated by $0 : :
358: */
359:
360: #ifndef __${HDR}_H__
361: #define __${HDR}_H__
362:
363: !
364: echo "#include <$lcl.h>" > $tmp.c
365: if $cc ${1+"$@"} -E $tmp.c > $tmp.i 2>/dev/null
366: then f=`sed -e '/^#[line ]*1[ ][ ]*"\/.*\/'$lcl'\.h"/!d' -e '/\/sys\/'$lcl'\.h"/d' -e s'/.*"\(.*\)".*/\1/' $tmp.i`
367: else f=
368: fi
369: case $lcl in
370: dirent) case $f in
371: "") h=sys/dir ;;
372: *) h=dirent ;;
373: esac
374: v=
375: for i in DIR opendir readdir rewinddir seekdir telldir closedir
376: do cat > $tmp.c <<!
377: #include <sys/types.h>
378: #include <$h.h>
379: #ifndef $i
380: (
381: #endif
382: !
383: if $cc ${1+"$@"} -c $tmp.c >/dev/null 2>&1
384: then v="$v $i"
385: fi
386: done
387: case $v in
388: ?*) echo "#if _dir_local"
389: for i in $v
390: do echo "#undef $i"
391: done
392: echo "#endif"
393: ;;
394: esac
395: ;;
396: esac
397: case $f in
398: "") echo "/* no local <$lcl.h> */"
399: ;;
400: *) echo "/* begin local <$lcl.h> */"
401: cat $f
402: cat <<!
403: /* end local <$lcl.h> */
404:
405: #undef _lcl_$lcl
406: #define _lcl_$lcl 1
407: !
408: ;;
409: esac
410: cat <<!
411:
412: #endif
413: !
414: ;;
415: limits) case $genhdr in
416: "") echo "$0: $hdr: genhdr arg required" >&2; exit 1 ;;
417: esac
418: cat <<!
419: /*
420: * AT&T Bell Laboratories
421: * C language implementation integral type sizes
422: * : : generated by $0 and $genhdr : :
423: */
424:
425: #ifndef __LIMITS_H__
426:
427: #include <lcllimits.h>
428:
429: #ifndef __LIMITS_H__
430: #define __LIMITS_H__
431: #endif
432:
433: !
434: $genhdr $hdr || exit 1
435: cat <<!
436: #endif
437: !
438: ;;
439: preroot)cat <<!
440: /*
441: * AT&T Bell Laboratories
442: * preroot interface definitions
443: * : : generated by $0 : :
444: */
445:
446: #ifndef __PREROOT_H__
447: #define __PREROOT_H__
448:
449: !
450: if (/etc/preroot / /bin/echo) >/dev/null 2>&1
451: then cat <<!
452: #define FS_PREROOT 1 /* preroot enabled */
453: #define PR_BASE "CCS" /* preroot base env var */
454: #define PR_COMMAND "/etc/preroot" /* the preroot command */
455: #define PR_REAL "/dev/.." /* real root pathname */
456: #define PR_SILENT "CCSQUIET" /* no command trace */
457:
458: #if __STDC__ || __cplusplus || c_plusplus
459: #if __cplusplus
460: extern "C" {
461: #endif
462:
463: extern char* getpreroot(char* path, char* cmd);
464: extern int ispreroot();
465: extern int realopen(char* path, int mode, int perm);
466: extern void setpreroot(int argc, char** argv, char* dir);
467:
468: #if __cplusplus
469: }
470: #endif
471:
472: #else
473:
474: extern char* getpreroot();
475: extern int ispreroot();
476: extern int realopen();
477: extern void setpreroot();
478:
479: #endif
480: !
481: else echo "/* preroot not enabled */"
482: fi
483: cat <<!
484:
485: #endif
486: !
487: ;;
488: sig) cat <<!
489: /*
490: * AT&T Bell Laboratories
491: * signal support
492: * : : generated by $0 : :
493: */
494:
495: #ifndef __SIG_H__
496: #define __SIG_H__
497:
498: #include <signal.h>
499:
500: #ifndef sigmask
501: #define sigmask(s) (1<<((s)-1))
502: #endif
503:
504: !
505: cat > $tmp.c <<!
506: #include <signal.h>
507: #ifdef TYPE
508: #if __STDC__
509: typedef TYPE (*signal_t)(int);
510: #else
511: typedef TYPE (*signal_t)();
512: #endif
513: #endif
514: signal_t f()
515: {
516: signal_t handler;
517: handler = signal(1, SIG_IGN);
518: return(handler);
519: }
520: !
521: if $cc ${1+"$@"} -c $tmp.c >/dev/null 2>&1
522: then :
523: else for i in void int
524: do $cc ${1+"$@"} -c -DTYPE=$i $tmp.c >/dev/null 2>&1 && break
525: done
526: cat <<!
527: #if __STDC__
528: typedef $i (*signal_t)(int);
529: #else
530: typedef $i (*signal_t)();
531: #endif
532:
533: !
534: fi
535: cat <<!
536: #endif
537: !
538: ;;
539: sigdata)case $genhdr in
540: "") echo "$0: $hdr: genhdr arg required" >&2; exit 1 ;;
541: esac
542: cat <<!
543: /*
544: * AT&T Bell Laboratories
545: * signal name/text tables
546: * : : generated by $0 and $genhdr : :
547: */
548:
549: !
550: $genhdr $hdr || exit 1
551: ;;
552: ttyinfo)
553: HDR=TTYINFO
554: cat <<!
555: /*
556: * AT&T Bell Laboratories
557: * tty info
558: * : : generated by $0 : :
559: */
560:
561: #ifndef __${HDR}_H__
562: #define __${HDR}_H__
563:
564: !
565: x="/* no local tty info */"
566: for i in sgtty termio termios sys/termios sys/ttyio sys/ioctl
567: do echo "#include <$i.h>" > $tmp.c
568: if $cc ${1+"$@"} -c $tmp.c >/dev/null 2>&1
569: then x="#include <$i.h>"
570: break
571: fi
572: done
573: cat <<!
574: $x
575:
576: #endif
577: !
578: ;;
579: *) echo "$0: $hdr: unknown header" >&2
580: exit 1
581: ;;
582: esac
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.