main.c (61523) | main.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 --- 28 unchanged lines hidden (view full) --- 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41#if 0 42static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; 43#endif 44static 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 --- 28 unchanged lines hidden (view full) --- 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41#if 0 42static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; 43#endif 44static const char rcsid[] = |
45 "$FreeBSD: head/usr.sbin/config/main.c 61523 2000-06-10 22:13:40Z peter $"; | 45 "$FreeBSD: head/usr.sbin/config/main.c 61640 2000-06-13 22:28:50Z peter $"; |
46#endif /* not lint */ 47 48#include <sys/types.h> 49#include <sys/stat.h> 50#include <sys/file.h> 51#include <sys/mman.h> 52#include <sys/param.h> 53#include <ctype.h> --- 17 unchanged lines hidden (view full) --- 71char * PREFIX; 72char destdir[MAXPATHLEN]; 73char srcdir[MAXPATHLEN]; 74 75static int no_config_clobber = TRUE; 76int debugging; 77int profiling; 78 | 46#endif /* not lint */ 47 48#include <sys/types.h> 49#include <sys/stat.h> 50#include <sys/file.h> 51#include <sys/mman.h> 52#include <sys/param.h> 53#include <ctype.h> --- 17 unchanged lines hidden (view full) --- 71char * PREFIX; 72char destdir[MAXPATHLEN]; 73char srcdir[MAXPATHLEN]; 74 75static int no_config_clobber = TRUE; 76int debugging; 77int profiling; 78 |
79static void configfile __P((void)); 80static void get_srcdir __P((void)); 81static void usage __P((void)); | 79static void configfile(void); 80static void get_srcdir(void); 81static void usage(void); |
82 83/* 84 * Config builds a set of files for building a UNIX 85 * system given a description of the desired system. 86 */ 87int | 82 83/* 84 * Config builds a set of files for building a UNIX 85 * system given a description of the desired system. 86 */ 87int |
88main(argc, argv) 89 int argc; 90 char **argv; | 88main(int argc, char **argv) |
91{ 92 93 struct stat buf; 94 int ch, len; 95 char *p; 96 97 while ((ch = getopt(argc, argv, "d:gprn")) != -1) 98 switch (ch) { --- 66 unchanged lines hidden (view full) --- 165 dtab = NULL; 166 if (yyparse()) 167 exit(3); 168 switch (machine) { 169 170 case MACHINE_I386: 171 case MACHINE_PC98: 172 case MACHINE_ALPHA: | 89{ 90 91 struct stat buf; 92 int ch, len; 93 char *p; 94 95 while ((ch = getopt(argc, argv, "d:gprn")) != -1) 96 switch (ch) { --- 66 unchanged lines hidden (view full) --- 163 dtab = NULL; 164 if (yyparse()) 165 exit(3); 166 switch (machine) { 167 168 case MACHINE_I386: 169 case MACHINE_PC98: 170 case MACHINE_ALPHA: |
173 newbus_ioconf(); /* Print ioconf.c */ | |
174 break; 175 176 default: 177 printf("Specify machine type, e.g. ``machine i386''\n"); 178 exit(1); 179 } 180 /* 181 * make symbolic links in compilation directory --- 19 unchanged lines hidden (view full) --- 201} 202 203/* 204 * get_srcdir 205 * determine the root of the kernel source tree 206 * and save that in srcdir. 207 */ 208static void | 171 break; 172 173 default: 174 printf("Specify machine type, e.g. ``machine i386''\n"); 175 exit(1); 176 } 177 /* 178 * make symbolic links in compilation directory --- 19 unchanged lines hidden (view full) --- 198} 199 200/* 201 * get_srcdir 202 * determine the root of the kernel source tree 203 * and save that in srcdir. 204 */ 205static void |
209get_srcdir() | 206get_srcdir(void) |
210{ 211 int i; 212 char *p; 213 214 (void)getcwd(srcdir, sizeof(srcdir)); 215 for (i = 0; i < 2; i++) { 216 p = strrchr(srcdir, '/'); 217 if (p != NULL) 218 *p = '\0'; 219 } 220 221 /* Sanity check */ 222 p = strrchr(srcdir, '/'); 223 if (p == NULL || strcmp(p + 1, "sys")) 224 errx(2, "non-standard kernel source tree"); 225} 226 227static void | 207{ 208 int i; 209 char *p; 210 211 (void)getcwd(srcdir, sizeof(srcdir)); 212 for (i = 0; i < 2; i++) { 213 p = strrchr(srcdir, '/'); 214 if (p != NULL) 215 *p = '\0'; 216 } 217 218 /* Sanity check */ 219 p = strrchr(srcdir, '/'); 220 if (p == NULL || strcmp(p + 1, "sys")) 221 errx(2, "non-standard kernel source tree"); 222} 223 224static void |
228usage() | 225usage(void) |
229{ 230 fprintf(stderr, "usage: config [-gpr] [-d destdir] sysname\n"); 231 exit(1); 232} 233 234/* 235 * get_word 236 * returns EOF on end of file 237 * NULL on end of line 238 * pointer to the word otherwise 239 */ 240char * | 226{ 227 fprintf(stderr, "usage: config [-gpr] [-d destdir] sysname\n"); 228 exit(1); 229} 230 231/* 232 * get_word 233 * returns EOF on end of file 234 * NULL on end of line 235 * pointer to the word otherwise 236 */ 237char * |
241get_word(fp) 242 register FILE *fp; | 238get_word(FILE *fp) |
243{ 244 static char line[80]; | 239{ 240 static char line[80]; |
245 register int ch; 246 register char *cp; | 241 int ch; 242 char *cp; |
247 int escaped_nl = 0; 248 249begin: 250 while ((ch = getc(fp)) != EOF) 251 if (ch != ' ' && ch != '\t') 252 break; 253 if (ch == EOF) 254 return ((char *)EOF); --- 24 unchanged lines hidden (view full) --- 279} 280 281/* 282 * get_quoted_word 283 * like get_word but will accept something in double or single quotes 284 * (to allow embedded spaces). 285 */ 286char * | 243 int escaped_nl = 0; 244 245begin: 246 while ((ch = getc(fp)) != EOF) 247 if (ch != ' ' && ch != '\t') 248 break; 249 if (ch == EOF) 250 return ((char *)EOF); --- 24 unchanged lines hidden (view full) --- 275} 276 277/* 278 * get_quoted_word 279 * like get_word but will accept something in double or single quotes 280 * (to allow embedded spaces). 281 */ 282char * |
287get_quoted_word(fp) 288 register FILE *fp; | 283get_quoted_word(FILE *fp) |
289{ 290 static char line[256]; | 284{ 285 static char line[256]; |
291 register int ch; 292 register char *cp; | 286 int ch; 287 char *cp; |
293 int escaped_nl = 0; 294 295begin: 296 while ((ch = getc(fp)) != EOF) 297 if (ch != ' ' && ch != '\t') 298 break; 299 if (ch == EOF) 300 return ((char *)EOF); --- 6 unchanged lines hidden (view full) --- 307 escaped_nl = 0; 308 goto begin; 309 } 310 else 311 return (NULL); 312 } 313 cp = line; 314 if (ch == '"' || ch == '\'') { | 288 int escaped_nl = 0; 289 290begin: 291 while ((ch = getc(fp)) != EOF) 292 if (ch != ' ' && ch != '\t') 293 break; 294 if (ch == EOF) 295 return ((char *)EOF); --- 6 unchanged lines hidden (view full) --- 302 escaped_nl = 0; 303 goto begin; 304 } 305 else 306 return (NULL); 307 } 308 cp = line; 309 if (ch == '"' || ch == '\'') { |
315 register int quote = ch; | 310 int quote = ch; |
316 317 while ((ch = getc(fp)) != EOF) { 318 if (ch == quote) 319 break; 320 if (ch == '\n') { 321 *cp = 0; 322 printf("config: missing quote reading `%s'\n", 323 line); --- 16 unchanged lines hidden (view full) --- 340 return ((char *)EOF); 341 return (line); 342} 343 344/* 345 * prepend the path to a filename 346 */ 347char * | 311 312 while ((ch = getc(fp)) != EOF) { 313 if (ch == quote) 314 break; 315 if (ch == '\n') { 316 *cp = 0; 317 printf("config: missing quote reading `%s'\n", 318 line); --- 16 unchanged lines hidden (view full) --- 335 return ((char *)EOF); 336 return (line); 337} 338 339/* 340 * prepend the path to a filename 341 */ 342char * |
348path(file) 349 char *file; | 343path(char *file) |
350{ | 344{ |
351 register char *cp; | 345 char *cp; |
352 353 cp = malloc((size_t)(strlen(destdir) + (file ? strlen(file) : 0) + 2)); 354 (void) strcpy(cp, destdir); 355 if (file) { 356 (void) strcat(cp, "/"); 357 (void) strcat(cp, file); 358 } 359 return (cp); 360} 361 362static void | 346 347 cp = malloc((size_t)(strlen(destdir) + (file ? strlen(file) : 0) + 2)); 348 (void) strcpy(cp, destdir); 349 if (file) { 350 (void) strcat(cp, "/"); 351 (void) strcat(cp, file); 352 } 353 return (cp); 354} 355 356static void |
363configfile() | 357configfile(void) |
364{ 365 FILE *fi, *fo; 366 char *p; 367 int i; 368 369 fi = fopen(PREFIX, "r"); 370 if (!fi) 371 err(2, "%s", PREFIX); --- 81 unchanged lines hidden --- | 358{ 359 FILE *fi, *fo; 360 char *p; 361 int i; 362 363 fi = fopen(PREFIX, "r"); 364 if (!fi) 365 err(2, "%s", PREFIX); --- 81 unchanged lines hidden --- |