summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2011-08-07 01:12:28 +0000
committerGreg Hudson <ghudson@mit.edu>2011-08-07 01:12:28 +0000
commit62a276e55287a06d66373f02202ab39c7ba74c00 (patch)
treed164f07b2a965f318d739a356e90835ea6dafd60 /src/include
parentb0b94b9330fbf671da6c9dcd06d3b07eab4c63c6 (diff)
downloadkrb5-62a276e55287a06d66373f02202ab39c7ba74c00.tar.gz
krb5-62a276e55287a06d66373f02202ab39c7ba74c00.tar.xz
krb5-62a276e55287a06d66373f02202ab39c7ba74c00.zip
Add internal APIs for portable path manipulation
k5_path_split separates a path into dirname and basename. k5_path_join joins two paths. k5_path_isabs determines if a path is absolute. All three functions follow the Python path function semantics. Currently the test module doesn't run in the Windows build, but the Windows path semantics are tested in the Unix build using specially built objects. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25074 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/include')
-rw-r--r--src/include/k5-platform.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/include/k5-platform.h b/src/include/k5-platform.h
index d8324839b7..147f87fb72 100644
--- a/src/include/k5-platform.h
+++ b/src/include/k5-platform.h
@@ -36,6 +36,9 @@
* + consistent getpwnam/getpwuid interfaces
* + va_copy fudged if not provided
* + [v]asprintf
+ * + mkstemp
+ * + zap (support function; macro is in k5-int.h)
+ * + path manipulation
* + _, N_, dgettext, bindtextdomain, setlocale (for localization)
*/
@@ -1012,6 +1015,25 @@ extern int krb5int_mkstemp(char *);
extern void krb5int_zap(void *ptr, size_t len);
/*
+ * Split a path into parent directory and basename. Either output parameter
+ * may be NULL if the caller doesn't need it. parent_out will be empty if path
+ * has no basename. basename_out will be empty if path ends with a path
+ * separator. Returns 0 on success or ENOMEM on allocation failure.
+ */
+long k5_path_split(const char *path, char **parent_out, char **basename_out);
+
+/*
+ * Compose two path components, inserting the platform-appropriate path
+ * separator if needed. If path2 is an absolute path, path1 will be discarded
+ * and path_out will be a copy of path2. Returns 0 on success or ENOMEM on
+ * allocation failure.
+ */
+long k5_path_join(const char *path1, const char *path2, char **path_out);
+
+/* Return 1 if path is absolute, 0 if it is relative. */
+int k5_path_isabs(const char *path);
+
+/*
* Localization macros. If we have gettext, define _ appropriately for
* translating a string. If we do not have gettext, define _, bindtextdomain,
* and setlocale as no-ops. N_ is always a no-op; it marks a string for