From a8566748df86fd4c403f21963d6d97f8cd7fd83e Mon Sep 17 00:00:00 2001 From: clayton Date: Fri, 24 Jul 1998 22:31:03 +0000 Subject: [PATCH] Fixed some constant handling for constants that return strings or other non-numeric data. Fixes problem with LDAP_OPT_ON/LDAP_OPT_OFF. git-svn-id: svn://10.0.0.236/trunk@6425 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/directory/perldap/API.pm | 44 +++-- mozilla/directory/perldap/constant.h | 238 +-------------------------- 2 files changed, 32 insertions(+), 250 deletions(-) diff --git a/mozilla/directory/perldap/API.pm b/mozilla/directory/perldap/API.pm index e5dd68934a4..0960f07211b 100644 --- a/mozilla/directory/perldap/API.pm +++ b/mozilla/directory/perldap/API.pm @@ -1,5 +1,5 @@ ############################################################################# -# $Id: API.pm,v 1.4 1998-07-24 19:01:47 clayton Exp $ +# $Id: API.pm,v 1.5 1998-07-24 22:31:02 clayton Exp $ # # The contents of this file are subject to the Mozilla Public License # Version 1.0 (the "License"); you may not use this file except in @@ -254,6 +254,27 @@ foreach my $EXP (keys %EXPORT_TAGS) $VERSION = '0.90'; +# The XS 'constant' routine returns an integer. There are all constants +# we want to return something else. +my %OVERRIDE_CONST = ( + "LDAP_ALL_USER_ATTRS","*", + "LDAP_CONTROL_ENTRYCHANGE","2.16.840.1.113730.3.4.7", + "LDAP_CONTROL_MANAGEDSAIT","2.16.840.1.113730.3.4.2", + "LDAP_CONTROL_PERSISTENTSEARCH","2.16.840.1.113730.3.4.3", + "LDAP_CONTROL_PWEXPIRED","2.16.840.1.113730.3.4.4", + "LDAP_CONTROL_PWEXPIRING","2.16.840.1.113730.3.4.5", + "LDAP_CONTROL_REFERRALS","1.2.840.113556.1.4.616", + "LDAP_CONTROL_SORTREQUEST","1.2.840.113556.1.4.473", + "LDAP_CONTROL_SORTRESPONSE","1.2.840.113556.1.4.474", + "LDAP_CONTROL_VLVREQUEST","2.16.840.1.113730.3.4.9", + "LDAP_CONTROL_VLVRESPONSE","2.16.840.1.113730.3.4.10", + "LDAP_NO_ATTRS","1.1", + "LDAP_OPT_OFF",0, + "LDAP_OPT_ON",1, + "LDAP_ROOT_DSE","", + "LDAP_SASL_EXTERNAL","EXTERNAL", +); + sub AUTOLOAD { # This AUTOLOAD is used to 'autoload' constants from the constant() # XS function. If a constant is not found then control is passed @@ -261,14 +282,20 @@ sub AUTOLOAD { my $constname; ($constname = $AUTOLOAD) =~ s/.*:://; - my $val = constant($constname, @_ ? $_[0] : 0); + my $val; + if (($val = $OVERRIDE_CONST{$constname})) + { + eval "sub $AUTOLOAD { $val }"; + goto &$AUTOLOAD; + } + $val = constant($constname, @_ ? $_[0] : 0); if ($! != 0) { if ($! =~ /Invalid/) { $AutoLoader::AUTOLOAD = $AUTOLOAD; goto &AutoLoader::AUTOLOAD; } else { - croak "Your vendor has not defined Ldap macro $constname"; + croak "Your vendor has not defined Mozilla::LDAP macro $constname"; } } eval "sub $AUTOLOAD { $val }"; @@ -296,21 +323,10 @@ Mozilla::LDAP::API - Perl extension for blah blah blah =head1 DESCRIPTION -Stub documentation for Ldap was created by h2xs. It looks like the -author of the extension was negligent enough to leave the stub -unedited. - -Blah blah blah. - -=head1 Exported constants - =head1 AUTHOR -A. U. Thor, a.u.thor@a.galaxy.far.far.away - =head1 SEE ALSO -perl(1). =cut diff --git a/mozilla/directory/perldap/constant.h b/mozilla/directory/perldap/constant.h index 2f6458e3a86..d43338df82f 100644 --- a/mozilla/directory/perldap/constant.h +++ b/mozilla/directory/perldap/constant.h @@ -1,6 +1,6 @@ /* ******************************************************************************* - * $Id: constant.h,v 1.3 1998-07-23 11:05:57 leif Exp $ + * $Id: constant.h,v 1.4 1998-07-24 22:31:03 clayton Exp $ * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in @@ -45,41 +45,13 @@ char *s; return -1; } -static double +double constant(name, arg) char *name; int arg; { errno = 0; switch (*name) { - case 'A': - break; - case 'B': - break; - case 'C': - break; - case 'D': - break; - case 'E': - break; - case 'F': - if (strEQ(name, "FD_SETSIZE")) -#ifdef FD_SETSIZE - return FD_SETSIZE; -#else - goto not_there; -#endif - break; - case 'G': - break; - case 'H': - break; - case 'I': - break; - case 'J': - break; - case 'K': - break; case 'L': if (strEQ(name, "LDAPS_PORT")) #ifdef LDAPS_PORT @@ -110,12 +82,6 @@ int arg; return LDAP_ALIAS_PROBLEM; #else goto not_there; -#endif - if (strEQ(name, "LDAP_ALL_USER_ATTRS")) -#ifdef LDAP_ALL_USER_ATTRS_CHAR - return LDAP_ALL_USER_ATTRS; -#else - goto not_there; #endif if (strEQ(name, "LDAP_ALREADY_EXISTS")) #ifdef LDAP_ALREADY_EXISTS @@ -242,72 +208,6 @@ int arg; return LDAP_CONSTRAINT_VIOLATION; #else goto not_there; -#endif - if (strEQ(name, "LDAP_CONTROL_ENTRYCHANGE")) -#ifdef LDAP_CONTROL_ENTRYCHANGE_CHAR - return LDAP_CONTROL_ENTRYCHANGE; -#else - goto not_there; -#endif - if (strEQ(name, "LDAP_CONTROL_MANAGEDSAIT")) -#ifdef LDAP_CONTROL_MANAGEDSAIT_CHAR - return LDAP_CONTROL_MANAGEDSAIT; -#else - goto not_there; -#endif - if (strEQ(name, "LDAP_CONTROL_NOT_FOUND")) -#ifdef LDAP_CONTROL_NOT_FOUND - return LDAP_CONTROL_NOT_FOUND; -#else - goto not_there; -#endif - if (strEQ(name, "LDAP_CONTROL_PERSISTENTSEARCH")) -#ifdef LDAP_CONTROL_PERSISTENTSEARCH_CHAR - return LDAP_CONTROL_PERSISTENTSEARCH; -#else - goto not_there; -#endif - if (strEQ(name, "LDAP_CONTROL_PWEXPIRED")) -#ifdef LDAP_CONTROL_PWEXPIRED_CHAR - return LDAP_CONTROL_PWEXPIRED; -#else - goto not_there; -#endif - if (strEQ(name, "LDAP_CONTROL_PWEXPIRING")) -#ifdef LDAP_CONTROL_PWEXPIRING_CHAR - return LDAP_CONTROL_PWEXPIRING; -#else - goto not_there; -#endif - if (strEQ(name, "LDAP_CONTROL_REFERRALS")) -#ifdef LDAP_CONTROL_REFERRALS_CHAR - return LDAP_CONTROL_REFERRALS; -#else - goto not_there; -#endif - if (strEQ(name, "LDAP_CONTROL_SORTREQUEST")) -#ifdef LDAP_CONTROL_SORTREQUEST_CHAR - return LDAP_CONTROL_SORTREQUEST; -#else - goto not_there; -#endif - if (strEQ(name, "LDAP_CONTROL_SORTRESPONSE")) -#ifdef LDAP_CONTROL_SORTRESPONSE_CHAR - return LDAP_CONTROL_SORTRESPONSE; -#else - goto not_there; -#endif - if (strEQ(name, "LDAP_CONTROL_VLVREQUEST")) -#ifdef LDAP_CONTROL_VLVREQUEST_CHAR - return LDAP_CONTROL_VLVREQUEST; -#else - goto not_there; -#endif - if (strEQ(name, "LDAP_CONTROL_VLVRESPONSE")) -#ifdef LDAP_CONTROL_VLVRESPONSE_CHAR - return LDAP_CONTROL_VLVRESPONSE; -#else - goto not_there; #endif if (strEQ(name, "LDAP_DECODING_ERROR")) #ifdef LDAP_DECODING_ERROR @@ -482,12 +382,6 @@ int arg; return LDAP_NOT_SUPPORTED; #else goto not_there; -#endif - if (strEQ(name, "LDAP_NO_ATTRS")) -#ifdef LDAP_NO_ATTRS_CHAR - return LDAP_NO_ATTRS; -#else - goto not_there; #endif if (strEQ(name, "LDAP_NO_LIMIT")) #ifdef LDAP_NO_LIMIT @@ -614,18 +508,6 @@ int arg; return LDAP_OPT_MEMALLOC_FN_PTRS; #else goto not_there; -#endif - if (strEQ(name, "LDAP_OPT_OFF")) -#ifdef LDAP_OPT_OFF_CHAR - return LDAP_OPT_OFF; -#else - goto not_there; -#endif - if (strEQ(name, "LDAP_OPT_ON")) -#ifdef LDAP_OPT_ON_CHAR - return LDAP_OPT_ON; -#else - goto not_there; #endif if (strEQ(name, "LDAP_OPT_PREFERRED_LANGUAGE")) #ifdef LDAP_OPT_PREFERRED_LANGUAGE @@ -836,24 +718,12 @@ int arg; return LDAP_RES_SEARCH_RESULT; #else goto not_there; -#endif - if (strEQ(name, "LDAP_ROOT_DSE")) -#ifdef LDAP_ROOT_DSE_CHAR - return LDAP_ROOT_DSE; -#else - goto not_there; #endif if (strEQ(name, "LDAP_SASL_BIND_IN_PROGRESS")) #ifdef LDAP_SASL_BIND_IN_PROGRESS return LDAP_SASL_BIND_IN_PROGRESS; #else goto not_there; -#endif - if (strEQ(name, "LDAP_SASL_EXTERNAL")) -#ifdef LDAP_SASL_EXTERNAL_CHAR - return LDAP_SASL_EXTERNAL; -#else - goto not_there; #endif if (strEQ(name, "LDAP_SASL_SIMPLE")) #ifdef LDAP_SASL_SIMPLE @@ -1036,110 +906,6 @@ int arg; goto not_there; #endif break; - case 'M': - break; - case 'N': - if (strEQ(name, "NBBY")) -#ifdef NBBY - return NBBY; -#else - goto not_there; -#endif - if (strEQ(name, "NFDBITS")) -#ifdef NFDBITS - return NFDBITS; -#else - goto not_there; -#endif - if (strEQ(name, "NULLLDAPURLDESC")) -#ifdef NULLLDAPURLDESC_CHAR - return NULLLDAPURLDESC; -#else - goto not_there; -#endif - if (strEQ(name, "NULLMSG")) -#ifdef NULLMSG_CHAR - return NULLMSG; -#else - goto not_there; -#endif - break; - case 'O': - break; - case 'P': - break; - case 'Q': - break; - case 'R': - break; - case 'S': - break; - case 'T': - break; - case 'U': - break; - case 'V': - break; - case 'W': - break; - case 'X': - break; - case 'Y': - break; - case 'Z': - break; - case 'a': - break; - case 'b': - break; - case 'c': - break; - case 'd': - break; - case 'e': - break; - case 'f': - break; - case 'g': - break; - case 'h': - break; - case 'i': - break; - case 'j': - break; - case 'k': - break; - case 'l': - break; - case 'm': - break; - case 'n': - break; - case 'o': - break; - case 'p': - break; - case 'q': - break; - case 'r': - break; - case 's': - break; - case 't': - break; - case 'u': - break; - case 'v': - break; - case 'w': - break; - case 'x': - break; - case 'y': - break; - case 'z': - break; } errno = EINVAL; return 0;