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