perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject functions returning status?
Date Wed, 30 Jan 2002 07:58:34 GMT
e.g. APR::Util::password_validate returns status, which is not what a 
Perl user expects. Since we try to adjust the APR's API to follow Perl 
style, I've "fixed" APR::Util::password_validate to DWIM. The patch is 
below.

The question remains is how to get to the value of the status, since the 
caller needs to know what's the error. Do we have a methodology for this 
issue? I think that the dual valued $! should be set to the returned 
status and its string representation. Though I guess it adds a certain 
overhead.

As a side effect we don't need to expose strerror and import many APR 
constants (not into the script but into APR::Const package). But I guess 
this doesn't matter.

Index: xs/APR/Util/APR__Util.h
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/APR/Util/APR__Util.h,v
retrieving revision 1.1
diff -u -r1.1 APR__Util.h
--- xs/APR/Util/APR__Util.h	30 Jan 2002 05:21:52 -0000	1.1
+++ xs/APR/Util/APR__Util.h	30 Jan 2002 07:47:42 -0000
@@ -32,3 +32,6 @@

      mpxs_set_targ(mpxs_apr_generate_random_bytes, ST(0));
  }
+
+#define mpxs_APR__Util_password_validate(passwd, hash) \
+(apr_password_validate(passwd, hash) == APR_SUCCESS)
Index: xs/maps/apr_functions.map
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/maps/apr_functions.map,v
retrieving revision 1.33
diff -u -r1.33 apr_functions.map
--- xs/maps/apr_functions.map	30 Jan 2002 06:57:31 -0000	1.33
+++ xs/maps/apr_functions.map	30 Jan 2002 07:47:42 -0000
@@ -410,12 +410,12 @@
  MODULE=APR::Util
   apr_filename_of_pathname
   apr_password_get
- apr_password_validate
  -apr_snprintf
  -apr_vformatter
  -apr_vsnprintf
   apr_generate_random_bytes | MPXS_ | length
   apr_strerror              | MPXS_ | statcode
+int:DEFINE_password_validate | | char *:passwd, char *:hash

  !MODULE=APR::General
  -apr_initialize

_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


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


Mime
View raw message