aboutsummaryrefslogtreecommitdiffstats
path: root/src/ckutil.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-11-10 22:47:03 +0200
committergramanas <anastasis.gramm2@gmail.com>2018-11-10 22:47:03 +0200
commit2638802ccd0d0776ebf1867181d4e3950a147074 (patch)
treecc535cc46c41d5dd347a7630f316cf1c84d00045 /src/ckutil.c
parent6d77eb748a6b15b9f473ab86371bfa474898cef1 (diff)
downloadck-2638802ccd0d0776ebf1867181d4e3950a147074.tar.gz
ck-2638802ccd0d0776ebf1867181d4e3950a147074.tar.bz2
ck-2638802ccd0d0776ebf1867181d4e3950a147074.zip
Home dir
Diffstat (limited to 'src/ckutil.c')
-rw-r--r--src/ckutil.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/ckutil.c b/src/ckutil.c
index 5f8da98..0895677 100644
--- a/src/ckutil.c
+++ b/src/ckutil.c
@@ -143,17 +143,12 @@ int str_is_empty(const char *s) {
return 1;
}
-int swap_tilde_and_home(char *ret, const char *s) {
- if (!ret || !s) {
- return -1;
- }
- char *home = getenv("HOME");
- if (!home) {
+int swap_tilde_with_home(char *ret, const char *s, const char *home) {
+ if (!ret || !s || !home) {
return -1;
}
ulong i;
ulong homelen = strlen(home);
-
if (s[0] == '~') {
strcpy(ret, home);
for (i = 1; i < strlen(s); i++) {
@@ -162,6 +157,16 @@ int swap_tilde_and_home(char *ret, const char *s) {
return 0;
}
+ return -1;
+}
+
+int swap_home_with_tilde(char *ret, const char *s, const char *home) {
+ if (!ret || !s || !home) {
+ return -1;
+ }
+ ulong i;
+ ulong homelen = strlen(home);
+
for (i = 0; i < strlen(home); i++) {
if (s[i] != home[i]) {
return -1;