Move the config file names out as #define into avrdude.h

This commit is contained in:
Joerg Wunsch 2022-01-04 23:03:47 +01:00
parent 374861f62e
commit 6a87a110cc
3 changed files with 16 additions and 9 deletions

View File

@ -21,6 +21,13 @@
#ifndef avrdude_h #ifndef avrdude_h
#define 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 * progname; /* name of program, for messages */
extern char progbuf[]; /* spaces same length as progname */ extern char progbuf[]; /* spaces same length as progname */

View File

@ -34,7 +34,7 @@ void win_sys_config_set(char sys_config[PATH_MAX])
sys_config[0] = 0; sys_config[0] = 0;
/* Use Windows API call to search for the Windows default system config file.*/ /* 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; return;
} }
@ -44,7 +44,7 @@ void win_usr_config_set(char usr_config[PATH_MAX])
usr_config[0] = 0; usr_config[0] = 0;
/* Use Windows API call to search for the Windows default user config file. */ /* 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; return;
} }

View File

@ -708,7 +708,7 @@ int main(int argc, char * argv [])
i = strlen(sys_config); i = strlen(sys_config);
if (i && (sys_config[i - 1] != '/')) if (i && (sys_config[i - 1] != '/'))
strcat(sys_config, "/"); strcat(sys_config, "/");
strcat(sys_config, "../etc/avrdude.conf"); strcat(sys_config, "../etc/" SYSTEM_CONF_FILE);
sys_config[PATH_MAX - 1] = '\0'; sys_config[PATH_MAX - 1] = '\0';
if (access(sys_config, F_OK) == 0) { if (access(sys_config, F_OK) == 0) {
sys_config_found = true; sys_config_found = true;
@ -720,7 +720,7 @@ int main(int argc, char * argv [])
i = strlen(sys_config); i = strlen(sys_config);
if (i && (sys_config[i - 1] != '/')) if (i && (sys_config[i - 1] != '/'))
strcat(sys_config, "/"); strcat(sys_config, "/");
strcat(sys_config, "avrdude.conf"); strcat(sys_config, SYSTEM_CONF_FILE);
sys_config[PATH_MAX - 1] = '\0'; sys_config[PATH_MAX - 1] = '\0';
if (access(sys_config, F_OK) == 0) { if (access(sys_config, F_OK) == 0) {
sys_config_found = true; sys_config_found = true;
@ -736,7 +736,7 @@ int main(int argc, char * argv [])
i = strlen(sys_config); i = strlen(sys_config);
if (i && (sys_config[i - 1] != '/')) if (i && (sys_config[i - 1] != '/'))
strcat(sys_config, "/"); strcat(sys_config, "/");
strcat(sys_config, "avrdude.conf"); strcat(sys_config, SYSTEM_CONF_FILE);
#endif #endif
if (access(sys_config, F_OK) == 0) { if (access(sys_config, F_OK) == 0) {
sys_config_found = true; sys_config_found = true;
@ -751,7 +751,7 @@ int main(int argc, char * argv [])
/* /*
* USER CONFIG * USER CONFIG
* ----------- * -----------
* Determine the location of '.avrduderc'. Nothing changed here. * Determine the location of '.avrduderc'.
*/ */
#if defined(WIN32NATIVE) #if defined(WIN32NATIVE)
win_usr_config_set(usr_config); win_usr_config_set(usr_config);
@ -763,7 +763,7 @@ int main(int argc, char * argv [])
i = strlen(usr_config); i = strlen(usr_config);
if (i && (usr_config[i - 1] != '/')) if (i && (usr_config[i - 1] != '/'))
strcat(usr_config, "/"); strcat(usr_config, "/");
strcat(usr_config, ".avrduderc"); strcat(usr_config, USER_CONF_FILE);
} }
#endif #endif