Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
58676d70
Commit
58676d70
authored
Feb 02, 2012
by
Hisham Muhammad
Browse files
minor style cleanups
parent
ff8d54c2
Changes
1
Show whitespace changes
Inline
Side-by-side
BatteryMeter.c
View file @
58676d70
...
@@ -50,17 +50,11 @@ static unsigned long int parseUevent(FILE * file, const char *key) {
...
@@ -50,17 +50,11 @@ static unsigned long int parseUevent(FILE * file, const char *key) {
}
}
static
unsigned
long
int
parseBatInfo
(
const
char
*
fileName
,
const
unsigned
short
int
lineNum
,
const
unsigned
short
int
wordNum
)
{
static
unsigned
long
int
parseBatInfo
(
const
char
*
fileName
,
const
unsigned
short
int
lineNum
,
const
unsigned
short
int
wordNum
)
{
DIR
*
batteryDir
;
const
struct
dirent
*
dirEntries
;
const
char
batteryPath
[]
=
PROCDIR
"/acpi/battery/"
;
const
char
batteryPath
[]
=
PROCDIR
"/acpi/battery/"
;
batteryDir
=
opendir
(
batteryPath
);
DIR
*
batteryDir
=
opendir
(
batteryPath
);
if
(
!
batteryDir
)
if
(
batteryDir
==
NULL
)
{
return
0
;
return
0
;
}
char
*
entryName
;
typedef
struct
listLbl
{
typedef
struct
listLbl
{
char
*
content
;
char
*
content
;
struct
listLbl
*
next
;
struct
listLbl
*
next
;
...
@@ -73,8 +67,8 @@ static unsigned long int parseBatInfo(const char *fileName, const unsigned short
...
@@ -73,8 +67,8 @@ static unsigned long int parseBatInfo(const char *fileName, const unsigned short
Some of this is based off of code found in kismet (they claim it came from gkrellm).
Some of this is based off of code found in kismet (they claim it came from gkrellm).
Written for multi battery use...
Written for multi battery use...
*/
*/
for
(
dirEntries
=
readdir
((
DIR
*
)
batteryDir
);
dirEntries
;
dirEntries
=
readdir
((
DIR
*
)
batteryDir
))
{
for
(
const
struct
dirent
*
dirEntries
=
readdir
((
DIR
*
)
batteryDir
);
dirEntries
;
dirEntries
=
readdir
((
DIR
*
)
batteryDir
))
{
entryName
=
(
char
*
)
dirEntries
->
d_name
;
char
*
entryName
=
(
char
*
)
dirEntries
->
d_name
;
if
(
strncmp
(
entryName
,
"BAT"
,
3
))
if
(
strncmp
(
entryName
,
"BAT"
,
3
))
continue
;
continue
;
...
@@ -122,22 +116,16 @@ static ACPresence chkIsOnline() {
...
@@ -122,22 +116,16 @@ static ACPresence chkIsOnline() {
ACPresence
isOn
=
AC_ERROR
;
ACPresence
isOn
=
AC_ERROR
;
if
(
access
(
PROCDIR
"/acpi/ac_adapter"
,
F_OK
)
==
0
)
{
if
(
access
(
PROCDIR
"/acpi/ac_adapter"
,
F_OK
)
==
0
)
{
const
struct
dirent
*
dirEntries
;
const
char
*
power_supplyPath
=
PROCDIR
"/acpi/ac_adapter"
;
const
char
*
power_supplyPath
=
PROCDIR
"/acpi/ac_adapter"
;
DIR
*
power_supplyDir
=
opendir
(
power_supplyPath
);
DIR
*
power_supplyDir
=
opendir
(
power_supplyPath
);
char
*
entryName
;
if
(
!
power_supplyDir
)
if
(
!
power_supplyDir
)
{
return
AC_ERROR
;
return
AC_ERROR
;
}
for
(
dirEntries
=
readdir
((
DIR
*
)
power_supplyDir
);
dirEntries
;
dirEntries
=
readdir
((
DIR
*
)
power_supplyDir
))
{
for
(
const
struct
dirent
*
dirEntries
=
readdir
((
DIR
*
)
power_supplyDir
);
dirEntries
;
dirEntries
=
readdir
((
DIR
*
)
power_supplyDir
))
{
entryName
=
(
char
*
)
dirEntries
->
d_name
;
char
*
entryName
=
(
char
*
)
dirEntries
->
d_name
;
if
(
strncmp
(
entryName
,
"A"
,
1
))
{
if
(
entryName
[
0
]
!=
'A'
)
continue
;
continue
;
}
char
statePath
[
50
];
char
statePath
[
50
];
snprintf
((
char
*
)
statePath
,
sizeof
statePath
,
"%s/%s/state"
,
power_supplyPath
,
entryName
);
snprintf
((
char
*
)
statePath
,
sizeof
statePath
,
"%s/%s/state"
,
power_supplyPath
,
entryName
);
...
@@ -247,11 +235,8 @@ static double getSysBatData() {
...
@@ -247,11 +235,8 @@ static double getSysBatData() {
const
struct
dirent
*
dirEntries
;
const
struct
dirent
*
dirEntries
;
const
char
*
power_supplyPath
=
"/sys/class/power_supply/"
;
const
char
*
power_supplyPath
=
"/sys/class/power_supply/"
;
DIR
*
power_supplyDir
=
opendir
(
power_supplyPath
);
DIR
*
power_supplyDir
=
opendir
(
power_supplyPath
);
if
(
!
power_supplyDir
)
if
(
!
power_supplyDir
)
{
return
0
;
return
0
;
}
char
*
entryName
;
char
*
entryName
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment