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
b291fba0
Commit
b291fba0
authored
Apr 09, 2015
by
Hisham Muhammad
Browse files
Fixes to use platform-specific compare routines.
parent
dc4576d3
Changes
5
Hide whitespace changes
Inline
Side-by-side
ProcessList.c
View file @
b291fba0
...
@@ -74,15 +74,15 @@ void ProcessList_goThroughEntries(ProcessList* pl);
...
@@ -74,15 +74,15 @@ void ProcessList_goThroughEntries(ProcessList* pl);
}*/
}*/
ProcessList
*
ProcessList_init
(
ProcessList
*
this
,
UsersTable
*
usersTable
,
Hashtable
*
pidWhiteList
,
uid_t
userId
)
{
ProcessList
*
ProcessList_init
(
ProcessList
*
this
,
ObjectClass
*
klass
,
UsersTable
*
usersTable
,
Hashtable
*
pidWhiteList
,
uid_t
userId
)
{
this
->
processes
=
Vector_new
(
C
lass
(
Process
)
,
true
,
DEFAULT_SIZE
);
this
->
processes
=
Vector_new
(
k
lass
,
true
,
DEFAULT_SIZE
);
this
->
processTable
=
Hashtable_new
(
140
,
false
);
this
->
processTable
=
Hashtable_new
(
140
,
false
);
this
->
usersTable
=
usersTable
;
this
->
usersTable
=
usersTable
;
this
->
pidWhiteList
=
pidWhiteList
;
this
->
pidWhiteList
=
pidWhiteList
;
this
->
userId
=
userId
;
this
->
userId
=
userId
;
// tree-view auxiliary buffer
s
// tree-view auxiliary buffer
this
->
processes2
=
Vector_new
(
C
lass
(
Process
)
,
true
,
DEFAULT_SIZE
);
this
->
processes2
=
Vector_new
(
k
lass
,
true
,
DEFAULT_SIZE
);
// set later by platform-specific code
// set later by platform-specific code
this
->
cpuCount
=
0
;
this
->
cpuCount
=
0
;
...
...
ProcessList.h
View file @
b291fba0
...
@@ -67,7 +67,7 @@ void ProcessList_delete(ProcessList* pl);
...
@@ -67,7 +67,7 @@ void ProcessList_delete(ProcessList* pl);
void
ProcessList_goThroughEntries
(
ProcessList
*
pl
);
void
ProcessList_goThroughEntries
(
ProcessList
*
pl
);
ProcessList
*
ProcessList_init
(
ProcessList
*
this
,
UsersTable
*
usersTable
,
Hashtable
*
pidWhiteList
,
uid_t
userId
);
ProcessList
*
ProcessList_init
(
ProcessList
*
this
,
ObjectClass
*
klass
,
UsersTable
*
usersTable
,
Hashtable
*
pidWhiteList
,
uid_t
userId
);
void
ProcessList_done
(
ProcessList
*
this
);
void
ProcessList_done
(
ProcessList
*
this
);
...
...
freebsd/FreeBSDProcess.c
View file @
b291fba0
...
@@ -36,6 +36,16 @@ typedef struct FreeBSDProcess_ {
...
@@ -36,6 +36,16 @@ typedef struct FreeBSDProcess_ {
}*/
}*/
ProcessClass
FreeBSDProcess_class
=
{
.
super
=
{
.
extends
=
Class
(
Process
),
.
display
=
Process_display
,
.
delete
=
Process_delete
,
.
compare
=
FreeBSDProcess_compare
},
.
writeField
=
(
Process_WriteField
)
FreeBSDProcess_writeField
,
};
ProcessFieldData
Process_fields
[]
=
{
ProcessFieldData
Process_fields
[]
=
{
[
0
]
=
{
.
name
=
""
,
.
title
=
NULL
,
.
description
=
NULL
,
.
flags
=
0
,
},
[
0
]
=
{
.
name
=
""
,
.
title
=
NULL
,
.
description
=
NULL
,
.
flags
=
0
,
},
[
PID
]
=
{
.
name
=
"PID"
,
.
title
=
" PID "
,
.
description
=
"Process/thread ID"
,
.
flags
=
0
,
},
[
PID
]
=
{
.
name
=
"PID"
,
.
title
=
" PID "
,
.
description
=
"Process/thread ID"
,
.
flags
=
0
,
},
...
@@ -94,7 +104,7 @@ void Process_setupColumnWidths() {
...
@@ -94,7 +104,7 @@ void Process_setupColumnWidths() {
FreeBSDProcess
*
FreeBSDProcess_new
(
Settings
*
settings
)
{
FreeBSDProcess
*
FreeBSDProcess_new
(
Settings
*
settings
)
{
FreeBSDProcess
*
this
=
calloc
(
sizeof
(
FreeBSDProcess
),
1
);
FreeBSDProcess
*
this
=
calloc
(
sizeof
(
FreeBSDProcess
),
1
);
Object_setClass
(
this
,
Class
(
Process
));
Object_setClass
(
this
,
Class
(
FreeBSD
Process
));
Process_init
(
&
this
->
super
,
settings
);
Process_init
(
&
this
->
super
,
settings
);
return
this
;
return
this
;
}
}
...
@@ -105,7 +115,7 @@ void Process_delete(Object* cast) {
...
@@ -105,7 +115,7 @@ void Process_delete(Object* cast) {
free
(
this
);
free
(
this
);
}
}
void
Process_writeField
(
Process
*
this
,
RichString
*
str
,
ProcessField
field
)
{
void
FreeBSD
Process_writeField
(
Process
*
this
,
RichString
*
str
,
ProcessField
field
)
{
//FreeBSDProcess* fp = (FreeBSDProcess*) this;
//FreeBSDProcess* fp = (FreeBSDProcess*) this;
char
buffer
[
256
];
buffer
[
255
]
=
'\0'
;
char
buffer
[
256
];
buffer
[
255
]
=
'\0'
;
int
attr
=
CRT_colors
[
DEFAULT_COLOR
];
int
attr
=
CRT_colors
[
DEFAULT_COLOR
];
...
@@ -113,13 +123,13 @@ void Process_writeField(Process* this, RichString* str, ProcessField field) {
...
@@ -113,13 +123,13 @@ void Process_writeField(Process* this, RichString* str, ProcessField field) {
switch
(
field
)
{
switch
(
field
)
{
// add FreeBSD-specific fields here
// add FreeBSD-specific fields here
default:
default:
Process_write
Default
Field
(
this
,
str
,
field
);
Process_writeField
(
this
,
str
,
field
);
return
;
return
;
}
}
RichString_append
(
str
,
attr
,
buffer
);
RichString_append
(
str
,
attr
,
buffer
);
}
}
long
Process_compare
(
const
void
*
v1
,
const
void
*
v2
)
{
long
FreeBSD
Process_compare
(
const
void
*
v1
,
const
void
*
v2
)
{
FreeBSDProcess
*
p1
,
*
p2
;
FreeBSDProcess
*
p1
,
*
p2
;
Settings
*
settings
=
((
Process
*
)
v1
)
->
settings
;
Settings
*
settings
=
((
Process
*
)
v1
)
->
settings
;
if
(
settings
->
direction
==
1
)
{
if
(
settings
->
direction
==
1
)
{
...
@@ -132,7 +142,7 @@ long Process_compare(const void* v1, const void* v2) {
...
@@ -132,7 +142,7 @@ long Process_compare(const void* v1, const void* v2) {
switch
(
settings
->
sortKey
)
{
switch
(
settings
->
sortKey
)
{
// add FreeBSD-specific fields here
// add FreeBSD-specific fields here
default:
default:
return
Process_
defaultC
ompare
(
v1
,
v2
);
return
Process_
c
ompare
(
v1
,
v2
);
}
}
}
}
...
...
freebsd/FreeBSDProcessList.c
View file @
b291fba0
...
@@ -45,7 +45,7 @@ static int pageSizeKb;
...
@@ -45,7 +45,7 @@ static int pageSizeKb;
ProcessList
*
ProcessList_new
(
UsersTable
*
usersTable
,
Hashtable
*
pidWhiteList
,
uid_t
userId
)
{
ProcessList
*
ProcessList_new
(
UsersTable
*
usersTable
,
Hashtable
*
pidWhiteList
,
uid_t
userId
)
{
FreeBSDProcessList
*
fpl
=
calloc
(
1
,
sizeof
(
FreeBSDProcessList
));
FreeBSDProcessList
*
fpl
=
calloc
(
1
,
sizeof
(
FreeBSDProcessList
));
ProcessList
*
pl
=
(
ProcessList
*
)
fpl
;
ProcessList
*
pl
=
(
ProcessList
*
)
fpl
;
ProcessList_init
(
pl
,
usersTable
,
pidWhiteList
,
userId
);
ProcessList_init
(
pl
,
Class
(
FreeBSDProcess
),
usersTable
,
pidWhiteList
,
userId
);
int
cpus
=
1
;
int
cpus
=
1
;
size_t
sizeof_cpus
=
sizeof
(
cpus
);
size_t
sizeof_cpus
=
sizeof
(
cpus
);
...
...
linux/LinuxProcessList.c
View file @
b291fba0
...
@@ -83,7 +83,7 @@ typedef struct LinuxProcessList_ {
...
@@ -83,7 +83,7 @@ typedef struct LinuxProcessList_ {
ProcessList
*
ProcessList_new
(
UsersTable
*
usersTable
,
Hashtable
*
pidWhiteList
,
uid_t
userId
)
{
ProcessList
*
ProcessList_new
(
UsersTable
*
usersTable
,
Hashtable
*
pidWhiteList
,
uid_t
userId
)
{
LinuxProcessList
*
this
=
calloc
(
1
,
sizeof
(
LinuxProcessList
));
LinuxProcessList
*
this
=
calloc
(
1
,
sizeof
(
LinuxProcessList
));
ProcessList
*
pl
=
&
(
this
->
super
);
ProcessList
*
pl
=
&
(
this
->
super
);
ProcessList_init
(
pl
,
usersTable
,
pidWhiteList
,
userId
);
ProcessList_init
(
pl
,
Class
(
LinuxProcess
),
usersTable
,
pidWhiteList
,
userId
);
// Update CPU count:
// Update CPU count:
FILE
*
file
=
fopen
(
PROCSTATFILE
,
"r"
);
FILE
*
file
=
fopen
(
PROCSTATFILE
,
"r"
);
...
...
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