You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Stas Bekman <st...@stason.org> on 2004/09/18 04:17:20 UTC

[patch] APR::Finfo constants tweaks

APR::Finfo wasn't completed until now, since there was an outstanding 
issue with the ambiguous enums/define names.

- APR::REG is too ambiguous, so this patch makes it and other constants 
from the apr_filetype_e enum to have a prefix of APR::FILETYPE_ (e.g. 
APR::FILETYPE_REG)

- same with APR::UREAD, so that fileperm group is now having a prefix 
APR::FILEPROT_ (e.g. APR::FILEPROT_UREAD)

The reason I haven't commited this patch, is that those renames are done 
only on the modperl side, and it's not clear yet whether they will go into 
APR.

If it was for me, I would have committed and used these non-ambiguous 
constants regardless of whether the C defines will be adjusted or not. But 
your mileage may vary. So please vote/comment...

Once this is resolved, I've the APR::Finfo manpage ready to be committed 
and once this is done we have the API documentation 100% completed (well 
at least for functions and methods, not all constants have been documented).

Index: lib/Apache/ParseSource.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/Apache/ParseSource.pm,v
retrieving revision 1.59
diff -u -u -r1.59 ParseSource.pm
--- lib/Apache/ParseSource.pm	13 Aug 2004 00:13:17 -0000	1.59
+++ lib/Apache/ParseSource.pm	18 Sep 2004 02:09:05 -0000
@@ -250,7 +250,8 @@
          error     => [qw{APR_E}],
          filemode  => ["APR_($filemode)"],
          filepath  => [qw{APR_FILEPATH_}],
-        fileperms => [qw{APR_\w(READ|WRITE|EXECUTE)}],
+        fileprot  => [qw{APR_FILEPROT_}],
+        filetype  => [qw{APR_FILETYPE_}],
          finfo     => [qw{APR_FINFO_}],
          flock     => [qw{APR_FLOCK_}],
          hook      => [qw{APR_HOOK_}],
@@ -276,7 +277,7 @@

  my %enums_wanted = (
      Apache => { map { $_, 1 } qw(cmd_how input_mode filter_type 
conn_keepalive) },
-    APR => { map { $_, 1 } qw(apr_shutdown_how apr_read_type apr_lockmech 
apr_filetype) },
+    APR => { map { $_, 1 } qw(apr_shutdown_how apr_read_type apr_lockmech) },
  );

  my $defines_unwanted = join '|', qw{
Index: lib/ModPerl/Code.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/ModPerl/Code.pm,v
retrieving revision 1.125
diff -u -u -r1.125 Code.pm
--- lib/ModPerl/Code.pm	2 Jul 2004 19:04:32 -0000	1.125
+++ lib/ModPerl/Code.pm	18 Sep 2004 02:09:05 -0000
@@ -655,7 +655,7 @@
                                          largefiles);
  my @h_names = (@c_names, map { "modperl_$_" } @h_src_names,
                 qw(types time apache_includes perl_includes apr_includes
-                  common_includes common_types));
+                  apr_compat common_includes common_types));
  sub h_files { [map { "$_.h" } @h_names, @g_h_names] }

  sub clean_files {
Index: src/modules/perl/modperl_common_includes.h
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_common_includes.h,v
retrieving revision 1.2
diff -u -u -r1.2 modperl_common_includes.h
--- src/modules/perl/modperl_common_includes.h	22 Jun 2004 22:34:10 -0000	1.2
+++ src/modules/perl/modperl_common_includes.h	18 Sep 2004 02:09:05 -0000
@@ -19,6 +19,7 @@
  /* header files which are independet of Apache/mod_perl */

  #include "modperl_apr_includes.h"
+#include "modperl_apr_compat.h"
  #include "modperl_perl_includes.h"
  #include "modperl_common_types.h"

Index: t/apr/constants.t
===================================================================
RCS file: /home/cvs/modperl-2.0/t/apr/constants.t,v
retrieving revision 1.4
diff -u -u -r1.4 constants.t
--- t/apr/constants.t	8 Jul 2004 06:06:33 -0000	1.4
+++ t/apr/constants.t	18 Sep 2004 02:09:05 -0000
@@ -16,4 +16,4 @@
  ok t_cmp (APR::SUCCESS, 0, 'APR::SUCCESS');
  ok t_cmp (APR::POLLIN, 0x001, 'APR::POLLIN');
  ok t_cmp (HOOK_LAST, 20, 'HOOK_LAST');
-ok t_cmp (APR::UNKFILE, 127, 'APR::UNKFILE');
+ok t_cmp (APR::FILETYPE_UNKFILE, 127, 'APR::UNKFILE');
Index: t/lib/TestAPRlib/finfo.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/lib/TestAPRlib/finfo.pm,v
retrieving revision 1.4
diff -u -u -r1.4 finfo.pm
--- t/lib/TestAPRlib/finfo.pm	17 Sep 2004 22:36:16 -0000	1.4
+++ t/lib/TestAPRlib/finfo.pm	18 Sep 2004 02:09:05 -0000
@@ -7,10 +7,6 @@
  use Apache::TestUtil;
  use Apache::TestTrace;
  use Apache::TestConfig;
-use constant WIN32 => Apache::TestConfig::WIN32;
-use constant OSX   => Apache::TestConfig::OSX;
-
-use constant APACHE_2_0_49_PLUS => have_min_apache_version('2.0.49');

  use File::Spec::Functions qw(catfile);
  use Fcntl qw(:mode);
@@ -18,8 +14,14 @@
  use APR::Finfo ();
  use APR::Pool ();

-use APR::Const -compile => qw(SUCCESS FINFO_NORM REG
-                              WREAD WWRITE WEXECUTE);
+use constant WIN32 => Apache::TestConfig::WIN32;
+use constant OSX   => Apache::TestConfig::OSX;
+
+use constant APACHE_2_0_49_PLUS => have_min_apache_version('2.0.49');
+
+use APR::Const -compile => qw(SUCCESS FINFO_NORM FILETYPE_REG
+                              FILEPROT_WREAD FILEPROT_WWRITE
+                              FILEPROT_WEXECUTE);

  sub num_of_tests {
      return 15;
@@ -69,6 +71,9 @@
              }
          }

