No empty .Rs/.Re
[netbsd-mini2440.git] / external / bsd / openldap / dist / libraries / libldap / addentry.c
blob63d107d98b708952af3dc4d39e8e8eeebdcec5ba
1 /* addentry.c */
2 /* $OpenLDAP: pkg/ldap/libraries/libldap/addentry.c,v 1.16.2.3 2008/02/11 23:26:41 kurt Exp $ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2008 The OpenLDAP Foundation.
6 * All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
10 * Public License.
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
16 /* Portions Copyright (c) 1990 Regents of the University of Michigan.
17 * All rights reserved.
20 #include "portable.h"
22 #include <stdio.h>
24 #include <ac/stdlib.h>
26 #include <ac/socket.h>
27 #include <ac/string.h>
28 #include <ac/time.h>
30 #include "ldap-int.h"
32 LDAPMessage *
33 ldap_delete_result_entry( LDAPMessage **list, LDAPMessage *e )
35 LDAPMessage *tmp, *prev = NULL;
37 assert( list != NULL );
38 assert( e != NULL );
40 for ( tmp = *list; tmp != NULL && tmp != e; tmp = tmp->lm_chain )
41 prev = tmp;
43 if ( tmp == NULL )
44 return( NULL );
46 if ( prev == NULL ) {
47 if ( tmp->lm_chain )
48 tmp->lm_chain->lm_chain_tail = (*list)->lm_chain_tail;
49 *list = tmp->lm_chain;
50 } else {
51 prev->lm_chain = tmp->lm_chain;
52 if ( prev->lm_chain == NULL )
53 (*list)->lm_chain_tail = prev;
55 tmp->lm_chain = NULL;
57 return( tmp );
60 void
61 ldap_add_result_entry( LDAPMessage **list, LDAPMessage *e )
63 assert( list != NULL );
64 assert( e != NULL );
66 e->lm_chain = *list;
67 if ( *list )
68 e->lm_chain_tail = (*list)->lm_chain_tail;
69 else
70 e->lm_chain_tail = e;
71 *list = e;