aboutsummaryrefslogtreecommitdiffstats
path: root/Settings.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:00:22 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:00:22 +0200
commitc74c38760df69bb87e93dff18cf91464e5d02f37 (patch)
treeee2a19a0ef3a808bdfc8c1e6a00e96d79966dcb0 /Settings.c
parent9379132a8234eeedf62d37ef57713e52c12db6ab (diff)
downloaddebian_htop-c74c38760df69bb87e93dff18cf91464e5d02f37.tar.gz
debian_htop-c74c38760df69bb87e93dff18cf91464e5d02f37.tar.bz2
debian_htop-c74c38760df69bb87e93dff18cf91464e5d02f37.zip
Imported Upstream version 0.8.1upstream/0.8.1
Diffstat (limited to 'Settings.c')
-rw-r--r--Settings.c74
1 files changed, 39 insertions, 35 deletions
diff --git a/Settings.c b/Settings.c
index e53358c..f062986 100644
--- a/Settings.c
+++ b/Settings.c
@@ -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;
+}

© 2014-2024 Faster IT GmbH | imprint | privacy policy