aboutsummaryrefslogtreecommitdiff
path: root/crealpath.h
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-07-24 23:17:48 +0200
committerXavier Del Campo Romero <xavi92@disroot.org>2025-09-24 11:03:39 +0200
commita74f4a72504d1c5923bd2b4e85941f34d9fce79f (patch)
tree10ddc5729cfa30ba1a15d26c2e385680c1e54e9d /crealpath.h
parentacfc7b820429b7ce2a0a7d41c735388a5529ed6a (diff)
downloadslcl-a74f4a72504d1c5923bd2b4e85941f34d9fce79f.tar.gz
Introduce crealpath
crealpath (for "custom realpath") is a custom implementation of realpath(3) that aims to work similarly to GNU's realpath(1). This implementation is provided due to the following reasons: - Future commits will require extracting an absolute path from a relative path, and/or process relative components from a path, such as ".." or ".". - realpath(3) is defined by POSIX.1-2008 as a XSI extension, and extensions are generally avoided in this repository whenever possible. - Additionally, realpath(3) requires the file or directory pointed to by the path to exist, which might not always be the case for slcl. - auth.c uses its own implementation to extract a dynamically allocated string by repeatedly calling getcwd(3). Future commits will also require this future, so it makes sense to keep it on a separate component.
Diffstat (limited to 'crealpath.h')
-rw-r--r--crealpath.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/crealpath.h b/crealpath.h
new file mode 100644
index 0000000..8a178c4
--- /dev/null
+++ b/crealpath.h
@@ -0,0 +1,8 @@
+#ifndef CREALPATH_H
+#define CREALPATH_H
+
+/* Custom implementation of a GNU's realpath(1)-like function that
+ * does not require GNU extensions. */
+char *crealpath(const char *path);
+
+#endif