From 6a87a110ccde968b61c910b7ccb6ecc176909321 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Tue, 4 Jan 2022 23:03:47 +0100 Subject: [PATCH] Move the config file names out as #define into avrdude.h --- src/avrdude.h | 7 +++++++ src/confwin.c | 8 ++++---- src/main.c | 10 +++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/avrdude.h b/src/avrdude.h index 738578f1..b4c7ee87 100644 --- a/src/avrdude.h +++ b/src/avrdude.h @@ -21,6 +21,13 @@ #ifndef avrdude_h #define avrdude_h +#define SYSTEM_CONF_FILE "avrdude.conf" +#if defined(WIN32NATIVE) +#define USER_CONF_FILE "avrdude.rc" +#else +#define USER_CONF_FILE ".avrduderc" +#endif + extern char * progname; /* name of program, for messages */ extern char progbuf[]; /* spaces same length as progname */ diff --git a/src/confwin.c b/src/confwin.c index 95446156..1be95e87 100644 --- a/src/confwin.c +++ b/src/confwin.c @@ -32,9 +32,9 @@ static char *filename; void win_sys_config_set(char sys_config[PATH_MAX]) { sys_config[0] = 0; - + /* Use Windows API call to search for the Windows default system config file.*/ - SearchPath(NULL, "avrdude.conf", NULL, PATH_MAX, sys_config, &filename); + SearchPath(NULL, SYSTEM_CONF_FILE, NULL, PATH_MAX, sys_config, &filename); return; } @@ -42,9 +42,9 @@ void win_sys_config_set(char sys_config[PATH_MAX]) void win_usr_config_set(char usr_config[PATH_MAX]) { usr_config[0] = 0; - + /* Use Windows API call to search for the Windows default user config file. */ - SearchPath(NULL, "avrdude.rc", NULL, PATH_MAX, usr_config, &filename); + SearchPath(NULL, USER_CONF_FILE, NULL, PATH_MAX, usr_config, &filename); return; } diff --git a/src/main.c b/src/main.c index a44540eb..47081c1b 100644 --- a/src/main.c +++ b/src/main.c @@ -708,7 +708,7 @@ int main(int argc, char * argv []) i = strlen(sys_config); if (i && (sys_config[i - 1] != '/')) strcat(sys_config, "/"); - strcat(sys_config, "../etc/avrdude.conf"); + strcat(sys_config, "../etc/" SYSTEM_CONF_FILE); sys_config[PATH_MAX - 1] = '\0'; if (access(sys_config, F_OK) == 0) { sys_config_found = true; @@ -720,7 +720,7 @@ int main(int argc, char * argv []) i = strlen(sys_config); if (i && (sys_config[i - 1] != '/')) strcat(sys_config, "/"); - strcat(sys_config, "avrdude.conf"); + strcat(sys_config, SYSTEM_CONF_FILE); sys_config[PATH_MAX - 1] = '\0'; if (access(sys_config, F_OK) == 0) { sys_config_found = true; @@ -736,7 +736,7 @@ int main(int argc, char * argv []) i = strlen(sys_config); if (i && (sys_config[i - 1] != '/')) strcat(sys_config, "/"); - strcat(sys_config, "avrdude.conf"); + strcat(sys_config, SYSTEM_CONF_FILE); #endif if (access(sys_config, F_OK) == 0) { sys_config_found = true; @@ -751,7 +751,7 @@ int main(int argc, char * argv []) /* * USER CONFIG * ----------- - * Determine the location of '.avrduderc'. Nothing changed here. + * Determine the location of '.avrduderc'. */ #if defined(WIN32NATIVE) win_usr_config_set(usr_config); @@ -763,7 +763,7 @@ int main(int argc, char * argv []) i = strlen(usr_config); if (i && (usr_config[i - 1] != '/')) strcat(usr_config, "/"); - strcat(usr_config, ".avrduderc"); + strcat(usr_config, USER_CONF_FILE); } #endif