| 1 |
// $OpenLDAP$ |
| 2 |
/* |
| 3 |
* Copyright 2000-2024 The OpenLDAP Foundation, All Rights Reserved. |
| 4 |
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file |
| 5 |
*/ |
| 6 |
|
| 7 |
|
| 8 |
#include "LDAPException.h" |
| 9 |
#include "LDAPSearchResult.h" |
| 10 |
#include "LDAPResult.h" |
| 11 |
|
| 12 |
#include "LDAPSearchResults.h" |
| 13 |
|
| 14 |
LDAPSearchResults::LDAPSearchResults(){ |
| 15 |
entryPos = entryList.begin(); |
| 16 |
refPos = refList.begin(); |
| 17 |
} |
| 18 |
|
| 19 |
LDAPResult* LDAPSearchResults::readMessageQueue(LDAPMessageQueue* msg){ |
| 20 |
if(msg != 0){ |
| 21 |
LDAPMsg* res=0; |
| 22 |
for(;;){ |
| 23 |
try{ |
| 24 |
res = msg->getNext(); |
| 25 |
}catch (LDAPException e){ |
| 26 |
throw; |
| 27 |
} |
| 28 |
switch(res->getMessageType()){ |
| 29 |
case LDAPMsg::SEARCH_ENTRY : |
| 30 |
entryList.addEntry(*((LDAPSearchResult*)res)->getEntry()); |
| 31 |
break; |
| 32 |
case LDAPMsg::SEARCH_REFERENCE : |
| 33 |
refList.addReference(*((LDAPSearchReference*)res)); |
| 34 |
break; |
| 35 |
default: |
| 36 |
entryPos=entryList.begin(); |
| 37 |
refPos=refList.begin(); |
| 38 |
return ((LDAPResult*) res); |
| 39 |
} |
| 40 |
delete res; |
| 41 |
res=0; |
| 42 |
} |
| 43 |
} |
| 44 |
return 0; |
| 45 |
} |
| 46 |
|
| 47 |
LDAPEntry* LDAPSearchResults::getNext(){ |
| 48 |
if( entryPos != entryList.end() ){ |
| 49 |
LDAPEntry* ret= new LDAPEntry(*entryPos); |
| 50 |
entryPos++; |
| 51 |
return ret; |
| 52 |
} |
| 53 |
if( refPos != refList.end() ){ |
| 54 |
LDAPUrlList urls= refPos->getUrls(); |
| 55 |
refPos++; |
| 56 |
throw(LDAPReferralException(urls)); |
| 57 |
} |
| 58 |
return 0; |
| 59 |
} |
| 60 |
|