Trimmed whitespace.

This commit is contained in:
n-a-c-h
2005-10-08 23:47:37 +00:00
parent ad6146b677
commit 2b3b6f0e1b
3 changed files with 17 additions and 17 deletions

View File

@@ -1341,11 +1341,11 @@ Special thanks David Lee Lambert for most of the code here
#ifdef linux #ifdef linux
int CheckBattery() int CheckBattery()
{ {
int battery = -1; //No battery / Can't get info int battery = -1; //No battery / Can't get info
const char *ac = "/proc/acpi/ac_adapter/"; const char *ac = "/proc/acpi/ac_adapter/";
//Check ac adapter //Check ac adapter
DIR *ac_dir = opendir(ac); DIR *ac_dir = opendir(ac);
if (ac_dir) if (ac_dir)
{ {
@@ -1353,12 +1353,12 @@ int CheckBattery()
FILE *fp; FILE *fp;
const char *pattern = " %39[^:]: %39[ -~]"; // for sscanf const char *pattern = " %39[^:]: %39[ -~]"; // for sscanf
char line[80], key[40], arg[40]; char line[80], key[40], arg[40];
struct dirent *ent; struct dirent *ent;
while ((ent = readdir(ac_dir))) while ((ent = readdir(ac_dir)))
{ {
if (ent->d_name[0] == '.') { continue; } if (ent->d_name[0] == '.') { continue; }
snprintf(fnbuf, 40, "%s%s/state", ac, ent->d_name); snprintf(fnbuf, 40, "%s%s/state", ac, ent->d_name);
fp = fopen(fnbuf, "r"); fp = fopen(fnbuf, "r");
if (fp) if (fp)
@@ -1392,8 +1392,8 @@ static int BatteryLifePercent;
static void update_battery_info() static void update_battery_info()
{ {
const char *batt = "/proc/acpi/battery/"; const char *batt = "/proc/acpi/battery/";
//Check batteries //Check batteries
DIR *batt_dir = opendir(batt); DIR *batt_dir = opendir(batt);
if (batt_dir) if (batt_dir)
{ {
@@ -1401,9 +1401,9 @@ static void update_battery_info()
FILE *fp; FILE *fp;
const char *pattern = " %39[^:]: %39[ -~]"; // for sscanf const char *pattern = " %39[^:]: %39[ -~]"; // for sscanf
char line[80], key[40], arg[40]; char line[80], key[40], arg[40];
float x, design_capacity = 0.0f, remaining_capacity = 0.0f, present_rate = 0.0f, full_capacity = 0.0f; float x, design_capacity = 0.0f, remaining_capacity = 0.0f, present_rate = 0.0f, full_capacity = 0.0f;
struct dirent *ent; struct dirent *ent;
while ((ent = readdir(batt_dir))) while ((ent = readdir(batt_dir)))
{ {
@@ -1421,7 +1421,7 @@ static void update_battery_info()
else if (strcmp(key, "last full capacity") == 0 && sscanf(arg, "%g", &x) == 1) else if (strcmp(key, "last full capacity") == 0 && sscanf(arg, "%g", &x) == 1)
{ {
full_capacity += x; full_capacity += x;
} }
} }
fclose(fp); fclose(fp);
} }
@@ -1462,7 +1462,7 @@ static void update_battery_info()
BatteryLifePercent = (int)floorf(remaining_capacity / ((full_capacity > 0.0f) ? full_capacity : design_capacity) * 100.0); BatteryLifePercent = (int)floorf(remaining_capacity / ((full_capacity > 0.0f) ? full_capacity : design_capacity) * 100.0);
if (present_rate < 0.0f) if (present_rate < 0.0f)
{ {
// Linux specifies rates in mWh or mAh // Linux specifies rates in mWh or mAh
BatteryLifeTime = (int)floorf(remaining_capacity / (-present_rate) * 3600.0); BatteryLifeTime = (int)floorf(remaining_capacity / (-present_rate) * 3600.0);
} }
} }

View File

@@ -357,8 +357,8 @@ void DisplayBatteryStatus()
#ifndef __MSDOS__ #ifndef __MSDOS__
int CheckBattery(); int CheckBattery();
int CheckBatteryTime(); int CheckBatteryTime();
int CheckBatteryPercent(); int CheckBatteryPercent();
*CSStatus2 = 0; *CSStatus2 = 0;
*CSStatus3 = 0; *CSStatus3 = 0;
@@ -367,7 +367,7 @@ void DisplayBatteryStatus()
case -1: //No battery case -1: //No battery
strcpy(CSStatus, "No battery present"); strcpy(CSStatus, "No battery present");
break; break;
case 0: //Plugged in case 0: //Plugged in
{ {
int percent = CheckBatteryPercent(); int percent = CheckBatteryPercent();
@@ -379,7 +379,7 @@ void DisplayBatteryStatus()
} }
} }
break; break;
case 1: //Not plugged in case 1: //Not plugged in
{ {
int percent = CheckBatteryPercent(); int percent = CheckBatteryPercent();

View File

@@ -3098,7 +3098,7 @@ int CheckBattery()
{ {
return(1); //Running off of battery return(1); //Running off of battery
} }
if ((SysPowerStat.BatteryFlag == 255) || //Unknown if ((SysPowerStat.BatteryFlag == 255) || //Unknown
(SysPowerStat.BatteryFlag & 128)) //No battery (SysPowerStat.BatteryFlag & 128)) //No battery
{ {
@@ -3110,7 +3110,7 @@ int CheckBattery()
{ {
return(0); //Plugged in return(0); //Plugged in
} }
return(1); //Running off of battery return(1); //Running off of battery
} }