Changeset 4711
- Timestamp:
- 08/26/07 15:21:05 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/lm-sensors-3.0.0/prog/sensors/main.c
r4710 r4711 39 39 #define VERSION LM_VERSION 40 40 #define DEFAULT_CONFIG_FILE ETCDIR "/sensors.conf" 41 42 FILE *config_file;43 41 44 42 extern int main(int argc, char *arv[]); … … 90 88 } 91 89 92 /* This examines global var config_file, and leaves the name there too. 93 It also opens config_file. */ 94 static void open_config_file(const char* config_file_name) 95 { 96 if (!strcmp(config_file_name, "-")) { 90 /* Return 0 on success, and an exit error code otherwise */ 91 static int read_config_file(const char *config_file_name) 92 { 93 FILE *config_file; 94 int err; 95 96 if (!strcmp(config_file_name, "-")) 97 97 config_file = stdin; 98 return; 99 } 100 101 config_file = fopen(config_file_name, "r"); 98 else 99 config_file = fopen(config_file_name, "r"); 100 102 101 if (!config_file) { 103 102 fprintf(stderr, "Could not open config file\n"); 104 103 perror(config_file_name); 105 exit(1); 106 } 107 } 108 109 static void close_config_file(const char* config_file_name) 110 { 111 if (fclose(config_file) == EOF) { 112 fprintf(stderr, "Could not close config file\n"); 104 return 1; 105 } 106 107 err = sensors_init(config_file); 108 if (err) { 109 fprintf(stderr, "sensors_init: %s\n", sensors_strerror(err)); 110 return 1; 111 } 112 113 if (fclose(config_file) == EOF) 113 114 perror(config_file_name); 114 } 115 116 return 0; 115 117 } 116 118 … … 200 202 } 201 203 202 open_config_file(config_file_name); 203 if ((res = sensors_init(config_file))) { 204 fprintf(stderr, "sensors_init: %s\n", sensors_strerror(res)); 205 exit(1); 206 } 207 close_config_file(config_file_name); 204 res = read_config_file(config_file_name); 205 if (res) 206 exit(res); 208 207 209 208 /* build the degrees string */
