]> git.sur5r.net Git - openldap/blob - libraries/libldap/addentry.c
C portability from HEAD
[openldap] / libraries / libldap / addentry.c
1 /*
2  *  Copyright (c) 1990 Regents of the University of Michigan.
3  *  All rights reserved.
4  *
5  *  addentry.c
6  */
7
8 #ifndef lint 
9 static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
10 #endif
11
12 #include <stdio.h>
13 #include <ctype.h>
14 #include <string.h>
15 #ifdef MACOS
16 #include <stdlib.h>
17 #include "macos.h"
18 #else /* MACOS */
19 #if defined( DOS ) || defined( _WIN32 )
20 #include <malloc.h>
21 #include "msdos.h"
22 #else /* DOS */
23 #include <sys/types.h>
24 #include <sys/socket.h>
25 #endif /* DOS */
26 #endif /* MACOS */
27
28 #include "lber.h"
29 #include "ldap.h"
30
31 LDAPMessage *
32 ldap_delete_result_entry( LDAPMessage **list, LDAPMessage *e )
33 {
34         LDAPMessage     *tmp, *prev = NULL;
35
36         for ( tmp = *list; tmp != NULL && tmp != e; tmp = tmp->lm_chain )
37                 prev = tmp;
38
39         if ( tmp == NULL )
40                 return( NULL );
41
42         if ( prev == NULL )
43                 *list = tmp->lm_chain;
44         else
45                 prev->lm_chain = tmp->lm_chain;
46         tmp->lm_chain = NULL;
47
48         return( tmp );
49 }
50
51 void
52 ldap_add_result_entry( LDAPMessage **list, LDAPMessage *e )
53 {
54         e->lm_chain = *list;
55         *list = e;
56 }