2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-09-04 08:15:13 +00:00

Use only one default configuration file (the one "make install"

will install). Display the default configuration file in "sensors --help".
Thanks go to Dave Hylands for the suggestion.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2767 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare
2004-11-21 19:26:56 +00:00
parent 7ca0a7018d
commit 2898ec26ea

View File

@@ -37,9 +37,6 @@
static char *config_file_name = NULL; static char *config_file_name = NULL;
FILE *config_file; FILE *config_file;
static const char *config_file_path[] =
{ "/etc", "/usr/local/etc", "/usr/lib/sensors", "/usr/local/lib/sensors",
"/usr/lib", "/usr/local/lib", ".", 0 };
extern const char *libsensors_version; extern const char *libsensors_version;
extern int main(int argc, char *arv[]); extern int main(int argc, char *arv[]);
@@ -68,7 +65,7 @@ void print_short_help(void)
void print_long_help(void) void print_long_help(void)
{ {
printf("Usage: %s [OPTION]... [CHIP]...\n",PROGRAM); printf("Usage: %s [OPTION]... [CHIP]...\n",PROGRAM);
printf(" -c, --config-file Specify a config file\n"); printf(" -c, --config-file Specify a config file (default: " ETCDIR "/" DEFAULT_CONFIG_FILE_NAME ")\n");
printf(" -h, --help Display this help text\n"); printf(" -h, --help Display this help text\n");
printf(" -s, --set Execute `set' statements too (root only)\n"); printf(" -s, --set Execute `set' statements too (root only)\n");
printf(" -f, --fahrenheit Show temperatures in degrees fahrenheit\n"); printf(" -f, --fahrenheit Show temperatures in degrees fahrenheit\n");
@@ -78,7 +75,6 @@ void print_long_help(void)
printf(" -u, --unknown Treat chips as unknown ones (testing only)\n"); printf(" -u, --unknown Treat chips as unknown ones (testing only)\n");
printf(" -v, --version Display the program version\n"); printf(" -v, --version Display the program version\n");
printf("\n"); printf("\n");
printf("By default, a list of directories is examined for config file `sensors.conf'.\n");
printf("Use `-' after `-c' to read the config file from stdin.\n"); printf("Use `-' after `-c' to read the config file from stdin.\n");
printf("If no chips are specified, all chip info will be printed.\n"); printf("If no chips are specified, all chip info will be printed.\n");
printf("Example chip names:\n"); printf("Example chip names:\n");
@@ -103,7 +99,7 @@ void open_config_file(void)
#define MAX_FILENAME_LEN 1024 #define MAX_FILENAME_LEN 1024
char *filename; char *filename;
char buffer[MAX_FILENAME_LEN]; char buffer[MAX_FILENAME_LEN];
int res,i; int res;
if (config_file_name && !strcmp(config_file_name,"-")) { if (config_file_name && !strcmp(config_file_name,"-")) {
config_file = stdin; config_file = stdin;
@@ -120,18 +116,16 @@ void open_config_file(void)
filename = config_file_name; filename = config_file_name;
else else
filename = DEFAULT_CONFIG_FILE_NAME; filename = DEFAULT_CONFIG_FILE_NAME;
for (i = 0; config_file_path[i]; i++) { if ((snprintf(buffer,MAX_FILENAME_LEN,
if ((snprintf(buffer,MAX_FILENAME_LEN, "%s/%s", ETCDIR, filename)) < 1) {
"%s/%s",config_file_path[i],filename)) < 1) { fprintf(stderr,
fprintf(stderr, "open_config_file: ridiculous long config file name!\n");
"open_config_file: ridiculous long config file name!\n"); exit(1);
exit(1); }
} if (!open_this_config_file(buffer)) {
if (!open_this_config_file(buffer)) { free(config_file_name);
free(config_file_name); config_file_name = strdup(buffer);
config_file_name = strdup(buffer); return;
return;
}
} }
fprintf(stderr,"Could not locate or open config file!\n"); fprintf(stderr,"Could not locate or open config file!\n");
exit(1); exit(1);