Changeset 4701
- Timestamp:
- 08/26/07 10:26:20 (6 years ago)
- Location:
- lm-sensors/branches/lm-sensors-3.0.0
- Files:
-
- 6 modified
-
lib/access.c (modified) (2 diffs)
-
lib/libsensors.3 (modified) (2 diffs)
-
lib/sensors.h (modified) (1 diff)
-
prog/sensord/rrd.c (modified) (1 diff)
-
prog/sensord/sense.c (modified) (1 diff)
-
prog/sensors/main.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/lm-sensors-3.0.0/lib/access.c
r4695 r4701 304 304 } 305 305 306 const sensors_chip_name *sensors_get_detected_chips(int *nr) 306 const sensors_chip_name *sensors_get_detected_chips(const sensors_chip_name 307 *match, int *nr) 307 308 { 308 309 const sensors_chip_name *res; 309 res = (*nr >= sensors_proc_chips_count ? 310 NULL : &sensors_proc_chips[*nr].chip); 311 (*nr)++; 312 return res; 310 311 while (*nr < sensors_proc_chips_count) { 312 res = &sensors_proc_chips[(*nr)++].chip; 313 if (!match || sensors_match_chip(res, match)) 314 return res; 315 } 316 return NULL; 313 317 } 314 318 … … 481 485 int res = 0; 482 486 483 for (nr = 0; (found_name = sensors_get_detected_chips(&nr));) 484 if (sensors_match_chip(name, found_name)) { 485 this_res = sensors_do_this_chip_sets(found_name); 486 if (!res) 487 res = this_res; 488 } 487 for (nr = 0; (found_name = sensors_get_detected_chips(name, &nr));) { 488 this_res = sensors_do_this_chip_sets(found_name); 489 if (this_res) 490 res = this_res; 491 } 489 492 return res; 490 493 } -
lm-sensors/branches/lm-sensors-3.0.0/lib/libsensors.3
r4699 r4701 45 45 \fBdouble value);\fP 46 46 .B int sensors_do_chip_sets(const sensors_chip_name *name); 47 .B const sensors_chip_name *sensors_get_detected_chips(int *nr); 47 .B const sensors_chip_name *sensors_get_detected_chips(const sensors_chip_name 48 \fB*match, int *nr);\fP 48 49 .B const sensors_feature_data *sensors_get_all_features 49 50 \fB(const sensors_chip_name *name, int *nr);\fP … … 99 100 Execute all set statements for this particular chip. The chip may contain wildcards! This function will return 0 on success, and <0 on failure. 100 101 101 \fBconst sensors_chip_name *sensors_get_detected_chips 102 (int *nr);\fP102 \fBconst sensors_chip_name *sensors_get_detected_chips(const sensors_chip_name 103 *match, int *nr);\fP 103 104 .br 104 This function returns all detected chips, one by one. To start at the beginning of the list, use 0 for nr; NULL is returned if we are at the end of the list. Do not try to change these chip names, as they point to internal structures! Do not use nr for anything else. 105 This function returns all detected chips that match a given chip name, 106 one by one. If no chip name is provided, all detected chips are returned. 107 To start at the beginning of the list, use 0 for nr; NULL is returned if 108 we are at the end of the list. Do not try to change these chip names, as 109 they point to internal structures! 105 110 106 111 This structure is used when you want to get all features of a specific chip. -
lm-sensors/branches/lm-sensors-3.0.0/lib/sensors.h
r4696 r4701 110 110 int sensors_do_chip_sets(const sensors_chip_name *name); 111 111 112 /* This function returns all detected chips, one by one. To start at the 113 beginning of the list, use 0 for nr; NULL is returned if we are 114 at the end of the list. Do not try to change these chip names, as 115 they point to internal structures! Do not use nr for anything else. */ 116 const sensors_chip_name *sensors_get_detected_chips(int *nr); 112 /* This function returns all detected chips that match a given chip name, 113 one by one. If no chip name is provided, all detected chips are returned. 114 To start at the beginning of the list, use 0 for nr; NULL is returned if 115 we are at the end of the list. Do not try to change these chip names, as 116 they point to internal structures! */ 117 const sensors_chip_name *sensors_get_detected_chips(const sensors_chip_name 118 *match, int *nr); 117 119 118 120 /* These defines are used in the mode field of sensors_feature_data */ -
lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/rrd.c
r4694 r4701 140 140 int i = 0, j, ret = 0, num = 0; 141 141 142 while ((ret == 0) && ((chip = sensors_get_detected_chips (&i)) != NULL)) { 143 for (j = 0; (ret == 0) && (j < numChipNames); ++ j) { 144 if (sensors_match_chip (chip, &chipNames[j])) { 145 int index0, subindex, chipindex = -1; 146 for (index0 = 0; knownChips[index0]; ++ index0) 147 for (subindex = 0; knownChips[index0]->names[subindex]; ++ subindex) 148 if (!strcmp (chip->prefix, knownChips[index0]->names[subindex])) 149 chipindex = index0; 150 if (chipindex >= 0) { 151 const ChipDescriptor *descriptor = knownChips[chipindex]; 152 const FeatureDescriptor *features = descriptor->features; 153 154 for (index0 = 0; (ret == 0) && (num < MAX_RRD_SENSORS) && features[index0].format; ++ index0) { 155 const FeatureDescriptor *feature = features + index0; 156 int labelNumber = feature->dataNumbers[0]; 157 const char *rawLabel = NULL; 158 char *label = NULL; 159 int valid = 0; 160 if (getValid (chip, labelNumber, &valid)) { 161 sensorLog (LOG_ERR, "Error getting sensor validity: %s/#%d", chip->prefix, labelNumber); 162 ret = -1; 163 } else if (getRawLabel (chip, labelNumber, &rawLabel)) { 164 sensorLog (LOG_ERR, "Error getting raw sensor label: %s/#%d", chip->prefix, labelNumber); 165 ret = -1; 166 } else if (!(label = sensors_get_label (chip, labelNumber))) { 167 sensorLog (LOG_ERR, "Error getting sensor label: %s/#%d", chip->prefix, labelNumber); 168 ret = -1; 169 } else if (valid) { 170 rrdCheckLabel (rawLabel, num); 171 ret = fn (data, rrdLabels[num], label, feature); 172 ++ num; 173 } 174 if (label) 175 free (label); 142 for (j = 0; (ret == 0) && (j < numChipNames); ++ j) { 143 while ((ret == 0) && ((chip = sensors_get_detected_chips (&chipNames[j], &i)) != NULL)) { 144 int index0, subindex, chipindex = -1; 145 for (index0 = 0; knownChips[index0]; ++ index0) 146 for (subindex = 0; knownChips[index0]->names[subindex]; ++ subindex) 147 if (!strcmp (chip->prefix, knownChips[index0]->names[subindex])) 148 chipindex = index0; 149 if (chipindex >= 0) { 150 const ChipDescriptor *descriptor = knownChips[chipindex]; 151 const FeatureDescriptor *features = descriptor->features; 152 153 for (index0 = 0; (ret == 0) && (num < MAX_RRD_SENSORS) && features[index0].format; ++ index0) { 154 const FeatureDescriptor *feature = features + index0; 155 int labelNumber = feature->dataNumbers[0]; 156 const char *rawLabel = NULL; 157 char *label = NULL; 158 int valid = 0; 159 if (getValid (chip, labelNumber, &valid)) { 160 sensorLog (LOG_ERR, "Error getting sensor validity: %s/#%d", chip->prefix, labelNumber); 161 ret = -1; 162 } else if (getRawLabel (chip, labelNumber, &rawLabel)) { 163 sensorLog (LOG_ERR, "Error getting raw sensor label: %s/#%d", chip->prefix, labelNumber); 164 ret = -1; 165 } else if (!(label = sensors_get_label (chip, labelNumber))) { 166 sensorLog (LOG_ERR, "Error getting sensor label: %s/#%d", chip->prefix, labelNumber); 167 ret = -1; 168 } else if (valid) { 169 rrdCheckLabel (rawLabel, num); 170 ret = fn (data, rrdLabels[num], label, feature); 171 ++ num; 176 172 } 173 if (label) 174 free (label); 177 175 } 178 176 } -
lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/sense.c
r4695 r4701 239 239 int i = 0, j, ret = 0; 240 240 241 while ((ret == 0) && ((chip = sensors_get_detected_chips (&i)) != NULL)) { 242 for (j = 0; (ret == 0) && (j < numChipNames); ++ j) { 243 if (sensors_match_chip (chip, &chipNames[j])) { 244 ret = doChip (chip, action); 245 } 241 for (j = 0; (ret == 0) && (j < numChipNames); ++ j) { 242 while ((ret == 0) && ((chip = sensors_get_detected_chips (&chipNames[j], &i)) != NULL)) { 243 ret = doChip (chip, action); 246 244 } 247 245 } -
lm-sensors/branches/lm-sensors-3.0.0/prog/sensors/main.c
r4698 r4701 252 252 253 253 *error = 0; 254 for ( chip_nr = 0; (chip = sensors_get_detected_chips(&chip_nr));)255 for(i = 0; i < chips_count; i++)256 if (sensors_match_chip(chip, &chips[i])) {257 if(do_sets) {258 if (do_a_set(chip))259 *error = 1;260 } else261 do_a_print(chip);262 i = chips_count;263 cnt++; 264 }265 return(cnt);254 for (i = 0; i < chips_count; i++) { 255 chip_nr = 0; 256 while ((chip = sensors_get_detected_chips(&chips[i], &chip_nr))) { 257 if (do_sets) { 258 if (do_a_set(chip)) 259 *error = 1; 260 } else 261 do_a_print(chip); 262 cnt++; 263 } 264 } 265 return cnt; 266 266 } 267 267
