Switch variable/field naming from WhiteList to MatchList

This commit is contained in:
Nathan Scott 2020-09-09 19:38:15 +10:00
parent c5808c56db
commit 4597332959
17 changed files with 34 additions and 34 deletions

View File

@ -15,11 +15,11 @@ in the source distribution for its full text.
#include <string.h>
ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) {
this->processes = Vector_new(klass, true, DEFAULT_SIZE);
this->processTable = Hashtable_new(140, false);
this->usersTable = usersTable;
this->pidWhiteList = pidWhiteList;
this->pidMatchList = pidMatchList;
this->userId = userId;
// tree-view auxiliary buffer
@ -254,7 +254,7 @@ void ProcessList_rebuildPanel(ProcessList* this) {
if ( (!p->show)
|| (this->userId != (uid_t) -1 && (p->st_uid != this->userId))
|| (incFilter && !(String_contains_i(p->comm, incFilter)))
|| (this->pidWhiteList && !Hashtable_get(this->pidWhiteList, p->tgid)) )
|| (this->pidMatchList && !Hashtable_get(this->pidMatchList, p->tgid)) )
hidden = true;
if (!hidden) {

View File

@ -38,7 +38,7 @@ typedef struct ProcessList_ {
int following;
uid_t userId;
const char* incFilter;
Hashtable* pidWhiteList;
Hashtable* pidMatchList;
#ifdef HAVE_LIBHWLOC
hwloc_topology_t topology;
@ -64,12 +64,12 @@ typedef struct ProcessList_ {
} ProcessList;
ProcessList* ProcessList_new(UsersTable* ut, Hashtable* pidWhiteList, uid_t userId);
ProcessList* ProcessList_new(UsersTable* ut, Hashtable* pidMatchList, uid_t userId);
void ProcessList_delete(ProcessList* pl);
void ProcessList_goThroughEntries(ProcessList* pl);
ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);
ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId);
void ProcessList_done(ProcessList* this);

View File

@ -114,11 +114,11 @@ struct kinfo_proc *ProcessList_getKInfoProcs(size_t *count) {
return processes;
}
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) {
size_t len;
DarwinProcessList* this = xCalloc(1, sizeof(DarwinProcessList));
ProcessList_init(&this->super, Class(Process), usersTable, pidWhiteList, userId);
ProcessList_init(&this->super, Class(Process), usersTable, pidMatchList, userId);
/* Initialize the CPU information */
this->super.cpuCount = ProcessList_allocateCPULoadInfo(&this->prev_load);

View File

@ -47,7 +47,7 @@ void ProcessList_getVMStats(vm_statistics_t p);
struct kinfo_proc *ProcessList_getKInfoProcs(size_t *count);
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId);
void ProcessList_delete(ProcessList* this);

View File

@ -41,12 +41,12 @@ static int MIB_kern_cp_time[2];
static int MIB_kern_cp_times[2];
static int kernelFScale;
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) {
size_t len;
char errbuf[_POSIX2_LINE_MAX];
DragonFlyBSDProcessList* dfpl = xCalloc(1, sizeof(DragonFlyBSDProcessList));
ProcessList* pl = (ProcessList*) dfpl;
ProcessList_init(pl, Class(DragonFlyBSDProcess), usersTable, pidWhiteList, userId);
ProcessList_init(pl, Class(DragonFlyBSDProcess), usersTable, pidMatchList, userId);
// physical memory in system: hw.physmem
// physical page size: hw.pagesize

View File

@ -53,7 +53,7 @@ typedef struct DragonFlyBSDProcessList_ {
#define _UNUSED_ __attribute__((unused))
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId);
void ProcessList_delete(ProcessList* this);

View File

@ -41,12 +41,12 @@ static int MIB_kern_cp_time[2];
static int MIB_kern_cp_times[2];
static int kernelFScale;
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) {
size_t len;
char errbuf[_POSIX2_LINE_MAX];
FreeBSDProcessList* fpl = xCalloc(1, sizeof(FreeBSDProcessList));
ProcessList* pl = (ProcessList*) fpl;
ProcessList_init(pl, Class(FreeBSDProcess), usersTable, pidWhiteList, userId);
ProcessList_init(pl, Class(FreeBSDProcess), usersTable, pidMatchList, userId);
// physical memory in system: hw.physmem
// physical page size: hw.pagesize

View File

@ -48,7 +48,7 @@ typedef struct FreeBSDProcessList_ {
} FreeBSDProcessList;
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId);
void ProcessList_delete(ProcessList* this);

