diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 11:11:40 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 11:11:40 +0000 |
commit | 7731832751ab9f3c6ddeb66f186d3d7fa1934a6d (patch) | |
tree | e91015872543a59be2aad26c2fea02e41b57005d /contrib/ldapc++/src/LDAPControlSet.cpp | |
parent | Initial commit. (diff) | |
download | openldap-7731832751ab9f3c6ddeb66f186d3d7fa1934a6d.tar.xz openldap-7731832751ab9f3c6ddeb66f186d3d7fa1934a6d.zip |
Adding upstream version 2.4.57+dfsg.upstream/2.4.57+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'contrib/ldapc++/src/LDAPControlSet.cpp')
-rw-r--r-- | contrib/ldapc++/src/LDAPControlSet.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/contrib/ldapc++/src/LDAPControlSet.cpp b/contrib/ldapc++/src/LDAPControlSet.cpp new file mode 100644 index 0000000..4e7741a --- /dev/null +++ b/contrib/ldapc++/src/LDAPControlSet.cpp @@ -0,0 +1,84 @@ +// $OpenLDAP$ +/* + * Copyright 2000-2021 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "debug.h" +#include "LDAPControlSet.h" + +using namespace std; + +LDAPControlSet::LDAPControlSet(){ +} + +LDAPControlSet::LDAPControlSet(const LDAPControlSet& cs){ + DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPControlSet::LDAPControlSet(&)" << endl); + data=cs.data; +} + +LDAPControlSet::LDAPControlSet(LDAPControl** controls){ + DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPControlSet::LDAPControlSet()" << endl); + if(controls != 0){ + LDAPControl** i; + for( i=controls; *i!=0;i++) { + add(LDAPCtrl(*i)); + } + } +} + +LDAPControlSet::~LDAPControlSet(){ + DEBUG(LDAP_DEBUG_DESTROY,"LDAPControlSet::~LDAPControlSet()" << endl); +} + +size_t LDAPControlSet::size() const { + DEBUG(LDAP_DEBUG_TRACE,"LDAPControlSet::size()" << endl); + return data.size(); +} + +bool LDAPControlSet::empty() const { + DEBUG(LDAP_DEBUG_TRACE,"LDAPControlSet::empty()" << endl); + return data.empty(); +} + +LDAPControlSet::const_iterator LDAPControlSet::begin() const{ + DEBUG(LDAP_DEBUG_TRACE,"LDAPControlSet::begin()" << endl); + return data.begin(); +} + + +LDAPControlSet::const_iterator LDAPControlSet::end() const{ + DEBUG(LDAP_DEBUG_TRACE,"LDAPControlSet::end()" << endl); + return data.end (); +} + +void LDAPControlSet::add(const LDAPCtrl& ctrl){ + DEBUG(LDAP_DEBUG_TRACE,"LDAPControlSet::add()" << endl); + data.push_back(ctrl); +} + +LDAPControl** LDAPControlSet::toLDAPControlArray() const{ + DEBUG(LDAP_DEBUG_TRACE, "LDAPControlSet::toLDAPControlArray()" << endl); + if(data.empty()){ + return 0; + }else{ + LDAPControl** ret= new LDAPControl*[data.size()+1]; + CtrlList::const_iterator i; + int j=0; + for(i=data.begin(); i!=data.end(); i++,j++){ + ret[j] = i->getControlStruct(); + } + ret[data.size()]=0; + return ret; + } +} + +void LDAPControlSet::freeLDAPControlArray(LDAPControl **ctrl){ + DEBUG(LDAP_DEBUG_TRACE, "LDAPControlSet::freeLDAPControlArray()" << endl); + if( ctrl ){ + for( LDAPControl **i = ctrl; *i != 0; ++i ){ + LDAPCtrl::freeLDAPControlStruct(*i); + } + } + delete[] ctrl; +} |