diff options
29 files changed, 418 insertions, 234 deletions
diff --git a/configure.in b/configure.in index f1fa52235..6efc88560 100644 --- a/configure.in +++ b/configure.in @@ -682,8 +682,8 @@ AC_SUBST(LIBPREFIX) AC_SUBST(EXEEXT) echo "Construct Makefiles and header files." -MAKEFILE1="Makefile lib/Makefile " -SUBDIRS="lib " +MAKEFILE1="Makefile lib/Makefile strings/Makefile" +SUBDIRS="lib strings " for dir in $MODULES do test -d $dir || $MKDIR -p $dir diff --git a/file_io/unix/dir.c b/file_io/unix/dir.c index 8791620e9..f1599d1de 100644 --- a/file_io/unix/dir.c +++ b/file_io/unix/dir.c @@ -53,6 +53,7 @@ */ #include "fileio.h" +#include "apr_strings.h" #include "apr_portable.h" static ap_status_t dir_cleanup(void *thedir) diff --git a/file_io/unix/fileacc.c b/file_io/unix/fileacc.c index e64336421..2a5135e82 100644 --- a/file_io/unix/fileacc.c +++ b/file_io/unix/fileacc.c @@ -52,6 +52,7 @@ * <http://www.apache.org/>. */ +#include "apr_strings.h" #ifdef OS2 #include "../os2/fileio.h" #elif defined(WIN32) diff --git a/file_io/unix/filedup.c b/file_io/unix/filedup.c index 2a953da08..b1f4f5e4b 100644 --- a/file_io/unix/filedup.c +++ b/file_io/unix/filedup.c @@ -53,6 +53,7 @@ */ #include "fileio.h" +#include "apr_strings.h" #include "apr_portable.h" ap_status_t ap_dupfile(ap_file_t **new_file, ap_file_t *old_file, ap_pool_t *p) diff --git a/file_io/unix/open.c b/file_io/unix/open.c index 6becd812c..a7c88cada 100644 --- a/file_io/unix/open.c +++ b/file_io/unix/open.c @@ -53,6 +53,7 @@ */ #include "fileio.h" +#include "apr_strings.h" #include "apr_portable.h" ap_status_t ap_unix_file_cleanup(void *thefile) diff --git a/file_io/unix/pipe.c b/file_io/unix/pipe.c index 97bbf72ee..0c666d674 100644 --- a/file_io/unix/pipe.c +++ b/file_io/unix/pipe.c @@ -53,6 +53,7 @@ */ #include "fileio.h" +#include "apr_strings.h" static ap_status_t pipeblock(ap_file_t *thepipe) { diff --git a/i18n/unix/xlate.c b/i18n/unix/xlate.c index d7f2fa137..a357a90dc 100644 --- a/i18n/unix/xlate.c +++ b/i18n/unix/xlate.c @@ -55,6 +55,7 @@ #include "apr_private.h" #include "apr_lib.h" +#include "apr_strings.h" #include "apr_xlate.h" /* If no implementation is available, don't generate code here since 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 */ diff --git a/lib/Makefile.in b/lib/Makefile.in index 3e290ff26..c508ec636 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -16,17 +16,14 @@ INCLUDES=-I$(INCDIR) -I$(INCDIR1) -I../misc/unix #LIB=@LIBPREFIX@apr.a -OBJS=apr_cpystrn.o \ - apr_fnmatch.o \ +OBJS=apr_fnmatch.o \ apr_execve.o \ apr_md5.o \ apr_pools.o \ apr_signal.o \ - apr_snprintf.o \ apr_tables.o \ apr_hash.o \ - apr_getpass.o \ - apr_strnatcmp.o + apr_getpass.o .c.o: $(CC) $(CFLAGS) -c $(INCLUDES) $< diff --git a/lib/apr_getpass.c b/lib/apr_getpass.c index 13cac5f78..2c1797775 100644 --- a/lib/apr_getpass.c +++ b/lib/apr_getpass.c @@ -58,6 +58,7 @@ * use one we define ourselves. */ #include "apr_private.h" +#include "apr_strings.h" #include "apr_lib.h" #include "apr_errno.h" #include <sys/types.h> diff --git a/lib/apr_md5.c b/lib/apr_md5.c index d553551ed..68aebfb8b 100644 --- a/lib/apr_md5.c +++ b/lib/apr_md5.c @@ -98,6 +98,7 @@ #ifndef WIN32 #include "apr_private.h" #endif +#include "apr_strings.h" #include "apr_md5.h" #include "apr_lib.h" diff --git a/lib/apr_pools.c b/lib/apr_pools.c index a32899778..8b7321bf6 100644 --- a/lib/apr_pools.c +++ b/lib/apr_pools.c @@ -63,6 +63,7 @@ #include "apr_private.h" #include "apr_portable.h" /* for get_os_proc */ +#include "apr_strings.h" #include "apr_general.h" #include "apr_pools.h" #include "apr_lib.h" @@ -953,72 +954,6 @@ APR_EXPORT(void *) ap_pcalloc(ap_pool_t *a, ap_size_t size) return res; } -APR_EXPORT(char *) ap_pstrdup(ap_pool_t *a, const char *s) -{ - char *res; - size_t len; - - if (s == NULL) { - return NULL; - } - len = strlen(s) + 1; - res = ap_palloc(a, len); - memcpy(res, s, len); - return res; -} - -APR_EXPORT(char *) ap_pstrndup(ap_pool_t *a, const char *s, ap_size_t n) -{ - char *res; - - if (s == NULL) { - return NULL; - } - res = ap_palloc(a, n + 1); - memcpy(res, s, n); - res[n] = '\0'; - return res; -} - -APR_EXPORT_NONSTD(char *) ap_pstrcat(ap_pool_t *a, ...) -{ - char *cp, *argp, *res; - - /* Pass one --- find length of required string */ - - ap_size_t len = 0; - va_list adummy; - - va_start(adummy, a); - - while ((cp = va_arg(adummy, char *)) != NULL) { - len += strlen(cp); - } - - va_end(adummy); - - /* Allocate the required string */ - - res = (char *) ap_palloc(a, len + 1); - cp = res; - *cp = '\0'; - - /* Pass two --- copy the argument strings into the result space */ - - va_start(adummy, a); - - while ((argp = va_arg(adummy, char *)) != NULL) { - strcpy(cp, argp); - cp += strlen(argp); - } - - va_end(adummy); - - /* Return the result string */ - - return res; -} - /* * ap_psprintf is implemented by writing directly into the current * block of the pool, starting right at first_avail. If there's diff --git a/lib/apr_tables.c b/lib/apr_tables.c index cb4920438..8c417b2eb 100644 --- a/lib/apr_tables.c +++ b/lib/apr_tables.c @@ -64,6 +64,7 @@ #include "apr_general.h" #include "apr_pools.h" #include "apr_tables.h" +#include "apr_strings.h" #include "apr_lib.h" #include "misc.h" #ifdef HAVE_STDLIB_H diff --git a/locks/unix/crossproc.c b/locks/unix/crossproc.c index 96d28625a..ed01583b3 100644 --- a/locks/unix/crossproc.c +++ b/locks/unix/crossproc.c @@ -53,6 +53,7 @@ */ #include "apr.h" +#include "apr_strings.h" #include "locks.h" #if APR_USE_SYSVSEM_SERIALIZE diff --git a/locks/unix/locks.c b/locks/unix/locks.c index 823c9ca37..3e25cc67e 100644 --- a/locks/unix/locks.c +++ b/locks/unix/locks.c @@ -53,6 +53,7 @@ */ #include "locks.h" +#include "apr_strings.h" #include "apr_portable.h" ap_status_t ap_create_lock(ap_lock_t **lock, ap_locktype_e type, diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c index a32899778..8b7321bf6 100644 --- a/memory/unix/apr_pools.c +++ b/memory/unix/apr_pools.c @@ -63,6 +63,7 @@ #include "apr_private.h" #include "apr_portable.h" /* for get_os_proc */ +#include "apr_strings.h" #include "apr_general.h" #include "apr_pools.h" #include "apr_lib.h" @@ -953,72 +954,6 @@ APR_EXPORT(void *) ap_pcalloc(ap_pool_t *a, ap_size_t size) return res; } -APR_EXPORT(char *) ap_pstrdup(ap_pool_t *a, const char *s) -{ - char *res; - size_t len; - - if (s == NULL) { - return NULL; - } - len = strlen(s) + 1; - res = ap_palloc(a, len); - memcpy(res, s, len); - return res; -} - -APR_EXPORT(char *) ap_pstrndup(ap_pool_t *a, const char *s, ap_size_t n) -{ - char *res; - - if (s == NULL) { - return NULL; - } - res = ap_palloc(a, n + 1); - memcpy(res, s, n); - res[n] = '\0'; - return res; -} - -APR_EXPORT_NONSTD(char *) ap_pstrcat(ap_pool_t *a, ...) -{ - char *cp, *argp, *res; - - /* Pass one --- find length of required string */ - - ap_size_t len = 0; - va_list adummy; - - va_start(adummy, a); - - while ((cp = va_arg(adummy, char *)) != NULL) { - len += strlen(cp); - } - - va_end(adummy); - - /* Allocate the required string */ - - res = (char *) ap_palloc(a, len + 1); - cp = res; - *cp = '\0'; - - /* Pass two --- copy the argument strings into the result space */ - - va_start(adummy, a); - - while ((argp = va_arg(adummy, char *)) != NULL) { - strcpy(cp, argp); - cp += strlen(argp); - } - - va_end(adummy); - - /* Return the result string */ - - return res; -} - /* * ap_psprintf is implemented by writing directly into the current * block of the pool, starting right at first_avail. If there's diff --git a/misc/unix/errorcodes.c b/misc/unix/errorcodes.c index fe98e55a9..0aee7c071 100644 --- a/misc/unix/errorcodes.c +++ b/misc/unix/errorcodes.c @@ -53,6 +53,7 @@ */ #include "misc.h" +#include "apr_strings.h" #include "apr_lib.h" #include "apr_dso.h" diff --git a/misc/unix/start.c b/misc/unix/start.c index c84782f0d..4543f5970 100644 --- a/misc/unix/start.c +++ b/misc/unix/start.c @@ -54,6 +54,7 @@ #include "misc.h" #include "locks.h" +#include "apr_strings.h" ap_status_t ap_create_pool(ap_pool_t **newcont, ap_pool_t *cont) { diff --git a/network_io/unix/sockaddr.c b/network_io/unix/sockaddr.c index 1a912d7f6..4bfd0b50e 100644 --- a/network_io/unix/sockaddr.c +++ b/network_io/unix/sockaddr.c @@ -53,6 +53,7 @@ */ #include "networkio.h" +#include "apr_strings.h" ap_status_t ap_set_local_port(ap_socket_t *sock, ap_uint32_t port) { diff --git a/network_io/unix/sockopt.c b/network_io/unix/sockopt.c index c4ca2ebc5..d8044c9ac 100644 --- a/network_io/unix/sockopt.c +++ b/network_io/unix/sockopt.c @@ -53,6 +53,7 @@ */ #include "networkio.h" +#include "apr_strings.h" static ap_status_t soblock(int sd) { diff --git a/strings/.cvsignore b/strings/.cvsignore new file mode 100644 index 000000000..f3c7a7c5d --- /dev/null +++ b/strings/.cvsignore @@ -0,0 +1 @@ +Makefile diff --git a/strings/Makefile.in b/strings/Makefile.in new file mode 100644 index 000000000..ef370c61c --- /dev/null +++ b/strings/Makefile.in @@ -0,0 +1,105 @@ +#CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS) +#LIBS=$(EXTRA_LIBS) $(LIBS1) +#INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES) +#LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS) + +CC=@CC@ +RANLIB=@RANLIB@ +AR=@AR@ +RM=@RM@ +CFLAGS=@CFLAGS@ @OPTIM@ +LIBS=@LIBS@ +LDFLAGS=@LDFLAGS@ $(LIBS) +INCDIR=../include +INCDIR1=../misc/@OSDIR@ +INCLUDES=-I$(INCDIR) -I$(INCDIR1) -I../misc/unix + +#LIB=@LIBPREFIX@apr.a + +OBJS=apr_cpystrn.o \ + apr_snprintf.o \ + apr_strnatcmp.o \ + apr_strings.o + +.c.o: + $(CC) $(CFLAGS) -c $(INCLUDES) $< + +all: $(OBJS) + +clean: + $(RM) -f *.o *.a *.so + +distclean: clean + -$(RM) -f Makefile + + +#$(LIB): $(OBJS) +# $(RM) -f $@ +# $(AR) cr $@ $(OBJS) +# $(RANLIB) $@ + +# +# We really don't expect end users to use this rule. It works only with +# gcc, and rebuilds Makefile.in. You have to re-run configure after +# using it. +# +depend: + cp Makefile.in Makefile.in.bak \ + && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.in > Makefile.new \ + && gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \ + && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \ + -e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \ + > Makefile.in \ + && rm Makefile.new + +# DO NOT REMOVE +apr_cpystrn.o: apr_cpystrn.c $(INCDIR)/apr.h $(INCDIR)/apr_private.h \ + $(INCDIR)/apr_lib.h $(INCDIR)/apr_pools.h \ + $(INCDIR)/apr_thread_proc.h $(INCDIR)/apr_file_io.h \ + $(INCDIR)/apr_general.h $(INCDIR)/apr_errno.h $(INCDIR)/apr_time.h \ + $(INCDIR)/apr_tables.h +apr_execve.o: apr_execve.c $(INCDIR)/apr_private.h +apr_fnmatch.o: apr_fnmatch.c $(INCDIR)/apr_private.h \ + $(INCDIR)/apr_fnmatch.h $(INCDIR)/apr_errno.h $(INCDIR)/apr.h \ + $(INCDIR)/apr_lib.h $(INCDIR)/apr_pools.h \ + $(INCDIR)/apr_thread_proc.h $(INCDIR)/apr_file_io.h \ + $(INCDIR)/apr_general.h $(INCDIR)/apr_time.h \ + $(INCDIR)/apr_tables.h +apr_getpass.o: apr_getpass.c $(INCDIR)/apr_private.h \ + $(INCDIR)/apr_lib.h $(INCDIR)/apr.h $(INCDIR)/apr_pools.h \ + $(INCDIR)/apr_thread_proc.h $(INCDIR)/apr_file_io.h \ + $(INCDIR)/apr_general.h $(INCDIR)/apr_errno.h $(INCDIR)/apr_time.h \ + $(INCDIR)/apr_tables.h +apr_hash.o: apr_hash.c $(INCDIR)/apr_private.h \ + $(INCDIR)/apr_general.h $(INCDIR)/apr.h $(INCDIR)/apr_errno.h \ + $(INCDIR)/apr_pools.h $(INCDIR)/apr_thread_proc.h \ + $(INCDIR)/apr_file_io.h $(INCDIR)/apr_time.h $(INCDIR)/apr_hash.h +apr_md5.o: apr_md5.c $(INCDIR)/apr_private.h $(INCDIR)/apr_md5.h \ + $(INCDIR)/apr_lib.h $(INCDIR)/apr.h $(INCDIR)/apr_pools.h \ + $(INCDIR)/apr_thread_proc.h $(INCDIR)/apr_file_io.h \ + $(INCDIR)/apr_general.h $(INCDIR)/apr_errno.h $(INCDIR)/apr_time.h \ + $(INCDIR)/apr_tables.h $(INCDIR)/apr_xlate.h +apr_pools.o: apr_pools.c $(INCDIR)/apr.h $(INCDIR)/apr_private.h \ + $(INCDIR)/apr_portable.h $(INCDIR)/apr_general.h \ + $(INCDIR)/apr_errno.h $(INCDIR)/apr_thread_proc.h \ + $(INCDIR)/apr_file_io.h $(INCDIR)/apr_time.h \ + $(INCDIR)/apr_network_io.h $(INCDIR)/apr_lock.h \ + $(INCDIR)/apr_dso.h $(INCDIR)/apr_pools.h $(INCDIR)/apr_lib.h \ + $(INCDIR)/apr_tables.h ../misc/unix/misc.h $(INCDIR)/apr_getopt.h +apr_signal.o: apr_signal.c $(INCDIR)/apr_private.h \ + $(INCDIR)/apr_lib.h $(INCDIR)/apr.h $(INCDIR)/apr_pools.h \ + $(INCDIR)/apr_thread_proc.h $(INCDIR)/apr_file_io.h \ + $(INCDIR)/apr_general.h $(INCDIR)/apr_errno.h $(INCDIR)/apr_time.h \ + $(INCDIR)/apr_tables.h +apr_snprintf.o: apr_snprintf.c $(INCDIR)/apr.h \ + $(INCDIR)/apr_private.h $(INCDIR)/apr_lib.h $(INCDIR)/apr_pools.h \ + $(INCDIR)/apr_thread_proc.h $(INCDIR)/apr_file_io.h \ + $(INCDIR)/apr_general.h $(INCDIR)/apr_errno.h $(INCDIR)/apr_time.h \ + $(INCDIR)/apr_tables.h +apr_strnatcmp.o: apr_strnatcmp.c $(INCDIR)/apr_strnatcmp.h +apr_tables.o: apr_tables.c $(INCDIR)/apr_private.h \ + $(INCDIR)/apr_general.h $(INCDIR)/apr.h $(INCDIR)/apr_errno.h \ + $(INCDIR)/apr_pools.h $(INCDIR)/apr_thread_proc.h \ + $(INCDIR)/apr_file_io.h $(INCDIR)/apr_time.h \ + $(INCDIR)/apr_tables.h $(INCDIR)/apr_lib.h ../misc/unix/misc.h \ + $(INCDIR)/apr_getopt.h diff --git a/lib/apr_cpystrn.c b/strings/apr_cpystrn.c index 37fd2bad5..0f6a503b2 100644 --- a/lib/apr_cpystrn.c +++ b/strings/apr_cpystrn.c @@ -53,6 +53,7 @@ */ #include "apr.h" +#include "apr_strings.h" #include "apr_private.h" #include "apr_lib.h" diff --git a/lib/apr_snprintf.c b/strings/apr_snprintf.c index 2fa0461ff..2fa0461ff 100644 --- a/lib/apr_snprintf.c +++ b/strings/apr_snprintf.c diff --git a/strings/apr_strings.c b/strings/apr_strings.c new file mode 100644 index 000000000..2d53695f8 --- /dev/null +++ b/strings/apr_strings.c @@ -0,0 +1,125 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + +#include "apr.h" +#include "apr_strings.h" +#include "apr_private.h" +#include "apr_lib.h" + +APR_EXPORT(char *) ap_pstrdup(ap_pool_t *a, const char *s) +{ + char *res; + size_t len; + + if (s == NULL) { + return NULL; + } + len = strlen(s) + 1; + res = ap_palloc(a, len); + memcpy(res, s, len); + return res; +} + +APR_EXPORT(char *) ap_pstrndup(ap_pool_t *a, const char *s, ap_size_t n) +{ + char *res; + + if (s == NULL) { + return NULL; + } + res = ap_palloc(a, n + 1); + memcpy(res, s, n); + res[n] = '\0'; + return res; +} + +APR_EXPORT_NONSTD(char *) ap_pstrcat(ap_pool_t *a, ...) +{ + char *cp, *argp, *res; + + /* Pass one --- find length of required string */ + + ap_size_t len = 0; + va_list adummy; + + va_start(adummy, a); + + while ((cp = va_arg(adummy, char *)) != NULL) { + len += strlen(cp); + } + + va_end(adummy); + + /* Allocate the required string */ + + res = (char *) ap_palloc(a, len + 1); + cp = res; + *cp = '\0'; + + /* Pass two --- copy the argument strings into the result space */ + + va_start(adummy, a); + + while ((argp = va_arg(adummy, char *)) != NULL) { + strcpy(cp, argp); + cp += strlen(argp); + } + + va_end(adummy); + + /* Return the result string */ + + return res; +} + diff --git a/lib/apr_strnatcmp.c b/strings/apr_strnatcmp.c index ea29fd177..ea29fd177 100644 --- a/lib/apr_strnatcmp.c +++ b/strings/apr_strnatcmp.c diff --git a/threadproc/unix/proc.c b/threadproc/unix/proc.c index 787501a1a..ca8be5050 100644 --- a/threadproc/unix/proc.c +++ b/threadproc/unix/proc.c @@ -53,6 +53,7 @@ */ #include "threadproc.h" +#include "apr_strings.h" #include "apr_portable.h" ap_status_t ap_createprocattr_init(ap_procattr_t **new, ap_pool_t *cont) |