apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: apr libapr.dsp apr.dsp NWGNUmakefile CHANGES
Date Wed, 12 Feb 2003 20:20:57 GMT
brane       2003/02/12 12:20:56

  Modified:    test     testall.dsp testall.c test_apr.h aprtest.dsp
                        Makefile.win Makefile.in
               include  apr_pools.h apr_file_info.h
               file_io/win32 filepath.c
               file_io/unix filepath.c Makefile.in
               .        libapr.dsp apr.dsp NWGNUmakefile CHANGES
  Added:       test     testpath.c
               file_io/unix filepath_util.c
  Log:
  Added two new functions, apr_filepath_list_split and apr_filepath_list_merge,
  for managing search paths. The common implementation is in a new file,
  file_io/unix/filepath_util.c.
  
  Also added tests for these functions a new file in the test suite, testpath.c.
  
  Revision  Changes    Path
  1.3       +4 -0      apr/test/testall.dsp
  
  Index: testall.dsp
  ===================================================================
  RCS file: /home/cvs/apr/test/testall.dsp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- testall.dsp	10 Jan 2003 15:10:49 -0000	1.2
  +++ testall.dsp	12 Feb 2003 20:20:55 -0000	1.3
  @@ -167,6 +167,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=.\testpath.c
  +# End Source File
  +# Begin Source File
  +
   SOURCE=.\testpipe.c
   # End Source File
   # Begin Source File
  
  
  
  1.40      +1 -0      apr/test/testall.c
  
  Index: testall.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testall.c,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- testall.c	1 Jan 2003 00:01:56 -0000	1.39
  +++ testall.c	12 Feb 2003 20:20:55 -0000	1.40
  @@ -106,6 +106,7 @@
       {"testargs", testgetopt},
       {"testnames", testnames},
       {"testuser", testuser},
  +    {"testpath", testpath},
       {"LastTest", NULL}
   };
   
  
  
  
  1.40      +1 -0      apr/test/test_apr.h
  
  Index: test_apr.h
  ===================================================================
  RCS file: /home/cvs/apr/test/test_apr.h,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- test_apr.h	1 Jan 2003 00:01:56 -0000	1.39
  +++ test_apr.h	12 Feb 2003 20:20:55 -0000	1.40
  @@ -94,6 +94,7 @@
   CuSuite *testgetopt(void);
   CuSuite *testnames(void);
   CuSuite *testuser(void);
  +CuSuite *testpath(void);
   
   /* Assert that RV is an APR_SUCCESS value; else fail giving strerror
    * for RV and CONTEXT message. */
  
  
  
  1.15      +4 -0      apr/test/aprtest.dsp
  
  Index: aprtest.dsp
  ===================================================================
  RCS file: /home/cvs/apr/test/aprtest.dsp,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- aprtest.dsp	21 May 2002 13:58:54 -0000	1.14
  +++ aprtest.dsp	12 Feb 2003 20:20:55 -0000	1.15
  @@ -140,6 +140,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=.\testpath.c
  +# End Source File
  +# Begin Source File
  +
   SOURCE=.\testpipe.c
   # End Source File
   # Begin Source File
  
  
  
  1.7       +2 -2      apr/test/Makefile.win
  
  Index: Makefile.win
  ===================================================================
  RCS file: /home/cvs/apr/test/Makefile.win,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Makefile.win	3 Jan 2003 19:14:54 -0000	1.6
  +++ Makefile.win	12 Feb 2003 20:20:55 -0000	1.7
  @@ -99,11 +99,11 @@
   	testfmt.obj testfile.obj testdir.obj testfileinfo.obj testrand.obj \
   	testdso.obj testoc.obj testdup.obj testsockets.obj testproc.obj \
   	testpoll.obj testlock.obj testsockopt.obj testpipe.obj testthread.obj \
  -	testhash.obj testargs.obj testnames.obj testuser.obj
  +	testhash.obj testargs.obj testnames.obj testuser.obj testpath.obj
   
   testall.exe: $(TESTS) CuTest.obj $(LOCAL_LIBS)
   	$(LINK) /debug /subsystem:console /machine:I386 $(TESTS) CuTest.obj \
   		$(LOCAL_LIBS) $(ALL_LIBS)
  -	
  +
   
   # DO NOT REMOVE
  
  
  
  1.133     +1 -1      apr/test/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/test/Makefile.in,v
  retrieving revision 1.132
  retrieving revision 1.133
  diff -u -r1.132 -r1.133
  --- Makefile.in	29 Dec 2002 19:19:28 -0000	1.132
  +++ Makefile.in	12 Feb 2003 20:20:55 -0000	1.133
  @@ -102,7 +102,7 @@
   	testfmt.lo testfile.lo testdir.lo testfileinfo.lo testrand.lo \
   	testdso.lo testoc.lo testdup.lo testsockets.lo testproc.lo \
   	testpoll.lo testlock.lo testsockopt.lo testpipe.lo testthread.lo \
  -	testhash.lo testargs.lo testnames.lo testuser.lo
  +	testhash.lo testargs.lo testnames.lo testuser.lo testpath.lo
   
   testall: $(TESTS) mod_test.la libmod_test.la occhild@EXEEXT@ \
   	 CuTest.lo proc_child@EXEEXT@ $(LOCAL_LIBS)
  
  
  
  1.1                  apr/test/testpath.c
  
  Index: testpath.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 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 "test_apr.h"
  #include "apr_file_info.h"
  #include "apr_errno.h"
  #include "apr_pools.h"
  #include "apr_tables.h"
  
  #if defined(WIN32) || defined(NETWARE) || defined(OS2)
  #define PSEP ";"
  #define DSEP "\\"
  #else
  #define PSEP ":"
  #define DSEP "/"
  #endif
  
  #define PX ""
  #define P1 "first path"
  #define P2 "second" DSEP "path"
  #define P3 "th ird" DSEP "path"
  #define P4 "fourth" DSEP "pa th"
  #define P5 "fifthpath"
  
  static const char *parts_in[] = { P1, P2, P3, PX, P4, P5 };
  static const char *path_in = P1 PSEP P2 PSEP P3 PSEP PX PSEP P4 PSEP P5;
  static const int  parts_in_count = sizeof(parts_in)/sizeof(*parts_in);
  
  static const char *parts_out[] = { P1, P2, P3, P4, P5 };
  static const char *path_out = P1 PSEP P2 PSEP P3 PSEP P4 PSEP P5;
  static const int  parts_out_count = sizeof(parts_out)/sizeof(*parts_out);
  
  static void list_split_multi(CuTest *tc)
  {
      int i;
      apr_status_t rv;
      apr_array_header_t *pathelts;
  
      pathelts = NULL;
      rv = apr_filepath_list_split(&pathelts, path_in, p);
      CuAssertPtrNotNull(tc, pathelts);
      CuAssertIntEquals(tc, APR_SUCCESS, rv);
      CuAssertIntEquals(tc, parts_out_count, pathelts->nelts);
      for (i = 0; i < pathelts->nelts; ++i)
          CuAssertStrEquals(tc, parts_out[i], ((char**)pathelts->elts)[i]);
  }
  
  static void list_split_single(CuTest *tc)
  {
      int i;
      apr_status_t rv;
      apr_array_header_t *pathelts;
  
      for (i = 0; i < parts_in_count; ++i)
      {
          pathelts = NULL;
          rv = apr_filepath_list_split(&pathelts, parts_in[i], p);
          CuAssertPtrNotNull(tc, pathelts);
          CuAssertIntEquals(tc, APR_SUCCESS, rv);
          if (parts_in[i][0] == '\0')
              CuAssertIntEquals(tc, 0, pathelts->nelts);
          else
          {
              CuAssertIntEquals(tc, 1, pathelts->nelts);
              CuAssertStrEquals(tc, parts_in[i], *(char**)pathelts->elts);
          }
      }
  }
  
  static void list_merge_multi(CuTest *tc)
  {
      int i;
      char *liststr;
      apr_status_t rv;
      apr_array_header_t *pathelts;
  
      pathelts = apr_array_make(p, parts_in_count, sizeof(const char*));
      for (i = 0; i < parts_in_count; ++i)
          *(const char**)apr_array_push(pathelts) = parts_in[i];
  
      liststr = NULL;
      rv = apr_filepath_list_merge(&liststr, pathelts, p);
      CuAssertPtrNotNull(tc, liststr);
      CuAssertIntEquals(tc, APR_SUCCESS, rv);
      CuAssertStrEquals(tc, liststr, path_out);
  }
  
  static void list_merge_single(CuTest *tc)
  {
      int i;
      char *liststr;
      apr_status_t rv;
      apr_array_header_t *pathelts;
  
      pathelts = apr_array_make(p, 1, sizeof(const char*));
      apr_array_push(pathelts);
      for (i = 0; i < parts_in_count; ++i)
      {
          *(const char**)pathelts->elts = parts_in[i];
          liststr = NULL;
          rv = apr_filepath_list_merge(&liststr, pathelts, p);
          if (parts_in[i][0] == '\0')
              CuAssertPtrEquals(tc, NULL, liststr);
          else
          {
              CuAssertPtrNotNull(tc, liststr);
              CuAssertIntEquals(tc, APR_SUCCESS, rv);
              CuAssertStrEquals(tc, liststr, parts_in[i]);
          }
      }
  }
  
  
  CuSuite *testpath(void)
  {
      CuSuite *suite = CuSuiteNew("Path lists");
  
      SUITE_ADD_TEST(suite, list_split_multi);
      SUITE_ADD_TEST(suite, list_split_single);
      SUITE_ADD_TEST(suite, list_merge_multi);
      SUITE_ADD_TEST(suite, list_merge_single);
  
      return suite;
  }
  
  
  
  
  1.100     +3 -0      apr/include/apr_pools.h
  
  Index: apr_pools.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_pools.h,v
  retrieving revision 1.99
  retrieving revision 1.100
  diff -u -r1.99 -r1.100
  --- apr_pools.h	1 Jan 2003 00:01:45 -0000	1.99
  +++ apr_pools.h	12 Feb 2003 20:20:55 -0000	1.100
  @@ -157,6 +157,9 @@
    * If level 0 was specified, debugging is switched off
    * </pre>
    */
  +
  +#define APR_POOL_DEBUG 1        /* FIXME: Don't commit this! */
  +
   #if defined(APR_POOL_DEBUG)
   #if (APR_POOL_DEBUG != 0) && (APR_POOL_DEBUG - 0 == 0)
   #undef APR_POOL_DEBUG
  
  
  
  1.39      +31 -0     apr/include/apr_file_info.h
  
  Index: apr_file_info.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_file_info.h,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- apr_file_info.h	3 Jan 2003 09:05:28 -0000	1.38
  +++ apr_file_info.h	12 Feb 2003 20:20:55 -0000	1.39
  @@ -58,6 +58,7 @@
   #include "apr.h"
   #include "apr_user.h"
   #include "apr_pools.h"
  +#include "apr_tables.h"
   #include "apr_time.h"
   #include "apr_errno.h"
   
  @@ -384,6 +385,36 @@
                                                const char *addpath, 
                                                apr_int32_t flags,
                                                apr_pool_t *p);
  +
  +/**
  + * Split a search path into separate components
  + * @ingroup apr_filepath
  + * @param pathelts the returned components of the search path
  + * @param liststr the search path (e.g., <tt>getenv("PATH")</tt>)
  + * @param p the pool to allocate the array and path components from
  + * @deffunc apr_status_t apr_filepath_list_split(apr_array_header_t **pathelts, const char
*liststr, apr_pool_t *p)
  + * @remark empty path componenta do not become part of @a pathelts.
  + * @remark the path separator in @a liststr is system specific;
  + * e.g., ':' on Unix, ';' on Windows, etc.
  + */
  +APR_DECLARE(apr_status_t) apr_filepath_list_split(apr_array_header_t **pathelts,
  +                                                  const char *liststr,
  +                                                  apr_pool_t *p);
  +
  +/**
  + * Merge a list of search path components into a single search path
  + * @ingroup apr_filepath
  + * @param liststr the returned search path; may be NULL if @a pathelts is empty
  + * @param pathelts the components of the search path
  + * @param p the pool to allocate the search path from
  + * @deffunc apr_status_t apr_filepath_list_merge(char **liststr, apr_array_header_t *pathelts,
apr_pool_t *p)
  + * @remark emtpy strings in the source array are ignored.
  + * @remark the path separator in @a liststr is system specific;
  + * e.g., ':' on Unix, ';' on Windows, etc.
  + */
  +APR_DECLARE(apr_status_t) apr_filepath_list_merge(char **liststr,
  +                                                  apr_array_header_t *pathelts,
  +                                                  apr_pool_t *p);
   
   /**
    * Return the default file path (for relative file names)
  
  
  
  1.39      +24 -0     apr/file_io/win32/filepath.c
  
  Index: filepath.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/filepath.c,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- filepath.c	28 Jan 2003 00:59:43 -0000	1.38
  +++ filepath.c	12 Feb 2003 20:20:55 -0000	1.39
  @@ -54,6 +54,7 @@
   
   #include "apr.h"
   #include "apr_arch_file_io.h"
  +#include "apr_arch_utf8.h"
   #include "apr_strings.h"
   #include "apr_lib.h"
   #include <string.h>
  @@ -974,6 +975,29 @@
       *newpath = apr_pmemdup(p, path, pathlen + 1);
       (*newpath)[pathlen] = '\0';
       return APR_SUCCESS;
  +}
  +
  +
  +apr_status_t apr_filepath_list_split_impl(apr_array_header_t **pathelts,
  +                                          const char *liststr,
  +                                          char separator,
  +                                          apr_pool_t *p);
  +apr_status_t apr_filepath_list_merge_impl(char **liststr,
  +                                          apr_array_header_t *pathelts,
  +                                          char separator,
  +                                          apr_pool_t *p);
  +
  +APR_DECLARE(apr_status_t) apr_filepath_list_split(apr_array_header_t **pathelts,
  +                                                  const char *liststr,
  +                                                  apr_pool_t *p)
  +{
  +    return apr_filepath_list_split_impl(pathelts, liststr, ';', p);
  +}
  +APR_DECLARE(apr_status_t) apr_filepath_list_merge(char **liststr,
  +                                                  apr_array_header_t *pathelts,
  +                                                  apr_pool_t *p)
  +{
  +    return apr_filepath_list_merge_impl(liststr, pathelts, ';', p);
   }
   
   
  
  
  
  1.21      +23 -0     apr/file_io/unix/filepath.c
  
  Index: filepath.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/unix/filepath.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- filepath.c	7 Jan 2003 00:52:53 -0000	1.20
  +++ filepath.c	12 Feb 2003 20:20:56 -0000	1.21
  @@ -326,6 +326,29 @@
   }
   
   
  +apr_status_t apr_filepath_list_split_impl(apr_array_header_t **pathelts,
  +                                          const char *liststr,
  +                                          char separator,
  +                                          apr_pool_t *p);
  +apr_status_t apr_filepath_list_merge_impl(char **liststr,
  +                                          apr_array_header_t *pathelts,
  +                                          char separator,
  +                                          apr_pool_t *p);
  +
  +APR_DECLARE(apr_status_t) apr_filepath_list_split(apr_array_header_t **pathelts,
  +                                                  const char *liststr,
  +                                                  apr_pool_t *p)
  +{
  +    return apr_filepath_list_split_impl(pathelts, liststr, ':', p);
  +}
  +APR_DECLARE(apr_status_t) apr_filepath_list_merge(char **liststr,
  +                                                  apr_array_header_t *pathelts,
  +                                                  apr_pool_t *p)
  +{
  +    return apr_filepath_list_merge_impl(liststr, pathelts, ':', p);
  +}
  +
  +
   APR_DECLARE(apr_status_t) apr_filepath_encoding(int *style, apr_pool_t *p)
   {
       *style = APR_FILEPATH_ENCODING_LOCALE;
  
  
  
  1.26      +1 -0      apr/file_io/unix/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr/file_io/unix/Makefile.in,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Makefile.in	22 Apr 2002 01:24:49 -0000	1.25
  +++ Makefile.in	12 Feb 2003 20:20:56 -0000	1.26
  @@ -7,6 +7,7 @@
   	fileacc.lo \
   	filedup.lo \
   	filepath.lo \
  +	filepath_util.lo \
   	filestat.lo \
   	flock.lo \
   	fullrw.lo \
  
  
  
  1.1                  apr/file_io/unix/filepath_util.c
  
  Index: filepath_util.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 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/>.
   */
  
  
  #define APR_WANT_STRFUNC
  #define APR_WANT_MEMFUNC
  #include "apr_want.h"
  
  #include "apr_errno.h"
  #include "apr_pools.h"
  #include "apr_strings.h"
  #include "apr_tables.h"
  
  
  apr_status_t apr_filepath_list_split_impl(apr_array_header_t **pathelts,
                                            const char *liststr,
                                            char separator,
                                            apr_pool_t *p)
  {
      char *path, *part, *ptr;
      char separator_string[2] = { separator, '\0' };
      apr_array_header_t *elts;
      int nelts;
  
      /* Count the number of path elements. We know there'll be at least
         one even if path is an empty string. */
      path = apr_pstrdup(p, liststr);
      for (nelts = 0, ptr = path; ptr != NULL; ++nelts)
      {
          ptr = strchr(ptr, separator);
          if (ptr)
              ++ptr;
      }
  
      /* Split the path into the array. */
      elts = apr_array_make(p, nelts, sizeof(char*));
      while ((part = apr_strtok(path, separator_string, &ptr)) != NULL)
      {
          if (*part == '\0')      /* Ignore empty path components. */
              continue;
  
          *(char**)apr_array_push(elts) = part;
          path = NULL;            /* For the next call to apr_strtok */
      }
  
      *pathelts = elts;
      return APR_SUCCESS;
  }
  
  
  apr_status_t apr_filepath_list_merge_impl(char **liststr,
                                            apr_array_header_t *pathelts,
                                            char separator,
                                            apr_pool_t *p)
  {
      apr_size_t path_size = 0;
      char *path;
      int i;
  
      /* This test isn't 100% certain, but it'll catch at least some
         invalid uses... */
      if (pathelts->elt_size != sizeof(char*))
          return APR_EINVAL;
  
      /* Calculate the size of the merged path */
      for (i = 0; i < pathelts->nelts; ++i)
          path_size += strlen(((char**)pathelts->elts)[i]);
  
      if (path_size == 0)
      {
          *liststr = NULL;
          return APR_SUCCESS;
      }
  
      if (i > 0)                  /* Add space for the separators */
          path_size += (i - 1);
  
      /* Merge the path components */
      path = *liststr = apr_palloc(p, path_size + 1);
      for (i = 0; i < pathelts->nelts; ++i)
      {
          /* ### Hmmmm. Calling strlen twice on the same string. Yuck.
                 But is is better than reallocation in apr_pstrcat? */
          const char *part = ((char**)pathelts->elts)[i];
          apr_size_t part_size = strlen(part);
          if (part_size == 0)     /* Ignore empty path components. */
              continue;
  
          if (i > 0)
              *path++ = separator;
          memcpy(path, part, part_size);
          path += part_size;
      }
      *path = '\0';
      return APR_SUCCESS;
  }
  
  
  
  1.85      +4 -0      apr/libapr.dsp
  
  Index: libapr.dsp
  ===================================================================
  RCS file: /home/cvs/apr/libapr.dsp,v
  retrieving revision 1.84
  retrieving revision 1.85
  diff -u -r1.84 -r1.85
  --- libapr.dsp	11 Feb 2003 18:16:52 -0000	1.84
  +++ libapr.dsp	12 Feb 2003 20:20:56 -0000	1.85
  @@ -132,6 +132,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=.\file_io\unix\filepath_util.c
  +# End Source File
  +# Begin Source File
  +
   SOURCE=.\file_io\win32\filestat.c
   # End Source File
   # Begin Source File
  
  
  
  1.121     +4 -0      apr/apr.dsp
  
  Index: apr.dsp
  ===================================================================
  RCS file: /home/cvs/apr/apr.dsp,v
  retrieving revision 1.120
  retrieving revision 1.121
  diff -u -r1.120 -r1.121
  --- apr.dsp	6 Feb 2003 22:54:55 -0000	1.120
  +++ apr.dsp	12 Feb 2003 20:20:56 -0000	1.121
  @@ -117,6 +117,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=.\file_io\unix\filepath_util.c
  +# End Source File
  +# Begin Source File
  +
   SOURCE=.\file_io\win32\filestat.c
   # End Source File
   # Begin Source File
  
  
  
  1.13      +1 -0      apr/NWGNUmakefile
  
  Index: NWGNUmakefile
  ===================================================================
  RCS file: /home/cvs/apr/NWGNUmakefile,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- NWGNUmakefile	10 Jan 2003 23:29:18 -0000	1.12
  +++ NWGNUmakefile	12 Feb 2003 20:20:56 -0000	1.13
  @@ -255,6 +255,7 @@
   	$(OBJDIR)/fileacc.o \
   	$(OBJDIR)/filedup.o \
   	$(OBJDIR)/filepath.o \
  +	$(OBJDIR)/filepath_util.o \
   	$(OBJDIR)/filestat.o \
   	$(OBJDIR)/filesys.o \
   	$(OBJDIR)/flock.o \
  
  
  
  1.377     +3 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.376
  retrieving revision 1.377
  diff -u -r1.376 -r1.377
  --- CHANGES	7 Feb 2003 21:02:30 -0000	1.376
  +++ CHANGES	12 Feb 2003 20:20:56 -0000	1.377
  @@ -1,5 +1,8 @@
   Changes with APR 0.9.2
   
  +  *) Add functions apr_filepath_list_split and apr_filepath_list_merge
  +     for managing search paths.  [Branko Cibej]
  +
     *) Introduce Release mode debugging symbols for Win32 builds of apr.
        All library builds gain /Zi for debug symbols (which are discarded
        at link time if some flavor of the /debug flag isn't passed to link)
  
  
  

Mime
View raw message