Update zoneinfo database.
[dragonfly.git] / contrib / sendmail / include / sm / ldap.h
1 /*
2  * Copyright (c) 2001-2002 Sendmail, Inc. and its suppliers.
3  *      All rights reserved.
4  *
5  * By using this file, you agree to the terms and conditions set
6  * forth in the LICENSE file which can be found at the top level of
7  * the sendmail distribution.
8  *
9  *      $Id: ldap.h,v 1.22 2002/03/05 02:17:26 ca Exp $
10  */
11
12 #ifndef SM_LDAP_H
13 # define SM_LDAP_H
14
15 # include <sm/conf.h>
16 # include <sm/rpool.h>
17
18 /*
19 **  NOTE: These should be changed from LDAPMAP_* to SM_LDAP_*
20 **        in the next major release (8.13) of sendmail.
21 */
22
23 # ifndef LDAPMAP_MAX_ATTR
24 #  define LDAPMAP_MAX_ATTR      64
25 # endif /* ! LDAPMAP_MAX_ATTR */
26 # ifndef LDAPMAP_MAX_FILTER
27 #  define LDAPMAP_MAX_FILTER    1024
28 # endif /* ! LDAPMAP_MAX_FILTER */
29 # ifndef LDAPMAP_MAX_PASSWD
30 #  define LDAPMAP_MAX_PASSWD    256
31 # endif /* ! LDAPMAP_MAX_PASSWD */
32
33 # if LDAPMAP
34
35 #  if _FFR_LDAP_RECURSION
36
37 /* Attribute types */
38 #   define SM_LDAP_ATTR_NONE            (-1)
39 #   define SM_LDAP_ATTR_OBJCLASS        0
40 #   define SM_LDAP_ATTR_NORMAL          1
41 #   define SM_LDAP_ATTR_DN              2
42 #   define SM_LDAP_ATTR_FILTER          3
43 #   define SM_LDAP_ATTR_URL             4
44
45 /* sm_ldap_results() flags */
46 #   define SM_LDAP_SINGLEMATCH  0x0001
47 #   define SM_LDAP_MATCHONLY    0x0002
48 #   define SM_LDAP_USE_ALLATTR  0x0004
49
50 #  endif /* _FFR_LDAP_RECURSION */
51
52 struct sm_ldap_struct
53 {
54         /* needed for ldap_open or ldap_init */
55         char            *ldap_target;
56         int             ldap_port;
57 #  if _FFR_LDAP_URI
58         bool            ldap_uri;
59 #  endif /* _FFR_LDAP_URI */
60 #  if _FFR_LDAP_SETVERSION
61         int             ldap_version;
62 #  endif /* _FFR_LDAP_SETVERSION */
63         pid_t           ldap_pid;
64
65         /* options set in ld struct before ldap_bind_s */
66         int             ldap_deref;
67         time_t          ldap_timelimit;
68         int             ldap_sizelimit;
69         int             ldap_options;
70
71         /* args for ldap_bind_s */
72         LDAP            *ldap_ld;
73         char            *ldap_binddn;
74         char            *ldap_secret;
75         int             ldap_method;
76
77         /* args for ldap_search */
78         char            *ldap_base;
79         int             ldap_scope;
80         char            *ldap_filter;
81         char            *ldap_attr[LDAPMAP_MAX_ATTR + 1];
82 #  if _FFR_LDAP_RECURSION
83         int             ldap_attr_type[LDAPMAP_MAX_ATTR + 1];
84         char            *ldap_attr_needobjclass[LDAPMAP_MAX_ATTR + 1];
85 #  endif /* _FFR_LDAP_RECURSION */
86         bool            ldap_attrsonly;
87
88         /* args for ldap_result */
89         struct timeval  ldap_timeout;
90         LDAPMessage     *ldap_res;
91
92         /* ldapmap_lookup options */
93         char            ldap_attrsep;
94
95         /* Linked list of maps sharing the same LDAP binding */
96         void            *ldap_next;
97 };
98
99 typedef struct sm_ldap_struct           SM_LDAP_STRUCT;
100
101 #  if _FFR_LDAP_RECURSION
102 struct sm_ldap_recurse_entry
103 {
104         char *lr_search;
105         int lr_type;
106         bool lr_done;
107 };
108
109 struct sm_ldap_recurse_list
110 {
111         int lr_size;
112         int lr_cnt;
113         struct sm_ldap_recurse_entry **lr_data;
114 };
115
116 typedef struct sm_ldap_recurse_entry    SM_LDAP_RECURSE_ENTRY;
117 typedef struct sm_ldap_recurse_list     SM_LDAP_RECURSE_LIST;
118 #  endif /* _FFR_LDAP_RECURSION */
119
120 /* functions */
121 extern void     sm_ldap_clear __P((SM_LDAP_STRUCT *));
122 extern bool     sm_ldap_start __P((char *, SM_LDAP_STRUCT *));
123 extern int      sm_ldap_search __P((SM_LDAP_STRUCT *, char *));
124 #  if _FFR_LDAP_RECURSION
125 extern int      sm_ldap_results __P((SM_LDAP_STRUCT *, int, int, int,
126                                      SM_RPOOL_T *, char **, int *, int *,
127                                      SM_LDAP_RECURSE_LIST *));
128 #  endif /* _FFR_LDAP_RECURSION */
129 extern void     sm_ldap_setopts __P((LDAP *, SM_LDAP_STRUCT *));
130 extern int      sm_ldap_geterrno __P((LDAP *));
131 extern void     sm_ldap_close __P((SM_LDAP_STRUCT *));
132
133 /* Portability defines */
134 #  if !SM_CONF_LDAP_MEMFREE
135 #   define ldap_memfree(x)      ((void) 0)
136 #  endif /* !SM_CONF_LDAP_MEMFREE */
137
138 # endif /* LDAPMAP */
139 #endif /* ! SM_LDAP_H */