summaryrefslogtreecommitdiffstats
path: root/Settings.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2008-03-09 08:58:38 +0000
committerHisham Muhammad <hisham@gobolinux.org>2008-03-09 08:58:38 +0000
commitda23c8c5a188324455c8f417293c10d85f65cb63 (patch)
treed7a4b8cb0af705de6650e20e00ba3da04d84b27f /Settings.c
parent12f4f09e6ed288bdedc86e4ef22f3cc34f0e787a (diff)
Clean up headers by using 'static' whenever possible.
Reduces resulting code size.
Diffstat (limited to 'Settings.c')
-rw-r--r--Settings.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/Settings.c b/Settings.c
index 380bcc76..f062986c 100644
--- a/Settings.c
+++ b/Settings.c
@@ -27,40 +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;
- pl->highlightThreads = false;
- }
- }
- return this;
-}
-
void Settings_delete(Settings* this) {
free(this->userSettings);
free(this);
@@ -89,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;
@@ -232,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