Changeset 98
- Timestamp:
- 12/21/98 15:14:25 (14 years ago)
- Location:
- lm-sensors/trunk/lib
- Files:
-
- 8 modified
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/lib/access.c
r97 r98 117 117 { 118 118 if ((chip.prefix == SENSORS_CHIP_NAME_PREFIX_ANY) || 119 (chip.bus == SENSORS_CHIP_NAME_BUS_ISA) ||120 119 (chip.bus == SENSORS_CHIP_NAME_BUS_ANY) || 121 120 (chip.bus == SENSORS_CHIP_NAME_BUS_ANY_I2C) || -
lm-sensors/trunk/lib/conf-lex.l
r91 r98 97 97 /* Some keywords at the beginning of lines */ 98 98 <INITIAL>"label" { 99 sensors_yylval.line = sensors_yylineno; 99 100 BEGIN(MIDDLE); 100 101 return LABEL; … … 102 103 103 104 <INITIAL>"set" { 105 sensors_yylval.line = sensors_yylineno; 104 106 BEGIN(MIDDLE); 105 107 return SET; … … 107 109 108 110 <INITIAL>"compute" { 111 sensors_yylval.line = sensors_yylineno; 109 112 BEGIN(MIDDLE); 110 113 return COMPUTE; … … 112 115 113 116 <INITIAL>"bus" { 117 sensors_yylval.line = sensors_yylineno; 114 118 BEGIN(MIDDLE); 115 119 return BUS; … … 117 121 118 122 <INITIAL>"chip" { 123 sensors_yylval.line = sensors_yylineno; 119 124 BEGIN(MIDDLE); 120 125 return CHIP; -
lm-sensors/trunk/lib/conf-parse.y
r91 r98 90 90 int bus; 91 91 sensors_chip_name chip; 92 int line; 92 93 } 93 94 … … 98 99 %token <nothing> ',' 99 100 %token <nothing> EOL 100 %token < nothing> BUS101 %token < nothing> LABEL102 %token < nothing> SET103 %token < nothing> CHIP104 %token < nothing> COMPUTE101 %token <line> BUS 102 %token <line> LABEL 103 %token <line> SET 104 %token <line> CHIP 105 %token <line> COMPUTE 105 106 %token <value> FLOAT 106 107 %token <name> NAME … … 134 135 bus_statement: BUS i2cbus_name adapter_name algorithm_name 135 136 { sensors_bus new_el; 137 new_el.lineno = $1; 136 138 new_el.number = $2; 137 139 new_el.adapter = $3; … … 144 146 { sensors_label new_el; 145 147 check_current_chip(); 148 new_el.lineno = $1; 146 149 new_el.name = $2; 147 150 new_el.value = $3; … … 153 156 { sensors_set new_el; 154 157 check_current_chip(); 158 new_el.lineno = $1; 155 159 new_el.name = $2; 156 160 new_el.value = $3; … … 162 166 { sensors_compute new_el; 163 167 check_current_chip(); 168 new_el.lineno = $1; 164 169 new_el.name = $2; 165 170 new_el.from_proc = $3; … … 171 176 chip_statement: CHIP chip_name_list 172 177 { sensors_chip new_el; 178 new_el.lineno = $1; 173 179 new_el.labels = NULL; 174 180 new_el.sets = NULL; -
lm-sensors/trunk/lib/data.c
r97 r98 199 199 } 200 200 201 201 202 int sensors_eval_expr(sensors_expr *expr, double val, double *result) 202 203 { -
lm-sensors/trunk/lib/data.h
r97 r98 55 55 char *name; 56 56 char *value; 57 int lineno; 57 58 } sensors_label; 58 59 … … 60 61 char *name; 61 62 sensors_expr *value; 63 int lineno; 62 64 } sensors_set; 63 65 … … 66 68 sensors_expr *from_proc; 67 69 sensors_expr *to_proc; 70 int lineno; 68 71 } sensors_compute; 69 72 … … 85 88 int computes_count; 86 89 int computes_max; 90 int lineno; 87 91 } sensors_chip; 88 92 … … 94 98 char *adapter; 95 99 char *algorithm; 100 int lineno; 96 101 } sensors_bus; 97 102 … … 100 105 sensors_chip_name name; 101 106 } sensors_proc_chips_entry; 107 102 108 103 109 extern sensors_chip *sensors_config_chips; … … 113 119 extern int sensors_proc_chips_max; 114 120 121 extern sensors_bus *sensors_proc_bus; 122 extern int sensors_proc_bus_count; 123 extern int sensors_proc_bus_max; 124 115 125 /* Parse an i2c bus name into its components. Returns 0 on succes, a value from 116 126 error.h on failure. */ -
lm-sensors/trunk/lib/init.c
r97 r98 19 19 20 20 #include <stdlib.h> 21 #include <stdio.h> 21 22 #include "sensors.h" 22 23 #include "data.h" … … 25 26 26 27 extern int sensors_yyparse(void); 28 extern FILE *sensors_yyin; 27 29 28 30 static void free_proc_chips_entry(sensors_proc_chips_entry entry); … … 35 37 static void free_expr(sensors_expr *expr); 36 38 37 int sensors_init( void)39 int sensors_init(FILE *input) 38 40 { 39 41 int res; … … 41 43 if ((res = sensors_read_proc_chips())) 42 44 return res; 45 if ((res = sensors_read_proc_bus())) 46 return res; 47 sensors_yyin = input; 43 48 if ((res = sensors_yyparse())) 44 49 return SENSORS_ERR_PARSE; … … 67 72 sensors_config_chips = NULL; 68 73 sensors_config_chips_count = sensors_config_chips_max = 0; 74 75 for (i = 0; i < sensors_proc_bus_count; i++) 76 free_bus(sensors_proc_bus[i]); 77 free(sensors_proc_bus); 78 sensors_proc_bus = NULL; 79 sensors_proc_bus_count = sensors_proc_bus_max = 0; 69 80 } 70 81 -
lm-sensors/trunk/lib/proc.c
r95 r98 19 19 20 20 #include <stddef.h> 21 #include <stdio.h> 22 #include <string.h> 21 23 #include <sys/sysctl.h> 22 24 #include <linux/sysctl.h> … … 37 39 static char buf[BUF_LEN]; 38 40 41 sensors_proc_chips_entry *sensors_proc_chips; 42 int sensors_proc_chips_count; 43 int sensors_proc_chips_max; 44 45 sensors_bus *sensors_proc_bus; 46 int sensors_proc_bus_count; 47 int sensors_proc_bus_max; 48 39 49 static int sensors_get_chip_id(sensors_chip_name name); 40 50 … … 44 54 &sensors_proc_chips_max,\ 45 55 sizeof(struct sensors_proc_chips_entry)) 56 57 #define add_bus(el) sensors_add_array_el(el,\ 58 (void **) &sensors_proc_bus,\ 59 &sensors_proc_bus_count,\ 60 &sensors_proc_bus_max,\ 61 sizeof(struct sensors_bus)) 46 62 47 63 /* This reads /proc/sys/dev/sensors/chips into memory */ … … 69 85 return 0; 70 86 } 87 88 int sensors_read_proc_bus(void) 89 { 90 FILE *f; 91 char line[255]; 92 char *border; 93 sensors_bus entry; 94 f = fopen("/proc/bus/i2c","r"); 95 if (!f) 96 return -SENSORS_ERR_PROC; 97 while (fgets(line,255,f)) { 98 if (! (border = rindex(line,'\t'))) 99 goto ERROR; 100 if (! (entry.algorithm = strdup(border+1))) 101 goto FAT_ERROR; 102 *border='\0'; 103 if (! (border = rindex(line,'\t'))) 104 goto ERROR; 105 if (! (entry.adapter = strdup(border + 1))) 106 goto FAT_ERROR; 107 *border='\0'; 108 if (! (border = rindex(line,'\t'))) 109 goto ERROR; 110 *border='\0'; 111 if (strncmp(line,"i2c-",4)) 112 goto ERROR; 113 if (sensors_parse_i2cbus_name(line,&entry.number)) 114 goto ERROR; 115 add_bus(&entry); 116 } 117 fclose(f); 118 return 0; 119 FAT_ERROR: 120 sensors_fatal_error("sensors_read_proc_bus","Allocating entry"); 121 ERROR: 122 fclose(f); 123 return -SENSORS_ERR_PROC; 124 } 125 71 126 72 127 /* This returns the first detected chip which matches the name */ -
lm-sensors/trunk/lib/sensors.h
r97 r98 21 21 #define LIB_SENSORS_SENSORS_H 22 22 23 #include <stdio.h> 24 23 25 /* Publicly accessible library functions */ 24 26 … … 36 38 37 39 /* (Re)load the configuration file and the detected chips list. */ 38 extern int sensors_init( void);40 extern int sensors_init(FILE *input); 39 41 40 42 /* Strictly optional clean-up function: You can't access anything after 41 43 this, until the next sensors_init() call! */ 42 44 extern void sensors_cleanup(void); 43 44 45 45 46 /* Parse a chip name to the internal representation. Return 0 on succes, <0
