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 --- 24 unchanged lines hidden (view full) --- 33 The Regents of the University of California. All rights reserved.\n"; 34#endif /* not lint */ 35 36#ifndef lint 37#if 0 38static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; 39#endif 40static const char rcsid[] = |
41 "$FreeBSD: head/usr.sbin/config/main.c 169512 2007-05-12 22:37:52Z wkoszek $"; |
42#endif /* not lint */ 43 44#include <sys/types.h> 45#include <sys/stat.h> 46#include <sys/sbuf.h> 47#include <sys/file.h> 48#include <sys/mman.h> 49#include <sys/param.h> 50 51#include <assert.h> 52#include <ctype.h> 53#include <err.h> 54#include <stdio.h> |
55#include <string.h> |
56#include <sysexits.h> 57#include <unistd.h> 58#include <dirent.h> 59#include "y.tab.h" 60#include "config.h" 61#include "configvers.h" 62 63#ifndef TRUE --- 329 unchanged lines hidden (view full) --- 393 */ 394static void 395configfile_dynamic(struct sbuf *sb) 396{ 397 struct cputype *cput; 398 struct device *d; 399 struct opt *ol; 400 char *lend; |
401 unsigned int i; |
402 403 asprintf(&lend, "\\n\\\n"); 404 assert(lend != NULL); 405 sbuf_printf(sb, "options\t%s%s", OPT_AUTOGEN, lend); 406 sbuf_printf(sb, "ident\t%s%s", ident, lend); 407 sbuf_printf(sb, "machine\t%s%s", machinename, lend); 408 SLIST_FOREACH(cput, &cputype, cpu_next) 409 sbuf_printf(sb, "cpu\t%s%s", cput->cpu_name, lend); 410 SLIST_FOREACH(ol, &mkopt, op_next) 411 sbuf_printf(sb, "makeoptions\t%s=%s%s", ol->op_name, 412 ol->op_value, lend); 413 SLIST_FOREACH(ol, &opt, op_next) { 414 if (strncmp(ol->op_name, "DEV_", 4) == 0) 415 continue; 416 sbuf_printf(sb, "options\t%s", ol->op_name); 417 if (ol->op_value != NULL) { |
418 sbuf_putc(sb, '='); 419 for (i = 0; i < strlen(ol->op_value); i++) { 420 if (ol->op_value[i] == '"') 421 sbuf_printf(sb, "\\%c", 422 ol->op_value[i]); 423 else 424 sbuf_printf(sb, "%c", 425 ol->op_value[i]); 426 } 427 sbuf_printf(sb, "%s", lend); |
428 } else { 429 sbuf_printf(sb, "%s", lend); 430 } 431 } 432 /* 433 * Mark this file as containing everything we need. 434 */ 435 STAILQ_FOREACH(d, &dtab, d_next) --- 259 unchanged lines hidden --- |