2008-03-28 07:05:10 -04:00
|
|
|
// $OpenLDAP$
|
2000-10-03 14:50:44 -04:00
|
|
|
/*
|
2011-03-28 21:08:19 -04:00
|
|
|
* Copyright 2000-2011 The OpenLDAP Foundation, All Rights Reserved.
|
2000-10-03 14:50:44 -04:00
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
#include "LDAPControlSet.h"
|
|
|
|
|
|
2001-09-28 12:39:58 -04:00
|
|
|
using namespace std;
|
|
|
|
|
|
2000-10-03 14:50:44 -04:00
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-07 13:43:55 -04:00
|
|
|
bool LDAPControlSet::empty() const {
|
|
|
|
|
DEBUG(LDAP_DEBUG_TRACE,"LDAPControlSet::empty()" << endl);
|
|
|
|
|
return data.empty();
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-03 14:50:44 -04:00
|
|
|
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);
|
2001-09-07 13:43:55 -04:00
|
|
|
if(data.empty()){
|
2000-10-03 14:50:44 -04:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-14 12:33:54 -05:00
|
|
|
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;
|
|
|
|
|
}
|