+        # XXX: untested
+        # ->name
+
          # XXX: are there any platforms csize is available at all?
          # We don't want to see the skipped message all the time if
          # it's not really used anywhere
@@ -84,21 +89,21 @@

          # match world bits

-        ok t_cmp($finfo->protection & APR::WREAD,
+        ok t_cmp($finfo->protection & APR::FILEPROT_WREAD,
                   $protection & S_IROTH,
-                 '$finfo->protection() & APR::WREAD');
+                 '$finfo->protection() & APR::FILEPROT_WREAD');

-        ok t_cmp($finfo->protection & APR::WWRITE,
+        ok t_cmp($finfo->protection & APR::FILEPROT_WWRITE,
                   $protection & S_IWOTH,
-                 '$finfo->protection() & APR::WWRITE');
+                 '$finfo->protection() & APR::FILEPROT_WWRITE');

          if (WIN32) {
              skip "different file semantics", 0;
          }
          else {
-            ok t_cmp($finfo->protection & APR::WEXECUTE,
+            ok t_cmp($finfo->protection & APR::FILEPROT_WEXECUTE,
                       $protection & S_IXOTH,
-                     '$finfo->protection() & APR::WEXECUTE');
+                     '$finfo->protection() & APR::FILEPROT_WEXECUTE');
          }
      }

@@ -115,7 +120,7 @@
          }

          ok t_cmp($finfo->filetype,
-                 APR::REG,
+                 APR::FILETYPE_REG,
                   '$finfo->filetype()');
      }
  }
Index: xs/tables/current/Apache/ConstantsTable.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/tables/current/Apache/ConstantsTable.pm,v
retrieving revision 1.42
diff -u -u -r1.42 ConstantsTable.pm
--- xs/tables/current/Apache/ConstantsTable.pm	13 Aug 2004 00:13:18 -0000	1.42
+++ xs/tables/current/Apache/ConstantsTable.pm	18 Sep 2004 02:09:05 -0000
@@ -2,7 +2,7 @@

  # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  # ! WARNING: generated by Apache::ParseSource/0.02
-# !          Thu Aug 12 17:10:15 2004
+# !          Fri Sep 17 21:00:55 2004
  # !          do NOT edit, any changes will be lost !
  # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

