]> git.sur5r.net Git - openldap/blob - servers/slapd/overlays/rwm.h
multiple precision with BIGNUM/gmp/ulong
[openldap] / servers / slapd / overlays / rwm.h
1 /* rwm.h - dn rewrite/attribute mapping header file */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 1999-2004 The OpenLDAP Foundation.
6  * Portions Copyright 1999-2003 Howard Chu.
7  * Portions Copyright 2000-2003 Pierangelo Masarati.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted only as authorized by the OpenLDAP
12  * Public License.
13  *
14  * A copy of this license is available in the file LICENSE in the
15  * top-level directory of the distribution or, alternatively, at
16  * <http://www.OpenLDAP.org/license.html>.
17  */
18 /* ACKNOWLEDGEMENTS:
19  * This work was initially developed by the Howard Chu for inclusion
20  * in OpenLDAP Software and subsequently enhanced by Pierangelo
21  * Masarati.
22  */
23
24 #ifndef RWM_H
25 #define RWM_H
26
27 /* String rewrite library */
28 #ifdef ENABLE_REWRITE
29 #include "rewrite.h"
30 #endif /* ENABLE_REWRITE */
31
32 LDAP_BEGIN_DECL
33
34 struct ldapmap {
35         int drop_missing;
36
37         Avlnode *map;
38         Avlnode *remap;
39 };
40
41 struct ldapmapping {
42         int                     m_flags;
43 #define RWMMAP_F_NONE           0x00
44 #define RWMMAP_F_IS_OC          0x01
45 #define RWMMAP_F_FREE_SRC       0x10
46 #define RWMMAP_F_FREE_DST       0x20
47         struct berval           m_src;
48         union {
49                 AttributeDescription    *m_s_ad;
50                 ObjectClass             *m_s_oc;
51         } m_src_ref;
52 #define m_src_ad        m_src_ref.m_s_ad
53 #define m_src_oc        m_src_ref.m_s_oc
54         struct berval           m_dst;
55         union {
56                 AttributeDescription    *m_d_ad;
57                 ObjectClass             *m_d_oc;
58         } m_dst_ref;
59 #define m_dst_ad        m_dst_ref.m_d_ad
60 #define m_dst_oc        m_dst_ref.m_d_oc
61 };
62
63 struct ldaprwmap {
64         /*
65          * DN rewriting
66          */
67 #ifdef ENABLE_REWRITE
68         struct rewrite_info *rwm_rw;
69 #else /* !ENABLE_REWRITE */
70         /* some time the suffix massaging without librewrite
71          * will be disabled */
72         BerVarray rwm_suffix_massage;
73 #endif /* !ENABLE_REWRITE */
74
75         /*
76          * Attribute/objectClass mapping
77          */
78         struct ldapmap rwm_oc;
79         struct ldapmap rwm_at;
80 };
81
82 /* Whatever context ldap_back_dn_massage needs... */
83 typedef struct dncookie {
84         struct ldaprwmap *rwmap;
85
86 #ifdef ENABLE_REWRITE
87         Connection *conn;
88         char *ctx;
89         SlapReply *rs;
90 #else
91         int normalized;
92         int tofrom;
93 #endif
94 } dncookie;
95
96 int rwm_dn_massage( dncookie *dc, struct berval *in,
97         struct berval *dn, struct berval *ndn );
98
99 /* attributeType/objectClass mapping */
100 int rwm_mapping_cmp (const void *, const void *);
101 int rwm_mapping_dup (void *, void *);
102
103 int rwm_map_init ( struct ldapmap *lm, struct ldapmapping ** );
104 void rwm_map ( struct ldapmap *map, struct berval *s, struct berval *m,
105         int remap );
106 int rwm_mapping ( struct ldapmap *map, struct berval *s,
107                 struct ldapmapping **m, int remap );
108 #define RWM_MAP 0
109 #define RWM_REMAP       1
110 char *
111 rwm_map_filter(
112                 struct ldapmap *at_map,
113                 struct ldapmap *oc_map,
114                 struct berval *f );
115
116 int
117 rwm_map_attrs(
118                 struct ldapmap *at_map,
119                 AttributeName *a,
120                 int remap,
121                 char ***mapped_attrs );
122
123 int
124 rwm_map_attrnames(
125                 struct ldapmap *at_map,
126                 struct ldapmap *oc_map,
127                 AttributeName *an,
128                 AttributeName **anp,
129                 int remap );
130
131 extern void rwm_mapping_free ( void *mapping );
132
133 extern int rwm_map_config(
134                 struct ldapmap  *oc_map,
135                 struct ldapmap  *at_map,
136                 const char      *fname,
137                 int             lineno,
138                 int             argc,
139                 char            **argv );
140
141 extern int
142 rwm_filter_map_rewrite(
143                 dncookie                *dc,
144                 Filter                  *f,
145                 struct berval           *fstr );
146
147 /* suffix massaging by means of librewrite */
148 #ifdef ENABLE_REWRITE
149 extern int rwm_suffix_massage_config( struct rewrite_info *info,
150                 struct berval *pvnc, struct berval *nvnc,
151                 struct berval *prnc, struct berval *nrnc);
152 #endif /* ENABLE_REWRITE */
153 extern int rwm_dnattr_rewrite(
154         Operation               *op,
155         SlapReply               *rs,
156         void                    *cookie,
157         BerVarray               a_vals,
158         BerVarray               *pa_nvals );
159 extern int rwm_referral_rewrite(
160         Operation               *op,
161         SlapReply               *rs,
162         void                    *cookie,
163         BerVarray               a_vals,
164         BerVarray               *pa_nvals );
165 extern int rwm_dnattr_result_rewrite( dncookie *dc, BerVarray a_vals );
166 extern int rwm_referral_result_rewrite( dncookie *dc, BerVarray a_vals );
167
168 LDAP_END_DECL
169
170 #endif /* RWM_H */