ProcessList.h 3.2 KB
Newer Older
Hisham Muhammad's avatar
Hisham Muhammad committed
1
/* Do not edit this file. It was automatically generated. */
Hisham Muhammad's avatar
Hisham Muhammad committed
2
3
4
5

#ifndef HEADER_ProcessList
#define HEADER_ProcessList
/*
Hisham Muhammad's avatar
Hisham Muhammad committed
6
7
htop - ProcessList.c
(C) 2004,2005 Hisham H. Muhammad
Hisham Muhammad's avatar
Hisham Muhammad committed
8
9
10
11
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/

Hisham Muhammad's avatar
Hisham Muhammad committed
12
13
14
15
16
#ifndef CONFIG_H
#define CONFIG_H
#include "config.h"
#endif

Hisham Muhammad's avatar
Hisham Muhammad committed
17
#include "Process.h"
18
#include "Vector.h"
Hisham Muhammad's avatar
Hisham Muhammad committed
19
20
21
22
23
24
25
26
27
28
29
30
#include "UsersTable.h"
#include "Hashtable.h"

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <stdbool.h>
#include <sys/utsname.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
31
#include <stdarg.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

#include "debug.h"
#include <assert.h>

#ifndef PROCDIR
#define PROCDIR "/proc"
#endif

#ifndef PROCSTATFILE
#define PROCSTATFILE "/proc/stat"
#endif

#ifndef PROCMEMINFOFILE
#define PROCMEMINFOFILE "/proc/meminfo"
#endif

#ifndef MAX_NAME
#define MAX_NAME 128
#endif

Hisham Muhammad's avatar
Hisham Muhammad committed
52
53
54
55
56
57
#ifndef MAX_READ
#define MAX_READ 8192
#endif



Hisham Muhammad's avatar
Hisham Muhammad committed
58
typedef struct ProcessList_ {
59
60
   Vector* processes;
   Vector* processes2;
Hisham Muhammad's avatar
Hisham Muhammad committed
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
   Hashtable* processTable;
   Process* prototype;
   UsersTable* usersTable;

   int processorCount;
   int totalTasks;
   int runningTasks;

   long int* totalTime;
   long int* userTime;
   long int* systemTime;
   long int* idleTime;
   long int* niceTime;
   long int* totalPeriod;
   long int* userPeriod;
   long int* systemPeriod;
   long int* idlePeriod;
   long int* nicePeriod;

   long int totalMem;
   long int usedMem;
   long int freeMem;
   long int sharedMem;
   long int buffersMem;
   long int cachedMem;
   long int totalSwap;
   long int usedSwap;
   long int freeSwap;

   ProcessField* fields;
   ProcessField sortKey;
   int direction;
   bool hideThreads;
   bool shadowOtherUsers;
   bool hideKernelThreads;
   bool hideUserlandThreads;
   bool treeView;
   bool highlightBaseName;
   bool highlightMegabytes;
Hisham Muhammad's avatar
Hisham Muhammad committed
100
101
102
   #ifdef DEBUG
   FILE* traceFile;
   #endif
Hisham Muhammad's avatar
Hisham Muhammad committed
103
104
105
106

} ProcessList;


Hisham Muhammad's avatar
Hisham Muhammad committed
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifdef DEBUG


#define ProcessList_read(this, buffer, format, ...) ProcessList_xread(this, (vxscanf) vsscanf, buffer, format, ## __VA_ARGS__ )
#define ProcessList_fread(this, file, format, ...)  ProcessList_xread(this, (vxscanf) vfscanf, file, format, ## __VA_ARGS__ )



#else

#ifndef ProcessList_read
#define ProcessList_fopen(this, path, mode) fopen(path, mode)
#define ProcessList_read(this, buffer, format, ...) sscanf(buffer, format, ## __VA_ARGS__ )
#define ProcessList_fread(this, file, format, ...) fscanf(file, format, ## __VA_ARGS__ )
#endif

#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
124
125
126
127
128
129
130
131
132

ProcessList* ProcessList_new(UsersTable* usersTable);

void ProcessList_delete(ProcessList* this);

void ProcessList_invertSortOrder(ProcessList* this);

RichString ProcessList_printHeader(ProcessList* this);

Hisham Muhammad's avatar
Hisham Muhammad committed
133

Hisham Muhammad's avatar
Hisham Muhammad committed
134
135
136
137
138
139
140
141
142
143
144
145
146
147
void ProcessList_prune(ProcessList* this);

void ProcessList_add(ProcessList* this, Process* p);

void ProcessList_remove(ProcessList* this, Process* p);

Process* ProcessList_get(ProcessList* this, int index);

int ProcessList_size(ProcessList* this);


void ProcessList_sort(ProcessList* this);


Hisham Muhammad's avatar
Hisham Muhammad committed
148
149
150
151
bool ProcessList_readStatusFile(ProcessList* this, Process* proc, char* dirname, char* name);

void ProcessList_processEntries(ProcessList* this, char* dirname, int parent, float period);

Hisham Muhammad's avatar
Hisham Muhammad committed
152
153
154
155
156
void ProcessList_scan(ProcessList* this);

void ProcessList_dontCrash(int signal);

#endif