--- /dev/null
+=pod
+
+=head1 NAME
+
+ossl_ends_with_dirsep - internal function to detect whether a path
+ends with directory separator
+
+=head1 SYNOPSIS
+
+ #include "internal/cryptlib.h"
+
+ int ossl_ends_with_dirsep(const char *path);
+
+=head1 DESCRIPTION
+
+ossl_ends_with_dirsep() detects whether the I<path> ends with a directory
+separator in platform agnostic way.
+
+=head1 RETURN VALUES
+
+ossl_ends_with_dirsep() returns 1 if the I<path> ends with a directory
+separator, 0 otherwise.
+
+=head1 HISTORY
+
+The function described here was added in OpenSSL 3.0.
+
+=head1 COPYRIGHT
+
+Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
+
+Licensed under the Apache License 2.0 (the "License"). You may not use
+this file except in compliance with the License. You can obtain a copy
+in the file LICENSE in the source distribution or at
+L<https://www.openssl.org/source/license.html>.
+
+=cut
+
return 1;
}
-static int ends_with_dirsep(const char *uri)
-{
- if (*uri != '\0')
- uri += strlen(uri) - 1;
-#if defined(__VMS)
- if (*uri == ']' || *uri == '>' || *uri == ':')
- return 1;
-#elif defined(_WIN32)
- if (*uri == '\\')
- return 1;
-#endif
- return *uri == '/';
-}
-
static int file_name_to_uri(OSSL_STORE_LOADER_CTX *ctx, const char *name,
char **data)
{
assert(name != NULL);
assert(data != NULL);
{
- const char *pathsep = ends_with_dirsep(ctx->uri) ? "" : "/";
+ const char *pathsep = ossl_ends_with_dirsep(ctx->uri) ? "" : "/";
long calculated_length = strlen(ctx->uri) + strlen(pathsep)
+ strlen(name) + 1 /* \0 */;
unsigned char *openssl_hexstr2buf_sep(const char *str, long *buflen,
const char sep);
+static ossl_inline int ossl_ends_with_dirsep(const char *path)
+{
+ if (*path != '\0')
+ path += strlen(path) - 1;
+# if defined __VMS
+ if (*path == ']' || *path == '>' || *path == ':')
+ return 1;
+# elif defined _WIN32
+ if (*path == '\\')
+ return 1;
+# endif
+ return *path == '/';
+}
+
#endif
#include <openssl/params.h>
#include <openssl/decoder.h>
#include <openssl/store.h> /* The OSSL_STORE_INFO type numbers */
+#include "internal/cryptlib.h"
#include "internal/o_dir.h"
#include "crypto/pem.h" /* For PVK and "blob" PEM headers */
#include "crypto/decoder.h"
* --------------------------------------
*/
-static int ends_with_dirsep(const char *uri)
-{
- if (*uri != '\0')
- uri += strlen(uri) - 1;
-#if defined(__VMS)
- if (*uri == ']' || *uri == '>' || *uri == ':')
- return 1;
-#elif defined(_WIN32)
- if (*uri == '\\')
- return 1;
-#endif
- return *uri == '/';
-}
-
static char *file_name_to_uri(struct file_ctx_st *ctx, const char *name)
{
char *data = NULL;
assert(name != NULL);
{
- const char *pathsep = ends_with_dirsep(ctx->uri) ? "" : "/";
+ const char *pathsep = ossl_ends_with_dirsep(ctx->uri) ? "" : "/";
long calculated_length = strlen(ctx->uri) + strlen(pathsep)
+ strlen(name) + 1 /* \0 */;