Changeset 101
- Timestamp:
- 12/22/98 02:25:25 (10 years ago)
- Files:
-
- lm-sensors/trunk/lib/access.h (modified) (1 diff)
- lm-sensors/trunk/lib/conf-parse.y (modified) (1 diff)
- lm-sensors/trunk/lib/data.c (modified) (2 diffs)
- lm-sensors/trunk/lib/error.h (modified) (1 diff)
- lm-sensors/trunk/lib/general.c (modified) (1 diff)
- lm-sensors/trunk/lib/general.h (modified) (1 diff)
- lm-sensors/trunk/lib/init.c (modified) (1 diff)
- lm-sensors/trunk/lib/proc.c (modified) (2 diffs)
- lm-sensors/trunk/lib/proc.h (modified) (1 diff)
- lm-sensors/trunk/lib/sensors.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lm-sensors/trunk/lib/access.h
r95 r101 71 71 const char *feature); 72 72 73 /* Substitute configuration bus numbers with real-world /proc bus numbers 74 in the chips lists */ 75 extern int sensors_substitute_busses(void); 76 73 77 #endif /* def LIB_SENSORS_ACCESS_H */ lm-sensors/trunk/lib/conf-parse.y
r98 r101 262 262 263 263 adapter_name: NAME 264 { $$ = $1; } 264 { sensors_strip_of_spaces($1); 265 $$ = $1; } 265 266 ; 266 267 267 268 algorithm_name: NAME 268 { $$ = $1; } 269 { sensors_strip_of_spaces($1); 270 $$ = $1; } 269 271 ; 270 272 lm-sensors/trunk/lib/data.c
r98 r101 33 33 int sensors_config_busses_max = 0; 34 34 35 static int sensors_substitute_chip(sensors_chip_name *name,int lineno); 35 36 36 37 /* Wow, this must be one of the ugliest functions I have ever written. … … 240 241 return 0; 241 242 } 243 244 int sensors_substitute_chip(sensors_chip_name *name,int lineno) 245 { 246 int i,j; 247 for (i = 0; i < sensors_config_busses_count; i++) 248 if (sensors_config_busses[i].number == name->bus) 249 break; 250 251 if (i == sensors_config_busses_count) { 252 sensors_parse_error("Undeclared i2c bus referenced",lineno); 253 name->bus = sensors_proc_bus_count; 254 return -SENSORS_ERR_BUS_NAME; 255 } 256 257 for (j = 0; j < sensors_proc_bus_count; j++) { 258 if (!strcmp(sensors_config_busses[i].adapter, 259 sensors_proc_bus[j].adapter) && 260 !strcmp(sensors_config_busses[i].algorithm, 261 sensors_proc_bus[j].algorithm)) 262 break; 263 } 264 265 /* Well, if we did not find anything, j - sensors_proc_bus_count; so if 266 we set this chip's bus number to j, it will never be matched. Good. */ 267 name->bus = j; 268 return 0; 269 } 270 242 271 272 int sensors_substitute_busses(void) 273 { 274 int err,i,j,lineno; 275 sensors_chip_name_list *chips; 276 int res=0; 243 277 278 for(i = 0; i < sensors_config_chips_count; i++) { 279 lineno = sensors_config_chips[i].lineno; 280 chips = &sensors_config_chips[i].chips; 281 for(j = 0; j < chips->fits_count; j++) 282 if ((chips->fits[j].bus != SENSORS_CHIP_NAME_BUS_ISA) && 283 (chips->fits[j].bus != SENSORS_CHIP_NAME_BUS_ANY) && 284 (chips->fits[j].bus != SENSORS_CHIP_NAME_BUS_ANY_I2C)) 285 if ((err = sensors_substitute_chip(chips->fits+j, lineno))) 286 res = err; 287 } 288 return res; 289 } lm-sensors/trunk/lib/error.h
r97 r101 37 37 /* This function is called when a parse error is detected. Give it a new 38 38 value, and your own function is called instead of the default (which 39 prints to stderr). */ 39 prints to stderr). This function may terminate the program, but it 40 usually outputs an error and returns. */ 40 41 extern void (*sensors_parse_error) (const char *err, int lineno); 41 42 lm-sensors/trunk/lib/general.c
r95 r101 75 75 *num_el += nr_els; 76 76 } 77 78 /* Strip a string of all terminating spaces */ 79 void sensors_strip_of_spaces(char *name) 80 { 81 int i; 82 for (i = strlen(name)-1; (i>=0) && (name[i] == ' '); i--); 83 name[i+1] = '\0'; 84 } lm-sensors/trunk/lib/general.h
r91 r101 34 34 int *num_el, int *max_el, int el_size); 35 35 36 /* Strip a string of all terminating spaces */ 37 extern void sensors_strip_of_spaces(char *name); 38 36 39 #endif /* LIB_SENSORS_GENERAL */ lm-sensors/trunk/lib/init.c
r98 r101 47 47 sensors_yyin = input; 48 48 if ((res = sensors_yyparse())) 49 return SENSORS_ERR_PARSE; 49 return -SENSORS_ERR_PARSE; 50 if ((res = sensors_substitute_busses())); 51 return res; 50 52 return 0; 51 53 } lm-sensors/trunk/lib/proc.c
r98 r101 96 96 return -SENSORS_ERR_PROC; 97 97 while (fgets(line,255,f)) { 98 if (strlen(line) > 0) 99 line[strlen(line)-1] = '\0'; 98 100 if (! (border = rindex(line,'\t'))) 99 101 goto ERROR; … … 113 115 if (sensors_parse_i2cbus_name(line,&entry.number)) 114 116 goto ERROR; 117 sensors_strip_of_spaces(entry.algorithm); 118 sensors_strip_of_spaces(entry.adapter); 115 119 add_bus(&entry); 116 120 } lm-sensors/trunk/lib/proc.h
r95 r101 24 24 extern int sensors_read_proc_chips(void); 25 25 26 /* Read /proc/bus/i2c */ 27 extern int sensors_read_proc_bus(void); 28 26 29 /* Read a value out of a /proc file */ 27 30 extern int sensors_read_proc(sensors_chip_name name, int feature, lm-sensors/trunk/lib/sensors.h
r98 r101 37 37 } sensors_chip_name; 38 38 39 /* (Re)load the configuration file and the detected chips list. */ 39 /* (Re)load the configuration file and the detected chips list. If this 40 returns a value unequal to zero, you are in trouble; you can not 41 assume anything will be initialized properly. */ 40 42 extern int sensors_init(FILE *input); 41 43