@@ -343,26 +343,30 @@
        'APR_FINFO_DIRENT'
      ],
      'filetype' => [
-      'APR_NOFILE',
-      'APR_REG',
-      'APR_DIR',
-      'APR_CHR',
-      'APR_BLK',
-      'APR_PIPE',
-      'APR_LNK',
-      'APR_SOCK',
-      'APR_UNKFILE'
-    ],
-    'fileperms' => [
-      'APR_UREAD',
-      'APR_UWRITE',
-      'APR_UEXECUTE',
-      'APR_GREAD',
-      'APR_GWRITE',
-      'APR_GEXECUTE',
-      'APR_WREAD',
-      'APR_WWRITE',
-      'APR_WEXECUTE'
+      'APR_FILETYPE_NOFILE',
+      'APR_FILETYPE_REG',
+      'APR_FILETYPE_DIR',
+      'APR_FILETYPE_CHR',
+      'APR_FILETYPE_BLK',
+      'APR_FILETYPE_PIPE',
+      'APR_FILETYPE_LNK',
+      'APR_FILETYPE_SOCK',
+      'APR_FILETYPE_UNKFILE'
+    ],
+    'fileprot' => [
+      'APR_FILEPROT_USETID',
+      'APR_FILEPROT_UREAD',
+      'APR_FILEPROT_UWRITE',
+      'APR_FILEPROT_UEXECUTE',
+      'APR_FILEPROT_GSETID',
+      'APR_FILEPROT_GREAD',
+      'APR_FILEPROT_GWRITE',
+      'APR_FILEPROT_GEXECUTE',
+      'APR_FILEPROT_WSTICKY',
+      'APR_FILEPROT_WREAD',
+      'APR_FILEPROT_WWRITE',
+      'APR_FILEPROT_WEXECUTE',
+      'APR_FILEPROT_OS_DEFAULT'
      ],
      'filepath' => [
        'APR_FILEPATH_NOTABOVEROOT',

--- /dev/null	1969-12-31 19:00:00.000000000 -0500
+++ src/modules/perl/modperl_apr_compat.h	2004-09-17 20:59:18.812677141 -0400
@@ -0,0 +1,109 @@
+/* Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed 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 MODPERL_APR_COMPAT_H
+#define MODPERL_APR_COMPAT_H
+
+/* back compat adjustements for older libapr versions */
+
+/* BACK_COMPAT_MARKER: make back compat issues easy to find :) */
+
+/* use the following format:
+ *     #if ! AP_MODULE_MAGIC_AT_LEAST(20020903,4)
+ *         [compat code]
+ *     #endif
+ * and don't forget to insert comments explaining exactly
+ * which httpd release allows us to remove the compat code
+ */
+
+/* apr_filetype_e entries rename */
+
+#ifndef APR_FILETYPE_NOFILE
+#define APR_FILETYPE_NOFILE  APR_NOFILE
+#endif
+#ifndef APR_FILETYPE_REG
+#define APR_FILETYPE_REG     APR_REG
+#endif
+#ifndef APR_FILETYPE_DIR
+#define APR_FILETYPE_DIR     APR_DIR
+#endif
+#ifndef APR_FILETYPE_CHR
+#define APR_FILETYPE_CHR     APR_CHR
+#endif
+#ifndef APR_FILETYPE_BLK
+#define APR_FILETYPE_BLK     APR_BLK
+#endif
+#ifndef APR_FILETYPE_PIPE
+#define APR_FILETYPE_PIPE    APR_PIPE
+#endif
+#ifndef APR_FILETYPE_LNK
+#define APR_FILETYPE_LNK     APR_LNK
+#endif
+#ifndef APR_FILETYPE_SOCK
+#define APR_FILETYPE_SOCK    APR_SOCK
+#endif
+#ifndef APR_FILETYPE_UNKFILE
+#define APR_FILETYPE_UNKFILE APR_UNKFILE
+#endif
+
+
+/* apr file permissions group rename (has no enum) */
+
+#ifndef APR_FILEPROT_USETID
+#define APR_FILEPROT_USETID     APR_USETID
+#endif
+#ifndef APR_FILEPROT_UREAD
+#define APR_FILEPROT_UREAD      APR_UREAD
+#endif
+#ifndef APR_FILEPROT_UWRITE
+#define APR_FILEPROT_UWRITE     APR_UWRITE
+#endif
+#ifndef APR_FILEPROT_UEXECUTE
+#define APR_FILEPROT_UEXECUTE   APR_UEXECUTE
+#endif
+#ifndef APR_FILEPROT_GSETID
+#define APR_FILEPROT_GSETID     APR_GSETID
+#endif
+#ifndef APR_FILEPROT_GREAD
+#define APR_FILEPROT_GREAD      APR_GREAD
+#endif
+#ifndef APR_FILEPROT_GWRITE
+#define APR_FILEPROT_GWRITE     APR_GWRITE
+#endif
+#ifndef APR_FILEPROT_GEXECUTE
+#define APR_FILEPROT_GEXECUTE   APR_GEXECUTE
+#endif
+#ifndef APR_FILEPROT_WSTICKY
+#define APR_FILEPROT_WSTICKY    APR_WSTICKY
+#endif
+#ifndef APR_FILEPROT_WREAD
+#define APR_FILEPROT_WREAD      APR_WREAD
+#endif
+#ifndef APR_FILEPROT_WWRITE
+#define APR_FILEPROT_WWRITE     APR_WWRITE
+#endif
+#ifndef APR_FILEPROT_WEXECUTE
+#define APR_FILEPROT_WEXECUTE   APR_WEXECUTE
+#endif
+#ifndef APR_FILEPROT_OS_DEFAULT
+#define APR_FILEPROT_OS_DEFAULT APR_OS_DEFAULT
+#endif
+/* APR_FILEPROT_FILE_SOURCE_PERMS seems to have only an internal apr
+ * use */
+
+
+
+
+#endif /* MODPERL_APR_COMPAT_H */

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org