From: Ralf Haferkamp Date: Tue, 16 Feb 2010 17:44:22 +0000 (+0000) Subject: use const where appropriate X-Git-Tag: MIGRATION_CVS2GIT~690 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=277b3318d4b7fcb9b1d10c408f625bb8561f0c99;p=openldap use const where appropriate --- diff --git a/contrib/ldapc++/src/TlsOptions.cpp b/contrib/ldapc++/src/TlsOptions.cpp index 9c5ebd67e5..8f95815b83 100644 --- a/contrib/ldapc++/src/TlsOptions.cpp +++ b/contrib/ldapc++/src/TlsOptions.cpp @@ -38,7 +38,7 @@ static tls_optmap_t optmap[] = { static const int TLS_CONNECT_ARG #endif -void checkOpt( TlsOptions::tls_option opt, opttype type ){ +static void checkOpt( TlsOptions::tls_option opt, opttype type ) { if ( opt < TlsOptions::CACERTFILE || opt >= TlsOptions::LASTOPT ){ throw( LDAPException( LDAP_PARAM_ERROR, "unknown Option" ) ); } @@ -50,17 +50,17 @@ void checkOpt( TlsOptions::tls_option opt, opttype type ){ TlsOptions::TlsOptions( LDAP* ld ): m_ld(ld) { } -void TlsOptions::setOption( tls_option opt, const std::string& value ) { +void TlsOptions::setOption( tls_option opt, const std::string& value ) const { checkOpt(opt, STRING); - this->setOption( opt, (void*) value.c_str()); + this->setOption( opt, value.empty() ? NULL : (void*) value.c_str() ); } -void TlsOptions::setOption( tls_option opt, int value ) { +void TlsOptions::setOption( tls_option opt, int value ) const { checkOpt(opt, INT); this->setOption( opt, (void*) &value); } -void TlsOptions::setOption( tls_option opt, void *value ) { +void TlsOptions::setOption( tls_option opt, void *value ) const { int ret = ldap_set_option( m_ld, optmap[opt].optval, value); if ( ret != LDAP_OPT_SUCCESS ) { @@ -72,7 +72,7 @@ void TlsOptions::setOption( tls_option opt, void *value ) { } } -void TlsOptions::getOption( tls_option opt, void* value ){ +void TlsOptions::getOption( tls_option opt, void* value ) const { int ret = ldap_get_option( m_ld, optmap[opt].optval, value); if ( ret != LDAP_OPT_SUCCESS ) { diff --git a/contrib/ldapc++/src/TlsOptions.h b/contrib/ldapc++/src/TlsOptions.h index 59da72a50e..a4cb0b44db 100644 --- a/contrib/ldapc++/src/TlsOptions.h +++ b/contrib/ldapc++/src/TlsOptions.h @@ -26,13 +26,13 @@ class TlsOptions { }; TlsOptions( LDAP* ld=NULL ); - void setOption(tls_option opt, const std::string& value); - void setOption(tls_option opt, int value); - void setOption(tls_option opt, void *value); + void setOption(tls_option opt, const std::string& value) const; + void setOption(tls_option opt, int value) const; + void setOption(tls_option opt, void *value) const; int getIntOption(tls_option opt) const; std::string getStringOption(tls_option opt) const; - void getOption(tls_option opt, void *value ); + void getOption(tls_option opt, void *value ) const; enum verifyMode { NEVER=0,