From 12c2affe923cd86b6a077acb5eb98840f6406d78 Mon Sep 17 00:00:00 2001 From: rliebscher Date: Tue, 10 Jan 2012 18:07:19 +0000 Subject: [PATCH] patch #7699 Read additional config files * main.c: Added reading of additional config files * avrdude.1: updated man page * doc/avrdude.texi: updated documentation git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1038 81a1dc3b-b13d-400b-aceb-764788c761c2 --- ChangeLog | 7 +++++++ avrdude.1 | 10 ++++++++++ doc/avrdude.texi | 8 ++++++++ main.c | 38 ++++++++++++++++++++++++++++++++++++-- 4 files changed, 61 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4e2418ac..85ca76a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-01-10 Rene Liebscher + + patch #7699 Read additional config files + * main.c: Added reading of additional config files + * avrdude.1: updated man page + * doc/avrdude.texi: updated documentation + 2012-01-10 Joerg Wunsch Submitted by Bob Frazier: diff --git a/avrdude.1 b/avrdude.1 index 66972571..798713ae 100644 --- a/avrdude.1 +++ b/avrdude.1 @@ -269,6 +269,16 @@ submit a patch back to the author so that it can be incorporated for the next version). See the config file, located at .Pa ${PREFIX}/etc/avrdude.conf , which contains a description of the format. +.Pp +If +.Ar config-file +is written as +.Pa +filename +then this file is read after the system wide and user configuration +files. This can be used to add entries to the configuration +without patching your system wide configuration file. It can be used +several times, the files are read in same order as given on the command +line. .It Fl D Disable auto erase for flash. When the .Fl U diff --git a/doc/avrdude.texi b/doc/avrdude.texi index bc613e6d..5e047273 100644 --- a/doc/avrdude.texi +++ b/doc/avrdude.texi @@ -513,6 +513,14 @@ specified, AVRDUDE reads the configuration file from /usr/local/etc/avrdude.conf (FreeBSD and Linux). See Appendix A for the method of searching for the configuration file for Windows. +If @var{config-file} is written as @var{+filename} +then this file is read after the system wide and user configuration +files. This can be used to add entries to the configuration +without patching your system wide configuration file. It can be used +several times, the files are read in same order as given on the command +line. + + @item -D Disable auto erase for flash. When the -U option with flash memory is specified, avrdude will perform a chip erase before starting any of the diff --git a/main.c b/main.c index bfc1777b..a57193e1 100644 --- a/main.c +++ b/main.c @@ -75,6 +75,8 @@ static LISTID updates; static LISTID extended_params; +static LISTID additional_config_files; + static PROGRAMMER * pgm; /* @@ -342,6 +344,12 @@ int main(int argc, char * argv []) exit(1); } + additional_config_files = lcreat(NULL, 0); + if (additional_config_files == NULL) { + fprintf(stderr, "%s: cannot initialize additional config files list\n", progname); + exit(1); + } + partdesc = NULL; port = default_parallel; erase = 0; @@ -448,8 +456,12 @@ int main(int argc, char * argv []) break; case 'C': /* system wide configuration file */ - strncpy(sys_config, optarg, PATH_MAX); - sys_config[PATH_MAX-1] = 0; + if (optarg[0] == '+') { + ladd(additional_config_files, optarg+1); + } else { + strncpy(sys_config, optarg, PATH_MAX); + sys_config[PATH_MAX-1] = 0; + } break; case 'D': /* disable auto erase */ @@ -620,6 +632,28 @@ int main(int argc, char * argv []) } } } + + if (lsize(additional_config_files) > 0) { + LNODEID ln1; + const char * p = NULL; + + for (ln1=lfirst(additional_config_files); ln1; ln1=lnext(ln1)) { + p = ldata(ln1); + if (verbose) { + fprintf(stderr, "%sAdditional configuration file is \"%s\"\n", + progbuf, p); + } + + rc = read_config(p); + if (rc) { + fprintf(stderr, + "%s: error reading additional configuration file \"%s\"\n", + progname, p); + exit(1); + } + } + } + // set bitclock from configuration files unless changed by command line if (default_bitclock > 0 && bitclock == 0.0) { bitclock = default_bitclock;