/* iterate over the dictionary returned by the kernel */
while ((obj = prop_object_iterator_next(iter)) != NULL) {
/* skip this dict if it's not what we're looking for */
- if ((strlen(prop_dictionary_keysym_cstring_nocopy(obj)) == strlen(sensor_desc)) &&
- (strncmp(sensor_desc,
- prop_dictionary_keysym_cstring_nocopy(obj),
- strlen(sensor_desc)) != 0))
+ if (strcmp(sensor_desc,
+ prop_dictionary_keysym_cstring_nocopy(obj)) != 0)
continue;
is_found = true;
while ((obj2 = prop_object_iterator_next(iter2)) != NULL) {
obj3 = prop_dictionary_get(obj2, "description");
- if (obj3 &&
- strlen(prop_string_cstring_nocopy(obj3)) == 8 &&
- strncmp("charging",
- prop_string_cstring_nocopy(obj3),
- 8) == 0) {
+ if (obj3 == NULL)
+ continue;
+
+ if (strcmp("charging", prop_string_cstring_nocopy(obj3)) == 0) {
obj3 = prop_dictionary_get(obj2, "cur-value");
if (prop_number_integer_value(obj3))
batt_info->status = CS_CHARGING;
else
batt_info->status = CS_DISCHARGING;
-
- continue;
- }
-
- if (obj3 &&
- strlen(prop_string_cstring_nocopy(obj3)) == 6 &&
- strncmp("charge",
- prop_string_cstring_nocopy(obj3),
- 6) == 0) {
+ } else if (strcmp("charge", prop_string_cstring_nocopy(obj3)) == 0) {
obj3 = prop_dictionary_get(obj2, "cur-value");
obj4 = prop_dictionary_get(obj2, "max-value");
obj5 = prop_dictionary_get(obj2, "type");
if (remaining == full_design)
is_full = true;
- if (strncmp("Ampere hour",
- prop_string_cstring_nocopy(obj5),
- 11) == 0)
+ if (strcmp("Ampere hour", prop_string_cstring_nocopy(obj5)) == 0)
watt_as_unit = false;
else
watt_as_unit = true;
-
- continue;
- }
-
- if (obj3 &&
- strlen(prop_string_cstring_nocopy(obj3)) == 14 &&
- strncmp("discharge rate",
- prop_string_cstring_nocopy(obj3),
- 14) == 0) {
+ } else if (strcmp("discharge rate", prop_string_cstring_nocopy(obj3)) == 0) {
obj3 = prop_dictionary_get(obj2, "cur-value");
batt_info->present_rate = prop_number_integer_value(obj3);
- continue;
- }
-
- if (obj3 &&
- strlen(prop_string_cstring_nocopy(obj3)) == 13 &&
- strncmp("last full cap",
- prop_string_cstring_nocopy(obj3),
- 13) == 0) {
+ } else if (strcmp("last full cap", prop_string_cstring_nocopy(obj3)) == 0) {
obj3 = prop_dictionary_get(obj2, "cur-value");
last_full_cap = prop_number_integer_value(obj3);
- continue;
- }
-
- if (obj3 &&
- strlen(prop_string_cstring_nocopy(obj3)) == 7 &&
- strncmp("voltage",
- prop_string_cstring_nocopy(obj3),
- 7) == 0) {
+ } else if (strcmp("voltage", prop_string_cstring_nocopy(obj3)) == 0) {
obj3 = prop_dictionary_get(obj2, "cur-value");
voltage = prop_number_integer_value(obj3);
- continue;
}
}
prop_object_iterator_release(iter2);