diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2015-08-19 13:56:46 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2015-08-19 13:56:46 -0300 |
commit | f70649a1785f0453c7af8c46e2d6712b07384994 (patch) | |
tree | 5355703c92163253c18b37ca46c464635ac06819 /darwin/Battery.c | |
parent | 907f8298a0337510f9f048df65a9f5d032f09d14 (diff) |
Standardize indentation.
Diffstat (limited to 'darwin/Battery.c')
-rw-r--r-- | darwin/Battery.c | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/darwin/Battery.c b/darwin/Battery.c index 2847f52f..d197c049 100644 --- a/darwin/Battery.c +++ b/darwin/Battery.c @@ -7,7 +7,7 @@ #include <IOKit/ps/IOPSKeys.h> void Battery_getData(double* level, ACPresence* isOnAC) { - CFTypeRef power_sources = IOPSCopyPowerSourcesInfo(); + CFTypeRef power_sources = IOPSCopyPowerSourcesInfo(); *level = -1; *isOnAC = AC_ERROR; @@ -22,50 +22,50 @@ void Battery_getData(double* level, ACPresence* isOnAC) { int len; if(NULL == list) { - CFRelease(power_sources); + CFRelease(power_sources); - return; + return; } len = CFArrayGetCount(list); /* Get the battery */ for(int i = 0; i < len && battery == NULL; ++i) { - CFDictionaryRef candidate = IOPSGetPowerSourceDescription(power_sources, - CFArrayGetValueAtIndex(list, i)); /* GET rule */ - CFStringRef type; - - if(NULL != candidate) { - type = (CFStringRef) CFDictionaryGetValue(candidate, - CFSTR(kIOPSTransportTypeKey)); /* GET rule */ - - if(kCFCompareEqualTo == CFStringCompare(type, CFSTR(kIOPSInternalType), 0)) { - CFRetain(candidate); - battery = candidate; - } - } + CFDictionaryRef candidate = IOPSGetPowerSourceDescription(power_sources, + CFArrayGetValueAtIndex(list, i)); /* GET rule */ + CFStringRef type; + + if(NULL != candidate) { + type = (CFStringRef) CFDictionaryGetValue(candidate, + CFSTR(kIOPSTransportTypeKey)); /* GET rule */ + + if(kCFCompareEqualTo == CFStringCompare(type, CFSTR(kIOPSInternalType), 0)) { + CFRetain(candidate); + battery = candidate; + } + } } if(NULL != battery) { - /* Determine the AC state */ - CFStringRef power_state = CFDictionaryGetValue(battery, CFSTR(kIOPSPowerSourceStateKey)); + /* Determine the AC state */ + CFStringRef power_state = CFDictionaryGetValue(battery, CFSTR(kIOPSPowerSourceStateKey)); - *isOnAC = (kCFCompareEqualTo == CFStringCompare(power_state, CFSTR(kIOPSACPowerValue), 0)) - ? AC_PRESENT - : AC_ABSENT; + *isOnAC = (kCFCompareEqualTo == CFStringCompare(power_state, CFSTR(kIOPSACPowerValue), 0)) + ? AC_PRESENT + : AC_ABSENT; - /* Get the percentage remaining */ - double current; - double max; + /* Get the percentage remaining */ + double current; + double max; - CFNumberGetValue(CFDictionaryGetValue(battery, CFSTR(kIOPSCurrentCapacityKey)), - kCFNumberDoubleType, ¤t); - CFNumberGetValue(CFDictionaryGetValue(battery, CFSTR(kIOPSMaxCapacityKey)), - kCFNumberDoubleType, &max); + CFNumberGetValue(CFDictionaryGetValue(battery, CFSTR(kIOPSCurrentCapacityKey)), + kCFNumberDoubleType, ¤t); + CFNumberGetValue(CFDictionaryGetValue(battery, CFSTR(kIOPSMaxCapacityKey)), + kCFNumberDoubleType, &max); - *level = (current * 100.0) / max; + *level = (current * 100.0) / max; - CFRelease(battery); + CFRelease(battery); } CFRelease(list); |