]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPMessage.cpp
Happy New Year
[openldap] / contrib / ldapc++ / src / LDAPMessage.cpp
1 // $OpenLDAP$
2 /*
3  * Copyright 2000-2018 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6
7
8 #include "LDAPMessage.h"
9
10 #include "LDAPResult.h"
11 #include "LDAPExtResult.h"
12 #include "LDAPSaslBindResult.h"
13 #include "LDAPRequest.h"
14 #include "LDAPSearchResult.h"
15 #include "LDAPSearchReference.h"
16 #include "debug.h"
17 #include <iostream>
18
19 using namespace std;
20
21 LDAPMsg::LDAPMsg(LDAPMessage *msg){
22     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPMsg::LDAPMsg()" << endl);
23     msgType=ldap_msgtype(msg);
24     m_hasControls=false;
25 }
26
27 LDAPMsg::LDAPMsg(int type, int id=0){
28     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPMsg::LDAPMsg()" << endl);
29     msgType = type;
30     msgID = id;
31     m_hasControls=false;
32 }
33
34 LDAPMsg* LDAPMsg::create(const LDAPRequest *req, LDAPMessage *msg){
35     DEBUG(LDAP_DEBUG_TRACE,"LDAPMsg::create()" << endl);
36     switch(ldap_msgtype(msg)){
37         case SEARCH_ENTRY :
38             return new LDAPSearchResult(req,msg);
39         break;
40         case SEARCH_REFERENCE :
41             return new LDAPSearchReference(req, msg);
42         break;
43         case EXTENDED_RESPONSE :
44             return new LDAPExtResult(req,msg);
45         break;
46         case BIND_RESPONSE :
47             return new LDAPSaslBindResult(req,msg);
48         default :
49             return new LDAPResult(req, msg);
50     }
51     return 0;
52 }
53
54
55 int LDAPMsg::getMessageType(){
56     DEBUG(LDAP_DEBUG_TRACE,"LDAPMsg::getMessageType()" << endl);
57     return msgType;
58 }
59
60 int LDAPMsg::getMsgID(){
61     DEBUG(LDAP_DEBUG_TRACE,"LDAPMsg::getMsgID()" << endl);
62     return msgID;
63 }
64
65 bool LDAPMsg::hasControls() const{
66     return m_hasControls;
67 }
68
69 const LDAPControlSet& LDAPMsg::getSrvControls() const {
70     return m_srvControls;
71 }
72