FreeBSD/usr.sbin/config/main.c
/*
 * Generate file from the configuration files.
 */
Generate file from the configuration files.
Generate file from the configuration files .
static void
configfile_filebased(struct sbuf *sb)
{
	FILE *cff;
	struct cfgfile *cf;
	int i;
	STAILQ_FOREACH(cf, &cfgfiles, cfg_next) {
		cff = fopen(cf->cfg_path, "r");
		if (cff == NULL) {
			warn("Couldn't open file %s", cf->cfg_path);
			continue;
		}
		while ((i = getc(cff)) != EOF) {
			if (i == '\n')
				sbuf_printf(sb, "\\n\\\n");
			else if (i == '"' || i == '\'')
				sbuf_printf(sb, "\\%c", i);
			else
				sbuf_putc(sb, i);
		}
		fclose(cff);
	}
}
static void configfile_filebased ( struct sbuf * sb ) { FILE * cff ; struct cfgfile * cf ; int i ; STAILQ_FOREACH ( cf , & cfgfiles , cfg_next ) { cff = fopen ( cf -> cfg_path , " " ) ; if ( cff == NULL ) { warn ( " " , cf -> cfg_path ) ; continue ; } while ( ( i = getc ( cff ) ) != EOF ) { if ( i == ' \n ' ) sbuf_printf ( sb , " \\ \\ \n " ) ; else if ( i == ' ' || i == ' \' ' ) sbuf_printf ( sb , " \\ " , i ) ; else sbuf_putc ( sb , i ) ; } fclose ( cff ) ; } }
Generate file from the configuration files.
Generate file from the configuration files .
/*
	 * Try to read all configuration files. Since those will be present as
	 * C string in the macro, we have to slash their ends then the line
	 * wraps.
	 */