commit 603e740b63d4d9828ddbf350788071c5d6cef05d
Author: Oswald Buddenhagen <o...@users.sf.net>
Date:   Tue Feb 8 15:02:15 2022 +0100

    move expand_strdup() to config.c
    
    it's not really a generic function.

 src/common.h |  2 --
 src/config.c | 34 ++++++++++++++++++++++++++++++++++
 src/config.h |  2 ++
 src/util.c   | 34 ----------------------------------
 4 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/src/common.h b/src/common.h
index 8757c352..f1eab8c3 100644
--- a/src/common.h
+++ b/src/common.h
@@ -184,8 +184,6 @@ int ATTR_PRINTFLIKE(3, 4) nfsnprintf( char *buf, int blen, 
const char *fmt, ...
 void ATTR_NORETURN oob( void );
 void ATTR_NORETURN oom( void );
 
-char *expand_strdup( const char *s );
-
 int map_name( const char *arg, char **result, uint reserve, const char *in, 
const char *out );
 
 #define DEFINE_ARRAY_TYPE(T) \
diff --git a/src/config.c b/src/config.c
index 0de5eb4a..e896bddd 100644
--- a/src/config.c
+++ b/src/config.c
@@ -20,6 +20,40 @@ char FieldDelimiter = ':';
 
 static store_conf_t *stores;
 
+char *
+expand_strdup( const char *s )
+{
+       struct passwd *pw;
+       const char *p, *q;
+       char *r;
+
+       if (*s == '~') {
+               s++;
+               if (!*s) {
+                       p = NULL;
+                       q = Home;
+               } else if (*s == '/') {
+                       p = s;
+                       q = Home;
+               } else {
+                       if ((p = strchr( s, '/' ))) {
+                               r = nfstrndup( s, (size_t)(p - s) );
+                               pw = getpwnam( r );
+                               free( r );
+                       } else {
+                               pw = getpwnam( s );
+                       }
+                       if (!pw)
+                               return NULL;
+                       q = pw->pw_dir;
+               }
+               nfasprintf( &r, "%s%s", q, p ? p : "" );
+               return r;
+       } else {
+               return nfstrdup( s );
+       }
+}
+
 char *
 get_arg( conffile_t *cfile, int required, int *comment )
 {
diff --git a/src/config.h b/src/config.h
index 375ef8c0..063c1286 100644
--- a/src/config.h
+++ b/src/config.h
@@ -26,6 +26,8 @@ extern char FieldDelimiter;
 #define ARG_OPTIONAL 0
 #define ARG_REQUIRED 1
 
+char *expand_strdup( const char *s );
+
 char *get_arg( conffile_t *cfile, int required, int *comment );
 
 char parse_bool( conffile_t *cfile );
diff --git a/src/util.c b/src/util.c
index 19b2bf5d..01e9e808 100644
--- a/src/util.c
+++ b/src/util.c
@@ -480,40 +480,6 @@ cur_user( void )
 }
 */
 
-char *
-expand_strdup( const char *s )
-{
-       struct passwd *pw;
-       const char *p, *q;
-       char *r;
-
-       if (*s == '~') {
-               s++;
-               if (!*s) {
-                       p = NULL;
-                       q = Home;
-               } else if (*s == '/') {
-                       p = s;
-                       q = Home;
-               } else {
-                       if ((p = strchr( s, '/' ))) {
-                               r = nfstrndup( s, (size_t)(p - s) );
-                               pw = getpwnam( r );
-                               free( r );
-                       } else {
-                               pw = getpwnam( s );
-                       }
-                       if (!pw)
-                               return NULL;
-                       q = pw->pw_dir;
-               }
-               nfasprintf( &r, "%s%s", q, p ? p : "" );
-               return r;
-       } else {
-               return nfstrdup( s );
-       }
-}
-
 /* Return value: 0 = ok, -1 = out found in arg, -2 = in found in arg but no 
out specified */
 int
 map_name( const char *arg, char **result, uint reserve, const char *in, const 
char *out )


_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to