+ return pwd->pw_name;
+}
+
+char *getHomeDir()
+{
+ static char *home_dir = NULL;
+
+ if (!home_dir)
+ {
+ if (!(home_dir = getenv("HOME")))
+ {
+ struct passwd *pwd;
+
+ if ((pwd = getpwuid(getuid())))
+ home_dir = pwd->pw_dir;
+ else
+ home_dir = ".";
+ }
+ }
+
+ return home_dir;
+}
+
+char *getPath2(char *path1, char *path2)
+{
+ char *complete_path = checked_malloc(strlen(path1) + 1 +
+ strlen(path2) + 1);
+
+ sprintf(complete_path, "%s/%s", path1, path2);
+ return complete_path;
+}
+
+char *getPath3(char *path1, char *path2, char *path3)
+{
+ char *complete_path = checked_malloc(strlen(path1) + 1 +
+ strlen(path2) + 1 +
+ strlen(path3) + 1);
+
+ sprintf(complete_path, "%s/%s/%s", path1, path2, path3);
+ return complete_path;
+}
+
+char *getStringCopy(char *s)
+{
+ char *s_copy = checked_malloc(strlen(s) + 1);
+
+ strcpy(s_copy, s);
+ return s_copy;
+}
+
+char *getStringToLower(char *s)
+{
+ char *s_copy = checked_malloc(strlen(s) + 1);
+ char *s_ptr = s_copy;
+
+ while (*s)
+ *s_ptr++ = tolower(*s++);
+
+ return s_copy;