[Asterisk-Dev] generation of config files from source code ?

Luigi Rizzo rizzo at icir.org
Sun Nov 20 02:42:48 MST 2005


How about this to keep sample config files in sync with the source code:

put the example config file for a channel/module/whatever embedded
in a comment in the source code (much like what is in channels/chan_oss.c)
and put in the configs/ directory a Makefile and a small awk
script to generate the sample from the source file.
It could be as simple as this:

        |<---note - the line in the files starts here

[config/Makefile]
	oss.conf.1: ../channels/chan_oss.c
		awk -f get_config.awk  $< >  $@

[config/get_config.awk]
	/^START_CONFIG/ {       echo = 1; next; }
	/^END_CONFIG/   {       exit;           }
			{       if (echo) print $0; }

[in the relevant source file]
	/*
	 * bla bla bla
	START_CONFIG [config_file_name]
	this gets copied into the config file
	END_CONFIG
	 * bla bla bla
	 */

We can make the process smarter by putting the config file name
into the source file (in fact, it is already there as it is a constant)
etc.etc but before that i wanted to know how people think of the idea.

	cheers
	luigi



More information about the asterisk-dev mailing list