1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 2002-2021 The OpenLDAP Foundation.
5  * Portions Copyright 1997,2002-2003 IBM Corporation.
6  * All rights reserved.
7  *
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.
11  *
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>.
15  */
16 /* ACKNOWLEDGEMENTS:
17  * This work was initially developed by IBM Corporation for use in
18  * IBM products and subsequently ported to OpenLDAP Software by
19  * Steve Omrani.  Additional significant contributors include:
20  *   Luke Howard
21  */
22 
23 #ifdef LDAP_SLAPI /* SLAPI is OPTIONAL */
24 
25 #ifndef _SLAPI_H
26 #define _SLAPI_H
27 
28 LDAP_BEGIN_DECL
29 
30 /*
31  * Quick 'n' dirty to make struct slapi_* in slapi-plugin.h opaque
32  */
33 #define slapi_entry	Entry
34 #define slapi_attr	Attribute
35 #define slapi_value	berval
36 #define slapi_valueset	berval *
37 #define slapi_filter	Filter
38 
39 LDAP_END_DECL
40 
41 #include <slapi-plugin.h>
42 
43 LDAP_BEGIN_DECL
44 
45 #define SLAPI_OVERLAY_NAME			"slapi"
46 
47 #define SLAPI_OPERATION_PBLOCK(_op)		((_op)->o_callback->sc_private)
48 #define SLAPI_BACKEND_PBLOCK(_be)		((_be)->be_pb)
49 
50 #define SLAPI_OPERATION_EXTENSIONS(_op)		((_op)->o_hdr->oh_extensions)
51 #define SLAPI_CONNECTION_EXTENSIONS(_conn)	((_conn)->c_extensions)
52 
53 #define SLAPI_CONTROL_MANAGEDSAIT_OID		LDAP_CONTROL_MANAGEDSAIT
54 #define SLAPI_CONTROL_SORTEDSEARCH_OID		LDAP_CONTROL_SORTREQUEST
55 #define SLAPI_CONTROL_PAGED_RESULTS_OID		LDAP_CONTROL_PAGEDRESULTS
56 
57 typedef int (*SLAPI_FUNC)( Slapi_PBlock *pb );
58 
59 typedef struct _slapi_control {
60         int			s_ctrl_num;
61         char			**s_ctrl_oids;
62         unsigned long		*s_ctrl_ops;
63 } Slapi_Control;
64 
65 typedef struct _ExtendedOp {
66 	struct berval		ext_oid;
67         SLAPI_FUNC		ext_func;
68         Backend			*ext_be;
69         struct _ExtendedOp	*ext_next;
70 } ExtendedOp;
71 
72 /* Computed attribute support */
73 struct _computed_attr_context {
74 	Slapi_PBlock	*cac_pb;
75 	Operation	*cac_op;
76 	void		*cac_private;
77 };
78 
79 /* for slapi_attr_type_cmp() */
80 #define SLAPI_TYPE_CMP_EXACT	0
81 #define SLAPI_TYPE_CMP_BASE	1
82 #define SLAPI_TYPE_CMP_SUBTYPE	2
83 
84 typedef enum slapi_extension_e {
85 	SLAPI_X_EXT_CONNECTION = 0,
86 	SLAPI_X_EXT_OPERATION = 1,
87 	SLAPI_X_EXT_MAX = 2
88 } slapi_extension_t;
89 
90 struct slapi_dn {
91 	unsigned char flag;
92 	struct berval dn;
93 	struct berval ndn;
94 };
95 
96 struct slapi_rdn {
97 	unsigned char flag;
98 	struct berval bv;
99 	LDAPRDN rdn;
100 };
101 
102 /*
103  * Was: slapi_pblock.h
104  */
105 
106 #ifndef NO_PBLOCK_CLASS		/* where's this test from? */
107 
108 typedef enum slapi_pblock_class_e {
109 	PBLOCK_CLASS_INVALID = 0,
110 	PBLOCK_CLASS_INTEGER,
111 	PBLOCK_CLASS_LONG_INTEGER,
112 	PBLOCK_CLASS_POINTER,
113 	PBLOCK_CLASS_FUNCTION_POINTER
114 } slapi_pblock_class_t;
115 
116 #define PBLOCK_SUCCESS			(0)
117 #define PBLOCK_ERROR			(-1)
118 #define PBLOCK_MAX_PARAMS		100
119 
120 union slapi_pblock_value {
121 	int pv_integer;
122 	long pv_long_integer;
123 	void *pv_pointer;
124 	int (*pv_function_pointer)();
125 };
126 
127 struct slapi_pblock {
128 	ldap_pvt_thread_mutex_t	pb_mutex;
129 	int			pb_nParams;
130 	int			pb_params[PBLOCK_MAX_PARAMS];
131 	union slapi_pblock_value pb_values[PBLOCK_MAX_PARAMS];
132 	/* native types */
133 	Connection		*pb_conn;
134 	Operation		*pb_op;
135 	SlapReply		*pb_rs;
136 	int			pb_intop;
137 	char			pb_textbuf[ SLAP_TEXT_BUFLEN ];
138 };
139 
140 #endif /* !NO_PBLOCK_CLASS */
141 
142 /*
143  * Was: plugin.h
144  */
145 
146 #define SLAPI_PLUGIN_IS_POST_FN(x) ((x) >= SLAPI_PLUGIN_POST_BIND_FN && (x) <= SLAPI_PLUGIN_BE_POST_DELETE_FN)
147 
148 #define SLAPI_IBM_PBLOCK			-3
149 
150 #define	SLAPI_ENTRY_PRE_OP			52
151 #define	SLAPI_ENTRY_POST_OP			53
152 
153 /* This is the spelling in the SunOne 5.2 docs */
154 #define	SLAPI_RES_CONTROLS	SLAPI_RESCONTROLS
155 
156 #define SLAPI_ABANDON_MSGID			120
157 
158 #define SLAPI_OPERATION_PARAMETERS		138
159 
160 #define SLAPI_SEQ_TYPE				150
161 #define SLAPI_SEQ_ATTRNAME			151
162 #define SLAPI_SEQ_VAL				152
163 
164 #define SLAPI_MR_FILTER_ENTRY			170
165 #define SLAPI_MR_FILTER_TYPE			171
166 #define SLAPI_MR_FILTER_VALUE			172
167 #define SLAPI_MR_FILTER_OID			173
168 #define SLAPI_MR_FILTER_DNATTRS			174
169 
170 #define SLAPI_LDIF2DB_FILE			180
171 #define SLAPI_LDIF2DB_REMOVEDUPVALS		185
172 
173 #define SLAPI_DB2LDIF_PRINTKEY			183
174 
175 #define	SLAPI_CHANGENUMBER			197
176 #define	SLAPI_LOG_OPERATION			198
177 
178 #define SLAPI_DBSIZE				199
179 
180 #define	SLAPI_PLUGIN_DB_TEST_FN			227
181 #define SLAPI_PLUGIN_DB_NO_ACL        		250
182 
183 /* OpenLDAP private parameters */
184 #define SLAPI_PLUGIN_COMPUTE_EVALUATOR_FN	1200
185 #define SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN	1201
186 
187 #define SLAPI_X_CONFIG_ARGV			1400
188 #define SLAPI_X_INTOP_FLAGS			1401
189 #define SLAPI_X_INTOP_RESULT_CALLBACK		1402
190 #define SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK	1403
191 #define SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK	1404
192 #define SLAPI_X_INTOP_CALLBACK_DATA		1405
193 #define SLAPI_X_OLD_RESCONTROLS			1406
194 
195 LDAP_SLAPI_V (ldap_pvt_thread_mutex_t)	slapi_hn_mutex;
196 LDAP_SLAPI_V (ldap_pvt_thread_mutex_t)	slapi_time_mutex;
197 LDAP_SLAPI_V (ldap_pvt_thread_mutex_t)	slapi_printmessage_mutex;
198 LDAP_SLAPI_V (char *)			slapi_log_file;
199 LDAP_SLAPI_V (int)			slapi_log_level;
200 
201 #include "proto-slapi.h"
202 
203 #endif /* _SLAPI_H */
204 #endif /* LDAP_SLAPI */
205