FreeBSD/usr.sbin/config/main.c
/*
 * Generate configuration file based on actual settings. With this mode, user
 * will be able to obtain and build conifguration file with one command.
 */
Generate configuration file based on actual settings. With this mode, user
will be able to obtain and build conifguration file with one command.
Generate configuration file based on actual settings . With this mode user will be able to obtain and build conifguration file with one command .
static void
configfile_dynamic(struct sbuf *sb)
{
	struct cputype *cput;
	struct device *d;
	struct opt *ol;
	char *lend;
	unsigned int i;
	asprintf(&lend, "\\n\\\n");
	assert(lend != NULL);
	sbuf_printf(sb, "options\t%s%s", OPT_AUTOGEN, lend);
	sbuf_printf(sb, "ident\t%s%s", ident, lend);
	sbuf_printf(sb, "machine\t%s%s", machinename, lend);
	SLIST_FOREACH(cput, &cputype, cpu_next)
		sbuf_printf(sb, "cpu\t%s%s", cput->cpu_name, lend);
	SLIST_FOREACH(ol, &mkopt, op_next)
		sbuf_printf(sb, "makeoptions\t%s=%s%s", ol->op_name,
		    ol->op_value, lend);
	SLIST_FOREACH(ol, &opt, op_next) {
		if (strncmp(ol->op_name, "DEV_", 4) == 0)
			continue;
		sbuf_printf(sb, "options\t%s", ol->op_name);
		if (ol->op_value != NULL) {
			sbuf_putc(sb, '=');
			for (i = 0; i < strlen(ol->op_value); i++) {
				if (ol->op_value[i] == '"')
					sbuf_printf(sb, "\\%c",
					    ol->op_value[i]);
				else
					sbuf_printf(sb, "%c",
					    ol->op_value[i]);
			}
			sbuf_printf(sb, "%s", lend);
		} else {
			sbuf_printf(sb, "%s", lend);
		}
	}
	STAILQ_FOREACH(d, &dtab, d_next)
		sbuf_printf(sb, "device\t%s%s", d->d_name, lend);
	free(lend);
}
static void configfile_dynamic ( struct sbuf * sb ) { struct cputype * cput ; struct device * d ; struct opt * ol ; char * lend ; unsigned int i ; asprintf ( & lend , " \\ \\ \n " ) ; assert ( lend != NULL ) ; sbuf_printf ( sb , " \t " , OPT_AUTOGEN , lend ) ; sbuf_printf ( sb , " \t " , ident , lend ) ; sbuf_printf ( sb , " \t " , machinename , lend ) ; SLIST_FOREACH ( cput , & cputype , cpu_next ) sbuf_printf ( sb , " \t " , cput -> cpu_name , lend ) ; SLIST_FOREACH ( ol , & mkopt , op_next ) sbuf_printf ( sb , " \t " , ol -> op_name , ol -> op_value , lend ) ; SLIST_FOREACH ( ol , & opt , op_next ) { if ( strncmp ( ol -> op_name , " " , 4 ) == 0 ) continue ; sbuf_printf ( sb , " \t " , ol -> op_name ) ; if ( ol -> op_value != NULL ) { sbuf_putc ( sb , ' ' ) ; for ( i = 0 ; i < strlen ( ol -> op_value ) ; i ++ ) { if ( ol -> op_value [ i ] == ' ' ) sbuf_printf ( sb , " \\ " , ol -> op_value [ i ] ) ; else sbuf_printf ( sb , " " , ol -> op_value [ i ] ) ; } sbuf_printf ( sb , " " , lend ) ; } else { sbuf_printf ( sb , " " , lend ) ; } } STAILQ_FOREACH ( d , & dtab , d_next ) sbuf_printf ( sb , " \t " , d -> d_name , lend ) ; free ( lend ) ; }
Generate configuration file based on actual settings.
Generate configuration file based on actual settings .
/*
	 * Mark this file as containing everything we need.
	 */