* Copyright (c) 1980 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)mkheaders.c 5.5 (Berkeley) 6/18/88";
* Make all the .h files for the optional entries
register struct file_list
*fl
;
for (fl
= ftab
; fl
!= 0; fl
= fl
->f_next
)
do_count(fl
->f_needs
, fl
->f_needs
, 1);
* count all the devices of a certain type and recurse to count
* whatever the device is connected to
do_count(dev
, hname
, search
)
register char *dev
, *hname
;
register struct device
*dp
, *mp
;
for (count
= 0,dp
= dtab
; dp
!= 0; dp
= dp
->d_next
)
if (dp
->d_unit
!= -1 && eq(dp
->d_name
, dev
)) {
if (dp
->d_type
== PSEUDO_DEVICE
) {
dp
->d_slave
!= UNKNOWN
? dp
->d_slave
: 1;
* Allow holes in unit numbering,
* assumption is unit numbering starts
if (dp
->d_unit
+ 1 > count
)
if (mp
!= 0 && mp
!= TO_NEXUS
&&
mp
->d_conn
!= 0 && mp
->d_conn
!= TO_NEXUS
) {
do_count(mp
->d_name
, hname
, 0);
do_header(dev
, hname
, count
);
do_header(dev
, hname
, count
)
char *file
, *name
, *inw
, *toheader(), *tomacro();
struct file_list
*fl
, *fl_head
;
fprintf(outf
, "#define %s %d\n", name
, count
);
if ((inw
= get_word(inf
)) == 0 || inw
== (char *)EOF
)
if ((inw
= get_word(inf
)) == 0 || inw
== (char *)EOF
)
if (cp
== 0 || cp
== (char *)EOF
)
fl
= (struct file_list
*) malloc(sizeof *fl
);
for (fl
= fl_head
; fl
!= 0; fl
= fl
->f_next
)
fl
= (struct file_list
*) malloc(sizeof *fl
);
for (fl
= fl_head
; fl
!= 0; fl
= fl
->f_next
) {
fprintf(outf
, "#define %s %u\n",
fl
->f_fn
, count
? fl
->f_type
: 0);
* convert a dev name to a .h file name
(void) strcpy(hbuf
, path(dev
));
(void) strcat(hbuf
, ".h");
* convert a dev name to a macro name