Changeset 4986

Show
Ignore:
Timestamp:
10/25/07 11:49:34 (6 years ago)
Author:
khali
Message:

"sensors" no longer needs a default configuration file name. If no
file name is provided on the command line, use the libsensors default.

Location:
lm-sensors/branches/lm-sensors-3.0.0
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/branches/lm-sensors-3.0.0/CHANGES

    r4985 r4986  
    77  sensors: Fix file handle leak on library initialization error 
    88           Handle the case where voltage measurements aren't available 
     9           No default configuration file name 
    910  sensors-detect: Fix SMSC LPC47B357/M967 detection 
    1011                  Select the right driver for FSC chips 
  • lm-sensors/branches/lm-sensors-3.0.0/prog/sensors/main.c

    r4973 r4986  
    4040#define PROGRAM                 "sensors" 
    4141#define VERSION                 LM_VERSION 
    42 #define DEFAULT_CONFIG_FILE     ETCDIR "/sensors.conf" 
    4342 
    4443static int do_sets, do_raw, hide_adapter; 
     
    5554{ 
    5655        printf("Usage: %s [OPTION]... [CHIP]...\n", PROGRAM); 
    57         printf("  -c, --config-file     Specify a config file (default: %s)\n", 
    58                DEFAULT_CONFIG_FILE); 
    59         puts("  -h, --help            Display this help text\n" 
     56        puts("  -c, --config-file     Specify a config file\n" 
     57             "  -h, --help            Display this help text\n" 
    6058             "  -s, --set             Execute `set' statements (root only)\n" 
    6159             "  -f, --fahrenheit      Show temperatures in degrees fahrenheit\n" 
     
    8987        int err; 
    9088 
    91         if (!strcmp(config_file_name, "-")) 
    92                 config_file = stdin; 
    93         else 
    94                 config_file = fopen(config_file_name, "r"); 
    95  
    96         if (!config_file) { 
    97                 fprintf(stderr, "Could not open config file\n"); 
    98                 perror(config_file_name); 
    99                 return 1; 
     89        if (config_file_name) { 
     90                if (!strcmp(config_file_name, "-")) 
     91                        config_file = stdin; 
     92                else 
     93                        config_file = fopen(config_file_name, "r"); 
     94 
     95                if (!config_file) { 
     96                        fprintf(stderr, "Could not open config file\n"); 
     97                        perror(config_file_name); 
     98                        return 1; 
     99                } 
     100        } else { 
     101                /* Use libsensors default */ 
     102                config_file = NULL; 
    100103        } 
    101104 
     
    107110        } 
    108111 
    109         if (fclose(config_file) == EOF) 
     112        if (config_file && fclose(config_file) == EOF) 
    110113                perror(config_file_name); 
    111114 
     
    240243{ 
    241244        int c, res, i, error, do_bus_list; 
    242         const char *config_file_name = DEFAULT_CONFIG_FILE; 
     245        const char *config_file_name = NULL; 
    243246 
    244247        struct option long_opts[] =  { 
  • lm-sensors/branches/lm-sensors-3.0.0/prog/sensors/sensors.1

    r4781 r4986  
    2323.\" the source, must acknowledge the copyright and authors of this work. 
    2424.\" 
    25 .TH sensors 1  "September 2007" "lm-sensors 3" "Linux User's Manual" 
     25.TH sensors 1  "October 2007" "lm-sensors 3" "Linux User's Manual" 
    2626.SH NAME 
    2727sensors \- print sensors information 
     
    5151.SH OPTIONS 
    5252.IP "-c config-file" 
    53 Specify a configuration file. If no file is specified, `/etc/sensors.conf' 
    54 is used. Use `-c /dev/null' to temporarily disable this default configuration 
    55 file. 
     53Specify a configuration file. If no file is specified, the libsensors 
     54default configuration file is used. Use `-c /dev/null' to temporarily 
     55disable this default configuration file. 
    5656.IP -h 
    5757Print a help text and exit.