aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/apr_lib.h22
-rw-r--r--include/apr_pools.h73
-rw-r--r--include/apr_strings.h164
3 files changed, 164 insertions, 95 deletions
diff --git a/include/apr_lib.h b/include/apr_lib.h
index 9aad9405f..e52c81e5c 100644
--- a/include/apr_lib.h
+++ b/include/apr_lib.h
@@ -368,28 +368,6 @@ B<Register a process to be killed when a pool dies.>
APR_EXPORT(void) ap_note_subprocess(struct ap_pool_t *a, ap_proc_t *pid,
enum kill_conditions how);
-/*
-
-=head1 char *ap_cpystrn(char *dst, const char *src, size_t dst_size)
-
-B<copy n characters from src to dest>
-
- arg 1) The destination string
- arg 2) The source string
- arg 3) The number of characters to copy
-
-B<NOTE>: We re-implement this function to implement these specific changes:
- 1) strncpy() doesn't always null terminate and we want it to.
- 2) strncpy() null fills, which is bogus, esp. when copy 8byte strings
- into 8k blocks.
- 3) Instead of returning the pointer to the beginning of the
- destination string, we return a pointer to the terminating '\0'
- to allow us to check for truncation.
-
-=cut
- */
-APR_EXPORT(char *) ap_cpystrn(char *dst, const char *src, size_t dst_size);
-
#ifdef __cplusplus
}
#endif
diff --git a/include/apr_pools.h b/include/apr_pools.h
index 2d0a937cb..1c00114aa 100644
--- a/include/apr_pools.h
+++ b/include/apr_pools.h
@@ -266,79 +266,6 @@ APR_EXPORT(void *) ap_pcalloc(ap_pool_t *p, ap_size_t size);
/*
-=head1 char *ap_pstrdup(ap_pool_t *c, const char *s)
-
-B<duplicate a string into memory allocated out of a pool>
-
- arg 1) The pool to allocate out of
- arg 2) The string to allocate
- return) The new string
-
-=cut
- */
-APR_EXPORT(char *) ap_pstrdup(ap_pool_t *p, const char *s);
-
-/*
-
-=head1 char *ap_pstrndup(ap_pool_t *c, const char *s, ap_size_t n)
-
-B<duplicate the first n characters ofa string into memory allocated out of a pool>
-
- arg 1) The pool to allocate out of
- arg 2) The string to allocate
- arg 3) The number of characters to duplicate
- return) The new string
-
-=cut
- */
-APR_EXPORT(char *) ap_pstrndup(ap_pool_t *p, const char *s, ap_size_t n);
-
-/*
-
-=head1 char *ap_pstrcat(ap_pool_t *c, ...)
-
-B<Concatenate multiple strings, allocating memory out a pool>
-
- arg 1) The pool to allocate out of
- ...) The strings to concatenate. The final string must be NULL
- return) The new string
-
-=cut
- */
-APR_EXPORT_NONSTD(char *) ap_pstrcat(ap_pool_t *p, ...);
-
-/*
-
-=head1 char *ap_pvsprintf(ap_pool_t *c, const char *fmt, va_list ap)
-
-B<printf-style style printing routine. The data is output to a string allocated from a pool>
-
- arg 1) The pool to allocate out of
- arg 2) The format of the string
- arg 3) The arguments to use while printing the data
- return) The new string
-
-=cut
- */
-APR_EXPORT(char *) ap_pvsprintf(ap_pool_t *p, const char *fmt, va_list ap);
-
-/*
-
-=head1 char *ap_psprintf(ap_pool_t *c, const char *fmt, ...)
-
-B<printf-style style printing routine. The data is output to a string allocated from a pool>
-
- arg 1) The pool to allocate out of
- arg 2) The format of the string
- ...) The arguments to use while printing the data
- return) The new string
-
-=cut
- */
-APR_EXPORT_NONSTD(char *) ap_psprintf(ap_pool_t *p, const char *fmt, ...);
-
-/*
-
=head1 void ap_register_cleanup(ap_pool_t *p, const void *data,
ap_status_t (*plain_cleanup)(void *),
ap_status_t (*child_cleanup)(void *))
diff --git a/include/apr_strings.h b/include/apr_strings.h
new file mode 100644
index 000000000..b241e5a8d
--- /dev/null
+++ b/include/apr_strings.h
@@ -0,0 +1,164 @@
+/* -*- mode: c; c-file-style: "k&r" -*-
+
+ strnatcmp.c -- Perform 'natural order' comparisons of strings in C.
+ Copyright (C) 2000 by Martin Pool <mbp@humbug.org.au>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "apr.h"
+#include "apr_lib.h"
+
+#ifndef APR_STRINGS_H
+#define APR_STRINGS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+
+=head1 int ap_strnatcmp(char const *a, char const *b)
+
+B<Do a natural order comparison of two strings.>
+
+ arg 1) The first string to compare
+ arg 2) The second string to compare
+ return) Either <0, 0, or >0. If the first string is less than the second
+ this returns <0, if they are equivalent it returns 0, and if the
+ first string is greater than second string it retuns >0.
+
+=cut
+ */
+int ap_strnatcmp(char const *a, char const *b);
+
+/*
+
+=head1 int ap_strnatcmp(char const *a, char const *b)
+
+B<Do a natural order comparison of two strings ignoring the case of the strings.>
+
+ arg 1) The first string to compare
+ arg 2) The second string to compare
+ return) Either <0, 0, or >0. If the first string is less than the second
+ this returns <0, if they are equivalent it returns 0, and if the
+ first string is greater than second string it retuns >0.
+
+=cut
+ */
+int ap_strnatcasecmp(char const *a, char const *b);
+
+/*
+
+=head1 char *ap_pstrdup(ap_pool_t *c, const char *s)
+
+B<duplicate a string into memory allocated out of a pool>
+
+ arg 1) The pool to allocate out of
+ arg 2) The string to allocate
+ return) The new string
+
+=cut
+ */
+APR_EXPORT(char *) ap_pstrdup(ap_pool_t *p, const char *s);
+
+/*
+
+=head1 char *ap_pstrndup(ap_pool_t *c, const char *s, ap_size_t n)
+
+B<duplicate the first n characters ofa string into memory allocated out of a poo
+l>
+
+ arg 1) The pool to allocate out of
+ arg 2) The string to allocate
+ arg 3) The number of characters to duplicate
+ return) The new string
+
+=cut
+ */
+APR_EXPORT(char *) ap_pstrndup(ap_pool_t *p, const char *s, ap_size_t n);
+
+/*
+=head1 char *ap_pstrcat(ap_pool_t *c, ...)
+
+B<Concatenate multiple strings, allocating memory out a pool>
+
+ arg 1) The pool to allocate out of
+ ...) The strings to concatenate. The final string must be NULL
+ return) The new string
+
+=cut
+ */
+APR_EXPORT_NONSTD(char *) ap_pstrcat(ap_pool_t *p, ...);
+
+/*
+
+=head1 char *ap_pvsprintf(ap_pool_t *c, const char *fmt, va_list ap)
+B<printf-style style printing routine. The data is output to a string allocated
+ from a pool>
+
+ arg 1) The pool to allocate out of
+ arg 2) The format of the string
+ arg 3) The arguments to use while printing the data
+ return) The new string
+
+=cut
+ */
+APR_EXPORT(char *) ap_pvsprintf(ap_pool_t *p, const char *fmt, va_list ap);
+
+/*
+
+=head1 char *ap_psprintf(ap_pool_t *c, const char *fmt, ...)
+
+B<printf-style style printing routine. The data is output to a string allocated from a pool>
+
+ arg 1) The pool to allocate out of
+ arg 2) The format of the string
+ ...) The arguments to use while printing the data
+ return) The new string
+
+=cut
+ */
+APR_EXPORT_NONSTD(char *) ap_psprintf(ap_pool_t *p, const char *fmt, ...);
+
+/*
+
+=head1 char *ap_cpystrn(char *dst, const char *src, size_t dst_size)
+
+B<copy n characters from src to dest>
+
+ arg 1) The destination string
+ arg 2) The source string
+ arg 3) The number of characters to copy
+
+B<NOTE>: We re-implement this function to implement these specific changes:
+ 1) strncpy() doesn't always null terminate and we want it to.
+ 2) strncpy() null fills, which is bogus, esp. when copy 8byte strings
+ into 8k blocks.
+ 3) Instead of returning the pointer to the beginning of the
+ destination string, we return a pointer to the terminating '\0'
+ to allow us to check for truncation.
+
+=cut
+ */
+APR_EXPORT(char *) ap_cpystrn(char *dst, const char *src, size_t dst_size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !APR_STRINGS_H */