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
c9e59b4a
Commit
c9e59b4a
authored
Feb 22, 2010
by
Hisham Muhammad
Browse files
minor tweaks by David Weber
parent
7dcd2beb
Changes
3
Hide whitespace changes
Inline
Side-by-side
BatteryMeter.c
View file @
c9e59b4a
...
@@ -35,7 +35,7 @@ static unsigned long int parseUevent(FILE * file, char *key) {
...
@@ -35,7 +35,7 @@ static unsigned long int parseUevent(FILE * file, char *key) {
while
(
fgets
(
line
,
sizeof
line
,
file
))
{
while
(
fgets
(
line
,
sizeof
line
,
file
))
{
if
(
strncmp
(
line
,
key
,
strlen
(
key
))
==
0
)
{
if
(
strncmp
(
line
,
key
,
strlen
(
key
))
==
0
)
{
char
*
value
;
char
*
value
;
value
=
strtok
(
line
,
"="
);
strtok
(
line
,
"="
);
value
=
strtok
(
NULL
,
"="
);
value
=
strtok
(
NULL
,
"="
);
dValue
=
atoi
(
value
);
dValue
=
atoi
(
value
);
break
;
break
;
...
@@ -122,7 +122,6 @@ static ACPresence chkIsOnline() {
...
@@ -122,7 +122,6 @@ static ACPresence chkIsOnline() {
char
*
entryName
;
char
*
entryName
;
if
(
!
power_supplyDir
)
{
if
(
!
power_supplyDir
)
{
closedir
(
power_supplyDir
);
return
AC_ERROR
;
return
AC_ERROR
;
}
}
...
@@ -246,7 +245,6 @@ static double getSysBatData() {
...
@@ -246,7 +245,6 @@ static double getSysBatData() {
if
(
!
power_supplyDir
)
{
if
(
!
power_supplyDir
)
{
closedir
(
power_supplyDir
);
return
0
;
return
0
;
}
}
...
...
ProcessList.c
View file @
c9e59b4a
...
@@ -488,10 +488,7 @@ static void ProcessList_readIoFile(ProcessList* this, Process* proc, char* dirna
...
@@ -488,10 +488,7 @@ static void ProcessList_readIoFile(ProcessList* this, Process* proc, char* dirna
unsigned
long
long
now
=
tv
.
tv_sec
*
1000
+
tv
.
tv_usec
/
1000
;
unsigned
long
long
now
=
tv
.
tv_sec
*
1000
+
tv
.
tv_usec
/
1000
;
unsigned
long
long
last_read
=
proc
->
io_read_bytes
;
unsigned
long
long
last_read
=
proc
->
io_read_bytes
;
unsigned
long
long
last_write
=
proc
->
io_write_bytes
;
unsigned
long
long
last_write
=
proc
->
io_write_bytes
;
while
(
!
feof
(
io
))
{
while
(
fgets
(
buffer
,
255
,
io
))
{
char
*
ok
=
fgets
(
buffer
,
255
,
io
);
if
(
!
ok
)
break
;
if
(
ProcessList_read
(
this
,
buffer
,
"rchar: %llu"
,
&
proc
->
io_rchar
))
continue
;
if
(
ProcessList_read
(
this
,
buffer
,
"rchar: %llu"
,
&
proc
->
io_rchar
))
continue
;
if
(
ProcessList_read
(
this
,
buffer
,
"wchar: %llu"
,
&
proc
->
io_wchar
))
continue
;
if
(
ProcessList_read
(
this
,
buffer
,
"wchar: %llu"
,
&
proc
->
io_wchar
))
continue
;
if
(
ProcessList_read
(
this
,
buffer
,
"syscr: %llu"
,
&
proc
->
io_syscr
))
continue
;
if
(
ProcessList_read
(
this
,
buffer
,
"syscr: %llu"
,
&
proc
->
io_syscr
))
continue
;
...
@@ -520,6 +517,7 @@ static bool ProcessList_processEntries(ProcessList* this, char* dirname, Process
...
@@ -520,6 +517,7 @@ static bool ProcessList_processEntries(ProcessList* this, char* dirname, Process
DIR
*
dir
;
DIR
*
dir
;
struct
dirent
*
entry
;
struct
dirent
*
entry
;
Process
*
prototype
=
this
->
prototype
;
Process
*
prototype
=
this
->
prototype
;
int
parentPid
=
parent
?
parent
->
pid
:
0
;
dir
=
opendir
(
dirname
);
dir
=
opendir
(
dirname
);
if
(
!
dir
)
return
false
;
if
(
!
dir
)
return
false
;
...
@@ -648,10 +646,7 @@ static bool ProcessList_processEntries(ProcessList* this, char* dirname, Process
...
@@ -648,10 +646,7 @@ static bool ProcessList_processEntries(ProcessList* this, char* dirname, Process
else
{
else
{
char
buffer
[
256
];
char
buffer
[
256
];
process
->
vxid
=
0
;
process
->
vxid
=
0
;
while
(
!
feof
(
status
))
{
while
(
fgets
(
buffer
,
255
,
status
))
{
char
*
ok
=
fgets
(
buffer
,
255
,
status
);
if
(
!
ok
)
break
;
if
(
String_startsWith
(
buffer
,
"VxID:"
))
{
if
(
String_startsWith
(
buffer
,
"VxID:"
))
{
int
vxid
;
int
vxid
;
...
@@ -687,9 +682,10 @@ static bool ProcessList_processEntries(ProcessList* this, char* dirname, Process
...
@@ -687,9 +682,10 @@ static bool ProcessList_processEntries(ProcessList* this, char* dirname, Process
command
[
i
]
=
' '
;
command
[
i
]
=
' '
;
command
[
amtRead
]
=
'\0'
;
command
[
amtRead
]
=
'\0'
;
}
}
fclose
(
status
);
command
[
PROCESS_COMM_LEN
]
=
'\0'
;
command
[
PROCESS_COMM_LEN
]
=
'\0'
;
process
->
comm
=
String_copy
(
command
);
process
->
comm
=
String_copy
(
command
);
fclose
(
status
);
}
}
int
percent_cpu
=
(
process
->
utime
+
process
->
stime
-
lasttimes
)
/
int
percent_cpu
=
(
process
->
utime
+
process
->
stime
-
lasttimes
)
/
...
@@ -737,8 +733,7 @@ void ProcessList_scan(ProcessList* this) {
...
@@ -737,8 +733,7 @@ void ProcessList_scan(ProcessList* this) {
status
=
ProcessList_fopen
(
this
,
PROCMEMINFOFILE
,
"r"
);
status
=
ProcessList_fopen
(
this
,
PROCMEMINFOFILE
,
"r"
);
assert
(
status
!=
NULL
);
assert
(
status
!=
NULL
);
int
processors
=
this
->
processorCount
;
int
processors
=
this
->
processorCount
;
while
(
!
feof
(
status
))
{
while
(
fgets
(
buffer
,
128
,
status
))
{
fgets
(
buffer
,
128
,
status
);
switch
(
buffer
[
0
])
{
switch
(
buffer
[
0
])
{
case
'M'
:
case
'M'
:
...
...
Settings.c
View file @
c9e59b4a
...
@@ -63,12 +63,10 @@ static bool Settings_read(Settings* this, char* fileName) {
...
@@ -63,12 +63,10 @@ static bool Settings_read(Settings* this, char* fileName) {
if
(
fd
==
NULL
)
{
if
(
fd
==
NULL
)
{
return
false
;
return
false
;
}
}
const
int
maxLine
=
65535
;
const
int
maxLine
=
2048
;
char
buffer
[
maxLine
];
char
buffer
[
maxLine
];
bool
readMeters
=
false
;
bool
readMeters
=
false
;
while
(
!
feof
(
fd
))
{
while
(
fgets
(
buffer
,
maxLine
,
fd
))
{
buffer
[
0
]
=
'\0'
;
fgets
(
buffer
,
maxLine
,
fd
);
char
**
option
=
String_split
(
buffer
,
'='
);
char
**
option
=
String_split
(
buffer
,
'='
);
if
(
String_eq
(
option
[
0
],
"fields"
))
{
if
(
String_eq
(
option
[
0
],
"fields"
))
{
char
*
trim
=
String_trim
(
option
[
1
]);
char
*
trim
=
String_trim
(
option
[
1
]);
...
...
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