summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2018-10-08 08:24:14 +0000
committerPeter Wemm <peter@FreeBSD.org>2018-10-08 08:24:14 +0000
commitf7eb533f85d0941dbf6edb3081f065e4c010b8cc (patch)
treea9a3ba945deee0800d3818a48c45323608935019 /include
parentdf84d2567179e9d8867957c089683d753016bd75 (diff)
Notes
Diffstat (limited to 'include')
-rw-r--r--include/apr.h.in1
-rw-r--r--include/apr.hnw1
-rw-r--r--include/apr.hw42
-rw-r--r--include/apr.hwc40
-rw-r--r--include/apr_allocator.h10
-rw-r--r--include/apr_atomic.h2
-rw-r--r--include/apr_cstr.h292
-rw-r--r--include/apr_errno.h31
-rw-r--r--include/apr_escape.h56
-rw-r--r--include/apr_file_info.h4
-rw-r--r--include/apr_file_io.h34
-rw-r--r--include/apr_general.h25
-rw-r--r--include/apr_global_mutex.h21
-rw-r--r--include/apr_hash.h3
-rw-r--r--include/apr_network_io.h47
-rw-r--r--include/apr_perms_set.h65
-rw-r--r--include/apr_poll.h45
-rw-r--r--include/apr_portable.h47
-rw-r--r--include/apr_proc_mutex.h19
-rw-r--r--include/apr_shm.h21
-rw-r--r--include/apr_skiplist.h126
-rw-r--r--include/apr_strings.h4
-rw-r--r--include/apr_tables.h28
-rw-r--r--include/apr_thread_proc.h13
-rw-r--r--include/apr_version.h8
-rw-r--r--include/arch/unix/apr_arch_networkio.h3
-rw-r--r--include/arch/unix/apr_arch_poll_private.h19
-rw-r--r--include/arch/unix/apr_arch_proc_mutex.h26
-rw-r--r--include/arch/unix/apr_arch_shm.h1
-rw-r--r--include/arch/unix/apr_arch_threadproc.h10
-rw-r--r--include/arch/unix/apr_private.h.in24
31 files changed, 970 insertions, 98 deletions
diff --git a/include/apr.h.in b/include/apr.h.in
index 0ad7a91aff3a8..4d188853b259f 100644
--- a/include/apr.h.in
+++ b/include/apr.h.in
@@ -245,6 +245,7 @@ extern "C" {
#define APR_HAVE_INET_ADDR @have_inet_addr@
#define APR_HAVE_INET_NETWORK @have_inet_network@
#define APR_HAVE_IPV6 @have_ipv6@
+#define APR_HAVE_SOCKADDR_UN @have_sockaddr_un@
#define APR_HAVE_MEMMOVE @have_memmove@
#define APR_HAVE_SETRLIMIT @have_setrlimit@
#define APR_HAVE_SIGACTION @have_sigaction@
diff --git a/include/apr.hnw b/include/apr.hnw
index d0c77e00e4084..540263126092b 100644
--- a/include/apr.hnw
+++ b/include/apr.hnw
@@ -180,6 +180,7 @@ extern "C" {
#else
#define APR_HAVE_IPV6 0
#endif
+#define APR_HAVE_SOCKADDR_UN 0
#define APR_HAVE_MEMCHR 1
#define APR_HAVE_MEMMOVE 1
#define APR_HAVE_SETRLIMIT 0
diff --git a/include/apr.hw b/include/apr.hw
index a75bc602943d7..300b2c8af0b5c 100644
--- a/include/apr.hw
+++ b/include/apr.hw
@@ -25,7 +25,7 @@
* And please, make an effort to stub apr.hnw and apr.h.in in the process.
*
* This is the Win32 specific version of apr.h. It is copied from
- * apr.hw by the apr.dsp and libapr.dsp projects.
+ * apr.hw by the apr.dsp and libapr.dsp projects.
*/
/**
@@ -60,7 +60,9 @@
* C4244: int to char/short - precision loss
* C4514: unreferenced inline function removed
*/
+#if defined(_MSC_VER)
#pragma warning(disable: 4100 4127 4163 4201 4514; once: 4057 4075 4244)
+#endif
/* Ignore Microsoft's interpretation of secure development
* and the POSIX string handling API
@@ -212,25 +214,42 @@
/** @} */
/** @} */
-/* We don't include our conditional headers within the doxyblocks
- * or the extern "C" namespace
+/* We don't include our conditional headers within the doxyblocks
+ * or the extern "C" namespace
*/
#if APR_HAVE_STDLIB_H
#include <stdlib.h>
#endif
+
#if APR_HAVE_STDIO_H
#include <stdio.h>
#endif
+
#if APR_HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
+
#if APR_HAVE_STDDEF_H
#include <stddef.h>
#endif
+
+#if APR_HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+#if APR_HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+#if APR_HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
#if APR_HAVE_TIME_H
#include <time.h>
#endif
+
#if APR_HAVE_PROCESS_H
#include <process.h>
#endif
@@ -261,12 +280,12 @@ extern "C" {
#define APR_USE_SHMEM_MMAP_ANON 0
#define APR_USE_SHMEM_BEOS 0
-#define APR_USE_FLOCK_SERIALIZE 0
+#define APR_USE_FLOCK_SERIALIZE 0
#define APR_USE_POSIXSEM_SERIALIZE 0
#define APR_USE_SYSVSEM_SERIALIZE 0
#define APR_USE_FCNTL_SERIALIZE 0
-#define APR_USE_PROC_PTHREAD_SERIALIZE 0
-#define APR_USE_PTHREAD_SERIALIZE 0
+#define APR_USE_PROC_PTHREAD_SERIALIZE 0
+#define APR_USE_PTHREAD_SERIALIZE 0
#define APR_HAS_FLOCK_SERIALIZE 0
#define APR_HAS_SYSVSEM_SERIALIZE 0
@@ -282,7 +301,8 @@ extern "C" {
#define APR_HAVE_IN_ADDR 1
#define APR_HAVE_INET_ADDR 1
#define APR_HAVE_INET_NETWORK 0
-#define APR_HAVE_IPV6 0
+#define APR_HAVE_IPV6 1
+#define APR_HAVE_SOCKADDR_UN 0
#define APR_HAVE_MEMMOVE 1
#define APR_HAVE_SETRLIMIT 0
#define APR_HAVE_SIGACTION 0
@@ -354,7 +374,7 @@ extern "C" {
/* Is the O_NONBLOCK flag inherited from listening sockets?
*/
-#define APR_O_NONBLOCK_INHERITED 1
+#define APR_O_NONBLOCK_INHERITED 1
/* Typedefs that APR needs. */
@@ -626,18 +646,20 @@ typedef int gid_t;
&& (*(const apr_uint32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff)))
#endif
-#endif /* APR_HAS_IPV6 */
+#endif /* APR_HAVE_IPV6 */
#ifdef __cplusplus
}
#endif
-/* Done with badly written headers
+/* Done with badly written headers, leave 'deprecated CRT' undeprecated
*/
#if defined(_MSC_VER) && _MSC_VER >= 1200
#pragma warning(pop)
+#if _MSC_VER >= 1400
#pragma warning(disable: 4996)
#endif
+#endif
#endif /* WIN32 */
diff --git a/include/apr.hwc b/include/apr.hwc
index 05799629508a6..5f025bdd2db83 100644
--- a/include/apr.hwc
+++ b/include/apr.hwc
@@ -25,7 +25,7 @@
* And please, make an effort to stub apr.hnw and apr.h.in in the process.
*
* This is the Win32 specific version of apr.h. It is copied from
- * apr.hw by the apr.dsp and libapr.dsp projects.
+ * apr.hw by the apr.dsp and libapr.dsp projects.
*/
/**
@@ -60,7 +60,9 @@
* C4244: int to char/short - precision loss
* C4514: unreferenced inline function removed
*/
+#if defined(_MSC_VER)
#pragma warning(disable: 4100 4127 4163 4201 4514; once: 4057 4075 4244)
+#endif
/* Ignore Microsoft's interpretation of secure development
* and the POSIX string handling API
@@ -209,25 +211,42 @@
/** @} */
/** @} */
-/* We don't include our conditional headers within the doxyblocks
- * or the extern "C" namespace
+/* We don't include our conditional headers within the doxyblocks
+ * or the extern "C" namespace
*/
#if APR_HAVE_STDLIB_H
#include <stdlib.h>
#endif
+
#if APR_HAVE_STDIO_H
#include <stdio.h>
#endif
+
#if APR_HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
+
#if APR_HAVE_STDDEF_H
#include <stddef.h>
#endif
+
+#if APR_HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+#if APR_HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+#if APR_HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
#if APR_HAVE_TIME_H
#include <time.h>
#endif
+
#if APR_HAVE_PROCESS_H
#include <process.h>
#endif
@@ -258,12 +277,12 @@ extern "C" {
#define APR_USE_SHMEM_MMAP_ANON 0
#define APR_USE_SHMEM_BEOS 0
-#define APR_USE_FLOCK_SERIALIZE 0
+#define APR_USE_FLOCK_SERIALIZE 0
#define APR_USE_POSIXSEM_SERIALIZE 0
#define APR_USE_SYSVSEM_SERIALIZE 0
#define APR_USE_FCNTL_SERIALIZE 0
-#define APR_USE_PROC_PTHREAD_SERIALIZE 0
-#define APR_USE_PTHREAD_SERIALIZE 0
+#define APR_USE_PROC_PTHREAD_SERIALIZE 0
+#define APR_USE_PTHREAD_SERIALIZE 0
#define APR_HAS_FLOCK_SERIALIZE 0
#define APR_HAS_SYSVSEM_SERIALIZE 0
@@ -280,6 +299,7 @@ extern "C" {
#define APR_HAVE_INET_ADDR 1
#define APR_HAVE_INET_NETWORK 0
#define APR_HAVE_IPV6 @apr_have_ipv6_10@
+#define APR_HAVE_SOCKADDR_UN 0
#define APR_HAVE_MEMMOVE 1
#define APR_HAVE_SETRLIMIT 0
#define APR_HAVE_SIGACTION 0
@@ -351,7 +371,7 @@ extern "C" {
/* Is the O_NONBLOCK flag inherited from listening sockets?
*/
-#define APR_O_NONBLOCK_INHERITED 1
+#define APR_O_NONBLOCK_INHERITED 1
/* Typedefs that APR needs. */
@@ -623,18 +643,20 @@ typedef int gid_t;
&& (*(const apr_uint32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff)))
#endif
-#endif /* APR_HAS_IPV6 */
+#endif /* APR_HAVE_IPV6 */
#ifdef __cplusplus
}
#endif
-/* Done with badly written headers
+/* Done with badly written headers, leave 'deprecated CRT' undeprecated
*/
#if defined(_MSC_VER) && _MSC_VER >= 1200
#pragma warning(pop)
+#if _MSC_VER >= 1400
#pragma warning(disable: 4996)
#endif
+#endif
#endif /* WIN32 */
diff --git a/include/apr_allocator.h b/include/apr_allocator.h
index 70d31efa0f594..be05d0e4f3820 100644
--- a/include/apr_allocator.h
+++ b/include/apr_allocator.h
@@ -103,6 +103,16 @@ APR_DECLARE(apr_memnode_t *) apr_allocator_alloc(apr_allocator_t *allocator,
APR_DECLARE(void) apr_allocator_free(apr_allocator_t *allocator,
apr_memnode_t *memnode)
__attribute__((nonnull(1,2)));
+
+/**
+ * Get the true size that would be allocated for the given size (including
+ * the header and alignment).
+ * @param allocator The allocator from which to the memory would be allocated
+ * @param size The size to align
+ * @return The aligned size (or zero on apr_size_t overflow)
+ */
+APR_DECLARE(apr_size_t) apr_allocator_align(apr_allocator_t *allocator,
+ apr_size_t size);
#include "apr_pools.h"
diff --git a/include/apr_atomic.h b/include/apr_atomic.h
index 60e4bb54d0eac..7ea257123ae2e 100644
--- a/include/apr_atomic.h
+++ b/include/apr_atomic.h
@@ -41,7 +41,7 @@ extern "C" {
* @param p pool
* @return APR_SUCCESS on successful completion
* @remark Programs do NOT need to call this directly. APR will call this
- * automatically from apr_initialize.
+ * automatically from apr_initialize().
* @internal
*/
APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p);
diff --git a/include/apr_cstr.h b/include/apr_cstr.h
new file mode 100644
index 0000000000000..3f1b1a0995a62
--- /dev/null
+++ b/include/apr_cstr.h
@@ -0,0 +1,292 @@
+/* ====================================================================
+ * 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_cstr.h
+ * @brief C string goodies.
+ */
+
+#ifndef APR_CSTR_H
+#define APR_CSTR_H
+
+#include <apr.h> /* for apr_size_t */
+#include <apr_pools.h> /* for apr_pool_t */
+#include <apr_tables.h> /* for apr_array_header_t */
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @defgroup apr_cstr C (POSIX) locale string functions
+ * @ingroup apr_strings
+ *
+ * The apr_cstr_* functions provide traditional C char * string text handling,
+ * and notabilty they treat all text in the C (a.k.a. POSIX) locale using the
+ * minimal POSIX character set, represented in either ASCII or a corresponding
+ * EBCDIC subset.
+ *
+ * Character values outside of that set are treated as opaque bytes, and all
+ * multi-byte character sequences are handled as individual distinct octets.
+ *
+ * Multi-byte characters sequences whose octets fall in the ASCII range cause
+ * unexpected results, such as in the ISO-2022-JP code page where ASCII octets
+ * occur within both shift-state and multibyte sequences.
+ *
+ * In the case of the UTF-8 encoding, all multibyte characters all fall outside
+ * of the C/POSIX range of characters, so these functions are generally safe
+ * to use on UTF-8 strings. The programmer must be aware that each octet may
+ * not represent a distinct printable character in such encodings.
+ *
+ * The standard C99/POSIX string functions, rather than apr_cstr, should be
+ * used in all cases where the current locale and encoding of the text is
+ * significant.
+ * @{
+ */
+
+
+/** Divide @a input into substrings, interpreting any char from @a sep
+ * as a token separator.
+ *
+ * Return an array of copies of those substrings (plain const char*),
+ * allocating both the array and the copies in @a pool.
+ *
+ * None of the elements added to the array contain any of the
+ * characters in @a sep_chars, and none of the new elements are empty
+ * (thus, it is possible that the returned array will have length
+ * zero).
+ *
+ * If @a chop_whitespace is TRUE, then remove leading and trailing
+ * whitespace from the returned strings.
+ *
+ * @since New in 1.6
+ */
+APR_DECLARE(apr_array_header_t *) apr_cstr_split(const char *input,
+ const char *sep_chars,
+ int chop_whitespace,
+ apr_pool_t *pool);
+
+/** Like apr_cstr_split(), but append to existing @a array instead of
+ * creating a new one. Allocate the copied substrings in @a pool
+ * (i.e., caller decides whether or not to pass @a array->pool as @a pool).
+ *
+ * @since New in 1.6
+ */
+APR_DECLARE(void) apr_cstr_split_append(apr_array_header_t *array,
+ const char *input,
+ const char *sep_chars,
+ int chop_whitespace,
+ apr_pool_t *pool);
+
+
+/** Return @c TRUE iff @a str matches any of the elements of @a list, a list
+ * of zero or more glob patterns.
+ *
+ * @since New in 1.6
+ */
+APR_DECLARE(int) apr_cstr_match_glob_list(const char *str,
+ const apr_array_header_t *list);
+
+/** Return @c TRUE iff @a str exactly matches any of the elements of @a list.
+ *
+ * @since New in 1.6
+ */
+APR_DECLARE(int) apr_cstr_match_list(const char *str,
+ const apr_array_header_t *list);
+
+/**
+ * Get the next token from @a *str interpreting any char from @a sep as a
+ * token separator. Separators at the beginning of @a str will be skipped.
+ * Returns a pointer to the beginning of the first token in @a *str or NULL
+ * if no token is left. Modifies @a str such that the next call will return
+ * the next token.
+ *
+ * @note The content of @a *str may be modified by this function.
+ *
+ * @since New in 1.6.
+ */
+APR_DECLARE(char *) apr_cstr_tokenize(const char *sep, char **str);
+
+/**
+ * Return the number of line breaks in @a msg, allowing any kind of newline
+ * termination (CR, LF, CRLF, or LFCR), even inconsistent.
+ *
+ * @since New in 1.6.
+ */
+APR_DECLARE(int) apr_cstr_count_newlines(const char *msg);
+
+#if 0 /* XXX: stringbuf logic is not present in APR */
+/**
+ * Return a cstring which is the concatenation of @a strings (an array
+ * of char *) each followed by @a separator (that is, @a separator
+ * will also end the resulting string). Allocate the result in @a pool.
+ * If @a strings is empty, then return the empty string.
+ *
+ * @since New in 1.6.
+ */
+APR_DECLARE(char *) apr_cstr_join(const apr_array_header_t *strings,
+ const char *separator,
+ apr_pool_t *pool);
+#endif
+
+/**
+ * Perform a case-insensitive comparison of two strings @a atr1 and @a atr2,
+ * treating upper and lower case values of the 26 standard C/POSIX alphabetic
+ * characters as equivalent. Extended latin characters outside of this set
+ * are treated as unique octets, irrespective of the current locale.
+ *
+ * Returns in integer greater than, equal to, or less than 0,
+ * according to whether @a str1 is considered greater than, equal to,
+ * or less than @a str2.
+ *
+ * @since New in 1.6.
+ */
+APR_DECLARE(int) apr_cstr_casecmp(const char *str1, const char *str2);
+
+/**
+ * Perform a case-insensitive comparison of two strings @a atr1 and @a atr2,
+ * treating upper and lower case values of the 26 standard C/POSIX alphabetic
+ * characters as equivalent. Extended latin characters outside of this set
+ * are treated as unique octets, irrespective of the current locale.
+ *
+ * Returns in integer greater than, equal to, or less than 0,
+ * according to whether @a str1 is considered greater than, equal to,
+ * or less than @a str2.
+ *
+ * @since New in 1.6.
+ */
+APR_DECLARE(int) apr_cstr_casecmpn(const char *str1,
+ const char *str2,
+ apr_size_t n);
+
+/**
+ * Parse the C string @a str into a 64 bit number, and return it in @a *n.
+ * Assume that the number is represented in base @a base.
+ * Raise an error if conversion fails (e.g. due to overflow), or if the
+ * converted number is smaller than @a minval or larger than @a maxval.
+ *
+ * Leading whitespace in @a str is skipped in a locale-dependent way.
+ * After that, the string may contain an optional '+' (positive, default)
+ * or '-' (negative) character, followed by an optional '0x' prefix if
+ * @a base is 0 or 16, followed by numeric digits appropriate for the base.
+ * If there are any more characters after the numeric digits, an error is
+ * returned.
+ *
+ * If @a base is zero, then a leading '0x' or '0X' prefix means hexadecimal,
+ * else a leading '0' means octal (implemented, though not documented, in
+ * apr_strtoi64() in APR 0.9.0 through 1.5.0), else use base ten.
+ *
+ * @since New in 1.6.
+ */
+APR_DECLARE(apr_status_t) apr_cstr_strtoi64(apr_int64_t *n, const char *str,
+ apr_int64_t minval,
+ apr_int64_t maxval,
+ int base);
+
+/**
+ * Parse the C string @a str into a 64 bit number, and return it in @a *n.
+ * Assume that the number is represented in base 10.
+ * Raise an error if conversion fails (e.g. due to overflow).
+ *
+ * The behaviour otherwise is as described for apr_cstr_strtoi64().
+ *
+ * @since New in 1.6.
+ */
+APR_DECLARE(apr_status_t) apr_cstr_atoi64(apr_int64_t *n, const char *str);
+
+/**
+ * Parse the C string @a str into a 32 bit number, and return it in @a *n.
+ * Assume that the number is represented in base 10.
+ * Raise an error if conversion fails (e.g. due to overflow).
+ *
+ * The behaviour otherwise is as described for apr_cstr_strtoi64().
+ *
+ * @since New in 1.6.
+ */
+APR_DECLARE(apr_status_t) apr_cstr_atoi(int *n, const char *str);
+
+/**
+ * Parse the C string @a str into an unsigned 64 bit number, and return
+ * it in @a *n. Assume that the number is represented in base @a base.
+ * Raise an error if conversion fails (e.g. due to overflow), or if the
+ * converted number is smaller than @a minval or larger than @a maxval.
+ *
+ * Leading whitespace in @a str is skipped in a locale-dependent way.
+ * After that, the string may contain an optional '+' (positive, default)
+ * or '-' (negative) character, followed by an optional '0x' prefix if
+ * @a base is 0 or 16, followed by numeric digits appropriate for the base.
+ * If there are any more characters after the numeric digits, an error is
+ * returned.
+ *
+ * If @a base is zero, then a leading '0x' or '0X' prefix means hexadecimal,
+ * else a leading '0' means octal (as implemented, though not documented, in
+ * apr_strtoi64(), else use base ten.
+ *
+ * @warning The implementation returns APR_ERANGE if the parsed number
+ * is greater than APR_INT64_MAX, even if it is not greater than @a maxval.
+ *
+ * @since New in 1.6.
+ */
+APR_DECLARE(apr_status_t) apr_cstr_strtoui64(apr_uint64_t *n, const char *str,
+ apr_uint64_t minval,
+ apr_uint64_t maxval,
+ int base);
+
+/**
+ * Parse the C string @a str into an unsigned 64 bit number, and return
+ * it in @a *n. Assume that the number is represented in base 10.
+ * Raise an error if conversion fails (e.g. due to overflow).
+ *
+ * The behaviour otherwise is as described for apr_cstr_strtoui64(),
+ * including the upper limit of APR_INT64_MAX.
+ *
+ * @since New in 1.6.
+ */
+APR_DECLARE(apr_status_t) apr_cstr_atoui64(apr_uint64_t *n, const char *str);
+
+/**
+ * Parse the C string @a str into an unsigned 32 bit number, and return
+ * it in @a *n. Assume that the number is represented in base 10.
+ * Raise an error if conversion fails (e.g. due to overflow).
+ *
+ * The behaviour otherwise is as described for apr_cstr_strtoui64(),
+ * including the upper limit of APR_INT64_MAX.
+ *
+ * @since New in 1.6.
+ */
+APR_DECLARE(apr_status_t) apr_cstr_atoui(unsigned int *n, const char *str);
+
+/**
+ * Skip the common prefix @a prefix from the C string @a str, and return
+ * a pointer to the next character after the prefix.
+ * Return @c NULL if @a str does not start with @a prefix.
+ *
+ * @since New in 1.6.
+ */
+APR_DECLARE(const char *) apr_cstr_skip_prefix(const char *str,
+ const char *prefix);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* SVN_STRING_H */
diff --git a/include/apr_errno.h b/include/apr_errno.h
index 58eaf73cc5ae3..8fa6628b98d2a 100644
--- a/include/apr_errno.h
+++ b/include/apr_errno.h
@@ -833,6 +833,20 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf,
#define APR_EAFNOSUPPORT (APR_OS_START_CANONERR + 27)
#endif
+/** @see APR_STATUS_IS_EOPNOTSUPP */
+#ifdef EOPNOTSUPP
+#define APR_EOPNOTSUPP EOPNOTSUPP
+#else
+#define APR_EOPNOTSUPP (APR_OS_START_CANONERR + 28)
+#endif
+
+/** @see APR_STATUS_IS_ERANGE */
+#ifdef ERANGE
+#define APR_ERANGE ERANGE
+#else
+#define APR_ERANGE (APR_OS_START_CANONERR + 29)
+#endif
+
/** @} */
#if defined(OS2) && !defined(DOXYGEN)
@@ -977,6 +991,9 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf,
|| (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED)
#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_AFNOSUPPORT \
|| (s) == APR_OS_START_SYSERR + SOCEAFNOSUPPORT)
+#define APR_STATUS_IS_EOPNOTSUPP(s) ((s) == APR_EOPNOTSUPP \
+ || (s) == APR_OS_START_SYSERR + SOCEOPNOTSUPP)
+#define APR_STATUS_IS_ERANGE(s) ((s) == APR_ERANGE)
/*
Sorry, too tired to wrap this up for OS2... feel free to
@@ -990,7 +1007,6 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf,
{ SOCENOPROTOOPT, ENOPROTOOPT },
{ SOCEPROTONOSUPPORT, EPROTONOSUPPORT },
{ SOCESOCKTNOSUPPORT, ESOCKTNOSUPPORT },
- { SOCEOPNOTSUPP, EOPNOTSUPP },
{ SOCEPFNOSUPPORT, EPFNOSUPPORT },
{ SOCEADDRINUSE, EADDRINUSE },
{ SOCEADDRNOTAVAIL, EADDRNOTAVAIL },
@@ -1122,6 +1138,9 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf,
|| (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY)
#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_EAFNOSUPPORT \
|| (s) == APR_OS_START_SYSERR + WSAEAFNOSUPPORT)
+#define APR_STATUS_IS_EOPNOTSUPP(s) ((s) == APR_EOPNOTSUPP \
+ || (s) == APR_OS_START_SYSERR + WSAEOPNOTSUPP)
+#define APR_STATUS_IS_ERANGE(s) ((s) == APR_ERANGE)
#elif defined(NETWARE) && defined(USE_WINSOCK) && !defined(DOXYGEN) /* !defined(OS2) && !defined(WIN32) */
@@ -1183,6 +1202,9 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf,
#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY)
#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_EAFNOSUPPORT \
|| (s) == APR_OS_START_SYSERR + WSAEAFNOSUPPORT)
+#define APR_STATUS_IS_EOPNOTSUPP(s) ((s) == APR_EOPNOTSUPP \
+ || (s) == APR_OS_START_SYSERR + WSAEOPNOTSUPP)
+#define APR_STATUS_IS_ERANGE(s) ((s) == APR_ERANGE)
#else /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */
@@ -1291,7 +1313,7 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf,
#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH)
/** network is unreachable */
#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH)
-/** inappropiate file type or format */
+/** inappropriate file type or format */
#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE)
/** broken pipe */
#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE)
@@ -1302,6 +1324,11 @@ APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf,
(s) == APR_EEXIST)
/** Address Family not supported */
#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_EAFNOSUPPORT)
+/** Socket operation not supported */
+#define APR_STATUS_IS_EOPNOTSUPP(s) ((s) == APR_EOPNOTSUPP)
+
+/** Numeric value not representable */
+#define APR_STATUS_IS_ERANGE(s) ((s) == APR_ERANGE)
/** @} */
#endif /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */
diff --git a/include/apr_escape.h b/include/apr_escape.h
index 5b60ac6eee216..428a8cb6bd88e 100644
--- a/include/apr_escape.h
+++ b/include/apr_escape.h
@@ -40,7 +40,22 @@ extern "C" {
* passed to indicate a string-valued key, and have the length computed
* automatically.
*/
-#define APR_ESCAPE_STRING (-1)
+#define APR_ESCAPE_STRING (-1)
+
+/**
+ * Apply LDAP distinguished name escaping as per RFC4514.
+ */
+#define APR_ESCAPE_LDAP_DN (0x01)
+
+/**
+ * Apply LDAP filter escaping as per RFC4515.
+ */
+#define APR_ESCAPE_LDAP_FILTER (0x02)
+
+/**
+ * Apply both RFC4514 and RFC4515 LDAP escaping.
+ */
+#define APR_ESCAPE_LDAP_ALL (0x03)
/**
* Perform shell escaping on the provided string.
@@ -208,8 +223,8 @@ APR_DECLARE(const char *) apr_pescape_urlencoded(apr_pool_t *p,
/**
* Apply entity encoding to a string. Characters are replaced as follows:
- * '<' becomes '&lt;', '>' becomes '&gt;', '&' becomes '&amp;', the
- * double quote becomes '&quot;" and the single quote becomes '&apos;'.
+ * '<' becomes '\&lt;', '>' becomes '\&gt;', '&' becomes '\&amp;', the
+ * double quote becomes '\&quot;" and the single quote becomes '\&apos;'.
*
* If toasc is not zero, any non ascii character will be encoded as
* '%\#ddd;', where ddd is the decimal code of the character.
@@ -227,9 +242,9 @@ APR_DECLARE(apr_status_t) apr_escape_entity(char *escaped, const char *str,
/**
* Apply entity encoding to a string, returning the result from a pool.
- * Characters are replaced as follows: '<' becomes '&lt;', '>' becomes
- * '&gt;', '&' becomes '&amp;', the double quote becomes '&quot;" and the
- * single quote becomes '&apos;'.
+ * Characters are replaced as follows: '<' becomes '\&lt;', '>' becomes
+ * '\&gt;', '&' becomes '\&amp;', the double quote becomes '\&quot;" and the
+ * single quote becomes '\&apos;'.
* @param p Pool to allocate from
* @param str The original string
* @param toasc If non zero, encode non ascii characters
@@ -366,6 +381,35 @@ APR_DECLARE(apr_status_t) apr_unescape_hex(void *dest, const char *str,
APR_DECLARE(const void *) apr_punescape_hex(apr_pool_t *p, const char *str,
int colon, apr_size_t *len);
+/**
+ * Apply LDAP escaping to binary data. Characters from RFC4514 and RFC4515
+ * are escaped with their hex equivalents.
+ * @param dest The destination buffer, can be NULL
+ * @param src The original buffer
+ * @param srclen The length of the original buffer
+ * @param flags APR_ESCAPE_LDAP_DN for RFC4514, APR_ESCAPE_LDAP_FILTER for
+ * RFC4515, APR_ESCAPE_LDAP_ALL for both
+ * @param len If present, returns the length of the string
+ * @return APR_SUCCESS, or APR_NOTFOUND if the string was NULL
+ */
+APR_DECLARE(apr_status_t) apr_escape_ldap(char *dest, const void *src,
+ apr_ssize_t srclen, int flags, apr_size_t *len);
+
+/**
+ * Apply LDAP escaping to binary data, and return the results from a
+ * pool. Characters from RFC4514 and RFC4515 are escaped with their hex
+ * equivalents.
+ * @param p Pool to allocate from
+ * @param src The original buffer
+ * @param slen The length of the original buffer
+ * @param flags APR_ESCAPE_LDAP_DN for RFC4514, APR_ESCAPE_LDAP_FILTER for
+ * RFC4515, APR_ESCAPE_LDAP_ALL for both
+ * @return A zero padded buffer allocated from the pool on success, or
+ * NULL if src was NULL.
+ */
+APR_DECLARE(const char *) apr_pescape_ldap(apr_pool_t *p, const void *src,
+ apr_ssize_t slen, int flags) __attribute__((nonnull(1)));
+
/** @} */
#ifdef __cplusplus
}
diff --git a/include/apr_file_info.h b/include/apr_file_info.h
index 1d19eb6a3f493..cfddc68da8b12 100644
--- a/include/apr_file_info.h
+++ b/include/apr_file_info.h
@@ -50,7 +50,7 @@ extern "C" {
/** apr_filetype_e values for the filetype member of the
* apr_file_info_t structure
- * @warning: Not all of the filetypes below can be determined.
+ * @warning Not all of the filetypes below can be determined.
* For example, a given platform might not correctly report
* a socket descriptor as APR_SOCK if that type isn't
* well-identified on that platform. In such cases where
@@ -413,7 +413,7 @@ APR_DECLARE(apr_status_t) apr_filepath_set(const char *path, apr_pool_t *p);
* Determine the encoding used internally by the FilePath functions
* @param style points to a variable which receives the encoding style flag
* @param p the pool to allocate any working storage
- * @remark Use @c apr_os_locale_encoding and/or @c apr_os_default_encoding
+ * @remark Use apr_os_locale_encoding() and/or apr_os_default_encoding()
* to get the name of the path encoding if it's not UTF-8.
*/
APR_DECLARE(apr_status_t) apr_filepath_encoding(int *style, apr_pool_t *p);
diff --git a/include/apr_file_io.h b/include/apr_file_io.h
index eb683afa74560..af931939abb38 100644
--- a/include/apr_file_io.h
+++ b/include/apr_file_io.h
@@ -315,6 +315,10 @@ APR_DECLARE(apr_status_t) apr_file_copy(const char *from_path,
* file's permissions are copied.
* @param pool The pool to use.
* @remark The new file does not need to exist, it will be created if required.
+ * @remark Note that advanced filesystem permissions such as ACLs are not
+ * duplicated by this API. The target permissions (including duplicating the
+ * source file permissions) are assigned only when the target file does not yet
+ * exist.
*/
APR_DECLARE(apr_status_t) apr_file_append(const char *from_path,
const char *to_path,
@@ -695,7 +699,7 @@ APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile,
* @bug Some platforms cannot toggle between blocking and nonblocking,
* and when passing a pipe as a standard handle to an application which
* does not expect it, a non-blocking stream will fluxor the client app.
- * @deprecated @see apr_file_pipe_create_ex()
+ * @deprecated @see apr_file_pipe_create_pools()
*/
APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in,
apr_file_t **out,
@@ -719,6 +723,7 @@ APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in,
* does not expect it, a non-blocking stream will fluxor the client app.
* Use this function rather than apr_file_pipe_create() to create pipes
* where one or both ends require non-blocking semantics.
+ * @deprecated @see apr_file_pipe_create_pools()
*/
APR_DECLARE(apr_status_t) apr_file_pipe_create_ex(apr_file_t **in,
apr_file_t **out,
@@ -726,6 +731,33 @@ APR_DECLARE(apr_status_t) apr_file_pipe_create_ex(apr_file_t **in,
apr_pool_t *pool);
/**
+ * Create an anonymous pipe which portably supports async timeout options,
+ * placing each side of the pipe in a different pool.
+ * @param in The newly created pipe's file for reading.
+ * @param out The newly created pipe's file for writing.
+ * @param blocking one of these values defined in apr_thread_proc.h;
+ * @li #APR_FULL_BLOCK
+ * @li #APR_READ_BLOCK
+ * @li #APR_WRITE_BLOCK
+ * @li #APR_FULL_NONBLOCK
+ * @param pool_in The pool for the reading pipe.
+ * @param pool_out The pool for the writing pipe.
+ * @remark By default, the returned file descriptors will be inherited
+ * by child processes created using apr_proc_create(). This can be
+ * changed using apr_file_inherit_unset().
+ * @remark Some platforms cannot toggle between blocking and nonblocking,
+ * and when passing a pipe as a standard handle to an application which
+ * does not expect it, a non-blocking stream will fluxor the client app.
+ * Use this function rather than apr_file_pipe_create() to create pipes
+ * where one or both ends require non-blocking semantics.
+ */
+APR_DECLARE(apr_status_t) apr_file_pipe_create_pools(apr_file_t **in,
+ apr_file_t **out,
+ apr_int32_t blocking,
+ apr_pool_t *pool_in,
+ apr_pool_t *pool_out);
+
+/**
* Create a named pipe.
* @param filename The filename of the named pipe
* @param perm The permissions for the newly created pipe.
diff --git a/include/apr_general.h b/include/apr_general.h
index c7389ec929699..fa073c859f543 100644
--- a/include/apr_general.h
+++ b/include/apr_general.h
@@ -170,8 +170,8 @@ void *memchr(const void *s, int c, size_t n);
/**
* Setup any APR internal data structures. This MUST be the first function
* called for any APR library. It is safe to call apr_initialize several
- * times as long as apr_terminate is called the same number of times.
- * @remark See apr_app_initialize if this is an application, rather than
+ * times as long as apr_terminate() is called the same number of times.
+ * @remark See apr_app_initialize() if this is an application, rather than
* a library consumer of apr.
*/
APR_DECLARE(apr_status_t) apr_initialize(void);
@@ -184,9 +184,9 @@ APR_DECLARE(apr_status_t) apr_initialize(void);
* @param argc Pointer to the argc that may be corrected
* @param argv Pointer to the argv that may be corrected
* @param env Pointer to the env that may be corrected, may be NULL
- * @remark See apr_initialize if this is a library consumer of apr.
- * Otherwise, this call is identical to apr_initialize, and must be closed
- * with a call to apr_terminate at the end of program execution.
+ * @remark See apr_initialize() if this is a library consumer of apr.
+ * Otherwise, this call is identical to apr_initialize(), and must be closed
+ * with a call to apr_terminate() at the end of program execution.
*/
APR_DECLARE(apr_status_t) apr_app_initialize(int *argc,
char const * const * *argv,
@@ -198,20 +198,21 @@ APR_DECLARE(apr_status_t) apr_app_initialize(int *argc,
* apr_initialize() or apr_app_initialize().
* @remark An APR program must call this function at termination once it
* has stopped using APR services. The APR developers suggest using
- * atexit to ensure this is called. When using APR from a language
- * other than C that has problems with the calling convention, use
- * apr_terminate2() instead.
+ * @c atexit(apr_terminate) to ensure this is called. When using APR
+ * from a language other than C that has problems with the calling
+ * convention, use apr_terminate2() instead.
+ * @see apr_terminate2
*/
APR_DECLARE_NONSTD(void) apr_terminate(void);
/**
* Tear down any APR internal data structures which aren't torn down
- * automatically, same as apr_terminate
- * @remark An APR program must call either the apr_terminate or apr_terminate2
+ * automatically, same as apr_terminate()
+ * @remark An APR program must call either the apr_terminate() or apr_terminate2
* function once it it has finished using APR services. The APR
- * developers suggest using atexit(apr_terminate) to ensure this is done.
+ * developers suggest using @c atexit(apr_terminate) to ensure this is done.
* apr_terminate2 exists to allow non-c language apps to tear down apr,
- * while apr_terminate is recommended from c language applications.
+ * while apr_terminate() is recommended from c language applications.
*/
APR_DECLARE(void) apr_terminate2(void);
diff --git a/include/apr_global_mutex.h b/include/apr_global_mutex.h
index db19301340088..90d9c55b04847 100644
--- a/include/apr_global_mutex.h
+++ b/include/apr_global_mutex.h
@@ -127,14 +127,25 @@ APR_DECLARE(apr_status_t) apr_global_mutex_destroy(apr_global_mutex_t *mutex);
APR_DECLARE(const char *) apr_global_mutex_lockfile(apr_global_mutex_t *mutex);
/**
- * Display the name of the mutex, as it relates to the actual method used
- * for the underlying apr_proc_mutex_t, if any. NULL is returned if
- * there is no underlying apr_proc_mutex_t.
- * @param mutex the name of the mutex
+ * Get the mechanism of the mutex, as it relates to the actual method
+ * used for the underlying apr_proc_mutex_t.
+ * @param mutex the mutex to get the mechanism from.
+ */
+APR_DECLARE(apr_lockmech_e) apr_global_mutex_mech(apr_global_mutex_t *mutex);
+
+/**
+ * Get the mechanism's name of the mutex, as it relates to the actual method
+ * used for the underlying apr_proc_mutex_t.
+ * @param mutex the mutex to get the mechanism's name from.
*/
APR_DECLARE(const char *) apr_global_mutex_name(apr_global_mutex_t *mutex);
/**
+ * Set mutex permissions.
+ */
+APR_PERMS_SET_IMPLEMENT(global_mutex);
+
+/**
* Get the pool used by this global_mutex.
* @return apr_pool_t the pool
*/
@@ -155,7 +166,9 @@ APR_POOL_DECLARE_ACCESSOR(global_mutex);
#define apr_global_mutex_unlock apr_proc_mutex_unlock
#define apr_global_mutex_destroy apr_proc_mutex_destroy
#define apr_global_mutex_lockfile apr_proc_mutex_lockfile
+#define apr_global_mutex_mech apr_proc_mutex_mech
#define apr_global_mutex_name apr_proc_mutex_name
+#define apr_global_mutex_perms_set apr_proc_mutex_perms_set
#define apr_global_mutex_pool_get apr_proc_mutex_pool_get
#endif
diff --git a/include/apr_hash.h b/include/apr_hash.h
index 37d972f9dd7d7..2276f84c3b074 100644
--- a/include/apr_hash.h
+++ b/include/apr_hash.h
@@ -102,7 +102,8 @@ APR_DECLARE(apr_hash_t *) apr_hash_copy(apr_pool_t *pool,
* @param key Pointer to the key
* @param klen Length of the key. Can be APR_HASH_KEY_STRING to use the string length.
* @param val Value to associate with the key
- * @remark If the value is NULL the hash entry is deleted.
+ * @remark If the value is NULL the hash entry is deleted. The key is stored as is,
+ * and so must have a lifetime at least as long as the hash table's pool.
*/
APR_DECLARE(void) apr_hash_set(apr_hash_t *ht, const void *key,
apr_ssize_t klen, const void *val);
diff --git a/include/apr_network_io.h b/include/apr_network_io.h
index 0d34a8458e465..43e578aca47ee 100644
--- a/include/apr_network_io.h
+++ b/include/apr_network_io.h
@@ -26,10 +26,14 @@
#include "apr_file_io.h"
#include "apr_errno.h"
#include "apr_inherit.h"
+#include "apr_perms_set.h"
#if APR_HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
+#if APR_HAVE_SYS_UN_H
+#include <sys/un.h>
+#endif
#ifdef __cplusplus
extern "C" {
@@ -101,6 +105,9 @@ extern "C" {
*/
#define APR_SO_BROADCAST 65536 /**< Allow broadcast
*/
+#define APR_SO_FREEBIND 131072 /**< Allow binding to addresses not owned
+ * by any interface
+ */
/** @} */
@@ -156,6 +163,25 @@ struct in_addr {
#define APR_INET6 AF_INET6
#endif
+#if APR_HAVE_SOCKADDR_UN
+#if defined (AF_UNIX)
+#define APR_UNIX AF_UNIX
+#elif defined(AF_LOCAL)
+#define APR_UNIX AF_LOCAL
+#else
+#error "Neither AF_UNIX nor AF_LOCAL is defined"
+#endif
+#else /* !APR_HAVE_SOCKADDR_UN */
+#if defined (AF_UNIX)
+#define APR_UNIX AF_UNIX
+#elif defined(AF_LOCAL)
+#define APR_UNIX AF_LOCAL
+#else
+/* TODO: Use a smarter way to detect unique APR_UNIX value */
+#define APR_UNIX 1234
+#endif
+#endif
+
/**
* @defgroup IP_Proto IP Protocol Definitions for use when creating sockets
* @{
@@ -247,6 +273,10 @@ struct apr_sockaddr_t {
* dependent on whether APR_HAVE_IPV6 is defined. */
struct sockaddr_storage sas;
#endif
+#if APR_HAVE_SOCKADDR_UN
+ /** Unix domain socket sockaddr structure */
+ struct sockaddr_un unx;
+#endif
} sa;
};
@@ -375,6 +405,7 @@ APR_DECLARE(apr_status_t) apr_socket_atreadeof(apr_socket_t *sock,
* @param sa The new apr_sockaddr_t.
* @param hostname The hostname or numeric address string to resolve/parse, or
* NULL to build an address that corresponds to 0.0.0.0 or ::
+ * or in case of APR_UNIX family it is absolute socket filename.
* @param family The address family to use, or APR_UNSPEC if the system should
* decide.
* @param port The port number.
@@ -401,6 +432,16 @@ APR_DECLARE(apr_status_t) apr_sockaddr_info_get(apr_sockaddr_t **sa,
apr_pool_t *p);
/**
+ * Copy apr_sockaddr_t src to dst on pool p.
+ * @param dst The destination apr_sockaddr_t.
+ * @param src The source apr_sockaddr_t.
+ * @param p The pool for the apr_sockaddr_t and associated storage.
+ */
+APR_DECLARE(apr_status_t) apr_sockaddr_info_copy(apr_sockaddr_t **dst,
+ const apr_sockaddr_t *src,
+ apr_pool_t *p);
+
+/**
* Look up the host name from an apr_sockaddr_t.
* @param hostname The hostname.
* @param sa The apr_sockaddr_t.
@@ -620,6 +661,7 @@ APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock,
* of local addresses.
* APR_SO_SNDBUF -- Set the SendBufferSize
* APR_SO_RCVBUF -- Set the ReceiveBufferSize
+ * APR_SO_FREEBIND -- Allow binding to non-local IP address.
* </PRE>
* @param on Value for the option.
*/
@@ -807,6 +849,11 @@ APR_DECLARE_INHERIT_SET(socket);
APR_DECLARE_INHERIT_UNSET(socket);
/**
+ * Set socket permissions.
+ */
+APR_PERMS_SET_IMPLEMENT(socket);
+
+/**
* @defgroup apr_mcast IP Multicast
* @{
*/
diff --git a/include/apr_perms_set.h b/include/apr_perms_set.h
new file mode 100644
index 0000000000000..92a1362b8e578
--- /dev/null
+++ b/include/apr_perms_set.h
@@ -0,0 +1,65 @@
+/* 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.
+ */
+
+#ifndef APR_PERMS_SET_H
+#define APR_PERMS_SET_H
+
+/**
+ * @file apr_perms_set.h
+ * @brief APR Process Locking Routines
+ */
+
+#include "apr.h"
+#include "apr_pools.h"
+#include "apr_errno.h"
+#include "apr_user.h"
+#include "apr_file_info.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @defgroup apr_perms_set Object permission set functions
+ * @ingroup APR
+ * @{
+ */
+
+/** Permission set callback function. */
+typedef apr_status_t (apr_perms_setfn_t)(void *object, apr_fileperms_t perms,
+ apr_uid_t uid, apr_gid_t gid);
+
+#define APR_PERMS_SET_IMPLEMENT(type) \
+ APR_DECLARE(apr_status_t) apr_##type##_perms_set \
+ (void *the##type, apr_fileperms_t perms, \
+ apr_uid_t uid, apr_gid_t gid)
+
+#define APR_PERMS_SET_ENOTIMPL(type) \
+ APR_DECLARE(apr_status_t) apr_##type##_perms_set \
+ (void *the##type, apr_fileperms_t perms, \
+ apr_uid_t uid, apr_gid_t gid) \
+ { return APR_ENOTIMPL ; }
+
+#define APR_PERMS_SET_FN(type) apr_##type##_perms_set
+
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ! APR_PERMS_SET */
diff --git a/include/apr_poll.h b/include/apr_poll.h
index 1381ddd138308..482d6ee1db7e0 100644
--- a/include/apr_poll.h
+++ b/include/apr_poll.h
@@ -66,7 +66,7 @@ extern "C" {
* are not copied
*/
#define APR_POLLSET_WAKEABLE 0x004 /**< Poll operations are interruptable by
- * apr_pollset_wakeup()
+ * apr_pollset_wakeup() or apr_pollcb_wakeup()
*/
#define APR_POLLSET_NODEFAULT 0x010 /**< Do not try to use the default method if
* the specified non-default method cannot be
@@ -323,8 +323,12 @@ typedef struct apr_pollcb_t apr_pollcb_t;
* @param p The pool from which to allocate the pollcb
* @param flags Optional flags to modify the operation of the pollcb.
*
+ * @remark If flags contains APR_POLLSET_WAKEABLE, then a pollcb is
+ * created with an additional internal pipe object used for the
+ * apr_pollcb_wakeup() call. The actual size of pollcb is
+ * in that case @a size + 1.
* @remark Pollcb is only supported on some platforms; the apr_pollcb_create()
- * call will fail with APR_ENOTIMPL on platforms where it is not supported.
+ * call will fail with APR_ENOTIMPL on platforms where it is not supported.
*/
APR_DECLARE(apr_status_t) apr_pollcb_create(apr_pollcb_t **pollcb,
apr_uint32_t size,
@@ -341,8 +345,12 @@ APR_DECLARE(apr_status_t) apr_pollcb_create(apr_pollcb_t **pollcb,
* method cannot be used, the default method will be used unless the
* APR_POLLSET_NODEFAULT flag has been specified.
*
+ * @remark If flags contains APR_POLLSET_WAKEABLE, then a pollcb is
+ * created with an additional internal pipe object used for the
+ * apr_pollcb_wakeup() call. The actual size of pollcb is
+ * in that case @a size + 1.
* @remark Pollcb is only supported on some platforms; the apr_pollcb_create_ex()
- * call will fail with APR_ENOTIMPL on platforms where it is not supported.
+ * call will fail with APR_ENOTIMPL on platforms where it is not supported.
*/
APR_DECLARE(apr_status_t) apr_pollcb_create_ex(apr_pollcb_t **pollcb,
apr_uint32_t size,
@@ -373,6 +381,7 @@ APR_DECLARE(apr_status_t) apr_pollcb_add(apr_pollcb_t *pollcb,
* Remove a descriptor from a pollcb
* @param pollcb The pollcb from which to remove the descriptor
* @param descriptor The descriptor to remove
+ * @remark If the descriptor is not found, APR_NOTFOUND is returned.
* @remark apr_pollcb_remove() cannot be used to remove a subset of requested
* events for a descriptor. The reqevents field in the apr_pollfd_t
* parameter must contain the same value when removing as when adding.
@@ -380,11 +389,14 @@ APR_DECLARE(apr_status_t) apr_pollcb_add(apr_pollcb_t *pollcb,
APR_DECLARE(apr_status_t) apr_pollcb_remove(apr_pollcb_t *pollcb,
apr_pollfd_t *descriptor);
-/** Function prototype for pollcb handlers
+/**
+ * Function prototype for pollcb handlers
* @param baton Opaque baton passed into apr_pollcb_poll()
- * @param descriptor Contains the notification for an active descriptor,
- * the rtnevents member contains what events were triggered
+ * @param descriptor Contains the notification for an active descriptor.
+ * The @a rtnevents member describes which events were triggered
* for this descriptor.
+ * @remark If the pollcb handler does not return APR_SUCCESS, the apr_pollcb_poll()
+ * call returns with the handler's return value.
*/
typedef apr_status_t (*apr_pollcb_cb_t)(void *baton, apr_pollfd_t *descriptor);
@@ -395,17 +407,34 @@ typedef apr_status_t (*apr_pollcb_cb_t)(void *baton, apr_pollfd_t *descriptor);
* maximum, not a minimum. If a descriptor is signalled, the
* function will return before this time. If timeout is
* negative, the function will block until a descriptor is
- * signalled.
+ * signalled or until apr_pollcb_wakeup() has been called.
* @param func Callback function to call for each active descriptor.
* @param baton Opaque baton passed to the callback function.
* @remark Multiple signalled conditions for the same descriptor may be reported
* in one or more calls to the callback function, depending on the
* implementation.
+ * @remark APR_EINTR will be returned if the pollset has been created with
+ * APR_POLLSET_WAKEABLE and apr_pollcb_wakeup() has been called while
+ * waiting for activity.
*/
APR_DECLARE(apr_status_t) apr_pollcb_poll(apr_pollcb_t *pollcb,
apr_interval_time_t timeout,
apr_pollcb_cb_t func,
- void *baton);
+ void *baton);
+
+/**
+ * Interrupt the blocked apr_pollcb_poll() call.
+ * @param pollcb The pollcb to use
+ * @remark If the pollcb was not created with APR_POLLSET_WAKEABLE the
+ * return value is APR_EINIT.
+ */
+APR_DECLARE(apr_status_t) apr_pollcb_wakeup(apr_pollcb_t *pollcb);
+
+/**
+ * Return a printable representation of the pollcb method.
+ * @param pollcb The pollcb to use
+ */
+APR_DECLARE(const char *) apr_pollcb_method_name(apr_pollcb_t *pollcb);
/** @} */
diff --git a/include/apr_portable.h b/include/apr_portable.h
index 45d53eb15422d..f56997e4d187a 100644
--- a/include/apr_portable.h
+++ b/include/apr_portable.h
@@ -46,6 +46,9 @@
#if APR_HAVE_PTHREAD_H
#include <pthread.h>
#endif
+#if APR_HAVE_SEMAPHORE_H
+#include <semaphore.h>
+#endif
#ifdef __cplusplus
extern "C" {
@@ -140,6 +143,10 @@ struct apr_os_proc_mutex_t {
pthread_mutex_t *intraproc;
#endif
#endif
+#if APR_HAS_POSIXSEM_SERIALIZE
+ /** Value used for POSIX semaphores serialization */
+ sem_t *psem_interproc;
+#endif
};
typedef int apr_os_file_t; /**< native file */
@@ -241,7 +248,7 @@ APR_DECLARE(apr_status_t) apr_os_sock_get(apr_os_sock_t *thesock,
apr_socket_t *sock);
/**
- * Convert the proc mutex from os specific type to apr type
+ * Convert the proc mutex from apr type to os specific type
* @param ospmutex The os specific proc mutex we are converting to.
* @param pmutex The apr proc mutex to convert.
*/
@@ -249,6 +256,19 @@ APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex,
apr_proc_mutex_t *pmutex);
/**
+ * Convert the proc mutex from apr type to os specific type, also
+ * providing the mechanism used by the apr mutex.
+ * @param ospmutex The os specific proc mutex we are converting to.
+ * @param pmutex The apr proc mutex to convert.
+ * @param mech The mechanism used by the apr proc mutex (if not NULL).
+ * @remark Allows for disambiguation for platforms with multiple mechanisms
+ * available.
+ */
+APR_DECLARE(apr_status_t) apr_os_proc_mutex_get_ex(apr_os_proc_mutex_t *ospmutex,
+ apr_proc_mutex_t *pmutex,
+ apr_lockmech_e *mech);
+
+/**
* Get the exploded time in the platforms native format.
* @param ostime the native time format
* @param aprtime the time to convert
@@ -380,7 +400,10 @@ APR_DECLARE(apr_status_t) apr_os_dir_put(apr_dir_t **dir,
apr_pool_t *cont);
/**
- * Convert a socket from the os specific type to the apr type
+ * Convert a socket from the os specific type to the APR type. If
+ * sock points to NULL, a socket will be created from the pool
+ * provided. If **sock does not point to NULL, the structure pointed
+ * to by sock will be reused and updated with the given socket.
* @param sock The pool to use.
* @param thesock The socket to convert to.
* @param cont The socket we are converting to an apr type.
@@ -416,6 +439,24 @@ APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex,
apr_pool_t *cont);
/**
+ * Convert the proc mutex from os specific type to apr type, using the
+ * specified mechanism.
+ * @param pmutex The apr proc mutex we are converting to.
+ * @param ospmutex The os specific proc mutex to convert.
+ * @param mech The apr mutex locking mechanism
+ * @param register_cleanup Whether to destroy the os mutex with the apr
+ * one (either on explicit destroy or pool cleanup).
+ * @param cont The pool to use if it is needed.
+ * @remark Allows for disambiguation for platforms with multiple mechanisms
+ * available.
+ */
+APR_DECLARE(apr_status_t) apr_os_proc_mutex_put_ex(apr_proc_mutex_t **pmutex,
+ apr_os_proc_mutex_t *ospmutex,
+ apr_lockmech_e mech,
+ int register_cleanup,
+ apr_pool_t *cont);
+
+/**
* Put the imploded time in the APR format.
* @param aprtime the APR time format
* @param ostime the time to convert
@@ -494,7 +535,7 @@ APR_DECLARE(const char*) apr_os_default_encoding(apr_pool_t *pool);
/**
* Get the name of the current locale character set.
* @param pool the pool to allocate the name from, if needed
- * @remark Defers to apr_os_default_encoding if the current locale's
+ * @remark Defers to apr_os_default_encoding() if the current locale's
* data can't be retrieved on this system.
*/
APR_DECLARE(const char*) apr_os_locale_encoding(apr_pool_t *pool);
diff --git a/include/apr_proc_mutex.h b/include/apr_proc_mutex.h
index ceb9c82a8dc9e..bb5b34f0c08ce 100644
--- a/include/apr_proc_mutex.h
+++ b/include/apr_proc_mutex.h
@@ -25,6 +25,7 @@
#include "apr.h"
#include "apr_pools.h"
#include "apr_errno.h"
+#include "apr_perms_set.h"
#ifdef __cplusplus
extern "C" {
@@ -140,9 +141,16 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *mutex);
APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex);
/**
- * Display the name of the mutex, as it relates to the actual method used.
- * This matches the valid options for Apache's AcceptMutex directive
- * @param mutex the name of the mutex
+ * Get the mechanism of the mutex, as it relates to the actual method
+ * used for the underlying apr_proc_mutex_t.
+ * @param mutex the mutex to get the mechanism from.
+ */
+APR_DECLARE(apr_lockmech_e) apr_proc_mutex_mech(apr_proc_mutex_t *mutex);
+
+/**
+ * Get the mechanism's name of the mutex, as it relates to the actual method
+ * used for the underlying apr_proc_mutex_t.
+ * @param mutex the mutex to get the mechanism's name from.
*/
APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex);
@@ -152,6 +160,11 @@ APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex);
APR_DECLARE(const char *) apr_proc_mutex_defname(void);
/**
+ * Set mutex permissions.
+ */
+APR_PERMS_SET_IMPLEMENT(proc_mutex);
+
+/**
* Get the pool used by this proc_mutex.
* @return apr_pool_t the pool
*/
diff --git a/include/apr_shm.h b/include/apr_shm.h
index 49543bb01946f..635c654b17fee 100644
--- a/include/apr_shm.h
+++ b/include/apr_shm.h
@@ -25,6 +25,7 @@
#include "apr.h"
#include "apr_pools.h"
#include "apr_errno.h"
+#include "apr_perms_set.h"
#ifdef __cplusplus
extern "C" {
@@ -136,6 +137,21 @@ APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename,
apr_pool_t *pool);
/**
+ * Delete named resource associated with a shared memory segment,
+ * preventing attachments to the resource.
+ * @param m The shared memory segment structure to delete.
+ * @remark This function is only supported on platforms which support
+ * name-based shared memory segments, and will return APR_ENOTIMPL on
+ * platforms without such support. Removing the file while the shm
+ * is in use is not entirely portable, caller may use this to enhance
+ * obscurity of the resource, but be prepared for the call to fail,
+ * and for concurrent attempts to create a resource of the same name
+ * to also fail. The pool cleanup of apr_shm_create (apr_shm_destroy)
+ * also removes the named resource.
+ */
+APR_DECLARE(apr_status_t) apr_shm_delete(apr_shm_t *m);
+
+/**
* Destroy a shared memory segment and associated memory.
* @param m The shared memory segment structure to destroy.
*/
@@ -195,6 +211,11 @@ APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m);
APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m);
/**
+ * Set shared memory permissions.
+ */
+APR_PERMS_SET_IMPLEMENT(shm);
+
+/**
* Get the pool used by this shared memory segment.
*/
APR_POOL_DECLARE_ACCESSOR(shm);
diff --git a/include/apr_skiplist.h b/include/apr_skiplist.h
index f56ff22c36d6a..eeab10bf9f44b 100644
--- a/include/apr_skiplist.h
+++ b/include/apr_skiplist.h
@@ -40,9 +40,7 @@ extern "C" {
/**
* apr_skiplist_compare is the function type that must be implemented
* per object type that is used in a skip list for comparisons to maintain
- * order. A value <0 indicates placement after this node; a value of 0
- * indicates collision with this exact node; a value >0 indicates placement
- * before this node.
+ * order
* */
typedef int (*apr_skiplist_compare) (void *, void *);
@@ -155,6 +153,30 @@ APR_DECLARE(void *) apr_skiplist_find_compare(apr_skiplist *sl,
APR_DECLARE(void *) apr_skiplist_find(apr_skiplist *sl, void *data, apr_skiplistnode **iter);
/**
+ * Return the last matching element in the skip list using the specified
+ * comparison function.
+ * @param sl The skip list
+ * @param data The value to search for
+ * @param iter A pointer to the returned skip list node representing the element
+ * found
+ * @param comp The comparison function to use
+ */
+APR_DECLARE(void *) apr_skiplist_last_compare(apr_skiplist *sl, void *data,
+ apr_skiplistnode **iter,
+ apr_skiplist_compare comp);
+
+/**
+ * Return the last matching element in the skip list using the current comparison
+ * function.
+ * @param sl The skip list
+ * @param data The value to search for
+ * @param iter A pointer to the returned skip list node representing the element
+ * found
+ */
+APR_DECLARE(void *) apr_skiplist_last(apr_skiplist *sl, void *data,
+ apr_skiplistnode **iter);
+
+/**
* Return the next element in the skip list.
* @param sl The skip list
* @param iter On entry, a pointer to the skip list node to start with; on return,
@@ -173,6 +195,12 @@ APR_DECLARE(void *) apr_skiplist_next(apr_skiplist *sl, apr_skiplistnode **iter)
APR_DECLARE(void *) apr_skiplist_previous(apr_skiplist *sl, apr_skiplistnode **iter);
/**
+ * Return the element of the skip list node
+ * @param iter The skip list node
+ */
+APR_DECLARE(void *) apr_skiplist_element(apr_skiplistnode *iter);
+
+/**
* Insert an element into the skip list using the specified comparison function
* if it does not already exist.
* @param sl The skip list
@@ -184,7 +212,7 @@ APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert_compare(apr_skiplist *sl,
/**
* Insert an element into the skip list using the existing comparison function
- * if it does not already exist (as determined by the comparison function)
+ * if it does not already exist.
* @param sl The skip list
* @param data The element to insert
* @remark If no comparison function has been set for the skip list, the element
@@ -193,6 +221,62 @@ APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert_compare(apr_skiplist *sl,
APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert(apr_skiplist* sl, void *data);
/**
+ * Add an element into the skip list using the specified comparison function
+ * allowing for duplicates.
+ * @param sl The skip list
+ * @param data The element to add
+ * @param comp The comparison function to use for placement into the skip list
+ */
+APR_DECLARE(apr_skiplistnode *) apr_skiplist_add_compare(apr_skiplist *sl,
+ void *data, apr_skiplist_compare comp);
+
+/**
+ * Add an element into the skip list using the existing comparison function
+ * allowing for duplicates.
+ * @param sl The skip list
+ * @param data The element to insert
+ * @remark If no comparison function has been set for the skip list, the element
+ * will not be inserted and NULL will be returned.
+ */
+APR_DECLARE(apr_skiplistnode *) apr_skiplist_add(apr_skiplist* sl, void *data);
+
+/**
+ * Add an element into the skip list using the specified comparison function
+ * removing the existing duplicates.
+ * @param sl The skip list
+ * @param data The element to insert
+ * @param comp The comparison function to use for placement into the skip list
+ * @param myfree A function to be called for each removed duplicate
+ * @remark If no comparison function has been set for the skip list, the element
+ * will not be inserted, none will be replaced, and NULL will be returned.
+ */
+APR_DECLARE(apr_skiplistnode *) apr_skiplist_replace_compare(apr_skiplist *sl,
+ void *data, apr_skiplist_freefunc myfree,
+ apr_skiplist_compare comp);
+
+/**
+ * Add an element into the skip list using the existing comparison function
+ * removing the existing duplicates.
+ * @param sl The skip list
+ * @param data The element to insert
+ * @param myfree A function to be called for each removed duplicate
+ * @remark If no comparison function has been set for the skip list, the element
+ * will not be inserted, none will be replaced, and NULL will be returned.
+ */
+APR_DECLARE(apr_skiplistnode *) apr_skiplist_replace(apr_skiplist *sl,
+ void *data, apr_skiplist_freefunc myfree);
+
+/**
+ * Remove a node from the skip list.
+ * @param sl The skip list
+ * @param iter The skip list node to remove
+ * @param myfree A function to be called for the removed element
+ */
+APR_DECLARE(int) apr_skiplist_remove_node(apr_skiplist *sl,
+ apr_skiplistnode *iter,
+ apr_skiplist_freefunc myfree);
+
+/**
* Remove an element from the skip list using the specified comparison function for
* locating the element. In the case of duplicates, the 1st entry will be removed.
* @param sl The skip list
@@ -248,6 +332,40 @@ APR_DECLARE(void *) apr_skiplist_pop(apr_skiplist *sl, apr_skiplist_freefunc myf
APR_DECLARE(void *) apr_skiplist_peek(apr_skiplist *sl);
/**
+ * Return the size of the list (number of elements), in O(1).
+ * @param sl The skip list
+ */
+APR_DECLARE(size_t) apr_skiplist_size(const apr_skiplist *sl);
+
+/**
+ * Return the height of the list (number of skip paths), in O(1).
+ * @param sl The skip list
+ */
+APR_DECLARE(int) apr_skiplist_height(const apr_skiplist *sl);
+
+/**
+ * Return the predefined maximum height of the skip list.
+ * @param sl The skip list
+ */
+APR_DECLARE(int) apr_skiplist_preheight(const apr_skiplist *sl);
+
+/**
+ * Set a predefined maximum height for the skip list.
+ * @param sl The skip list
+ * @param to The preheight to set, or a nul/negative value to disable.
+ * @remark When a preheight is used, the height of each inserted element is
+ * computed randomly up to this preheight instead of the current skip list's
+ * height plus one used by the default implementation. Using a preheight can
+ * probably ensure more fairness with long living elements (since with an
+ * adaptative height, former elements may have been created with a low height,
+ * hence a longest path to reach them while the skip list grows). On the other
+ * hand, the default behaviour (preheight <= 0) with a growing and decreasing
+ * maximum height is more adaptative/suitable for short living values.
+ * @note Should be called before any insertion/add.
+ */
+APR_DECLARE(void) apr_skiplist_set_preheight(apr_skiplist *sl, int to);
+
+/**
* Merge two skip lists. XXX SEMANTICS
* @param sl1 One of two skip lists to be merged
* @param sl2 The other of two skip lists to be merged
diff --git a/include/apr_strings.h b/include/apr_strings.h
index c0642adb2113e..d5f8719d2dc5e 100644
--- a/include/apr_strings.h
+++ b/include/apr_strings.h
@@ -101,10 +101,10 @@ APR_DECLARE(char *) apr_pstrdup(apr_pool_t *p, const char *s);
* @param s The block of characters to duplicate
* @param n The number of characters to duplicate
* @return The new string or NULL if s == NULL
- * @remark This is a faster alternative to apr_pstrndup, for use
+ * @remark This is a faster alternative to apr_pstrndup(), for use
* when you know that the string being duplicated really
* has 'n' or more characters. If the string might contain
- * fewer characters, use apr_pstrndup.
+ * fewer characters, use apr_pstrndup().
*/
APR_DECLARE(char *) apr_pstrmemdup(apr_pool_t *p, const char *s, apr_size_t n)
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
diff --git a/include/apr_tables.h b/include/apr_tables.h
index 194af02f2f090..27974c0e8ca7a 100644
--- a/include/apr_tables.h
+++ b/include/apr_tables.h
@@ -179,7 +179,7 @@ APR_DECLARE(void) apr_array_cat(apr_array_header_t *dst,
* @param p The pool to allocate the copy of the array out of
* @param arr The array to copy
* @return An exact copy of the array passed in
- * @remark The alternate apr_array_copy_hdr copies only the header, and arranges
+ * @remark The alternate apr_array_copy_hdr() copies only the header, and arranges
* for the elements to be copied if (and only if) the code subsequently
* does a push or arraycat.
*/
@@ -191,7 +191,7 @@ APR_DECLARE(apr_array_header_t *) apr_array_copy(apr_pool_t *p,
* @param p The pool to allocate the copy of the array out of
* @param arr The array to copy
* @return An exact copy of the array passed in
- * @remark The alternate apr_array_copy copies the *entire* array.
+ * @remark The alternate apr_array_copy() copies the *entire* array.
*/
APR_DECLARE(apr_array_header_t *) apr_array_copy_hdr(apr_pool_t *p,
const apr_array_header_t *arr);
@@ -318,7 +318,7 @@ APR_DECLARE(void) apr_table_unset(apr_table_t *t, const char *key);
* @param t The table to search for the data
* @param key The key to merge data for (case does not matter)
* @param val The data to add
- * @remark If the key is not found, then this function acts like apr_table_add
+ * @remark If the key is not found, then this function acts like apr_table_add()
*/
APR_DECLARE(void) apr_table_merge(apr_table_t *t, const char *key,
const char *val);
@@ -330,7 +330,7 @@ APR_DECLARE(void) apr_table_merge(apr_table_t *t, const char *key,
* @param t The table to search for the data
* @param key The key to merge data for (case does not matter)
* @param val The data to add
- * @remark If the key is not found, then this function acts like apr_table_addn
+ * @remark If the key is not found, then this function acts like apr_table_addn()
*/
APR_DECLARE(void) apr_table_mergen(apr_table_t *t, const char *key,
const char *val);
@@ -380,6 +380,7 @@ APR_DECLARE(apr_table_t *) apr_table_overlay(apr_pool_t *p,
* @remark Iteration continues while this callback function returns non-zero.
* To export the callback function for apr_table_[v]do() it must be declared
* in the _NONSTD convention.
+ * @see apr_table_do @see apr_table_vdo
*/
typedef int (apr_table_do_callback_fn_t)(void *rec, const char *key,
const char *value);
@@ -392,7 +393,7 @@ typedef int (apr_table_do_callback_fn_t)(void *rec, const char *key,
* in the table. Otherwise, the function is invoked only for those
* elements matching the keys specified.
*
- * If an invocation of the @param comp function returns zero,
+ * If an invocation of the comp function returns zero,
* iteration will continue using the next specified key, if any.
*
* @param comp The function to run
@@ -401,7 +402,7 @@ typedef int (apr_table_do_callback_fn_t)(void *rec, const char *key,
* @param ... A varargs array of zero or more (char *) keys followed by NULL
* @return FALSE if one of the comp() iterations returned zero; TRUE if all
* iterations returned non-zero
- * @see apr_table_do_callback_fn_t
+ * @see apr_table_do_callback_fn_t @see apr_table_vdo
*/
APR_DECLARE_NONSTD(int) apr_table_do(apr_table_do_callback_fn_t *comp,
void *rec, const apr_table_t *t, ...)
@@ -412,13 +413,13 @@ APR_DECLARE_NONSTD(int) apr_table_do(apr_table_do_callback_fn_t *comp,
/**
* Iterate over a table running the provided function once for every
- * element in the table. The @param vp varargs parameter must be a
+ * element in the table. The vp varargs parameter must be a
* list of zero or more (char *) keys followed by a NULL pointer. If
* zero keys are given, the @param comp function will be invoked for
* every element in the table. Otherwise, the function is invoked
* only for those elements matching the keys specified.
*
- * If an invocation of the @param comp function returns zero,
+ * If an invocation of the comp function returns zero,
* iteration will continue using the next specified key, if any.
*
* @param comp The function to run
@@ -427,7 +428,7 @@ APR_DECLARE_NONSTD(int) apr_table_do(apr_table_do_callback_fn_t *comp,
* @param vp List of zero or more (char *) keys followed by NULL
* @return FALSE if one of the comp() iterations returned zero; TRUE if all
* iterations returned non-zero
- * @see apr_table_do_callback_fn_t
+ * @see apr_table_do_callback_fn_t @see apr_table_do
*/
APR_DECLARE(int) apr_table_vdo(apr_table_do_callback_fn_t *comp,
void *rec, const apr_table_t *t, va_list vp);
@@ -436,6 +437,8 @@ APR_DECLARE(int) apr_table_vdo(apr_table_do_callback_fn_t *comp,
#define APR_OVERLAP_TABLES_SET (0)
/** flag for overlap to use apr_table_mergen */
#define APR_OVERLAP_TABLES_MERGE (1)
+/** flag for overlap to use apr_table_addn */
+#define APR_OVERLAP_TABLES_ADD (2)
/**
* For each element in table b, either use setn or mergen to add the data
* to table a. Which method is used is determined by the flags passed in.
@@ -444,6 +447,7 @@ APR_DECLARE(int) apr_table_vdo(apr_table_do_callback_fn_t *comp,
* @param flags How to add the table to table a. One of:
* APR_OVERLAP_TABLES_SET Use apr_table_setn
* APR_OVERLAP_TABLES_MERGE Use apr_table_mergen
+ * APR_OVERLAP_TABLES_ADD Use apr_table_addn
* @remark When merging duplicates, the two values are concatenated,
* separated by the string ", ".
* @remark This function is highly optimized, and uses less memory and CPU cycles
@@ -461,6 +465,9 @@ APR_DECLARE(int) apr_table_vdo(apr_table_do_callback_fn_t *comp,
* if (flags & APR_OVERLAP_TABLES_MERGE) {
* apr_table_mergen(a, belt[i].key, belt[i].val);
* }
+ * else if (flags & APR_OVERLAP_TABLES_ADD) {
+ * apr_table_addn(a, belt[i].key, belt[i].val);
+ * }
* else {
* apr_table_setn(a, belt[i].key, belt[i].val);
* }
@@ -484,7 +491,8 @@ APR_DECLARE(void) apr_table_overlap(apr_table_t *a, const apr_table_t *b,
*
* @param t Table.
* @param flags APR_OVERLAP_TABLES_MERGE to merge, or
- * APR_OVERLAP_TABLES_SET to overwrite
+ * APR_OVERLAP_TABLES_SET to overwrite, or
+ * APR_OVERLAP_TABLES_ADD to add
* @remark When merging duplicates, the two values are concatenated,
* separated by the string ", ".
*/
diff --git a/include/apr_thread_proc.h b/include/apr_thread_proc.h
index e721ede9e96a7..6b171e9ab6390 100644
--- a/include/apr_thread_proc.h
+++ b/include/apr_thread_proc.h
@@ -26,6 +26,7 @@
#include "apr_file_io.h"
#include "apr_pools.h"
#include "apr_errno.h"
+#include "apr_perms_set.h"
#if APR_HAVE_STRUCT_RLIMIT
#include <sys/time.h>
@@ -579,6 +580,18 @@ APR_DECLARE(apr_status_t) apr_procattr_group_set(apr_procattr_t *attr,
const char *groupname);
+/**
+ * Register permission set function
+ * @param attr The procattr we care about.
+ * @param perms_set_fn Permission set callback
+ * @param data Data to pass to permission callback function
+ * @param perms Permissions to set
+ */
+APR_DECLARE(apr_status_t) apr_procattr_perms_set_register(apr_procattr_t *attr,
+ apr_perms_setfn_t *perms_set_fn,
+ void *data,
+ apr_fileperms_t perms);
+
#if APR_HAS_FORK
/**
* This is currently the only non-portable call in APR. This executes
diff --git a/include/apr_version.h b/include/apr_version.h
index c7cbb8f60d5fe..3dfbe0e07fdc0 100644
--- a/include/apr_version.h
+++ b/include/apr_version.h
@@ -38,7 +38,7 @@
*/
-#define APR_COPYRIGHT "Copyright (c) 2000-2015 The Apache Software " \
+#define APR_COPYRIGHT "Copyright (c) 2000-2018 The Apache Software " \
"Foundation or its licensors, as applicable."
/* The numeric compile-time version constants. These constants are the
@@ -56,20 +56,20 @@
* Minor API changes that do not cause binary compatibility problems.
* Reset to 0 when upgrading APR_MAJOR_VERSION
*/
-#define APR_MINOR_VERSION 5
+#define APR_MINOR_VERSION 6
/** patch level
* The Patch Level never includes API changes, simply bug fixes.
* Reset to 0 when upgrading APR_MINOR_VERSION
*/
-#define APR_PATCH_VERSION 2
+#define APR_PATCH_VERSION 5
/**
* The symbol APR_IS_DEV_VERSION is only defined for internal,
* "development" copies of APR. It is undefined for released versions
* of APR.
*/
-/* #define APR_IS_DEV_VERSION */
+/* #undef APR_IS_DEV_VERSION */
/**
* Check at compile time if the APR version is at least a certain
diff --git a/include/arch/unix/apr_arch_networkio.h b/include/arch/unix/apr_arch_networkio.h
index 91018f7c6bd00..5f3189d966650 100644
--- a/include/arch/unix/apr_arch_networkio.h
+++ b/include/arch/unix/apr_arch_networkio.h
@@ -111,6 +111,9 @@ struct apr_socket_t {
#ifndef HAVE_POLL
int connected;
#endif
+#if APR_HAVE_SOCKADDR_UN
+ int bound;
+#endif
int local_port_unknown;
int local_interface_unknown;
int remote_addr_unknown;
diff --git a/include/arch/unix/apr_arch_poll_private.h b/include/arch/unix/apr_arch_poll_private.h
index 2dd7b1fd6fbee..ff81312313494 100644
--- a/include/arch/unix/apr_arch_poll_private.h
+++ b/include/arch/unix/apr_arch_poll_private.h
@@ -126,7 +126,7 @@ struct apr_pollset_t
apr_file_t *wakeup_pipe[2];
apr_pollfd_t wakeup_pfd;
apr_pollset_private_t *p;
- apr_pollset_provider_t *provider;
+ const apr_pollset_provider_t *provider;
};
typedef union {
@@ -149,10 +149,14 @@ struct apr_pollcb_t {
apr_pool_t *pool;
apr_uint32_t nelts;
apr_uint32_t nalloc;
+ apr_uint32_t flags;
+ /* Pipe descriptors used for wakeup */
+ apr_file_t *wakeup_pipe[2];
+ apr_pollfd_t wakeup_pfd;
int fd;
apr_pollcb_pset pollset;
apr_pollfd_t **copyset;
- apr_pollcb_provider_t *provider;
+ const apr_pollcb_provider_t *provider;
};
struct apr_pollset_provider_t {
@@ -169,10 +173,17 @@ struct apr_pollcb_provider_t {
apr_status_t (*add)(apr_pollcb_t *, apr_pollfd_t *);
apr_status_t (*remove)(apr_pollcb_t *, apr_pollfd_t *);
apr_status_t (*poll)(apr_pollcb_t *, apr_interval_time_t, apr_pollcb_cb_t, void *);
+ apr_status_t (*cleanup)(apr_pollcb_t *);
const char *name;
};
-/* Private functions */
-void apr_pollset_drain_wakeup_pipe(apr_pollset_t *pollset);
+/*
+ * Private functions used for the implementation of both apr_pollcb_* and
+ * apr_pollset_*
+ */
+apr_status_t apr_poll_create_wakeup_pipe(apr_pool_t *pool, apr_pollfd_t *pfd,
+ apr_file_t **wakeup_pipe);
+apr_status_t apr_poll_close_wakeup_pipe(apr_file_t **wakeup_pipe);
+void apr_poll_drain_wakeup_pipe(apr_file_t **wakeup_pipe);
#endif /* APR_ARCH_POLL_PRIVATE_H */
diff --git a/include/arch/unix/apr_arch_proc_mutex.h b/include/arch/unix/apr_arch_proc_mutex.h
index ec9796bc9d478..af49c17031f47 100644
--- a/include/arch/unix/apr_arch_proc_mutex.h
+++ b/include/arch/unix/apr_arch_proc_mutex.h
@@ -62,9 +62,6 @@
#if APR_HAVE_PTHREAD_H
#include <pthread.h>
#endif
-#if APR_HAVE_SEMAPHORE_H
-#include <semaphore.h>
-#endif
/* End System Headers */
struct apr_proc_mutex_unix_lock_methods_t {
@@ -75,6 +72,8 @@ struct apr_proc_mutex_unix_lock_methods_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 *);
+ apr_status_t (*perms_set)(apr_proc_mutex_t *, apr_fileperms_t, apr_uid_t, apr_gid_t);
+ apr_lockmech_e mech;
const char *name;
};
typedef struct apr_proc_mutex_unix_lock_methods_t apr_proc_mutex_unix_lock_methods_t;
@@ -93,17 +92,24 @@ union semun {
struct apr_proc_mutex_t {
apr_pool_t *pool;
const apr_proc_mutex_unix_lock_methods_t *meth;
- const apr_proc_mutex_unix_lock_methods_t *inter_meth;
int curr_locked;
char *fname;
-#if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE
- apr_file_t *interproc;
-#endif
-#if APR_HAS_POSIXSEM_SERIALIZE
- sem_t *psem_interproc;
+
+ apr_os_proc_mutex_t os; /* Native mutex holder. */
+
+#if APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE
+ apr_file_t *interproc; /* For apr_file_ calls on native fd. */
+ int interproc_closing; /* whether the native fd is opened/closed with
+ * 'interproc' or apr_os_file_put()ed (hence
+ * needing an an explicit close for consistency
+ * with other methods).
+ */
#endif
#if APR_HAS_PROC_PTHREAD_SERIALIZE
- pthread_mutex_t *pthread_interproc;
+ int pthread_refcounting; /* Whether the native mutex is refcounted or
+ * apr_os_proc_mutex_put()ed, which makes
+ * refcounting impossible/undesirable.
+ */
#endif
};
diff --git a/include/arch/unix/apr_arch_shm.h b/include/arch/unix/apr_arch_shm.h
index bbd373e363282..e9d25cadb404b 100644
--- a/include/arch/unix/apr_arch_shm.h
+++ b/include/arch/unix/apr_arch_shm.h
@@ -67,6 +67,7 @@ struct apr_shm_t {
const char *filename; /* NULL if anonymous */
#if APR_USE_SHMEM_SHMGET || APR_USE_SHMEM_SHMGET_ANON
int shmid; /* shmem ID returned from shmget() */
+ key_t shmkey; /* shmem key IPC_ANON or returned from ftok() */
#endif
};
diff --git a/include/arch/unix/apr_arch_threadproc.h b/include/arch/unix/apr_arch_threadproc.h
index a61830f6ee8ce..7a3b3c0925b5f 100644
--- a/include/arch/unix/apr_arch_threadproc.h
+++ b/include/arch/unix/apr_arch_threadproc.h
@@ -19,6 +19,7 @@
#include "apr_thread_proc.h"
#include "apr_file_io.h"
#include "apr_arch_file_io.h"
+#include "apr_perms_set.h"
/* System headers required for thread/process library */
#if APR_HAVE_PTHREAD_H
@@ -76,6 +77,14 @@ struct apr_thread_once_t {
#endif
+typedef struct apr_procattr_pscb_t apr_procattr_pscb_t;
+struct apr_procattr_pscb_t {
+ struct apr_procattr_pscb_t *next;
+ apr_perms_setfn_t *perms_set_fn;
+ apr_fileperms_t perms;
+ const void *data;
+};
+
struct apr_procattr_t {
apr_pool_t *pool;
apr_file_t *parent_in;
@@ -103,6 +112,7 @@ struct apr_procattr_t {
apr_int32_t errchk;
apr_uid_t uid;
apr_gid_t gid;
+ apr_procattr_pscb_t *perms_set_callbacks;
};
#endif /* ! THREAD_PROC_H */
diff --git a/include/arch/unix/apr_private.h.in b/include/arch/unix/apr_private.h.in
index 12af027472ece..c794b1962ec3e 100644
--- a/include/arch/unix/apr_private.h.in
+++ b/include/arch/unix/apr_private.h.in
@@ -8,6 +8,9 @@
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
+/* Define if apr_allocator should use guard pages */
+#undef APR_ALLOCATOR_GUARD_PAGES
+
/* Define if apr_allocator should use mmap */
#undef APR_ALLOCATOR_USES_MMAP
@@ -18,6 +21,9 @@
/* Define as function used for conversion of strings to apr_off_t */
#undef APR_OFF_T_STRFN
+/* Define if pool functions should abort if concurrent usage is detected */
+#undef APR_POOL_CONCURRENCY_CHECK
+
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
@@ -274,6 +280,9 @@
/* Define if MAP_ANON is defined in sys/mman.h */
#undef HAVE_MAP_ANON
+/* Define to 1 if you have the <memcheck.h> header file. */
+#undef HAVE_MEMCHECK_H
+
/* Define to 1 if you have the `memchr' function. */
#undef HAVE_MEMCHR
@@ -295,6 +304,9 @@
/* Define to 1 if you have the `mmap64' function. */
#undef HAVE_MMAP64
+/* Define to 1 if you have the `mprotect' function. */
+#undef HAVE_MPROTECT
+
/* Define to 1 if you have the `munmap' function. */
#undef HAVE_MUNMAP
@@ -316,6 +328,9 @@
/* Define to 1 if you have the <net/errno.h> header file. */
#undef HAVE_NET_ERRNO_H
+/* Define to 1 if you have the <net/if.h> header file. */
+#undef HAVE_NET_IF_H
+
/* Define to 1 if you have the `nl_langinfo' function. */
#undef HAVE_NL_LANGINFO
@@ -688,6 +703,12 @@
/* Define to 1 if you have the <uuid/uuid.h> header file. */
#undef HAVE_UUID_UUID_H
+/* Compile in valgrind support */
+#undef HAVE_VALGRIND
+
+/* Define to 1 if you have the <valgrind.h> header file. */
+#undef HAVE_VALGRIND_H
+
/* Define if C compiler supports VLA */
#undef HAVE_VLA
@@ -706,8 +727,7 @@
/* Define for z/OS pthread API nuances */
#undef HAVE_ZOS_PTHREADS
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR
/* Define if EAI_ error codes from getaddrinfo are negative */