1 /*
2 *
3 * Copyright 13/01/98 Sun Microsystems, Inc. All Rights Reserved
4 * Comments:
5 *
6 */
7 #pragma ident "%Z%%M% %I% %E% SMI"
8 #include <stdio.h>
9 #include <ctype.h>
10 #include <string.h>
11 #include "lber.h"
12 #include "ldap.h"
13 #include "ldap-private.h"
14 #include "ldap-int.h"
15
ldap_first_notif(LDAP * ld)16 LDAPMessage *ldap_first_notif(LDAP *ld)
17 {
18 return ld->ld_notifs;
19 }
20
ldap_next_notif(LDAP * ld,LDAPMessage * current)21 LDAPMessage *ldap_next_notif(LDAP *ld, LDAPMessage *current)
22 {
23 if ( current == NULLMSG )
24 return NULLMSG;
25 else
26 return current->lm_next;
27 }
28
ldap_reset_notif(LDAP * ld,int freeit)29 int ldap_reset_notif(LDAP *ld, int freeit)
30 {
31 LDAPMessage *L_n=NULLMSG;
32 LDAPMessage *L_q=NULLMSG;
33
34 if ( freeit )
35 {
36 for (L_n=ld->ld_notifs; L_n!=NULLMSG; L_n=L_n->lm_next)
37 {
38 if ( L_n->lm_next != NULLMSG )
39 {
40 L_q = L_n->lm_next;
41 ldap_msgfree(L_n);
42 L_n = L_q;
43 }
44 else
45 {
46 ldap_msgfree(L_n);
47 break;
48 }
49 }
50 }
51 ld->ld_notifs = NULLMSG;
52
53 return (LDAP_SUCCESS);
54 }
55
ldap_remove_notif(LDAP * ld,LDAPMessage * notif,int freeit)56 int ldap_remove_notif(LDAP *ld, LDAPMessage *notif, int freeit)
57 {
58 LDAPMessage *L_n=NULLMSG, *L_q=NULLMSG;
59
60 for ( L_n=ld->ld_notifs; L_n!=NULLMSG; L_n=L_n->lm_next)
61 {
62 if ( L_n == notif)
63 {
64 if ( L_q == NULLMSG )
65 ld->ld_notifs = L_n->lm_next;
66 else
67 L_q->lm_next = L_n->lm_next;
68
69 L_n->lm_next = NULLMSG;
70 if ( freeit )
71 ldap_msgfree(L_n);
72
73 break;
74 }
75 L_q = L_n;
76 }
77 return (LDAP_SUCCESS);
78 }
79
80 /* Add in tail */
ldap_add_notif(LDAP * ld,LDAPMessage * notif)81 int ldap_add_notif(LDAP *ld, LDAPMessage *notif)
82 {
83 LDAPMessage *L_n=NULLMSG, *L_q=NULLMSG;
84
85 for ( L_n=ld->ld_notifs; L_n!=NULLMSG; L_n=L_n->lm_next)
86 L_q = L_n;
87
88 notif->lm_next = NULLMSG;
89 if ( L_q == NULLMSG )
90 ld->ld_notifs = notif;
91 else
92 L_q->lm_next = notif;
93
94 return (LDAP_SUCCESS);
95 }
96
97 /* Add in head */
ldap_insert_notif(LDAP * ld,LDAPMessage * notif)98 int ldap_insert_notif(LDAP *ld, LDAPMessage *notif)
99 {
100
101 notif->lm_next = ld->ld_notifs;
102 ld->ld_notifs = notif;
103
104 return (LDAP_SUCCESS);
105 }
106
107