diff options
-rw-r--r-- | config.h | 3 | ||||
-rw-r--r-- | readConfig.c | 9 |
2 files changed, 11 insertions, 1 deletions
@@ -1,6 +1,9 @@ #ifndef CONFIG_H #define CONFIG_H +#include<sys/types.h> +#include<pwd.h> + typedef struct config_t { char SMS_INBOX[256]; char SMS_OUTBOX[256]; diff --git a/readConfig.c b/readConfig.c index 3640f65..3497b0e 100644 --- a/readConfig.c +++ b/readConfig.c @@ -48,7 +48,14 @@ int searchConfigFile(char* configFile) { #endif // Home first - sprintf(path, "%s/.mesmsrc", getenv("HOME")); + char* home; + struct passwd* pw = getpwuid(getuid()); + home = pw->pw_dir; + + if( !*home ) + home = getenv("HOME"); + + sprintf(path, "%s/.mesmsrc", home); f_canRead = fopen(path, "r"); if( f_canRead ) { |