Code

utils os: Add sdb_realpath().
[sysdb.git] / src / include / utils / os.h
index 8ffca4bcd70a5b6ea117ba748cd3b75cb2cf6c47..42fdea3dad5e99872dc0eac03bc68cf3caa8a4e4 100644 (file)
 extern "C" {
 #endif
 
+/*
+ * sdb_get_homedir:
+ * Returns the home directory of the current user. The buffer to hold the
+ * return value is allocated dynamically and has to be freed by the caller.
+ *
+ * Returns:
+ *  - the current user's home directory on success
+ *  - NULL else
+ */
+char *
+sdb_get_homedir(void);
+
+/*
+ * sdb_realpath:
+ * Returns the canonicalized absolute pathname for the specified path. The
+ * function expands all symbolic links and resolves references to '.', '..',
+ * and extra slash characters (/).
+ *
+ * '~/' at the start of the string will be replaced by the current user's home
+ * directory.
+ *
+ * Returns:
+ *  - the canonicalized absolute pathname on success
+ *  - NULL else
+ */
+char *
+sdb_realpath(const char *path);
+
 /*
  * sysdb_mkdir_all:
  * Recursively create the directory 'pathname' (similar to 'mkdir -p' on the