From 031c3bb95f3d0a74d985286068baa6dd4d29d83f Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Mon, 11 Apr 2016 13:00:18 +0200 Subject: Imported Upstream version 0.5.3 --- CPUMeter.c | 8 ++++- ChangeLog | 20 ++++++++++++ DebugMemory.c | 2 +- FunctionBar.c | 2 +- Header.c | 2 ++ ListBox.c | 8 ++++- Makefile.am | 5 +-- Makefile.in | 15 +++++---- Meter.c | 5 ++- Process.c | 3 +- Process.h | 2 +- ProcessList.c | 50 +++++++--------------------- README | 6 +++- RichString.c | 5 ++- Settings.c | 24 +++++++++----- Signal.c | 99 -------------------------------------------------------- Signal.h | 41 ----------------------- SignalItem.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ SignalItem.h | 41 +++++++++++++++++++++++ SignalsListBox.c | 2 +- SignalsListBox.h | 2 +- UsersTable.c | 6 ---- config.h | 6 ++-- configure | 71 ++++++++++++++++++++++++++++++++++------ configure.ac | 5 ++- htop.c | 2 +- htop.h | 2 +- 27 files changed, 305 insertions(+), 228 deletions(-) delete mode 100644 Signal.c delete mode 100644 Signal.h create mode 100644 SignalItem.c create mode 100644 SignalItem.h diff --git a/CPUMeter.c b/CPUMeter.c index 8e598d0..d624802 100644 --- a/CPUMeter.c +++ b/CPUMeter.c @@ -14,7 +14,6 @@ in the source distribution for its full text. #include #include #include -#include #include "debug.h" #include @@ -31,6 +30,13 @@ struct CPUMeter_ { }*/ +#ifndef MIN +#define MIN(a,b) ((a)<(b)?(a):(b)) +#endif +#ifndef MAX +#define MAX(a,b) ((a)>(b)?(a):(b)) +#endif + CPUMeter* CPUMeter_new(ProcessList* pl, int processor) { CPUMeter* this = malloc(sizeof(CPUMeter)); char* caption; diff --git a/ChangeLog b/ChangeLog index c9d5918..993a83d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,24 @@ +What's new in version 0.5.3 + +* Read new field "steal" on newer /proc/stat files +* Auto-detects format of /proc/stat, to cope + with patched 2.4 kernels which display 2.6-style + information (most notably those on RHEL 3) + (thanks to Fernando Dotta for the report) +* Support $HOME_ETC initiative + (see http://www.pld-linux.org/Docs/home-etc) + (thanks to Roman Barczynski for the tip) +* The configure script now tests for /proc, so + that it fails early on unsupported platforms + instead of during compilation/execution. +* Made presentation of the function keys in the + status bar consistent across views + (thanks to David Mathog for the report) +* Minor changes to make the codebase more friendly + to possible future ports + (thanks to Jari Aalto and David Mathog for the reports) + What's new in version 0.5.2 * BUGFIX: Correct display of user field diff --git a/DebugMemory.c b/DebugMemory.c index 26db5c7..8f28af6 100644 --- a/DebugMemory.c +++ b/DebugMemory.c @@ -46,7 +46,7 @@ void DebugMemory_new() { singleton->allocations = 0; singleton->deallocations = 0; singleton->size = 0; - singleton->file = fopen("alloc.txt", "w"); + singleton->file = fopen("/tmp/htop-debug-alloc.txt", "w"); } void* DebugMemory_malloc(int size, char* file, int line) { diff --git a/FunctionBar.c b/FunctionBar.c index 49597bd..d2ad57b 100644 --- a/FunctionBar.c +++ b/FunctionBar.c @@ -28,7 +28,7 @@ typedef struct FunctionBar_ { }*/ /* private property */ -char* FunctionBar_FKeys[10] = {" 1", " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10"}; +char* FunctionBar_FKeys[10] = {"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10"}; /* private property */ int FunctionBar_FEvents[10] = {KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5), KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10)}; diff --git a/Header.c b/Header.c index a044bd1..9068817 100644 --- a/Header.c +++ b/Header.c @@ -36,6 +36,8 @@ typedef struct Header_ { }*/ +#define MAX(a,b) ((a)>(b)?(a):(b)) + Header* Header_new(ProcessList* pl) { Header* this = malloc(sizeof(Header)); this->leftMeters = TypedVector_new(METER_CLASS, true, DEFAULT_SIZE); diff --git a/ListBox.c b/ListBox.c index e2df377..a00f0dd 100644 --- a/ListBox.c +++ b/ListBox.c @@ -12,7 +12,6 @@ in the source distribution for its full text. #include "RichString.h" #include -#include #include #include "debug.h" @@ -50,6 +49,13 @@ extern char* LISTBOX_CLASS; }*/ +#ifndef MIN +#define MIN(a,b) ((a)<(b)?(a):(b)) +#endif +#ifndef MAX +#define MAX(a,b) ((a)>(b)?(a):(b)) +#endif + /* private property */ char* LISTBOX_CLASS = "ListBox"; diff --git a/Makefile.am b/Makefile.am index d4a42a5..2302b3f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,17 +4,18 @@ dist_man_MANS = htop.1 EXTRA_DIST = $(dist_man_MANS) AM_CFLAGS = -pedantic -Wall -std=c99 +AM_CPPFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\" htop_SOURCES = AvailableMetersListBox.c CategoriesListBox.c ClockMeter.c \ CPUMeter.c CRT.c DebugMemory.c DisplayOptionsListBox.c FunctionBar.c \ Hashtable.c Header.c htop.c ListBox.c ListItem.c LoadAverageMeter.c \ LoadMeter.c MemoryMeter.c Meter.c MetersListBox.c Object.c Process.c \ -ProcessList.c RichString.c ScreenManager.c Settings.c Signal.c \ +ProcessList.c RichString.c ScreenManager.c Settings.c SignalItem.c \ SignalsListBox.c String.c SwapMeter.c TasksMeter.c TypedVector.c \ UptimeMeter.c UsersTable.c AvailableMetersListBox.h CategoriesListBox.h \ ClockMeter.h config.h CPUMeter.h CRT.h debug.h DebugMemory.h \ DisplayOptionsListBox.h FunctionBar.h Hashtable.h Header.h htop.h ListBox.h \ ListItem.h LoadAverageMeter.h LoadMeter.h MemoryMeter.h Meter.h \ MetersListBox.h Object.h Process.h ProcessList.h RichString.h ScreenManager.h \ -Settings.h Signal.h SignalsListBox.h String.h SwapMeter.h TasksMeter.h \ +Settings.h SignalItem.h SignalsListBox.h String.h SwapMeter.h TasksMeter.h \ TypedVector.h UptimeMeter.h UsersTable.h CheckItem.c CheckItem.h diff --git a/Makefile.in b/Makefile.in index e08dfde..bdcceb7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -65,10 +65,10 @@ am_htop_OBJECTS = AvailableMetersListBox.$(OBJEXT) \ MemoryMeter.$(OBJEXT) Meter.$(OBJEXT) MetersListBox.$(OBJEXT) \ Object.$(OBJEXT) Process.$(OBJEXT) ProcessList.$(OBJEXT) \ RichString.$(OBJEXT) ScreenManager.$(OBJEXT) \ - Settings.$(OBJEXT) Signal.$(OBJEXT) SignalsListBox.$(OBJEXT) \ - String.$(OBJEXT) SwapMeter.$(OBJEXT) TasksMeter.$(OBJEXT) \ - TypedVector.$(OBJEXT) UptimeMeter.$(OBJEXT) \ - UsersTable.$(OBJEXT) CheckItem.$(OBJEXT) + Settings.$(OBJEXT) SignalItem.$(OBJEXT) \ + SignalsListBox.$(OBJEXT) String.$(OBJEXT) SwapMeter.$(OBJEXT) \ + TasksMeter.$(OBJEXT) TypedVector.$(OBJEXT) \ + UptimeMeter.$(OBJEXT) UsersTable.$(OBJEXT) CheckItem.$(OBJEXT) htop_OBJECTS = $(am_htop_OBJECTS) htop_LDADD = $(LDADD) DEFAULT_INCLUDES = -I. -I$(srcdir) -I. @@ -170,18 +170,19 @@ target_alias = @target_alias@ dist_man_MANS = htop.1 EXTRA_DIST = $(dist_man_MANS) AM_CFLAGS = -pedantic -Wall -std=c99 +AM_CPPFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\" htop_SOURCES = AvailableMetersListBox.c CategoriesListBox.c ClockMeter.c \ CPUMeter.c CRT.c DebugMemory.c DisplayOptionsListBox.c FunctionBar.c \ Hashtable.c Header.c htop.c ListBox.c ListItem.c LoadAverageMeter.c \ LoadMeter.c MemoryMeter.c Meter.c MetersListBox.c Object.c Process.c \ -ProcessList.c RichString.c ScreenManager.c Settings.c Signal.c \ +ProcessList.c RichString.c ScreenManager.c Settings.c SignalItem.c \ SignalsListBox.c String.c SwapMeter.c TasksMeter.c TypedVector.c \ UptimeMeter.c UsersTable.c AvailableMetersListBox.h CategoriesListBox.h \ ClockMeter.h config.h CPUMeter.h CRT.h debug.h DebugMemory.h \ DisplayOptionsListBox.h FunctionBar.h Hashtable.h Header.h htop.h ListBox.h \ ListItem.h LoadAverageMeter.h LoadMeter.h MemoryMeter.h Meter.h \ MetersListBox.h Object.h Process.h ProcessList.h RichString.h ScreenManager.h \ -Settings.h Signal.h SignalsListBox.h String.h SwapMeter.h TasksMeter.h \ +Settings.h SignalItem.h SignalsListBox.h String.h SwapMeter.h TasksMeter.h \ TypedVector.h UptimeMeter.h UsersTable.h CheckItem.c CheckItem.h all: config.h @@ -296,7 +297,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RichString.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ScreenManager.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Settings.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Signal.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SignalItem.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SignalsListBox.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/String.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SwapMeter.Po@am__quote@ diff --git a/Meter.c b/Meter.c index bba5078..45cf7e2 100644 --- a/Meter.c +++ b/Meter.c @@ -15,7 +15,6 @@ in the source distribution for its full text. #include #include #include -#include #include "debug.h" #include @@ -64,6 +63,10 @@ extern char* METER_CLASS; }*/ +#ifndef MIN +#define MIN(a,b) ((a)<(b)?(a):(b)) +#endif + /* private property */ char* METER_CLASS = "Meter"; diff --git a/Process.c b/Process.c index 81fea4e..98f5abe 100644 --- a/Process.c +++ b/Process.c @@ -40,7 +40,7 @@ int kill(pid_t pid, int signal); typedef enum ProcessField_ { PID, COMM, STATE, PPID, PGRP, SESSION, TTY_NR, TPGID, FLAGS, MINFLT, CMINFLT, MAJFLT, CMAJFLT, UTIME, STIME, CUTIME, CSTIME, PRIORITY, NICE, ITREALVALUE, STARTTIME, VSIZE, RSS, RLIM, STARTCODE, ENDCODE, - STARTSTACK, KSTKESP, KSTKEIP, SIGNAL, BLOCKED, SIGIGNORE, SIGCATCH, WCHAN, NSWAP, CNSWAP, EXIT_SIGNAL, + STARTSTACK, KSTKESP, KSTKEIP, SIGNAL, BLOCKED, SSIGIGNORE, SIGCATCH, WCHAN, NSWAP, CNSWAP, EXIT_SIGNAL, PROCESSOR, M_SIZE, M_RESIDENT, M_SHARE, M_TRS, M_DRS, M_LRS, M_DT, ST_UID, PERCENT_CPU, PERCENT_MEM, USER, TIME, LAST_PROCESSFIELD } ProcessField; @@ -268,6 +268,7 @@ void Process_writeField(Process* this, RichString* str, ProcessField field) { case SESSION: snprintf(buffer, n, "%5d ", this->session); break; case TTY_NR: snprintf(buffer, n, "%5d ", this->tty_nr); break; case TPGID: snprintf(buffer, n, "%5d ", this->tpgid); break; + case PROCESSOR: snprintf(buffer, n, "%3d ", this->processor+1); break; case COMM: { if (!this->pl->treeView || this->indent == 0) { Process_writeCommand(this, attr, str); diff --git a/Process.h b/Process.h index 556a093..77b5427 100644 --- a/Process.h +++ b/Process.h @@ -42,7 +42,7 @@ int kill(pid_t pid, int signal); typedef enum ProcessField_ { PID, COMM, STATE, PPID, PGRP, SESSION, TTY_NR, TPGID, FLAGS, MINFLT, CMINFLT, MAJFLT, CMAJFLT, UTIME, STIME, CUTIME, CSTIME, PRIORITY, NICE, ITREALVALUE, STARTTIME, VSIZE, RSS, RLIM, STARTCODE, ENDCODE, - STARTSTACK, KSTKESP, KSTKEIP, SIGNAL, BLOCKED, SIGIGNORE, SIGCATCH, WCHAN, NSWAP, CNSWAP, EXIT_SIGNAL, + STARTSTACK, KSTKESP, KSTKEIP, SIGNAL, BLOCKED, SSIGIGNORE, SIGCATCH, WCHAN, NSWAP, CNSWAP, EXIT_SIGNAL, PROCESSOR, M_SIZE, M_RESIDENT, M_SHARE, M_TRS, M_DRS, M_LRS, M_DT, ST_UID, PERCENT_CPU, PERCENT_MEM, USER, TIME, LAST_PROCESSFIELD } ProcessField; diff --git a/ProcessList.c b/ProcessList.c index 25d4482..93394fb 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -77,11 +77,6 @@ typedef struct ProcessList_ { long int usedSwap; long int freeSwap; - int kernelMajor; - int kernelMiddle; - int kernelMinor; - int kernelTiny; - ProcessField* fields; ProcessField sortKey; int direction; @@ -96,19 +91,6 @@ typedef struct ProcessList_ { } ProcessList; }*/ -/* private */ -void ProcessList_getKernelVersion(ProcessList* this) { - struct utsname uts; - (void) uname(&uts); - char** items = String_split(uts.release, '.'); - this->kernelMajor = atoi(items[0]); - this->kernelMiddle = atoi(items[1]); - this->kernelMinor = atoi(items[2]); - this->kernelTiny = items[3] ? atoi(items[3]) : 0; - for (int i = 0; items[i] != NULL; i++) free(items[i]); - free(items); -} - /* private property */ ProcessField defaultHeaders[LAST_PROCESSFIELD] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, LAST_PROCESSFIELD }; @@ -125,8 +107,6 @@ ProcessList* ProcessList_new(UsersTable* usersTable) { this->processes2 = TypedVector_new(PROCESS_CLASS, true, DEFAULT_SIZE); TypedVector_setCompareFunction(this->processes2, Process_compare); - ProcessList_getKernelVersion(this); - FILE* status = fopen(PROCSTATFILE, "r"); assert(status != NULL); char buffer[256]; @@ -562,25 +542,19 @@ void ProcessList_scan(ProcessList* this) { assert(status != NULL); for (int i = 0; i <= this->processorCount; i++) { int cpuid; - if (this->kernelMajor == 2 && this->kernelMiddle <= 4) { - if (i == 0) { - fscanf(status, "cpu %ld %ld %ld %ld\n", &usertime, &nicetime, &systemtime, &idletime); - } else { - fscanf(status, "cpu%d %ld %ld %ld %ld\n", &cpuid, &usertime, &nicetime, &systemtime, &idletime); - assert(cpuid == i - 1); - } - totaltime = usertime + nicetime + systemtime + idletime; - } else { - long int ioWait, irq, softIrq; - if (i == 0) - fscanf(status, "cpu %ld %ld %ld %ld %ld %ld %ld\n", &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq); - else { - fscanf(status, "cpu%d %ld %ld %ld %ld %ld %ld %ld\n", &cpuid, &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq); - assert(cpuid == i - 1); - } - systemtime += ioWait + irq + softIrq; - totaltime = usertime + nicetime + systemtime + idletime; + int fieldsread; + long int ioWait, irq, softIrq, steal; + ioWait = irq = softIrq = steal = 0; + if (i == 0) + fieldsread = fscanf(status, "cpu %ld %ld %ld %ld %ld %ld %ld\n", &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal); + else { + fieldsread = fscanf(status, "cpu%d %ld %ld %ld %ld %ld %ld %ld\n", &cpuid, &usertime, &nicetime, &systemtime, &idletime, &ioWait, &irq, &softIrq, &steal); + assert(cpuid == i - 1); } + // Fields existing on kernels >= 2.6 + // (and RHEL's patched kernel 2.4...) + systemtime += ioWait + irq + softIrq + steal; + totaltime = usertime + nicetime + systemtime + idletime; assert (usertime >= this->userTime[i]); assert (nicetime >= this->niceTime[i]); assert (systemtime >= this->systemTime[i]); diff --git a/README b/README index d0fbe48..88ce1f4 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ htop by Hisham Muhammad -May-Aug, 2004. +May, 2004 - July, 2005 Introduction ~~~~~~~~~~~~ @@ -10,6 +10,10 @@ Introduction This is htop, an interactive process viewer for Linux. It requires ncurses. Tested with Linux 2.4 and 2.6. +Note that, currently, htop is _Linux_ specific -- it is based +on the Linux /proc filesystem. Contributions of ports to +other operating systems are welcome and will gladly be merged. + This software has evolved considerably during the last months, and is reasonably complete, but there is still room for improvement. Read the TODO file to see what's known to be missing. diff --git a/RichString.c b/RichString.c index 63db850..7a92e08 100644 --- a/RichString.c +++ b/RichString.c @@ -4,7 +4,6 @@ #include #include #include -#include #include "debug.h" #include @@ -20,6 +19,10 @@ typedef struct RichString_ { }*/ +#ifndef MIN +#define MIN(a,b) ((a)<(b)?(a):(b)) +#endif + /* private property */ WINDOW* workArea = NULL; diff --git a/Settings.c b/Settings.c index 5e9bbfd..9172d11 100644 --- a/Settings.c +++ b/Settings.c @@ -26,13 +26,20 @@ Settings* Settings_new(ProcessList* pl, Header* header) { Settings* this = malloc(sizeof(Settings)); this->pl = pl; this->header = header; - // TODO: how to get SYSCONFDIR correctly through Autoconf? - // char* systemSettings = String_cat(SYSCONFDIR, "/htoprc"); - // Settings_read(this, systemSettings); - char* home = getenv("HOME"); + char* home; + home = getenv("HOME_ETC"); + if (!home) home = getenv("HOME"); this->userSettings = String_cat(home, "/.htoprc"); - Settings_read(this, this->userSettings); - // free(systemSettings); + bool ok = Settings_read(this, this->userSettings); + if (!ok) { + // TODO: how to get SYSCONFDIR correctly through Autoconf? + char* systemSettings = String_cat(SYSCONFDIR, "/htoprc"); + ok = Settings_read(this, systemSettings); + free(systemSettings); + if (!ok) { + Header_defaultMeters(this->header); + } + } return this; } @@ -72,7 +79,6 @@ bool Settings_read(Settings* this, char* fileName) { FILE* fd; fd = fopen(fileName, "r"); if (fd == NULL) { - Header_defaultMeters(this->header); return false; } const int maxLine = 512; @@ -176,8 +182,10 @@ bool Settings_write(Settings* this) { fprintf(fd, "tree_view=%d\n", (int) this->pl->treeView); fprintf(fd, "header_margin=%d\n", (int) this->header->margin); fprintf(fd, "left_meters="); - for (int i = 0; i < Header_size(this->header, LEFT_HEADER); i++) + for (int i = 0; i < Header_size(this->header, LEFT_HEADER); i++) { +fprintf(stderr, "Field #%d\n", i); fprintf(fd, "%s ", Header_readMeterName(this->header, i, LEFT_HEADER)); + } fprintf(fd, "\n"); fprintf(fd, "left_meter_modes="); for (int i = 0; i < Header_size(this->header, LEFT_HEADER); i++) diff --git a/Signal.c b/Signal.c deleted file mode 100644 index 3653a66..0000000 --- a/Signal.c +++ /dev/null @@ -1,99 +0,0 @@ -/* -htop -(C) 2004 Hisham H. Muhammad -Released under the GNU GPL, see the COPYING file -in the source distribution for its full text. -*/ - -#include "Signal.h" -#include "String.h" -#include "Object.h" -#include "RichString.h" -#include - -#include "debug.h" - -#define SIGNAL_COUNT 34 - -/*{ - -typedef struct Signal_ { - Object super; - char* name; - int number; -} Signal; - -extern char* SIGNAL_CLASS; -}*/ - -/* private property */ -char* SIGNAL_CLASS = "Signal"; - -Signal* Signal_new(char* name, int number) { - Signal* this = malloc(sizeof(Signal)); - ((Object*)this)->class = SIGNAL_CLASS; - ((Object*)this)->display = Signal_display; - ((Object*)this)->delete = Signal_delete; - this->name = name; - this->number = number; - return this; -} - -void Signal_delete(Object* cast) { - Signal* this = (Signal*)cast; - assert (this != NULL); - // names are string constants, so we're not deleting them. - free(this); -} - -void Signal_display(Object* cast, RichString* out) { - Signal* this = (Signal*)cast; - assert (this != NULL); - - char buffer[31]; - snprintf(buffer, 30, "%2d %s", this->number, this->name); - RichString_write(out, CRT_colors[DEFAULT_COLOR], buffer); -} - -int Signal_getSignalCount() { - return SIGNAL_COUNT; -} - -Signal** Signal_getSignalTable() { - Signal** signals = malloc(sizeof(Signal*) * SIGNAL_COUNT); - signals[0] = Signal_new("Cancel", 0); - signals[1] = Signal_new("SIGHUP", 1); - signals[2] = Signal_new("SIGINT", 2); - signals[3] = Signal_new("SIGQUIT", 3); - signals[4] = Signal_new("SIGILL", 4); - signals[5] = Signal_new("SIGTRAP", 5); - signals[6] = Signal_new("SIGABRT", 6); - signals[7] = Signal_new("SIGIOT", 6); - signals[8] = Signal_new("SIGBUS", 7); - signals[9] = Signal_new("SIGFPE", 8); - signals[10] = Signal_new("SIGKILL", 9); - signals[11] = Signal_new("SIGUSR1", 10); - signals[12] = Signal_new("SIGSEGV", 11); - signals[13] = Signal_new("SIGUSR2", 12); - signals[14] = Signal_new("SIGPIPE", 13); - signals[15] = Signal_new("SIGALRM", 14); - signals[16] = Signal_new("SIGTERM", 15); - signals[17] = Signal_new("SIGSTKFLT", 16); - signals[18] = Signal_new("SIGCHLD", 17); - signals[19] = Signal_new("SIGCONT", 18); - signals[20] = Signal_new("SIGSTOP", 19); - signals[21] = Signal_new("SIGTSTP", 20); - signals[22] = Signal_new("SIGTTIN", 21); - signals[23] = Signal_new("SIGTTOU", 22); - signals[24] = Signal_new("SIGURG", 23); - signals[25] = Signal_new("SIGXCPU", 24); - signals[26] = Signal_new("SIGXFSZ", 25); - signals[27] = Signal_new("SIGVTALRM", 26); - signals[28] = Signal_new("SIGPROF", 27); - signals[29] = Signal_new("SIGWINCH", 28); - signals[30] = Signal_new("SIGIO", 29); - signals[31] = Signal_new("SIGPOLL", 29); - signals[32] = Signal_new("SIGPWR", 30); - signals[33] = Signal_new("SIGSYS", 31); - return signals; -} diff --git a/Signal.h b/Signal.h deleted file mode 100644 index 7dcfa72..0000000 --- a/Signal.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Do not edit this file. It was automatically genarated. */ - -#ifndef HEADER_Signal -#define HEADER_Signal -/* -htop -(C) 2004 Hisham H. Muhammad -Released under the GNU GPL, see the COPYING file -in the source distribution for its full text. -*/ - -#include "String.h" -#include "Object.h" -#include "RichString.h" -#include - -#include "debug.h" - -#define SIGNAL_COUNT 34 - - -typedef struct Signal_ { - Object super; - char* name; - int number; -} Signal; - -extern char* SIGNAL_CLASS; - - -Signal* Signal_new(char* name, int number); - -void Signal_delete(Object* cast); - -void Signal_display(Object* cast, RichString* out); - -int Signal_getSignalCount(); - -Signal** Signal_getSignalTable(); - -#endif diff --git a/SignalItem.c b/SignalItem.c new file mode 100644 index 0000000..795fb94 --- /dev/null +++ b/SignalItem.c @@ -0,0 +1,99 @@ +/* +htop +(C) 2004 Hisham H. Muhammad +Released under the GNU GPL, see the COPYING file +in the source distribution for its full text. +*/ + +#include "SignalItem.h" +#include "String.h" +#include "Object.h" +#include "RichString.h" +#include + +#include "debug.h" + +#define SIGNAL_COUNT 34 + +/*{ + +typedef struct Signal_ { + Object super; + char* name; + int number; +} Signal; + +extern char* SIGNAL_CLASS; +}*/ + +/* private property */ +char* SIGNAL_CLASS = "Signal"; + +Signal* Signal_new(char* name, int number) { + Signal* this = malloc(sizeof(Signal)); + ((Object*)this)->class = SIGNAL_CLASS; + ((Object*)this)->display = Signal_display; + ((Object*)this)->delete = Signal_delete; + this->name = name; + this->number = number; + return this; +} + +void Signal_delete(Object* cast) { + Signal* this = (Signal*)cast; + assert (this != NULL); + // names are string constants, so we're not deleting them. + free(this); +} + +void Signal_display(Object* cast, RichString* out) { + Signal* this = (Signal*)cast; + assert (this != NULL); + + char buffer[31]; + snprintf(buffer, 30, "%2d %s", this->number, this->name); + RichString_write(out, CRT_colors[DEFAULT_COLOR], buffer); +} + +int Signal_getSignalCount() { + return SIGNAL_COUNT; +} + +Signal** Signal_getSignalTable() { + Signal** signals = malloc(sizeof(Signal*) * SIGNAL_COUNT); + signals[0] = Signal_new("Cancel", 0); + signals[1] = Signal_new("SIGHUP", 1); + signals[2] = Signal_new("SIGINT", 2); + signals[3] = Signal_new("SIGQUIT", 3); + signals[4] = Signal_new("SIGILL", 4); + signals[5] = Signal_new("SIGTRAP", 5); + signals[6] = Signal_new("SIGABRT", 6); + signals[7] = Signal_new("SIGIOT", 6); + signals[8] = Signal_new("SIGBUS", 7); + signals[9] = Signal_new("SIGFPE", 8); + signals[10] = Signal_new("SIGKILL", 9); + signals[11] = Signal_new("SIGUSR1", 10); + signals[12] = Signal_new("SIGSEGV", 11); + signals[13] = Signal_new("SIGUSR2", 12); + signals[14] = Signal_new("SIGPIPE", 13); + signals[15] = Signal_new("SIGALRM", 14); + signals[16] = Signal_new("SIGTERM", 15); + signals[17] = Signal_new("SIGSTKFLT", 16); + signals[18] = Signal_new("SIGCHLD", 17); + signals[19] = Signal_new("SIGCONT", 18); + signals[20] = Signal_new("SIGSTOP", 19); + signals[21] = Signal_new("SIGTSTP", 20); + signals[22] = Signal_new("SIGTTIN", 21); + signals[23] = Signal_new("SIGTTOU", 22); + signals[24] = Signal_new("SIGURG", 23); + signals[25] = Signal_new("SIGXCPU", 24); + signals[26] = Signal_new("SIGXFSZ", 25); + signals[27] = Signal_new("SIGVTALRM", 26); + signals[28] = Signal_new("SIGPROF", 27); + signals[29] = Signal_new("SIGWINCH", 28); + signals[30] = Signal_new("SIGIO", 29); + signals[31] = Signal_new("SIGPOLL", 29); + signals[32] = Signal_new("SIGPWR", 30); + signals[33] = Signal_new("SIGSYS", 31); + return signals; +} diff --git a/SignalItem.h b/SignalItem.h new file mode 100644 index 0000000..7dcfa72 --- /dev/null +++ b/SignalItem.h @@ -0,0 +1,41 @@ +/* Do not edit this file. It was automatically genarated. */ + +#ifndef HEADER_Signal +#define HEADER_Signal +/* +htop +(C) 2004 Hisham H. Muhammad +Released under the GNU GPL, see the COPYING file +in the source distribution for its full text. +*/ + +#include "String.h" +#include "Object.h" +#include "RichString.h" +#include + +#include "debug.h" + +#define SIGNAL_COUNT 34 + + +typedef struct Signal_ { + Object super; + char* name; + int number; +} Signal; + +extern char* SIGNAL_CLASS; + + +Signal* Signal_new(char* name, int number); + +void Signal_delete(Object* cast); + +void Signal_display(Object* cast, RichString* out); + +int Signal_getSignalCount(); + +Signal** Signal_getSignalTable(); + +#endif diff --git a/SignalsListBox.c b/SignalsListBox.c index a087db0..e626994 100644 --- a/SignalsListBox.c +++ b/SignalsListBox.c @@ -1,7 +1,7 @@ #include "SignalsListBox.h" #include "ListBox.h" -#include "Signal.h" +#include "SignalItem.h" #include "RichString.h" #include "debug.h" diff --git a/SignalsListBox.h b/SignalsListBox.h index 6bcb3cd..af2fbf7 100644 --- a/SignalsListBox.h +++ b/SignalsListBox.h @@ -4,7 +4,7 @@ #define HEADER_SignalsListBox #include "ListBox.h" -#include "Signal.h" +#include "SignalItem.h" #include "RichString.h" #include "debug.h" diff --git a/UsersTable.c b/UsersTable.c index 381a741..2c9c34f 100644 --- a/UsersTable.c +++ b/UsersTable.c @@ -17,12 +17,6 @@ in the source distribution for its full text. #include "debug.h" #include -/*{ -#ifndef SYSCONFDIR -#define SYSCONFDIR "/etc" -#endif -}*/ - /*{ typedef struct UsersTable_ { Hashtable* users; diff --git a/config.h b/config.h index f49c1d9..bc474c3 100644 --- a/config.h +++ b/config.h @@ -105,13 +105,13 @@ #define PACKAGE_NAME "htop" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "htop 0.5.2" +#define PACKAGE_STRING "htop 0.5.3" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "htop" /* Define to the version of this package. */ -#define PACKAGE_VERSION "0.5.2" +#define PACKAGE_VERSION "0.5.3" /* Define as the return type of signal handlers (`int' or `void'). */ #define RETSIGTYPE void @@ -120,7 +120,7 @@ #define STDC_HEADERS 1 /* Version number of package */ -#define VERSION "0.5.2" +#define VERSION "0.5.3" /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ diff --git a/configure b/configure index bc8485b..c9e3cc5 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for htop 0.5.2. +# Generated by GNU Autoconf 2.59 for htop 0.5.3. # # Report bugs to . # @@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='htop' PACKAGE_TARNAME='htop' -PACKAGE_VERSION='0.5.2' -PACKAGE_STRING='htop 0.5.2' +PACKAGE_VERSION='0.5.3' +PACKAGE_STRING='htop 0.5.3' PACKAGE_BUGREPORT='loderunner@users.sourceforge.net' ac_unique_file="htop.c" @@ -780,7 +780,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures htop 0.5.2 to adapt to many kinds of systems. +\`configure' configures htop 0.5.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -842,7 +842,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of htop 0.5.2:";; + short | recursive ) echo "Configuration of htop 0.5.3:";; esac cat <<\_ACEOF @@ -960,7 +960,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -htop configure 0.5.2 +htop configure 0.5.3 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -974,7 +974,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by htop $as_me 0.5.2, which was +It was created by htop $as_me 0.5.3, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -1617,7 +1617,7 @@ fi # Define the identity of the package. PACKAGE='htop' - VERSION='0.5.2' + VERSION='0.5.3' cat >>confdefs.h <<_ACEOF @@ -5200,6 +5200,57 @@ fi done +echo "$as_me:$LINENO: checking for /proc/stat" >&5 +echo $ECHO_N "checking for /proc/stat... $ECHO_C" >&6 +if test "${ac_cv_file__proc_stat+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + test "$cross_compiling" = yes && + { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 +echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} + { (exit 1); exit 1; }; } +if test -r "/proc/stat"; then + ac_cv_file__proc_stat=yes +else + ac_cv_file__proc_stat=no +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_file__proc_stat" >&5 +echo "${ECHO_T}$ac_cv_file__proc_stat" >&6 +if test $ac_cv_file__proc_stat = yes; then + : +else + { { echo "$as_me:$LINENO: error: Cannot find /proc/stat. Make sure you have a Linux-compatible /proc filesystem mounted. See the file README for help." >&5 +echo "$as_me: error: Cannot find /proc/stat. Make sure you have a Linux-compatible /proc filesystem mounted. See the file README for help." >&2;} + { (exit 1); exit 1; }; } +fi + +echo "$as_me:$LINENO: checking for /proc/meminfo" >&5 +echo $ECHO_N "checking for /proc/meminfo... $ECHO_C" >&6 +if test "${ac_cv_file__proc_meminfo+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + test "$cross_compiling" = yes && + { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 +echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} + { (exit 1); exit 1; }; } +if test -r "/proc/meminfo"; then + ac_cv_file__proc_meminfo=yes +else + ac_cv_file__proc_meminfo=no +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_file__proc_meminfo" >&5 +echo "${ECHO_T}$ac_cv_file__proc_meminfo" >&6 +if test $ac_cv_file__proc_meminfo = yes; then + : +else + { { echo "$as_me:$LINENO: error: Cannot find /proc/meminfo. Make sure you have a Linux-compatible /proc filesystem mounted. See the file README for help." >&5 +echo "$as_me: error: Cannot find /proc/meminfo. Make sure you have a Linux-compatible /proc filesystem mounted. See the file README for help." >&2;} + { (exit 1); exit 1; }; } +fi + + ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF @@ -5578,7 +5629,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by htop $as_me 0.5.2, which was +This file was extended by htop $as_me 0.5.3, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5641,7 +5692,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -htop config.status 0.5.2 +htop config.status 0.5.3 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.ac b/configure.ac index 9474a47..66f58ea 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.57) -AC_INIT([htop],[0.5.2],[loderunner@users.sourceforge.net]) +AC_INIT([htop],[0.5.3],[loderunner@users.sourceforge.net]) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([htop.c]) AC_CONFIG_HEADER([config.h]) @@ -33,5 +33,8 @@ AC_TYPE_SIGNAL AC_FUNC_STAT AC_CHECK_FUNCS([memmove strncasecmp strstr strdup]) +AC_CHECK_FILE(/proc/stat,,AC_MSG_ERROR(Cannot find /proc/stat. Make sure you have a Linux-compatible /proc filesystem mounted. See the file README for help.)) +AC_CHECK_FILE(/proc/meminfo,,AC_MSG_ERROR(Cannot find /proc/meminfo. Make sure you have a Linux-compatible /proc filesystem mounted. See the file README for help.)) + AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/htop.c b/htop.c index a0f431a..d2bbc39 100644 --- a/htop.c +++ b/htop.c @@ -9,7 +9,7 @@ in the source distribution for its full text. #include "CRT.h" #include "ListBox.h" #include "UsersTable.h" -#include "Signal.h" +#include "SignalItem.h" #include "RichString.h" #include "Settings.h" #include "ScreenManager.h" diff --git a/htop.h b/htop.h index cfa2f2d..98efa1d 100644 --- a/htop.h +++ b/htop.h @@ -13,7 +13,7 @@ in the source distribution for its full text. #include "CRT.h" #include "ListBox.h" #include "UsersTable.h" -#include "Signal.h" +#include "SignalItem.h" #include "RichString.h" #include "Settings.h" #include "ScreenManager.h" -- cgit v1.2.3