aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/apr.h.in48
-rw-r--r--include/apr.hnw1
-rw-r--r--include/apr.hw1
-rw-r--r--include/apr.hwc1
-rw-r--r--include/apr_atomic.h67
-rw-r--r--include/apr_encode.h569
-rw-r--r--include/apr_escape.h13
-rw-r--r--include/apr_global_mutex.h13
-rw-r--r--include/apr_network_io.h25
-rw-r--r--include/apr_proc_mutex.h15
-rw-r--r--include/apr_thread_mutex.h13
-rw-r--r--include/apr_thread_proc.h7
-rw-r--r--include/apr_time.h4
-rw-r--r--include/apr_version.h6
-rw-r--r--include/arch/unix/apr_arch_atomic.h18
-rw-r--r--include/arch/unix/apr_arch_proc_mutex.h2
-rw-r--r--include/arch/unix/apr_arch_thread_mutex.h3
-rw-r--r--include/arch/unix/apr_private.h.in57
-rw-r--r--include/private/apr_encode_private.h84
19 files changed, 921 insertions, 26 deletions
diff --git a/include/apr.h.in b/include/apr.h.in
index 4d188853b259..ee99deff1036 100644
--- a/include/apr.h.in
+++ b/include/apr.h.in
@@ -93,6 +93,7 @@
#define APR_HAVE_STDLIB_H @stdlibh@
#define APR_HAVE_STRING_H @stringh@
#define APR_HAVE_STRINGS_H @stringsh@
+#define APR_HAVE_INTTYPES_H @inttypesh@
#define APR_HAVE_SYS_IOCTL_H @sys_ioctlh@
#define APR_HAVE_SYS_SENDFILE_H @sys_sendfileh@
#define APR_HAVE_SYS_SIGNAL_H @sys_signalh@
@@ -168,16 +169,25 @@
#include <sys/socket.h>
#endif
-#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)
+#if APR_HAVE_STDINT_H
+#ifdef __cplusplus
/* C99 7.18.4 requires that stdint.h only exposes INT64_C
* and UINT64_C for C++ implementations if this is defined: */
+#ifndef __STDC_CONSTANT_MACROS
#define __STDC_CONSTANT_MACROS
#endif
-
-#if APR_HAVE_STDINT_H
+/* C++ needs this too for PRI*NN formats: */
+#ifndef __STDC_FORMAT_MACROS
+#define __STDC_FORMAT_MACROS
+#endif
+#endif /* __cplusplus */
#include <stdint.h>
#endif
+#if APR_HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
#if APR_HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
@@ -197,6 +207,13 @@
#endif
#endif
+/* __APPLE__ is now the official pre-defined macro for macOS */
+#ifdef __APPLE__
+#undef DARWIN
+#undef DARWIN_10
+#define DARWIN
+#define DARWIN_10
+#endif /* __APPLE__ */
#ifdef __cplusplus
extern "C" {
@@ -280,6 +297,7 @@ extern "C" {
#define APR_HAS_LARGE_FILES @aprlfs@
#define APR_HAS_XTHREAD_FILES @apr_has_xthread_files@
#define APR_HAS_OS_UUID @osuuid@
+#define APR_HAS_TIMEDLOCKS @apr_has_timedlocks@
#define APR_PROCATTR_USER_SET_REQUIRES_PASSWORD @apr_procattr_user_set_requires_password@
@@ -334,24 +352,28 @@ typedef unsigned @int_value@ apr_uint32_t;
*/
#ifdef DARWIN_10
#undef APR_SIZEOF_VOIDP
-#undef INT64_C
-#undef UINT64_C
+#undef APR_INT64_C
+#undef APR_UINT64_C
#ifdef __LP64__
typedef long apr_int64_t;
typedef unsigned long apr_uint64_t;
#define APR_SIZEOF_VOIDP 8
- #define INT64_C(v) (v ## L)
- #define UINT64_C(v) (v ## UL)
+ #define APR_INT64_C(v) (v ## L)
+ #define APR_UINT64_C(v) (v ## UL)
#else
typedef long long apr_int64_t;
typedef unsigned long long apr_uint64_t;
#define APR_SIZEOF_VOIDP 4
- #define INT64_C(v) (v ## LL)
- #define UINT64_C(v) (v ## ULL)
+ #define APR_INT64_C(v) (v ## LL)
+ #define APR_UINT64_C(v) (v ## ULL)
#endif
#else
- typedef @long_value@ apr_int64_t;
- typedef unsigned @long_value@ apr_uint64_t;
+ typedef @int64_value@ apr_int64_t;
+ typedef @uint64_value@ apr_uint64_t;
+
+ /* Mechanisms to properly type numeric literals */
+ @int64_literal@
+ @uint64_literal@
#endif
typedef @size_t_value@ apr_size_t;
@@ -369,10 +391,6 @@ typedef apr_uint32_t apr_uintptr_t;
/* Are we big endian? */
#define APR_IS_BIGENDIAN @bigendian@
-/* Mechanisms to properly type numeric literals */
-@int64_literal@
-@uint64_literal@
-
#ifdef INT16_MIN
#define APR_INT16_MIN INT16_MIN
#else
diff --git a/include/apr.hnw b/include/apr.hnw
index 540263126092..5df7d9d51858 100644
--- a/include/apr.hnw
+++ b/include/apr.hnw
@@ -214,6 +214,7 @@ extern "C" {
#define APR_HAS_LARGE_FILES 1
#define APR_HAS_XTHREAD_FILES 0
#define APR_HAS_OS_UUID 0
+#define APR_HAS_TIMEDLOCKS 1
#define APR_PROCATTR_USER_SET_REQUIRES_PASSWORD 0
diff --git a/include/apr.hw b/include/apr.hw
index 300b2c8af0b5..35a9589885ed 100644
--- a/include/apr.hw
+++ b/include/apr.hw
@@ -339,6 +339,7 @@ extern "C" {
#define APR_HAS_UNICODE_FS 1
#define APR_HAS_PROC_INVOKED 1
#define APR_HAS_OS_UUID 1
+#define APR_HAS_TIMEDLOCKS 1
#ifndef _WIN32_WCE
#define APR_HAS_SENDFILE 1
diff --git a/include/apr.hwc b/include/apr.hwc
index 5f025bdd2db8..331c31774242 100644
--- a/include/apr.hwc
+++ b/include/apr.hwc
@@ -336,6 +336,7 @@ extern "C" {
#define APR_HAS_UNICODE_FS 1
#define APR_HAS_PROC_INVOKED 1
#define APR_HAS_OS_UUID 1
+#define APR_HAS_TIMEDLOCKS 1
#ifndef _WIN32_WCE
#define APR_HAS_SENDFILE 1
diff --git a/include/apr_atomic.h b/include/apr_atomic.h
index 7ea257123ae2..3d203edc30a6 100644
--- a/include/apr_atomic.h
+++ b/include/apr_atomic.h
@@ -113,6 +113,73 @@ APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint3
*/
APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint32_t val);
+/*
+ * Atomic operations on 64-bit values
+ * Note: Each of these functions internally implements a memory barrier
+ * on platforms that require it
+ */
+
+/**
+ * atomically read an apr_uint64_t from memory
+ * @param mem the pointer
+ */
+APR_DECLARE(apr_uint64_t) apr_atomic_read64(volatile apr_uint64_t *mem);
+
+/**
+ * atomically set an apr_uint64_t in memory
+ * @param mem pointer to the object
+ * @param val value that the object will assume
+ */
+APR_DECLARE(void) apr_atomic_set64(volatile apr_uint64_t *mem, apr_uint64_t val);
+
+/**
+ * atomically add 'val' to an apr_uint64_t
+ * @param mem pointer to the object
+ * @param val amount to add
+ * @return old value pointed to by mem
+ */
+APR_DECLARE(apr_uint64_t) apr_atomic_add64(volatile apr_uint64_t *mem, apr_uint64_t val);
+
+/**
+ * atomically subtract 'val' from an apr_uint64_t
+ * @param mem pointer to the object
+ * @param val amount to subtract
+ */
+APR_DECLARE(void) apr_atomic_sub64(volatile apr_uint64_t *mem, apr_uint64_t val);
+
+/**
+ * atomically increment an apr_uint64_t by 1
+ * @param mem pointer to the object
+ * @return old value pointed to by mem
+ */
+APR_DECLARE(apr_uint64_t) apr_atomic_inc64(volatile apr_uint64_t *mem);
+
+/**
+ * atomically decrement an apr_uint64_t by 1
+ * @param mem pointer to the atomic value
+ * @return zero if the value becomes zero on decrement, otherwise non-zero
+ */
+APR_DECLARE(int) apr_atomic_dec64(volatile apr_uint64_t *mem);
+
+/**
+ * compare an apr_uint64_t's value with 'cmp'.
+ * If they are the same swap the value with 'with'
+ * @param mem pointer to the value
+ * @param with what to swap it with
+ * @param cmp the value to compare it to
+ * @return the old value of *mem
+ */
+APR_DECLARE(apr_uint64_t) apr_atomic_cas64(volatile apr_uint64_t *mem, apr_uint64_t with,
+ apr_uint64_t cmp);
+
+/**
+ * exchange an apr_uint64_t's value with 'val'.
+ * @param mem pointer to the value
+ * @param val what to swap it with
+ * @return the old value of *mem
+ */
+APR_DECLARE(apr_uint64_t) apr_atomic_xchg64(volatile apr_uint64_t *mem, apr_uint64_t val);
+
/**
* compare the pointer's value with cmp.
* If they are the same swap the value with 'with'
diff --git a/include/apr_encode.h b/include/apr_encode.h
new file mode 100644
index 000000000000..20fc932f6f54
--- /dev/null
+++ b/include/apr_encode.h
@@ -0,0 +1,569 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file apr_encode.h
+ * @brief APR-UTIL Encoding
+ */
+#ifndef APR_ENCODE_H
+#define APR_ENCODE_H
+
+#include "apr.h"
+#include "apr_general.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup APR_Util_Encode Base64/Base64Url/Base32/Base32Hex/Base16 Encoding
+ * @ingroup APR_Util
+ * @{
+ */
+
+/**
+ * RFC4648 and RFC7515 compliant BASE64, BASE64URL, BASE32, BASE32HEX
+ * and BASE16 encode/decode functions.
+ *
+ * The following encodings are supported:
+ *
+ * - Base 64 Encoding
+ *
+ * o Use flag APR_ENCODE_NONE
+ * o https://tools.ietf.org/html/rfc4648#section-4
+ *
+ * - Base 64 Encoding with URL and Filename Safe Alphabet
+ *
+ * o Use flag APR_ENCODE_URL
+ * o https://tools.ietf.org/html/rfc4648#section-5
+ *
+ * - Base 64 URL Encoding without Padding
+ *
+ * o Use flag APR_ENCODE_BASE64URL
+ * o https://tools.ietf.org/html/rfc7515#appendix-C
+ *
+ * - Base 32 Encoding
+ *
+ * o Use flag APR_ENCODE_NONE
+ * o https://tools.ietf.org/html/rfc4648#section-6
+ *
+ * - Base 32 Encoding with Extended Hex Alphabet
+ *
+ * o Use flag APR_ENCODE_BASE32HEX
+ * o https://tools.ietf.org/html/rfc4648#section-7
+ *
+ * - Base 16 Encoding
+ *
+ * o Use flags APR_ENCODE_NONE/APR_ENCODE_COLON
+ * o https://tools.ietf.org/html/rfc4648#section-8
+ *
+ * If a non valid character of any kind including whitespace is passed to any
+ * of the decoder functions, APR_BADCH will be returned. In this case decoding
+ * will still take place, but the results can not be trusted.
+ *
+ * If APR_ENCODE_RELAXED is passed to the decoder functions, decoding will be
+ * attempted up until the first non valid character. If this results in an
+ * invalid state in the decoder, such as but not limited to an odd number of
+ * base16 characters, APR_BADCH will still be returned.
+ *
+ * If APR_ENCODE_RELAXED is not passed to a decoder function, the decoding will
+ * be done in constant time regardless of whether the result returns APR_SUCCESS
+ * or APR_BADCH.
+ *
+ * If the dest parameter is NULL, the maximum theoretical buffer size is
+ * returned in the len field, including space for a terminating zero character
+ * if the destination is a string. This value can be used to allocate buffers
+ * of a suitable safe size.
+ *
+ * If the dest parameter is provided, the encoding or decoding will take place,
+ * and the actual number of characters written is returned in the len field,
+ * ignoring any terminating zero.
+ *
+ * Plain strings are not assumed '\0' terminated unless APR_ENCODE_STRING is
+ * provided.
+ *
+ */
+
+/**
+ * When passing a string to one of the encode functions, this value can be
+ * passed to indicate a string-valued key, and have the length computed
+ * automatically.
+ */
+#define APR_ENCODE_STRING (-1)
+
+/**
+ * Generate RFC4648 base16/base32/base64.
+ */
+#define APR_ENCODE_NONE 0
+
+/**
+ * If relaxed, decode up until the first non base16/base32/base64 character.
+ */
+#define APR_ENCODE_RELAXED 1
+
+/**
+ * Omit the padding character (=) while encoding.
+ */
+#define APR_ENCODE_NOPADDING 2
+
+/**
+ * Generate RFC4648 Base 64 Encoding with URL and Filename Safe Alphabet
+ */
+#define APR_ENCODE_URL 4
+
+/**
+ * Generate RFC7515 BASE64URL
+ */
+#define APR_ENCODE_BASE64URL (APR_ENCODE_NOPADDING | APR_ENCODE_URL)
+
+/**
+ * Generate base32hex encoding instead of base32 encoding
+ */
+#define APR_ENCODE_BASE32HEX 8
+
+/**
+ * Generate base16 with colons between each token.
+ */
+#define APR_ENCODE_COLON 16
+
+/**
+ * Generate base16 with lower case characters.
+ */
+#define APR_ENCODE_LOWER 32
+
+/**
+ * Convert text data to base64.
+ * @param dest The destination string, can be NULL.
+ * @param src The original string.
+ * @param slen The length of the original string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, emit RFC4648 Base 64 Encoding. If
+ * APR_ENCODE_NOPADDING, omit the = padding character. If APR_ENCODE_URL,
+ * use RFC4648 Base 64 Encoding with URL and Filename Safe Alphabet.
+ * If APR_ENCODE_BASE64URL, use RFC7515 base64url Encoding.
+ * @param len If present and src is NULL, returns the maximum possible length
+ * of the destination string, including a zero pad. If present and src is
+ * not NULL, returns the number of characters actually written.
+ * @return APR_SUCCESS, or APR_NOTFOUND if the string was NULL.
+ */
+APR_DECLARE(apr_status_t) apr_encode_base64(char *dest, const char *src,
+ apr_ssize_t slen, int flags, apr_size_t * len);
+
+/**
+ * Convert binary data to base64.
+ * @param dest The destination string, can be NULL.
+ * @param src The original buffer.
+ * @param slen The length of the original buffer.
+ * @param flags If APR_ENCODE_NONE, emit RFC4648 Base 64 Encoding. If
+ * APR_ENCODE_NOPADDING, omit the = padding character. If APR_ENCODE_URL,
+ * use RFC4648 Base 64 Encoding with URL and Filename Safe Alphabet.
+ * If APR_ENCODE_BASE64URL, use RFC7515 base64url Encoding.
+ * @param len If present and src is NULL, returns the maximum possible length
+ * of the destination string, including a zero pad. If present and src is
+ * not NULL, returns the number of characters actually written.
+ * @return APR_SUCCESS, or APR_NOTFOUND if the string was NULL.
+ */
+APR_DECLARE(apr_status_t) apr_encode_base64_binary(char *dest, const unsigned char *src,
+ apr_ssize_t slen, int flags, apr_size_t * len);
+
+/**
+ * Convert text data to base64, and return the results from a pool.
+ * @param p Pool to allocate from.
+ * @param src The original string.
+ * @param slen The length of the original string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, emit RFC4648 Base 64 Encoding. If
+ * APR_ENCODE_NOPADDING, omit the = padding character. If APR_ENCODE_URL,
+ * use RFC4648 Base 64 Encoding with URL and Filename Safe Alphabet.
+ * If APR_ENCODE_BASE64URL, use RFC7515 base64url Encoding.
+ * @param len If present, returns the number of characters written excluding
+ * the zero pad.
+ * @return A zero padded string allocated from the pool on success, or
+ * NULL if src was NULL.
+ */
+APR_DECLARE(const char *)apr_pencode_base64(apr_pool_t * p, const char *src,
+ apr_ssize_t slen, int flags, apr_size_t * len)__attribute__((nonnull(1)));
+
+/**
+ * Convert binary data to base64, and return the results from a pool.
+ * @param p Pool to allocate from.
+ * @param src The original buffer.
+ * @param slen The length of the original buffer.
+ * @param flags If APR_ENCODE_NONE, emit RFC4648 Base 64 Encoding. If
+ * APR_ENCODE_NOPADDING, omit the = padding character. If APR_ENCODE_URL,
+ * use RFC4648 Base 64 Encoding with URL and Filename Safe Alphabet.
+ * If APR_ENCODE_BASE64URL, use RFC7515 base64url Encoding.
+ * @param len If present, returns the number of characters written excluding
+ * the zero pad.
+ * @return A zero padded string allocated from the pool on success, or
+ * NULL if src was NULL.
+ */
+APR_DECLARE(const char *)apr_pencode_base64_binary(apr_pool_t * p, const unsigned char *src,
+ apr_ssize_t slen, int flags, apr_size_t * len)__attribute__((nonnull(1)));
+
+/**
+ * Convert base64 or base64url with or without padding to text data.
+ * @param dest The destination string, can be NULL.
+ * @param src The original string.
+ * @param slen The length of the original string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, attempt to decode the full original buffer,
+ * and return NULL if any bad character is detected. If APR_ENCODE_RELAXED,
+ * decode until the first non base64/base64url character.
+ * @param len If present and src is NULL, returns the maximum possible length
+ * of the destination string, including a zero pad. If present and src is
+ * not NULL, returns the number of characters actually written.
+ * @return APR_SUCCESS, or APR_NOTFOUND if the string was NULL, or APR_BADCH
+ * if a non hex character is present.
+ */
+APR_DECLARE(apr_status_t) apr_decode_base64(char *dest, const char *src,
+ apr_ssize_t slen, int flags, apr_size_t * len);
+
+/**
+ * Convert base64 or base64url with or without padding to binary data.
+ * @param dest The destination buffer, can be NULL.
+ * @param src The original string.
+ * @param slen The length of the original string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, attempt to decode the full original buffer,
+ * and return NULL if any bad character is detected. If APR_ENCODE_RELAXED,
+ * decode until the first non base64/base64url character.
+ * @param len If present and src is NULL, returns the maximum possible length
+ * of the destination buffer, including a zero pad. If present and src is
+ * not NULL, returns the number of characters actually written.
+ * @return APR_SUCCESS, or APR_NOTFOUND if the src was NULL, or APR_BADCH
+ * if a non base64 character is present.
+ */
+APR_DECLARE(apr_status_t) apr_decode_base64_binary(unsigned char *dest,
+ const char *src, apr_ssize_t slen, int flags, apr_size_t * len);
+
+/**
+ * Convert base64 or base64url with or without padding to text data, and
+ * return the results from a pool.
+ * @param p Pool to allocate from.
+ * @param src The base64 string to decode.
+ * @param slen The length of the base64 string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, attempt to decode the full original buffer,
+ * and return NULL if any bad character is detected. If APR_ENCODE_RELAXED,
+ * decode until the first non base64/base64url character.
+ * @param len If present, returns the number of characters written, excluding
+ * the zero padding.
+ * @return A string allocated from the pool containing the result with a zero
+ * pad. If src was NULL, or an error occurred, NULL is returned.
+ */
+APR_DECLARE(const char *)apr_pdecode_base64(apr_pool_t * p, const char *src,
+ apr_ssize_t slen, int flags, apr_size_t * len)
+ __attribute__((nonnull(1)));
+
+/**
+ * Convert base64 or base64url with or without padding to binary data, and
+ * return the results from a pool.
+ * @param p Pool to allocate from.
+ * @param src The original string.
+ * @param slen The length of the original string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, attempt to decode the full original buffer,
+ * and return NULL if any bad character is detected. If APR_ENCODE_RELAXED,
+ * decode until the first non base64/base64url character.
+ * @param len If present, returns the number of characters written, excluding
+ * the zero padding.
+ * @return A buffer allocated from the pool containing the result with a zero
+ * pad. If src was NULL, or an error occurred, NULL is returned.
+ */
+APR_DECLARE(const unsigned char *)apr_pdecode_base64_binary(apr_pool_t * p,
+ const char *src, apr_ssize_t slen, int flags, apr_size_t * len)
+ __attribute__((nonnull(1)));
+
+/**
+ * Convert text data to base32.
+ * @param dest The destination string, can be NULL.
+ * @param src The original string.
+ * @param slen The length of the original string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, emit RFC4648 Base 32 Encoding. If
+ * APR_ENCODE_NOPADDING, omit the = padding character. If APR_ENCODE_BASE32HEX,
+ * use RFC4648 base32hex Encoding.
+ * @param len If present and src is NULL, returns the maximum possible length
+ * of the destination string, including a zero pad. If present and src is
+ * not NULL, returns the number of characters actually written.
+ * @return APR_SUCCESS, or APR_NOTFOUND if the string was NULL.
+ */
+APR_DECLARE(apr_status_t) apr_encode_base32(char *dest, const char *src,
+ apr_ssize_t slen, int flags, apr_size_t * len);
+
+/**
+ * Convert binary data to base32.
+ * @param dest The destination string, can be NULL.
+ * @param src The original buffer.
+ * @param slen The length of the original buffer.
+ * @param flags If APR_ENCODE_NONE, emit RFC4648 Base 32 Encoding. If
+ * APR_ENCODE_NOPADDING, omit the = padding character. If APR_ENCODE_BASE32HEX,
+ * use RFC4648 base32hex Encoding.
+ * @param len If present and src is NULL, returns the maximum possible length
+ * of the destination string, including a zero pad. If present and src is
+ * not NULL, returns the number of characters actually written.
+ * @return APR_SUCCESS, or APR_NOTFOUND if the string was NULL.
+ */
+APR_DECLARE(apr_status_t) apr_encode_base32_binary(char *dest, const unsigned char *src,
+ apr_ssize_t slen, int flags, apr_size_t * len);
+
+/**
+ * Convert text data to base32, and return the results from a pool.
+ * @param p Pool to allocate from.
+ * @param src The original string.
+ * @param slen The length of the original string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, emit RFC4648 Base 32 Encoding. If
+ * APR_ENCODE_NOPADDING, omit the = padding character. If APR_ENCODE_BASE32HEX,
+ * use RFC4648 base32hex Encoding.
+ * @param len If present, returns the number of characters written excluding
+ * the zero pad.
+ * @return A zero padded string allocated from the pool on success, or
+ * NULL if src was NULL.
+ */
+APR_DECLARE(const char *)apr_pencode_base32(apr_pool_t * p, const char *src,
+ apr_ssize_t slen, int flags, apr_size_t * len)
+ __attribute__((nonnull(1)));
+
+/**
+ * Convert binary data to base32, and return the results from a pool.
+ * @param p Pool to allocate from.
+ * @param src The original buffer.
+ * @param slen The length of the original buffer.
+ * @param flags If APR_ENCODE_NONE, emit RFC4648 Base 32 Encoding. If
+ * APR_ENCODE_NOPADDING, omit the = padding character. If APR_ENCODE_BASE32HEX,
+ * use RFC7515 base32hex Encoding.
+ * @param len If present, returns the number of characters written excluding
+ * the zero pad.
+ * @return A zero padded string allocated from the pool on success, or
+ * NULL if src was NULL.
+ */
+APR_DECLARE(const char *)apr_pencode_base32_binary(apr_pool_t * p, const unsigned char *src,
+ apr_ssize_t slen, int flags, apr_size_t * len)
+ __attribute__((nonnull(1)));
+
+/**
+ * Convert base32 or base32hex with or without padding to text data.
+ * @param dest The destination string, can be NULL.
+ * @param src The original string.
+ * @param slen The length of the original string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, parse RFC4648 Base 32 Encoding. If
+ * APR_ENCODE_BASE32HEX, use RFC4648 base32hex Encoding.
+ * @param len If present and src is NULL, returns the maximum possible length
+ * of the destination buffer, including a zero pad. If present and src is
+ * not NULL, returns the number of characters actually written.
+ * @return APR_SUCCESS, or APR_NOTFOUND if the string was NULL, or APR_BADCH
+ * if a non base32 character is present.
+ */
+APR_DECLARE(apr_status_t) apr_decode_base32(char *dest, const char *src,
+ apr_ssize_t slen, int flags, apr_size_t * len);
+
+/**
+ * Convert base32 or base32hex with or without padding to binary data.
+ * @param dest The destination buffer, can be NULL.
+ * @param src The original string.
+ * @param slen The length of the original string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, parse RFC4648 Base 32 Encoding. If
+ * APR_ENCODE_BASE32HEX, use RFC4648 base32hex Encoding.
+ * @param len If present and src is NULL, returns the maximum possible length
+ * of the destination buffer, including a zero pad. If present and src is
+ * not NULL, returns the number of characters actually written.
+ * @return APR_SUCCESS, or APR_NOTFOUND if the src was NULL, or APR_BADCH
+ * if a non base32 character is present.
+ */
+APR_DECLARE(apr_status_t) apr_decode_base32_binary(unsigned char *dest,
+ const char *src, apr_ssize_t slen, int flags, apr_size_t * len);
+
+/**
+ * Convert base32 or base32hex with or without padding to text data, and
+ * return the results from a pool.
+ * @param p Pool to allocate from.
+ * @param src The base32 string to decode.
+ * @param slen The length of the base32 string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, parse RFC4648 Base 32 Encoding. If
+ * APR_ENCODE_BASE32HEX, use RFC4648 base32hex Encoding.
+ * @param len If present, returns the number of characters written, excluding
+ * the zero padding.
+ * @return A string allocated from the pool containing the result with a zero
+ * pad. If src was NULL, or an error occurred, NULL is returned.
+ */
+APR_DECLARE(const char *)apr_pdecode_base32(apr_pool_t * p, const char *src,
+ apr_ssize_t slen, int flags, apr_size_t * len)
+ __attribute__((nonnull(1)));
+
+/**
+ * Convert base32 or base32hex with or without padding to binary data, and
+ * return the results from a pool.
+ * @param p Pool to allocate from.
+ * @param src The original string.
+ * @param slen The length of the original string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, parse RFC4648 Base 32 Encoding. If
+ * APR_ENCODE_BASE32HEX, use RFC4648 base32hex Encoding.
+ * @param len If present, returns the number of characters written, excluding
+ * the zero padding.
+ * @return A buffer allocated from the pool containing the result with a zero
+ * pad. If src was NULL, or an error occurred, NULL is returned.
+ */
+APR_DECLARE(const unsigned char *)apr_pdecode_base32_binary(apr_pool_t * p,
+ const char *src, apr_ssize_t slen, int flags, apr_size_t * len)
+ __attribute__((nonnull(1)));
+
+/**
+ * Convert text data to base16 (hex).
+ * @param dest The destination string, can be NULL.
+ * @param src The original string.
+ * @param slen The length of the original string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, emit RFC4648 Base 16 Encoding. If
+ * APR_ENCODE_COLON, separate each token with a colon.
+ * @param len If present and src is NULL, returns the maximum possible length
+ * of the destination buffer, including a zero pad. If present and src is
+ * not NULL, returns the number of characters actually written.
+ * @return APR_SUCCESS, or APR_NOTFOUND if the string was NULL.
+ */
+APR_DECLARE(apr_status_t) apr_encode_base16(char *dest, const char *src,
+ apr_ssize_t slen, int flags, apr_size_t * len);
+
+/**
+ * Convert binary data to base16 (hex).
+ * @param dest The destination string, can be NULL.
+ * @param src The original buffer.
+ * @param slen The length of the original buffer.
+ * @param flags If APR_ENCODE_NONE, emit RFC4648 Base 16 Encoding. If
+ * APR_ENCODE_COLON, separate each token with a colon.
+ * @param len If present and src is NULL, returns the maximum possible length
+ * of the destination buffer, including a zero pad. If present and src is
+ * not NULL, returns the number of characters actually written.
+ * @return APR_SUCCESS, or APR_NOTFOUND if the string was NULL.
+ */
+APR_DECLARE(apr_status_t) apr_encode_base16_binary(char *dest,
+ const unsigned char *src, apr_ssize_t slen, int flags,
+ apr_size_t * len);
+
+/**
+ * Convert text data to base16 (hex), and return the results from a
+ * pool.
+ * @param p Pool to allocate from.
+ * @param src The original string.
+ * @param slen The length of the original string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, emit RFC4648 Base 16 Encoding. If
+ * APR_ENCODE_COLON, separate each token with a colon.
+ * @param len If present, returns the number of characters written, excluding
+ * the zero padding.
+ * @return A string allocated from the pool containing the result with a zero
+ * pad. If src was NULL, or an error occurred, NULL is returned.
+ */
+APR_DECLARE(const char *)apr_pencode_base16(apr_pool_t * p, const char *src,
+ apr_ssize_t slen, int flags, apr_size_t * len)
+ __attribute__((nonnull(1)));
+
+/**
+ * Convert binary data to base16 (hex), and return the results from a
+ * pool.
+ * @param p Pool to allocate from.
+ * @param src The original buffer.
+ * @param slen The length of the original buffer.
+ * @param flags If APR_ENCODE_NONE, emit RFC4648 Base 16 Encoding. If
+ * APR_ENCODE_COLON, separate each token with a colon.
+ * @param len If present, returns the number of characters written, excluding
+ * the zero padding.
+ * @return A string allocated from the pool containing the result with a zero
+ * pad. If src was NULL, or an error occurred, NULL is returned.
+ */
+APR_DECLARE(const char *)apr_pencode_base16_binary(apr_pool_t * p,
+ const unsigned char *src, apr_ssize_t slen,
+ int flags, apr_size_t * len)__attribute__((nonnull(1)));
+
+/**
+ * Convert base16 (hex) to text data.
+ * @param dest The destination string, can be NULL.
+ * @param src The original string.
+ * @param slen The length of the original string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, parse RFC4648 Base 16 Encoding. If
+ * APR_ENCODE_COLON, allow tokens to be separated with a colon.
+ * @param len If present and src is NULL, returns the maximum possible length
+ * of the destination buffer, including a zero pad. If present and src is
+ * not NULL, returns the number of characters actually written.
+ * @return APR_SUCCESS, or APR_NOTFOUND if the string was NULL, or APR_BADCH
+ * if a non hex character is present. A zero pad is appended to the buffer.
+ */
+APR_DECLARE(apr_status_t) apr_decode_base16(char *dest, const char *src,
+ apr_ssize_t slen, int flags, apr_size_t * len);
+
+/**
+ * Convert base16 (hex) to binary data.
+ * @param dest The destination buffer, can be NULL.
+ * @param src The original string.
+ * @param slen The length of the original string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, parse RFC4648 Base 16 Encoding. If
+ * APR_ENCODE_COLON, allow tokens to be separated with a colon.
+ * @param len If present and src is NULL, returns the maximum possible length
+ * of the destination buffer, including a zero pad. If present and src is
+ * not NULL, returns the number of characters actually written.
+ * @return APR_SUCCESS, or APR_NOTFOUND if the string was NULL, or APR_BADCH
+ * if a non hex character is present. No zero pad is written to the buffer.
+ */
+APR_DECLARE(apr_status_t) apr_decode_base16_binary(unsigned char *dest,
+ const char *src, apr_ssize_t slen, int flags, apr_size_t * len);
+
+/**
+ * Convert base16 (hex) and return the results from a pool.
+ * @param p Pool to allocate from.
+ * @param src The original string.
+ * @param slen The length of the original string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, parse RFC4648 Base 16 Encoding. If
+ * APR_ENCODE_COLON, allow tokens to be separated with a colon.
+ * @param len If present, returns the number of characters written, excluding
+ * the zero padding.
+ * @return A buffer allocated from the pool containing the result with a zero
+ * pad. If src was NULL, or an error occurred, NULL is returned.
+ */
+APR_DECLARE(const char *)apr_pdecode_base16(apr_pool_t * p, const char *src,
+ apr_ssize_t slen, int flags, apr_size_t * len)
+ __attribute__((nonnull(1)));
+
+/**
+ * Convert base16 (hex) to binary data, and return the results from a pool.
+ * @param p Pool to allocate from.
+ * @param src The original string.
+ * @param slen The length of the original string, or APR_ENCODE_STRING if
+ * NUL terminated.
+ * @param flags If APR_ENCODE_NONE, parse RFC4648 Base 16 Encoding. If
+ * APR_ENCODE_COLON, allow tokens to be separated with a colon.
+ * @param len If present, returns the number of characters written, excluding
+ * the zero padding.
+ * @return A buffer allocated from the pool containing the result with a zero
+ * pad. If src was NULL, or an error occurred, NULL is returned.
+ */
+APR_DECLARE(const unsigned char *)apr_pdecode_base16_binary(apr_pool_t * p,
+ const char *src, apr_ssize_t slen, int flags, apr_size_t * len)
+ __attribute__((nonnull(1)));
+
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !APR_ENCODE_H */
diff --git a/include/apr_escape.h b/include/apr_escape.h
index 428a8cb6bd88..ed048c956d25 100644
--- a/include/apr_escape.h
+++ b/include/apr_escape.h
@@ -33,6 +33,19 @@ extern "C" {
/* Simple escape/unescape functions.
*
+ * The design goal of these functions are:
+ *
+ * - Avoid unnecessary work.
+ *
+ * In most cases the strings passed in do not need to be escaped at all. In
+ * these cases the original string will be returned.
+ *
+ * - Lowest possible memory footprint.
+ *
+ * The amount of memory allocated for a given encoding is calculated based
+ * on the exact amount of memory needed, and not the theoretical worst case
+ * scenario.
+ *
*/
/**
diff --git a/include/apr_global_mutex.h b/include/apr_global_mutex.h
index 90d9c55b0484..e3cba23ff202 100644
--- a/include/apr_global_mutex.h
+++ b/include/apr_global_mutex.h
@@ -29,6 +29,7 @@
#if APR_PROC_MUTEX_IS_GLOBAL
#include "apr_proc_mutex.h"
#endif
+#include "apr_time.h"
#ifdef __cplusplus
extern "C" {
@@ -66,6 +67,7 @@ typedef struct apr_global_mutex_t apr_global_mutex_t;
* APR_LOCK_POSIXSEM
* APR_LOCK_PROC_PTHREAD
* APR_LOCK_DEFAULT pick the default mechanism for the platform
+ * APR_LOCK_DEFAULT_TIMED pick the default timed mechanism
* </PRE>
* @param pool the pool from which to allocate the mutex.
* @warning Check APR_HAS_foo_SERIALIZE defines to see if the platform supports
@@ -109,6 +111,17 @@ APR_DECLARE(apr_status_t) apr_global_mutex_lock(apr_global_mutex_t *mutex);
APR_DECLARE(apr_status_t) apr_global_mutex_trylock(apr_global_mutex_t *mutex);
/**
+ * Attempt to acquire the lock for the given mutex until timeout expires.
+ * If the acquisition time outs, the call returns with APR_TIMEUP.
+ * @param mutex the mutex on which to attempt the lock acquiring.
+ * @param timeout the relative timeout (microseconds).
+ * @note A negative or nul timeout means immediate attempt, returning
+ * APR_TIMEUP without blocking if it the lock is already acquired.
+ */
+APR_DECLARE(apr_status_t) apr_global_mutex_timedlock(apr_global_mutex_t *mutex,
+ apr_interval_time_t timeout);
+
+/**
* Release the lock for the given mutex.
* @param mutex the mutex from which to release the lock.
*/
diff --git a/include/apr_network_io.h b/include/apr_network_io.h
index 43e578aca47e..7d6957bc763e 100644
--- a/include/apr_network_io.h
+++ b/include/apr_network_io.h
@@ -441,6 +441,31 @@ APR_DECLARE(apr_status_t) apr_sockaddr_info_copy(apr_sockaddr_t **dst,
const apr_sockaddr_t *src,
apr_pool_t *p);
+/* Set the zone of an IPv6 link-local address object.
+ * @param sa Socket address object
+ * @param zone_id Zone ID (textual "eth0" or numeric "3").
+ * @return Returns APR_EBADIP for non-IPv6 socket or an IPv6 address
+ * which isn't link-local.
+ */
+APR_DECLARE(apr_status_t) apr_sockaddr_zone_set(apr_sockaddr_t *sa,
+ const char *zone_id);
+
+
+/* Retrieve the zone of an IPv6 link-local address object.
+ * @param sa Socket address object
+ * @param name If non-NULL, set to the textual representation of the zone id
+ * @param id If non-NULL, set to the integer zone id
+ * @param p Pool from which *name is allocated if used.
+ * @return Returns APR_EBADIP for non-IPv6 socket or socket without any zone id
+ * set, or other error if the interface could not be mapped to a name.
+ * @remark Both name and id may be NULL, neither are modified if
+ * non-NULL in error cases.
+ */
+APR_DECLARE(apr_status_t) apr_sockaddr_zone_get(const apr_sockaddr_t *sa,
+ const char **name,
+ apr_uint32_t *id,
+ apr_pool_t *p);
+
/**
* Look up the host name from an apr_sockaddr_t.
* @param hostname The hostname.
diff --git a/include/apr_proc_mutex.h b/include/apr_proc_mutex.h
index bb5b34f0c08c..418c95048a70 100644
--- a/include/apr_proc_mutex.h
+++ b/include/apr_proc_mutex.h
@@ -26,6 +26,7 @@
#include "apr_pools.h"
#include "apr_errno.h"
#include "apr_perms_set.h"
+#include "apr_time.h"
#ifdef __cplusplus
extern "C" {
@@ -48,7 +49,8 @@ typedef enum {
APR_LOCK_SYSVSEM, /**< System V Semaphores */
APR_LOCK_PROC_PTHREAD, /**< POSIX pthread process-based locking */
APR_LOCK_POSIXSEM, /**< POSIX semaphore process-based locking */
- APR_LOCK_DEFAULT /**< Use the default process lock */
+ APR_LOCK_DEFAULT, /**< Use the default process lock */
+ APR_LOCK_DEFAULT_TIMED /**< Use the default process timed lock */
} apr_lockmech_e;
/** Opaque structure representing a process mutex. */
@@ -114,6 +116,17 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex);
APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex);
/**
+ * Attempt to acquire the lock for the given mutex until timeout expires.
+ * If the acquisition time outs, the call returns with APR_TIMEUP.
+ * @param mutex the mutex on which to attempt the lock acquiring.
+ * @param timeout the relative timeout (microseconds).
+ * @note A negative or nul timeout means immediate attempt, returning
+ * APR_TIMEUP without blocking if it the lock is already acquired.
+ */
+APR_DECLARE(apr_status_t) apr_proc_mutex_timedlock(apr_proc_mutex_t *mutex,
+ apr_interval_time_t timeout);
+
+/**
* Release the lock for the given mutex.
* @param mutex the mutex from which to release the lock.
*/
diff --git a/include/apr_thread_mutex.h b/include/apr_thread_mutex.h
index 193a70a3822c..8eb617291b82 100644
--- a/include/apr_thread_mutex.h
+++ b/include/apr_thread_mutex.h
@@ -43,9 +43,11 @@ typedef struct apr_thread_mutex_t apr_thread_mutex_t;
#define APR_THREAD_MUTEX_DEFAULT 0x0 /**< platform-optimal lock behavior */
#define APR_THREAD_MUTEX_NESTED 0x1 /**< enable nested (recursive) locks */
#define APR_THREAD_MUTEX_UNNESTED 0x2 /**< disable nested locks */
+#define APR_THREAD_MUTEX_TIMED 0x4 /**< enable timed locks */
/* Delayed the include to avoid a circular reference */
#include "apr_pools.h"
+#include "apr_time.h"
/**
* Create and initialize a mutex that can be used to synchronize threads.
@@ -82,6 +84,17 @@ APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex);
APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex);
/**
+ * Attempt to acquire the lock for the given mutex until timeout expires.
+ * If the acquisition time outs, the call returns with APR_TIMEUP.
+ * @param mutex the mutex on which to attempt the lock acquiring.
+ * @param timeout the relative timeout (microseconds).
+ * @note A timeout negative or nul means immediate attempt, returning
+ * APR_TIMEUP without blocking if it the lock is already acquired.
+ */
+APR_DECLARE(apr_status_t) apr_thread_mutex_timedlock(apr_thread_mutex_t *mutex,
+ apr_interval_time_t timeout);
+
+/**
* Release the lock for the given mutex.
* @param mutex the mutex from which to release the lock.
*/
diff --git a/include/apr_thread_proc.h b/include/apr_thread_proc.h
index 6b171e9ab639..ea3c43f90507 100644
--- a/include/apr_thread_proc.h
+++ b/include/apr_thread_proc.h
@@ -816,6 +816,13 @@ APR_DECLARE(apr_status_t) apr_setup_signal_thread(void);
* functions should return 1 if the signal has been handled, 0 otherwise.
* @param signal_handler The function to call when a signal is received
* apr_status_t apr_signal_thread((int)(*signal_handler)(int signum))
+ * @note Synchronous signals like SIGABRT/SIGSEGV/SIGBUS/... are ignored by
+ * apr_signal_thread() and thus can't be waited by this function (they remain
+ * handled by the operating system or its native signals interface).
+ * @remark In APR version 1.6 and ealier, SIGUSR2 was part of these ignored
+ * signals and thus was never passed in to the signal_handler. From APR 1.7
+ * this is no more the case so SIGUSR2 can be handled in signal_handler and
+ * acted upon like the other asynchronous signals.
*/
APR_DECLARE(apr_status_t) apr_signal_thread(int(*signal_handler)(int signum));
diff --git a/include/apr_time.h b/include/apr_time.h
index 15e0b9611527..b0efd791c98a 100644
--- a/include/apr_time.h
+++ b/include/apr_time.h
@@ -23,7 +23,6 @@
*/
#include "apr.h"
-#include "apr_pools.h"
#include "apr_errno.h"
#ifdef __cplusplus
@@ -120,6 +119,9 @@ struct apr_time_exp_t {
apr_int32_t tm_gmtoff;
};
+/* Delayed the include to avoid a circular reference */
+#include "apr_pools.h"
+
/**
* Convert an ansi time_t to an apr_time_t
* @param result the resulting apr_time_t
diff --git a/include/apr_version.h b/include/apr_version.h
index 3dfbe0e07fdc..e96de38357c2 100644
--- a/include/apr_version.h
+++ b/include/apr_version.h
@@ -38,7 +38,7 @@
*/
-#define APR_COPYRIGHT "Copyright (c) 2000-2018 The Apache Software " \
+#define APR_COPYRIGHT "Copyright (c) 2000-2019 The Apache Software " \
"Foundation or its licensors, as applicable."
/* The numeric compile-time version constants. These constants are the
@@ -56,13 +56,13 @@
* Minor API changes that do not cause binary compatibility problems.
* Reset to 0 when upgrading APR_MAJOR_VERSION
*/
-#define APR_MINOR_VERSION 6
+#define APR_MINOR_VERSION 7
/** patch level
* The Patch Level never includes API changes, simply bug fixes.
* Reset to 0 when upgrading APR_MINOR_VERSION
*/
-#define APR_PATCH_VERSION 5
+#define APR_PATCH_VERSION 0
/**
* The symbol APR_IS_DEV_VERSION is only defined for internal,
diff --git a/include/arch/unix/apr_arch_atomic.h b/include/arch/unix/apr_arch_atomic.h
index f8019060e505..559257debb72 100644
--- a/include/arch/unix/apr_arch_atomic.h
+++ b/include/arch/unix/apr_arch_atomic.h
@@ -18,28 +18,36 @@
#define ATOMIC_H
#include "apr.h"
+#include "apr_pools.h"
#include "apr_private.h"
#include "apr_atomic.h"
-#include "apr_thread_mutex.h"
#if defined(USE_ATOMICS_GENERIC)
/* noop */
-#elif defined(__GNUC__) && defined(__STRICT_ANSI__)
-/* force use of generic atomics if building e.g. with -std=c89, which
- * doesn't allow inline asm */
-# define USE_ATOMICS_GENERIC
#elif HAVE_ATOMIC_BUILTINS
# define USE_ATOMICS_BUILTINS
#elif defined(SOLARIS2) && SOLARIS2 >= 10
# define USE_ATOMICS_SOLARIS
+# define NEED_ATOMICS_GENERIC64
+#elif defined(__GNUC__) && defined(__STRICT_ANSI__)
+/* force use of generic atomics if building e.g. with -std=c89, which
+ * doesn't allow inline asm */
+# define USE_ATOMICS_GENERIC
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
# define USE_ATOMICS_IA32
+# define NEED_ATOMICS_GENERIC64
#elif defined(__GNUC__) && (defined(__PPC__) || defined(__ppc__))
# define USE_ATOMICS_PPC
+# define NEED_ATOMICS_GENERIC64
#elif defined(__GNUC__) && (defined(__s390__) || defined(__s390x__))
# define USE_ATOMICS_S390
+# define NEED_ATOMICS_GENERIC64
#else
# define USE_ATOMICS_GENERIC
#endif
+#if defined(USE_ATOMICS_GENERIC) || defined (NEED_ATOMICS_GENERIC64)
+apr_status_t apr__atomic_generic64_init(apr_pool_t *p);
+#endif
+
#endif /* ATOMIC_H */
diff --git a/include/arch/unix/apr_arch_proc_mutex.h b/include/arch/unix/apr_arch_proc_mutex.h
index af49c17031f4..cfa0049f754b 100644
--- a/include/arch/unix/apr_arch_proc_mutex.h
+++ b/include/arch/unix/apr_arch_proc_mutex.h
@@ -26,6 +26,7 @@
#include "apr_portable.h"
#include "apr_file_io.h"
#include "apr_arch_file_io.h"
+#include "apr_time.h"
/* System headers required by Locks library */
#if APR_HAVE_SYS_TYPES_H
@@ -69,6 +70,7 @@ struct apr_proc_mutex_unix_lock_methods_t {
apr_status_t (*create)(apr_proc_mutex_t *, const char *);
apr_status_t (*acquire)(apr_proc_mutex_t *);
apr_status_t (*tryacquire)(apr_proc_mutex_t *);
+ apr_status_t (*timedacquire)(apr_proc_mutex_t *, apr_interval_time_t);
apr_status_t (*release)(apr_proc_mutex_t *);
apr_status_t (*cleanup)(void *);
apr_status_t (*child_init)(apr_proc_mutex_t **, apr_pool_t *, const char *);
diff --git a/include/arch/unix/apr_arch_thread_mutex.h b/include/arch/unix/apr_arch_thread_mutex.h
index 40cdef3c656b..4fe46c3b4275 100644
--- a/include/arch/unix/apr_arch_thread_mutex.h
+++ b/include/arch/unix/apr_arch_thread_mutex.h
@@ -21,6 +21,7 @@
#include "apr_private.h"
#include "apr_general.h"
#include "apr_thread_mutex.h"
+#include "apr_thread_cond.h"
#include "apr_portable.h"
#include "apr_atomic.h"
@@ -32,6 +33,8 @@
struct apr_thread_mutex_t {
apr_pool_t *pool;
pthread_mutex_t mutex;
+ apr_thread_cond_t *cond;
+ int locked, num_waiters;
};
#endif
diff --git a/include/arch/unix/apr_private.h.in b/include/arch/unix/apr_private.h.in
index c794b1962ec3..2377fcbf4336 100644
--- a/include/arch/unix/apr_private.h.in
+++ b/include/arch/unix/apr_private.h.in
@@ -89,6 +89,12 @@
/* Define if accept4 function is supported */
#undef HAVE_ACCEPT4
+/* Define to 1 if you have the `acquire_sem' function. */
+#undef HAVE_ACQUIRE_SEM
+
+/* Define to 1 if you have the `acquire_sem_etc' function. */
+#undef HAVE_ACQUIRE_SEM_ETC
+
/* Define if async i/o supports message q's */
#undef HAVE_AIO_MSGQ
@@ -99,6 +105,9 @@
*/
#undef HAVE_ALLOCA_H
+/* Define to 1 if you have the `arc4random_buf' function. */
+#undef HAVE_ARC4RANDOM_BUF
+
/* Define to 1 if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H
@@ -129,6 +138,10 @@
/* Define to 1 if you have the <ctype.h> header file. */
#undef HAVE_CTYPE_H
+/* Define to 1 if you have the declaration of `SYS_getrandom', and to 0 if you
+ don't. */
+#undef HAVE_DECL_SYS_GETRANDOM
+
/* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you
don't. */
#undef HAVE_DECL_SYS_SIGLIST
@@ -217,6 +230,9 @@
/* Define to 1 if you have the `getpwuid_r' function. */
#undef HAVE_GETPWUID_R
+/* Define to 1 if you have the `getrandom' function. */
+#undef HAVE_GETRANDOM
+
/* Define to 1 if you have the `getrlimit' function. */
#undef HAVE_GETRLIMIT
@@ -232,6 +248,12 @@
/* Define if hstrerror is present */
#undef HAVE_HSTRERROR
+/* Define to 1 if you have the `if_indextoname' function. */
+#undef HAVE_IF_INDEXTONAME
+
+/* Define to 1 if you have the `if_nametoindex' function. */
+#undef HAVE_IF_NAMETOINDEX
+
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
@@ -265,6 +287,9 @@
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
+/* Define to 1 if you have the <linux/random.h> header file. */
+#undef HAVE_LINUX_RANDOM_H
+
/* Define to 1 if you have the `localtime_r' function. */
#undef HAVE_LOCALTIME_R
@@ -361,6 +386,9 @@
/* Define to 1 if you have the `pthread_attr_setguardsize' function. */
#undef HAVE_PTHREAD_ATTR_SETGUARDSIZE
+/* Define to 1 if you have the `pthread_condattr_setpshared' function. */
+#undef HAVE_PTHREAD_CONDATTR_SETPSHARED
+
/* Define to 1 if you have the <pthread.h> header file. */
#undef HAVE_PTHREAD_H
@@ -376,6 +404,12 @@
/* Define if cross-process robust mutexes are available */
#undef HAVE_PTHREAD_MUTEX_ROBUST
+/* Define if non-posix/portable cross-process robust mutexes are available */
+#undef HAVE_PTHREAD_MUTEX_ROBUST_NP
+
+/* Define to 1 if you have the `pthread_mutex_timedlock' function. */
+#undef HAVE_PTHREAD_MUTEX_TIMEDLOCK
+
/* Define if PTHREAD_PROCESS_SHARED is defined in pthread.h */
#undef HAVE_PTHREAD_PROCESS_SHARED
@@ -412,12 +446,21 @@
/* Define to 1 if you have the `semget' function. */
#undef HAVE_SEMGET
+/* Define to 1 if you have the `semop' function. */
+#undef HAVE_SEMOP
+
+/* Define to 1 if you have the `semtimedop' function. */
+#undef HAVE_SEMTIMEDOP
+
/* Define to 1 if you have the `sem_close' function. */
#undef HAVE_SEM_CLOSE
/* Define to 1 if you have the `sem_post' function. */
#undef HAVE_SEM_POST
+/* Define to 1 if you have the `sem_timedwait' function. */
+#undef HAVE_SEM_TIMEDWAIT
+
/* Define if SEM_UNDO is defined in sys/sem.h */
#undef HAVE_SEM_UNDO
@@ -601,6 +644,9 @@
/* Define to 1 if you have the <sys/poll.h> header file. */
#undef HAVE_SYS_POLL_H
+/* Define to 1 if you have the <sys/random.h> header file. */
+#undef HAVE_SYS_RANDOM_H
+
/* Define to 1 if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H
@@ -628,6 +674,9 @@
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
+/* Define to 1 if you have the <sys/syscall.h> header file. */
+#undef HAVE_SYS_SYSCALL_H
+
/* Define to 1 if you have the <sys/sysctl.h> header file. */
#undef HAVE_SYS_SYSCTL_H
@@ -763,7 +812,7 @@
/* Define if pthread_getspecific() has two args */
#undef PTHREAD_GETSPECIFIC_TAKES_TWO_ARGS
-/* Define if readdir is thread safe */
+/* Modern readdir is thread safe */
#undef READDIR_IS_THREAD_SAFE
/* Define to 1 if the `setpgrp' function takes no argument. */
@@ -825,6 +874,9 @@
/* Define if SysV semaphores affect threads within the process */
#undef SYSVSEM_IS_GLOBAL
+/* Define system call of random */
+#undef SYS_RANDOM
+
/* Define if use of generic atomics is requested */
#undef USE_ATOMICS_GENERIC
@@ -837,6 +889,9 @@
/* Define if 4.2BSD-style flock() will be used */
#undef USE_FLOCK_SERIALIZE
+/* Define if pthread pshared mutex will be used */
+#undef USE_PROC_PTHREAD_SERIALIZE
+
/* Define if BeOS areas will be used */
#undef USE_SHMEM_BEOS
diff --git a/include/private/apr_encode_private.h b/include/private/apr_encode_private.h
new file mode 100644
index 000000000000..8db2e016695e
--- /dev/null
+++ b/include/private/apr_encode_private.h
@@ -0,0 +1,84 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file apr_encode_private.h
+ * @brief APR-UTIL Encoding Private
+ */
+#ifndef APR_ENCODE_PRIVATE_H
+#define APR_ENCODE_PRIVATE_H
+
+#include "apr.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup APR_Util_Encode_Private
+ * @ingroup APR_Util
+ * @{
+ */
+
+#if APR_CHARSET_EBCDIC
+ static int convert_a2e[256] = {
+ 0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, 0x16, 0x05, 0x15, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, 0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F,
+ 0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, 0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61,
+ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F,
+ 0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6,
+ 0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xAD, 0xE0, 0xBD, 0x5F, 0x6D,
+ 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
+ 0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xC0, 0x4F, 0xD0, 0xA1, 0x07,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x06, 0x17, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x09, 0x0A, 0x1B,
+ 0x30, 0x31, 0x1A, 0x33, 0x34, 0x35, 0x36, 0x08, 0x38, 0x39, 0x3A, 0x3B, 0x04, 0x14, 0x3E, 0xFF,
+ 0x41, 0xAA, 0x4A, 0xB1, 0x9F, 0xB2, 0x6A, 0xB5, 0xBB, 0xB4, 0x9A, 0x8A, 0xB0, 0xCA, 0xAF, 0xBC,
+ 0x90, 0x8F, 0xEA, 0xFA, 0xBE, 0xA0, 0xB6, 0xB3, 0x9D, 0xDA, 0x9B, 0x8B, 0xB7, 0xB8, 0xB9, 0xAB,
+ 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9E, 0x68, 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77,
+ 0xAC, 0x69, 0xED, 0xEE, 0xEB, 0xEF, 0xEC, 0xBF, 0x80, 0xFD, 0xFE, 0xFB, 0xFC, 0xBA, 0xAE, 0x59,
+ 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9C, 0x48, 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57,
+ 0x8C, 0x49, 0xCD, 0xCE, 0xCB, 0xCF, 0xCC, 0xE1, 0x70, 0xDD, 0xDE, 0xDB, 0xDC, 0x8D, 0x8E, 0xDF};
+
+ static int convert_e2a[256] = {
+ 0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F, 0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x10, 0x11, 0x12, 0x13, 0x9D, 0x0A, 0x08, 0x87, 0x18, 0x19, 0x92, 0x8F, 0x1C, 0x1D, 0x1E, 0x1F,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x17, 0x1B, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x05, 0x06, 0x07,
+ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, 0x98, 0x99, 0x9A, 0x9B, 0x14, 0x15, 0x9E, 0x1A,
+ 0x20, 0xA0, 0xE2, 0xE4, 0xE0, 0xE1, 0xE3, 0xE5, 0xE7, 0xF1, 0xA2, 0x2E, 0x3C, 0x28, 0x2B, 0x7C,
+ 0x26, 0xE9, 0xEA, 0xEB, 0xE8, 0xED, 0xEE, 0xEF, 0xEC, 0xDF, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0x5E,
+ 0x2D, 0x2F, 0xC2, 0xC4, 0xC0, 0xC1, 0xC3, 0xC5, 0xC7, 0xD1, 0xA6, 0x2C, 0x25, 0x5F, 0x3E, 0x3F,
+ 0xF8, 0xC9, 0xCA, 0xCB, 0xC8, 0xCD, 0xCE, 0xCF, 0xCC, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22,
+ 0xD8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0xAB, 0xBB, 0xF0, 0xFD, 0xFE, 0xB1,
+ 0xB0, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0xAA, 0xBA, 0xE6, 0xB8, 0xC6, 0xA4,
+ 0xB5, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0xA1, 0xBF, 0xD0, 0x5B, 0xDE, 0xAE,
+ 0xAC, 0xA3, 0xA5, 0xB7, 0xA9, 0xA7, 0xB6, 0xBC, 0xBD, 0xBE, 0xDD, 0xA8, 0xAF, 0x5D, 0xB4, 0xD7,
+ 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0xAD, 0xF4, 0xF6, 0xF2, 0xF3, 0xF5,
+ 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0xB9, 0xFB, 0xFC, 0xF9, 0xFA, 0xFF,
+ 0x5C, 0xF7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0xB2, 0xD4, 0xD6, 0xD2, 0xD3, 0xD5,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0xB3, 0xDB, 0xDC, 0xD9, 0xDA, 0x9F};
+#define decode ENCODE_TO_ASCII(ch) convert_e2a[(unsigned char)ch]
+#define decode ENCODE_TO_NATIVE(ch) convert_a2e[(unsigned char)ch]
+#else /* APR_CHARSET_EBCDIC */
+#define ENCODE_TO_ASCII(ch) (ch)
+#define ENCODE_TO_NATIVE(ch) (ch)
+#endif /* !APR_CHARSET_EBCDIC */
+
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !APR_ENCODE_PRIVATE_H */