Changeset 120
- Timestamp:
- 12/25/98 23:15:48 (14 years ago)
- Location:
- lm-sensors/trunk/lib
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/lib/access.c
r119 r120 59 59 you want the match that was latest in the config file. */ 60 60 sensors_chip *sensors_for_all_config_chips(sensors_chip_name chip_name, 61 sensors_chip *last)61 const sensors_chip *last) 62 62 { 63 63 int nr,i; … … 78 78 Do not modify the struct the return value points to! Returns NULL if 79 79 not found.*/ 80 sensors_chip_feature *sensors_lookup_feature_nr(const char *prefix, int feature) 80 const sensors_chip_feature *sensors_lookup_feature_nr(const char *prefix, 81 int feature) 81 82 { 82 83 int i,j; 83 sensors_chip_feature *features;84 const sensors_chip_feature *features; 84 85 for (i = 0; sensors_chip_features_list[i].prefix; i++) 85 86 if (!strcmp(sensors_chip_features_list[i].prefix,prefix)) { … … 95 96 Do not modify the struct the return value points to! Returns NULL if 96 97 not found.*/ 97 sensors_chip_feature *sensors_lookup_feature_name(const char *prefix,98 const char *feature)98 const sensors_chip_feature *sensors_lookup_feature_name(const char *prefix, 99 const char *feature) 99 100 { 100 101 int i,j; 101 sensors_chip_feature *features;102 const sensors_chip_feature *features; 102 103 for (i = 0; sensors_chip_features_list[i].prefix; i++) 103 104 if (!strcmp(sensors_chip_features_list[i].prefix,prefix)) { … … 130 131 int sensors_get_label(sensors_chip_name name, int feature, char **result) 131 132 { 132 sensors_chip *chip;133 sensors_chip_feature *featureptr;133 const sensors_chip *chip; 134 const sensors_chip_feature *featureptr; 134 135 int i; 135 136 … … 152 153 /* Read the value of a feature of a certain chip. Note that chip should not 153 154 contain wildcard values! This function will return 0 on success, and <0 154 on failure. */155 on failure. */ 155 156 int sensors_get_feature(sensors_chip_name name, int feature, double *result) 156 157 { 157 sensors_chip_feature *main_feature;158 sensors_chip_feature *alt_feature;159 sensors_chip *chip;160 sensors_expr *expr = NULL;158 const sensors_chip_feature *main_feature; 159 const sensors_chip_feature *alt_feature; 160 const sensors_chip *chip; 161 const sensors_expr *expr = NULL; 161 162 double val; 162 163 int res,i; … … 195 196 /* Set the value of a feature of a certain chip. Note that chip should not 196 197 contain wildcard values! This function will return 0 on success, and <0 197 on failure. */198 on failure. BUGGY! */ 198 199 int sensors_set_feature(sensors_chip_name name, int feature, double value) 199 200 { 200 sensors_chip_feature *featureptr;201 sensors_chip *chip;202 sensors_expr *expr = NULL;201 const sensors_chip_feature *featureptr; 202 const sensors_chip *chip; 203 const sensors_expr *expr = NULL; 203 204 int i,res; 204 205 … … 281 282 } 282 283 283 int sensors_eval_expr(sensors_chip_name chipname, sensors_expr *expr,284 int sensors_eval_expr(sensors_chip_name chipname, const sensors_expr *expr, 284 285 double val, double *result) 285 286 { 286 287 double res1,res2; 287 288 int res; 288 sensors_chip_feature *feature;289 const sensors_chip_feature *feature; 289 290 290 291 if (expr->kind == sensors_kind_val) { … … 330 331 return 0; 331 332 } 332 333 -
lm-sensors/trunk/lib/access.h
r119 r120 32 32 you want the match that was latest in the config file. */ 33 33 extern sensors_chip *sensors_for_all_config_chips(sensors_chip_name chip_name, 34 sensors_chip *last);34 const sensors_chip *last); 35 35 36 36 /* Look up a resource in the intern chip list, and return a pointer to it. 37 37 Do not modify the struct the return value points to! Returns NULL if 38 38 not found. */ 39 extern sensors_chip_feature *sensors_lookup_feature_nr(const char *prefix,40 int feature);39 extern const sensors_chip_feature *sensors_lookup_feature_nr(const char *prefix, 40 int feature); 41 41 42 42 /* Look up a resource in the intern chip list, and return a pointer to it. 43 43 Do not modify the struct the return value points to! Returns NULL if 44 44 not found.*/ 45 extern sensors_chip_feature *sensors_lookup_feature_name(const char *prefix,46 const char *feature);45 extern const sensors_chip_feature *sensors_lookup_feature_name 46 (const char *prefix, const char *feature); 47 47 48 48 /* Substitute configuration bus numbers with real-world /proc bus numbers … … 56 56 57 57 /* Evaluate an expression */ 58 extern int sensors_eval_expr(sensors_chip_name chipname, sensors_expr *expr, 58 extern int sensors_eval_expr(sensors_chip_name chipname, 59 const sensors_expr *expr, 59 60 double val, double *result); 60 61 -
lm-sensors/trunk/lib/error.c
r97 r120 53 53 void sensors_default_parse_error(const char *err, int lineno) 54 54 { 55 fprintf(stderr," Line %d: %s\n",lineno,err);55 fprintf(stderr,"Error: Line %d: %s\n",lineno,err); 56 56 } 57 57 -
lm-sensors/trunk/lib/proc.c
r101 r120 68 68 char *bufptr = buf; 69 69 sensors_proc_chips_entry entry; 70 int res ;70 int res,lineno; 71 71 72 72 if (sysctl(name, 3, bufptr, &buflen, NULL, 0)) 73 73 return -SENSORS_ERR_PROC; 74 74 75 lineno = 1; 75 76 while (buflen >= sizeof(struct sensors_chips_data)) { 76 77 if ((res = 77 78 sensors_parse_chip_name(((struct sensors_chips_data *) bufptr)->name, 78 &entry.name))) 79 &entry.name))) { 80 sensors_parse_error("Parsing /proc/sys/dev/sensors/chips",lineno); 79 81 return res; 82 } 80 83 entry.sysctl = ((struct sensors_chips_data *) bufptr)->sysctl_id; 81 84 add_proc_chips(&entry); 82 85 bufptr += sizeof(struct sensors_chips_data); 83 86 buflen -= sizeof(struct sensors_chips_data); 87 lineno++; 84 88 } 85 89 return 0; … … 92 96 char *border; 93 97 sensors_bus entry; 98 int lineno; 99 94 100 f = fopen("/proc/bus/i2c","r"); 95 101 if (!f) 96 102 return -SENSORS_ERR_PROC; 103 lineno=1; 97 104 while (fgets(line,255,f)) { 98 105 if (strlen(line) > 0) … … 118 125 sensors_strip_of_spaces(entry.adapter); 119 126 add_bus(&entry); 127 lineno++; 120 128 } 121 129 fclose(f); … … 124 132 sensors_fatal_error("sensors_read_proc_bus","Allocating entry"); 125 133 ERROR: 134 sensors_parse_error("Parsing /proc/bus/i2c",lineno); 126 135 fclose(f); 127 136 return -SENSORS_ERR_PROC; … … 143 152 { 144 153 int sysctl_name[4] = { CTL_DEV, DEV_SENSORS }; 145 sensors_chip_feature *the_feature;154 const sensors_chip_feature *the_feature; 146 155 int buflen = BUF_LEN; 147 156 int mag; … … 165 174 { 166 175 int sysctl_name[4] = { CTL_DEV, DEV_SENSORS }; 167 sensors_chip_feature *the_feature;176 const sensors_chip_feature *the_feature; 168 177 int buflen = BUF_LEN; 169 178 int mag;
