mkheaders.c (61523) | mkheaders.c (61640) |
---|---|
1/* 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)mkheaders.c 8.1 (Berkeley) 6/6/93"; 37#endif 38static const char rcsid[] = | 1/* 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)mkheaders.c 8.1 (Berkeley) 6/6/93"; 37#endif 38static const char rcsid[] = |
39 "$FreeBSD: head/usr.sbin/config/mkheaders.c 61523 2000-06-10 22:13:40Z peter $"; | 39 "$FreeBSD: head/usr.sbin/config/mkheaders.c 61640 2000-06-13 22:28:50Z peter $"; |
40#endif /* not lint */ 41 42/* 43 * Make all the .h files for the optional entries 44 */ 45 46#include <ctype.h> 47#include <err.h> 48#include <stdio.h> 49#include <string.h> 50#include "config.h" 51#include "y.tab.h" 52 | 40#endif /* not lint */ 41 42/* 43 * Make all the .h files for the optional entries 44 */ 45 46#include <ctype.h> 47#include <err.h> 48#include <stdio.h> 49#include <string.h> 50#include "config.h" 51#include "y.tab.h" 52 |
53static void do_header __P((char *, int)); 54static void do_count __P((char *)); 55static char *toheader __P((char *)); 56static char *tomacro __P((char *)); | 53static void do_header(char *, int); 54static void do_count(char *); 55static char *toheader(char *); 56static char *tomacro(char *); |
57 58void | 57 58void |
59headers() | 59headers(void) |
60{ | 60{ |
61 register struct file_list *fl; | 61 struct file_list *fl; |
62 struct device *dp; 63 64 for (fl = ftab; fl != 0; fl = fl->f_next) { 65 if (fl->f_needs != 0) { 66 for (dp = dtab; dp != 0; dp = dp->d_next) { 67 if (eq(dp->d_name, fl->f_needs)) { | 62 struct device *dp; 63 64 for (fl = ftab; fl != 0; fl = fl->f_next) { 65 if (fl->f_needs != 0) { 66 for (dp = dtab; dp != 0; dp = dp->d_next) { 67 if (eq(dp->d_name, fl->f_needs)) { |
68 if ((dp->d_type & TYPEMASK) == PSEUDO_DEVICE) | 68 if ((dp->d_type & TYPEMASK) == DEVICE) |
69 dp->d_type |= DEVDONE; | 69 dp->d_type |= DEVDONE; |
70 else if ((dp->d_type & TYPEMASK) == DEVICE) 71 dp->d_type |= DEVDONE; | |
72 } 73 } 74 if (fl->f_flags & NEED_COUNT) 75 do_count(fl->f_needs); 76 } 77 } 78 for (dp = dtab; dp != 0; dp = dp->d_next) { | 70 } 71 } 72 if (fl->f_flags & NEED_COUNT) 73 do_count(fl->f_needs); 74 } 75 } 76 for (dp = dtab; dp != 0; dp = dp->d_next) { |
79 if ((dp->d_type & TYPEMASK) == PSEUDO_DEVICE) { 80 if (!(dp->d_type & DEVDONE)) 81 printf("Warning: pseudo-device \"%s\" is unknown\n", 82 dp->d_name); 83 } | |
84 if ((dp->d_type & TYPEMASK) == DEVICE) { 85 if (!(dp->d_type & DEVDONE)) 86 printf("Warning: device \"%s\" is unknown\n", 87 dp->d_name); 88 } 89 } 90} 91 92/* 93 * count all the devices of a certain type and recurse to count 94 * whatever the device is connected to 95 */ 96static void | 77 if ((dp->d_type & TYPEMASK) == DEVICE) { 78 if (!(dp->d_type & DEVDONE)) 79 printf("Warning: device \"%s\" is unknown\n", 80 dp->d_name); 81 } 82 } 83} 84 85/* 86 * count all the devices of a certain type and recurse to count 87 * whatever the device is connected to 88 */ 89static void |
97do_count(dev) 98 register char *dev; | 90do_count(char *dev) |
99{ | 91{ |
100 register struct device *dp; 101 register int count, hicount; | 92 struct device *dp; 93 int count, hicount; |
102 103 /* 104 * After this loop, "count" will be the actual number of units, 105 * and "hicount" will be the highest unit declared. do_header() 106 * must use this higher of these values. 107 */ 108 for (hicount = count = 0, dp = dtab; dp != 0; dp = dp->d_next) { | 94 95 /* 96 * After this loop, "count" will be the actual number of units, 97 * and "hicount" will be the highest unit declared. do_header() 98 * must use this higher of these values. 99 */ 100 for (hicount = count = 0, dp = dtab; dp != 0; dp = dp->d_next) { |
109 if (dp->d_unit != -1 && eq(dp->d_name, dev)) { 110 if ((dp->d_type & TYPEMASK) == PSEUDO_DEVICE) { 111 count = 112 dp->d_count != UNKNOWN ? dp->d_count : 1; 113 break; 114 } 115 count++; 116 /* 117 * Allow holes in unit numbering, 118 * assumption is unit numbering starts 119 * at zero. 120 */ 121 if (dp->d_unit + 1 > hicount) 122 hicount = dp->d_unit + 1; | 101 if (eq(dp->d_name, dev)) { 102 count = 103 dp->d_count != UNKNOWN ? dp->d_count : 1; 104 break; |
123 } 124 } | 105 } 106 } |
125 do_header(dev, count > hicount ? count : hicount); | 107 do_header(dev, count); |
126} 127 128static void | 108} 109 110static void |
129do_header(dev, count) 130 char *dev; 131 int count; | 111do_header(char *dev, int count) |
132{ 133 char *file, *name, *inw; 134 struct file_list *fl, *fl_head, *tflp; 135 FILE *inf, *outf; 136 int inc, oldcount; 137 138 file = toheader(dev); 139 name = tomacro(dev); --- 62 unchanged lines hidden (view full) --- 202 } 203 (void) fclose(outf); 204} 205 206/* 207 * convert a dev name to a .h file name 208 */ 209static char * | 112{ 113 char *file, *name, *inw; 114 struct file_list *fl, *fl_head, *tflp; 115 FILE *inf, *outf; 116 int inc, oldcount; 117 118 file = toheader(dev); 119 name = tomacro(dev); --- 62 unchanged lines hidden (view full) --- 182 } 183 (void) fclose(outf); 184} 185 186/* 187 * convert a dev name to a .h file name 188 */ 189static char * |
210toheader(dev) 211 char *dev; | 190toheader(char *dev) |
212{ 213 static char hbuf[80]; 214 215 (void) strcpy(hbuf, path(dev)); 216 (void) strcat(hbuf, ".h"); 217 return (hbuf); 218} 219 220/* 221 * convert a dev name to a macro name 222 */ 223static char * | 191{ 192 static char hbuf[80]; 193 194 (void) strcpy(hbuf, path(dev)); 195 (void) strcat(hbuf, ".h"); 196 return (hbuf); 197} 198 199/* 200 * convert a dev name to a macro name 201 */ 202static char * |
224tomacro(dev) 225 register char *dev; | 203tomacro(char *dev) |
226{ 227 static char mbuf[20]; | 204{ 205 static char mbuf[20]; |
228 register char *cp; | 206 char *cp; |
229 230 cp = mbuf; 231 *cp++ = 'N'; 232 while (*dev) 233 *cp++ = islower(*dev) ? toupper(*dev++) : *dev++; 234 *cp++ = 0; 235 return (mbuf); 236} | 207 208 cp = mbuf; 209 *cp++ = 'N'; 210 while (*dev) 211 *cp++ = islower(*dev) ? toupper(*dev++) : *dev++; 212 *cp++ = 0; 213 return (mbuf); 214} |