16
htop.c
View File

@ -57,7 +57,7 @@ static void printHelpFlag() {
// ----------------------------------------
typedef struct CommandLineSettings_ {
Hashtable* pidWhiteList;
Hashtable* pidMatchList;
uid_t userId;
int sortKey;
int delay;
@ -70,7 +70,7 @@ typedef struct CommandLineSettings_ {
static CommandLineSettings parseArguments(int argc, char** argv) {
CommandLineSettings flags = {
.pidWhiteList = NULL,
.pidMatchList = NULL,
.userId = -1, // -1 is guaranteed to be an invalid uid_t (see setreuid(2))
.sortKey = 0,
.delay = -1,
@ -163,13 +163,13 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
char* saveptr;
char* pid = strtok_r(argCopy, ",", &saveptr);
if(!flags.pidWhiteList) {
flags.pidWhiteList = Hashtable_new(8, false);
if(!flags.pidMatchList) {
flags.pidMatchList = Hashtable_new(8, false);
}
while(pid) {
unsigned int num_pid = atoi(pid);
Hashtable_put(flags.pidWhiteList, num_pid, (void *) 1);
Hashtable_put(flags.pidMatchList, num_pid, (void *) 1);
pid = strtok_r(NULL, ",", &saveptr);
}
free(argCopy);
@ -215,7 +215,7 @@ int main(int argc, char** argv) {
Process_setupColumnWidths();
UsersTable* ut = UsersTable_new();
ProcessList* pl = ProcessList_new(ut, flags.pidWhiteList, flags.userId);
ProcessList* pl = ProcessList_new(ut, flags.pidMatchList, flags.userId);
Settings* settings = Settings_new(pl->cpuCount);
pl->settings = settings;
@ -281,8 +281,8 @@ int main(int argc, char** argv) {
UsersTable_delete(ut);
Settings_delete(settings);
if(flags.pidWhiteList) {
Hashtable_delete(flags.pidWhiteList);
if(flags.pidMatchList) {
Hashtable_delete(flags.pidMatchList);
}
return 0;
}

View File

@ -149,11 +149,11 @@ static void LinuxProcessList_initNetlinkSocket(LinuxProcessList* this) {
#endif
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) {
LinuxProcessList* this = xCalloc(1, sizeof(LinuxProcessList));
ProcessList* pl = &(this->super);
ProcessList_init(pl, Class(LinuxProcess), usersTable, pidWhiteList, userId);
ProcessList_init(pl, Class(LinuxProcess), usersTable, pidMatchList, userId);
LinuxProcessList_initTtyDrivers(this);
#ifdef HAVE_DELAYACCT

View File

@ -92,7 +92,7 @@ typedef struct LinuxProcessList_ {
#define PROC_LINE_LENGTH 4096
#endif
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId);
void ProcessList_delete(ProcessList* pl);

View File

@ -29,7 +29,7 @@ in the source distribution for its full text.
static long fscale;
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) {
int mib[] = { CTL_HW, HW_NCPU };
int fmib[] = { CTL_KERN, KERN_FSCALE };
int i, e;

View File

@ -39,7 +39,7 @@ typedef struct OpenBSDProcessList_ {
} OpenBSDProcessList;
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId);
void ProcessList_delete(ProcessList* this);

View File

@ -38,10 +38,10 @@ char* SolarisProcessList_readZoneName(kstat_ctl_t* kd, SolarisProcess* sproc) {
return zname;
}
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) {
SolarisProcessList* spl = xCalloc(1, sizeof(SolarisProcessList));
ProcessList* pl = (ProcessList*) spl;
ProcessList_init(pl, Class(SolarisProcess), usersTable, pidWhiteList, userId);
ProcessList_init(pl, Class(SolarisProcess), usersTable, pidMatchList, userId);
spl->kd = kstat_open();

View File

@ -48,7 +48,7 @@ typedef struct SolarisProcessList_ {
char* SolarisProcessList_readZoneName(kstat_ctl_t* kd, SolarisProcess* sproc);
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId);
void ProcessList_delete(ProcessList* pl);

View File

@ -12,9 +12,9 @@ in the source distribution for its full text.
#include <string.h>
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) {
ProcessList* this = xCalloc(1, sizeof(ProcessList));
ProcessList_init(this, Class(Process), usersTable, pidWhiteList, userId);
ProcessList_init(this, Class(Process), usersTable, pidMatchList, userId);
return this;
}

View File

@ -7,7 +7,7 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId);
void ProcessList_delete(ProcessList* this);