xref: /illumos-gate/usr/src/lib/libldap5/sources/ldap/common/message.c (revision cbea7aca3fd7787405cbdbd93752998f03dfc25f)
1 /*
2  * The contents of this file are subject to the Netscape Public
3  * License Version 1.1 (the "License"); you may not use this file
4  * except in compliance with the License. You may obtain a copy of
5  * the License at http://www.mozilla.org/NPL/
6  *
7  * Software distributed under the License is distributed on an "AS
8  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9  * implied. See the License for the specific language governing
10  * rights and limitations under the License.
11  *
12  * The Original Code is Mozilla Communicator client code, released
13  * March 31, 1998.
14  *
15  * The Initial Developer of the Original Code is Netscape
16  * Communications Corporation. Portions created by Netscape are
17  * Copyright (C) 1998-1999 Netscape Communications Corporation. All
18  * Rights Reserved.
19  *
20  * Contributor(s):
21  */
22 #include "ldap-int.h"
23 
24 int
25 LDAP_CALL
26 ldap_msgid( LDAPMessage *lm )
27 {
28 	if ( !NSLDAPI_VALID_LDAPMESSAGE_POINTER( lm )) {
29 		return( -1 );
30 	}
31 
32 	return( lm->lm_msgid );
33 }
34 
35 int
36 LDAP_CALL
37 ldap_msgtype( LDAPMessage *lm )
38 {
39 	if ( !NSLDAPI_VALID_LDAPMESSAGE_POINTER( lm )) {
40 		return( -1 );
41 	}
42 
43 	return( lm->lm_msgtype );
44 }
45 
46 
47 LDAPMessage *
48 LDAP_CALL
49 ldap_first_message( LDAP *ld, LDAPMessage *chain )
50 {
51 	if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) {
52 		return( NULLMSG );		/* punt */
53 	}
54 
55 	return( chain );
56 }
57 
58 
59 LDAPMessage *
60 LDAP_CALL
61 ldap_next_message( LDAP *ld, LDAPMessage *msg )
62 {
63 	if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) {
64 		return( NULLMSG );		/* punt */
65 	}
66 
67 	if ( msg == NULLMSG || msg->lm_chain == NULLMSG ) {
68 		return( NULLMSG );
69 	}
70 
71 	return( msg->lm_chain );
72 }
73 
74 
75 int
76 LDAP_CALL
77 ldap_count_messages( LDAP *ld, LDAPMessage *chain )
78 {
79 	int	i;
80 
81 	if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) {
82 		return( -1 );
83 	}
84 
85 	for ( i = 0; chain != NULL; chain = chain->lm_chain ) {
86 		i++;
87 	}
88 
89 	return( i );
90 }
91