diff options
author | Eugene V. Lyubimkin <jackyf.devel@gmail.com> | 2008-11-16 20:36:18 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:23 +0200 |
commit | bcb965d78ae0b4599fe77a2d641b3ff035658fc9 (patch) | |
tree | 59066e7fa5473b02eefaea37ac015cfaea7cd7c6 /Settings.c | |
parent | 2eabf3432b05b93ce4de9af283ae549d0f7c18c8 (diff) | |
parent | c74c38760df69bb87e93dff18cf91464e5d02f37 (diff) | |
download | debian_htop-bcb965d78ae0b4599fe77a2d641b3ff035658fc9.tar.gz debian_htop-bcb965d78ae0b4599fe77a2d641b3ff035658fc9.tar.bz2 debian_htop-bcb965d78ae0b4599fe77a2d641b3ff035658fc9.zip |
Imported Debian patch 0.8.1-1debian/0.8.1-1
Diffstat (limited to 'Settings.c')
-rw-r--r-- | Settings.c | 74 |
1 files changed, 39 insertions, 35 deletions
@@ -27,39 +27,6 @@ typedef struct Settings_ { }*/ -Settings* Settings_new(ProcessList* pl, Header* header) { - Settings* this = malloc(sizeof(Settings)); - this->pl = pl; - this->header = header; - char* home; - char* rcfile; - home = getenv("HOME_ETC"); - if (!home) home = getenv("HOME"); - if (!home) home = ""; - rcfile = getenv("HOMERC"); - if (!rcfile) - this->userSettings = String_cat(home, "/.htoprc"); - else - this->userSettings = String_copy(rcfile); - this->colorScheme = 0; - this->changed = false; - this->delay = DEFAULT_DELAY; - bool ok = Settings_read(this, this->userSettings); - if (!ok) { - this->changed = true; - // 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); - pl->hideKernelThreads = true; - pl->highlightMegabytes = true; - } - } - return this; -} - void Settings_delete(Settings* this) { free(this->userSettings); free(this); @@ -88,7 +55,7 @@ static void Settings_readMeterModes(Settings* this, char* line, HeaderSide side) String_freeArray(ids); } -bool Settings_read(Settings* this, char* fileName) { +static bool Settings_read(Settings* this, char* fileName) { // TODO: implement File object and make // file I/O object-oriented. FILE* fd; @@ -96,7 +63,7 @@ bool Settings_read(Settings* this, char* fileName) { if (fd == NULL) { return false; } - const int maxLine = 512; + const int maxLine = 65535; char buffer[maxLine]; bool readMeters = false; while (!feof(fd)) { @@ -137,6 +104,8 @@ bool Settings_read(Settings* this, char* fileName) { this->pl->highlightBaseName = atoi(option[1]); } else if (String_eq(option[0], "highlight_megabytes")) { this->pl->highlightMegabytes = atoi(option[1]); + } else if (String_eq(option[0], "highlight_threads")) { + this->pl->highlightThreads = atoi(option[1]); } else if (String_eq(option[0], "header_margin")) { this->header->margin = atoi(option[1]); } else if (String_eq(option[0], "expand_system_time")) { @@ -198,6 +167,7 @@ bool Settings_write(Settings* this) { fprintf(fd, "shadow_other_users=%d\n", (int) this->pl->shadowOtherUsers); fprintf(fd, "highlight_base_name=%d\n", (int) this->pl->highlightBaseName); fprintf(fd, "highlight_megabytes=%d\n", (int) this->pl->highlightMegabytes); + fprintf(fd, "highlight_threads=%d\n", (int) this->pl->highlightThreads); fprintf(fd, "tree_view=%d\n", (int) this->pl->treeView); fprintf(fd, "header_margin=%d\n", (int) this->header->margin); fprintf(fd, "detailed_cpu_time=%d\n", (int) this->pl->detailedCPUTime); @@ -228,3 +198,37 @@ bool Settings_write(Settings* this) { fclose(fd); return true; } + +Settings* Settings_new(ProcessList* pl, Header* header) { + Settings* this = malloc(sizeof(Settings)); + this->pl = pl; + this->header = header; + char* home; + char* rcfile; + home = getenv("HOME_ETC"); + if (!home) home = getenv("HOME"); + if (!home) home = ""; + rcfile = getenv("HOMERC"); + if (!rcfile) + this->userSettings = String_cat(home, "/.htoprc"); + else + this->userSettings = String_copy(rcfile); + this->colorScheme = 0; + this->changed = false; + this->delay = DEFAULT_DELAY; + bool ok = Settings_read(this, this->userSettings); + if (!ok) { + this->changed = true; + // 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); + pl->hideKernelThreads = true; + pl->highlightMegabytes = true; + pl->highlightThreads = false; + } + } + return this; +} |