=head1 NAME
-ossl_ends_with_dirsep - internal function to detect whether a path
-ends with directory separator
+ossl_ends_with_dirsep, ossl_is_absolute_path
+- internal functions to work with paths
=head1 SYNOPSIS
int ossl_ends_with_dirsep(const char *path);
+ int ossl_is_absolute_path(const char *path);
+
=head1 DESCRIPTION
ossl_ends_with_dirsep() detects whether the I<path> ends with a directory
-separator in platform agnostic way.
+separator in a platform agnostic way.
+
+ossl_is_absolute_path() detects whether the I<path> is absolute path in
+a platform agnostic way.
=head1 RETURN VALUES
ossl_ends_with_dirsep() returns 1 if the I<path> ends with a directory
separator, 0 otherwise.
+ossl_is_absolute_path() returns 1 if the I<path> is absolute, 0 otherwise.
+
=head1 HISTORY
-The function described here was added in OpenSSL 3.0.
+The functions described here were added in OpenSSL 3.0.
=head1 COPYRIGHT
return *path == '/';
}
+static ossl_inline int ossl_is_absolute_path(const char *path)
+{
+# if defined __VMS
+ if (strchr(path, ':') != NULL
+ || ((path[0] == '[' || path[0] == '<')
+ && path[1] != '.' && path[1] != '-'
+ && path[1] != ']' && path[1] != '>'))
+ return 1;
+# elif defined _WIN32
+ if (path[0] == '\\'
+ || (path[0] != '\0' && path[1] == ':'))
+ return 1;
+# endif
+ return path[0] == '/';
+}
+
#endif