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