2 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6 * Copyright IBM Corp. 1997,2002
7 * Use of this source code is subject to the terms of The OpenLDAP Public
8 * License (version 2.7 or later).
9 * No trademarks of the IBM Corporation are to be used to identify, endorse
10 * or promote any products derived from this code without the prior
11 * written consent of IBM
14 #ifndef _PROTO_SLAPI_H
15 #define _PROTO_SLAPI_H
23 extern int slapi_log_error( int severity, char *subsystem, char *fmt, ... );
24 extern Slapi_Entry *slapi_str2entry( char *s, int flags );
25 extern char *slapi_entry2str( Slapi_Entry *e, int *len );
26 extern int slapi_entry_attr_merge( Slapi_Entry *e, char *type, struct berval **vals );
27 extern int slapi_entry_attr_find( Slapi_Entry *e, char *type, Slapi_Attr **attr );
28 extern char *slapi_entry_attr_get_charptr( const Slapi_Entry *e, const char *type );
29 extern int slapi_entry_attr_delete( Slapi_Entry *e, char *type );
30 extern int slapi_entry_attr_get_int( const Slapi_Entry *e, const char *type );
31 extern int slapi_entry_attr_get_long( const Slapi_Entry *e, const char *type );
32 extern int slapi_entry_attr_get_uint( const Slapi_Entry *e, const char *type );
33 extern int slapi_entry_attr_get_ulong( const Slapi_Entry *e, const char *type );
34 extern int slapi_entry_attr_hasvalue( Slapi_Entry *e, const char *type, const char *value );
35 extern int slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
36 extern void slapi_entry_attr_set_charptr(Slapi_Entry* e, const char *type, const char *value);
37 extern void slapi_entry_attr_set_int( Slapi_Entry* e, const char *type, int l);
38 extern void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type, unsigned int l);
39 extern void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l);
40 extern void slapi_entry_attr_set_ulong(Slapi_Entry* e, const char *type, unsigned long l);
41 extern int slapi_is_rootdse( const char *dn );
42 extern int slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
43 extern int slapi_entry_add_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
44 extern int slapi_entry_add_valueset(Slapi_Entry *e, const char *type, Slapi_ValueSet *vs);
45 extern int slapi_entry_delete_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
46 extern int slapi_entry_merge_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
47 extern int slapi_entry_attr_replace_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
48 extern int slapi_entry_add_value(Slapi_Entry *e, const char *type, const Slapi_Value *value);
49 extern int slapi_entry_add_string(Slapi_Entry *e, const char *type, const char *value);
50 extern int slapi_entry_delete_string(Slapi_Entry *e, const char *type, const char *value);
51 extern int slapi_entry_first_attr( const Slapi_Entry *e, Slapi_Attr **attr );
52 extern int slapi_entry_next_attr( const Slapi_Entry *e, Slapi_Attr *prevattr, Slapi_Attr **attr );
53 extern char *slapi_entry_get_dn( Slapi_Entry *e );
54 extern int slapi_x_entry_get_id( Slapi_Entry *e );
55 extern void slapi_entry_set_dn( Slapi_Entry *e, char *dn );
56 extern Slapi_Entry *slapi_entry_dup( Slapi_Entry *e );
57 extern Slapi_Entry *slapi_entry_alloc();
58 extern void slapi_entry_free( Slapi_Entry *e );
59 extern int slapi_attr_get_values( Slapi_Attr *attr, struct berval ***vals );
62 extern int slapi_access_allowed( Slapi_PBlock *pb, Slapi_Entry *e, char *attr,
63 struct berval *val, int access );
64 extern int slapi_acl_check_mods( Slapi_PBlock *pb, Slapi_Entry *e, LDAPMod **mods,
66 extern Slapi_Attr *slapi_attr_new( void );
67 extern Slapi_Attr *slapi_attr_init( Slapi_Attr *a, const char *type );
68 extern void slapi_attr_free( Slapi_Attr **a );
69 extern Slapi_Attr *slapi_attr_dup( const Slapi_Attr *attr );
70 extern int slapi_attr_add_value( Slapi_Attr *a, const Slapi_Value *v );
71 extern int slapi_attr_type2plugin( const char *type, void **pi );
72 extern int slapi_attr_get_type( const Slapi_Attr *attr, char **type );
73 extern int slapi_attr_get_oid_copy( const Slapi_Attr *attr, char **oidp );
74 extern int slapi_attr_get_flags( const Slapi_Attr *attr, unsigned long *flags );
75 extern int slapi_attr_flag_is_set( const Slapi_Attr *attr, unsigned long flag );
76 extern int slapi_attr_value_cmp( const Slapi_Attr *attr, const struct berval *v1,
77 const struct berval *v2 );
78 extern int slapi_attr_value_find( const Slapi_Attr *a, struct berval *v );
80 #define SLAPI_TYPE_CMP_EXACT 0
81 #define SLAPI_TYPE_CMP_BASE 1
82 #define SLAPI_TYPE_CMP_SUBTYPE 2
84 extern int slapi_attr_type_cmp( const char *t1, const char *t2, int opt );
85 extern int slapi_attr_types_equivalent( const char *t1, const char *t2 );
86 extern int slapi_attr_first_value( Slapi_Attr *a, Slapi_Value **v );
87 extern int slapi_attr_next_value( Slapi_Attr *a, int hint, Slapi_Value **v );
88 extern int slapi_attr_get_numvalues( const Slapi_Attr *a, int *numValues );
89 extern int slapi_attr_get_valueset( const Slapi_Attr *a, Slapi_ValueSet **vs );
90 extern int slapi_attr_get_bervals_copy( Slapi_Attr *a, struct berval ***vals );
91 extern char *slapi_attr_syntax_normalize( const char *s );
93 extern Slapi_Value *slapi_value_new( void );
94 extern Slapi_Value *slapi_value_new_berval(const struct berval *bval);
95 extern Slapi_Value *slapi_value_new_value(const Slapi_Value *v);
96 extern Slapi_Value *slapi_value_new_string(const char *s);
97 extern Slapi_Value *slapi_value_init(Slapi_Value *v);
98 extern Slapi_Value *slapi_value_init_berval(Slapi_Value *v, struct berval *bval);
99 extern Slapi_Value *slapi_value_init_string(Slapi_Value *v,const char *s);
100 extern Slapi_Value *slapi_value_dup(const Slapi_Value *v);
101 extern void slapi_value_free(Slapi_Value **value);
102 extern const struct berval *slapi_value_get_berval( const Slapi_Value *value );
103 extern Slapi_Value *slapi_value_set_berval( Slapi_Value *value, const struct berval *bval );
104 extern Slapi_Value *slapi_value_set_value( Slapi_Value *value, const Slapi_Value *vfrom);
105 extern Slapi_Value *slapi_value_set( Slapi_Value *value, void *val, unsigned long len);
106 extern int slapi_value_set_string(Slapi_Value *value, const char *strVal);
107 extern int slapi_value_set_int(Slapi_Value *value, int intVal);
108 extern const char*slapi_value_get_string(const Slapi_Value *value);
109 extern int slapi_value_get_int(const Slapi_Value *value);
110 extern unsigned int slapi_value_get_uint(const Slapi_Value *value);
111 extern long slapi_value_get_long(const Slapi_Value *value);
112 extern unsigned long slapi_value_get_ulong(const Slapi_Value *value);
113 extern size_t slapi_value_get_length(const Slapi_Value *value);
114 extern int slapi_value_compare(const Slapi_Attr *a,const Slapi_Value *v1,const Slapi_Value *v2);
116 extern Slapi_ValueSet *slapi_valueset_new( void );
117 extern void slapi_valueset_free(Slapi_ValueSet *vs);
118 extern void slapi_valueset_init(Slapi_ValueSet *vs);
119 extern void slapi_valueset_done(Slapi_ValueSet *vs);
120 extern void slapi_valueset_add_value(Slapi_ValueSet *vs, const Slapi_Value *addval);
121 extern int slapi_valueset_first_value( Slapi_ValueSet *vs, Slapi_Value **v );
122 extern int slapi_valueset_next_value( Slapi_ValueSet *vs, int index, Slapi_Value **v);
123 extern int slapi_valueset_count( const Slapi_ValueSet *vs);
124 extern void slapi_valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
126 extern Slapi_Mutex *slapi_new_mutex( void );
127 extern void slapi_destroy_mutex( Slapi_Mutex *mutex );
128 extern void slapi_lock_mutex( Slapi_Mutex *mutex );
129 extern int slapi_unlock_mutex( Slapi_Mutex *mutex );
130 extern Slapi_CondVar *slapi_new_condvar( Slapi_Mutex *mutex );
131 extern void slapi_destroy_condvar( Slapi_CondVar *cvar );
132 extern int slapi_wait_condvar( Slapi_CondVar *cvar, struct timeval *timeout );
133 extern int slapi_notify_condvar( Slapi_CondVar *cvar, int notify_all );
135 extern char *slapi_ch_malloc( unsigned long size );
136 extern void slapi_ch_free( void **ptr );
137 extern void slapi_ch_free_string( char **s );
138 extern char *slapi_ch_calloc( unsigned long nelem, unsigned long size );
139 extern char *slapi_ch_realloc( char *block, unsigned long size );
140 extern char *slapi_ch_strdup( char *s );
141 extern void slapi_ch_array_free( char **arrayp );
142 extern struct berval *slapi_ch_bvdup(const struct berval *v);
143 extern struct berval **slapi_ch_bvecdup(const struct berval **v);
146 * FIXME: these two were missing, but widely used in a couple of .c files
148 extern size_t slapi_strlen(char *s );
149 #define slapi_ch_stlen(s) slapi_strlen(s)
153 extern char *slapi_dn_normalize( char *dn );
154 extern char *slapi_dn_normalize_case( char *dn );
155 extern char * slapi_esc_dn_normalize( char *dn );
156 extern char * slapi_esc_dn_normalize_case( char *dn );
157 extern int slapi_dn_isroot( Slapi_PBlock *pb, char *dn );
158 extern int slapi_dn_issuffix( char *dn, char *suffix );
159 extern char *slapi_dn_ignore_case( char *dn );
160 extern char *slapi_get_hostname();
161 extern void slapi_register_supported_saslmechanism( char *mechanism );
162 extern void slapi_send_ldap_result( Slapi_PBlock *pb, int err,
163 char *matched, char *text, int nentries, struct berval **urls );
164 extern int slapi_send_ldap_extended_response(Connection *conn, Operation *op,
165 int errornum, char *respName, struct berval *response);
166 extern int slapi_send_ldap_search_entry( Slapi_PBlock *pb, Slapi_Entry *e,
167 LDAPControl **ectrls, char **attrs, int attrsonly );
168 extern void slapi_register_supported_control(char *controloid,
169 unsigned long controlops);
170 extern int slapi_get_supported_controls(char ***ctrloidsp, unsigned long **ctrlopsp);
171 extern int slapi_control_present( LDAPControl **controls, char *oid,
172 struct berval **val, int *iscritical);
173 extern LDAPControl *slapi_dup_control(LDAPControl *control);
174 extern void slapi_register_supported_saslmechanism(char *mechanism);
175 extern char **slapi_get_supported_saslmechanisms();
176 extern char **slapi_get_supported_extended_ops(void);
177 extern int checkControlHonored(LDAPControl **controls, char *pControlOid,
178 unsigned long operation, int *isHonored );
179 extern void slapi_broadcast_be(int funcType, Slapi_PBlock *pPB);
180 extern Slapi_Filter *slapi_str2filter( char *str );
181 extern Slapi_Filter *slapi_filter_dup( Slapi_Filter *f );
182 extern void slapi_filter_free( Slapi_Filter *f, int recurse );
183 extern int slapi_filter_get_choice( Slapi_Filter *f);
184 extern int slapi_filter_get_ava( Slapi_Filter *f, char **type, struct berval **bval );
185 extern Slapi_Filter *slapi_filter_list_first( Slapi_Filter *f );
186 extern Slapi_Filter *slapi_filter_list_next( Slapi_Filter *f, Slapi_Filter *fprev );
187 extern int slapi_filter_get_attribute_type( Slapi_Filter *f, char **type );
188 extern int slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial,
189 char ***any, char **final );
190 extern Slapi_Filter *slapi_filter_join( int ftype, Slapi_Filter *f1, Slapi_Filter *f2);
191 extern int slapi_x_filter_append( int choice, Slapi_Filter **pContainingFilter,
192 Slapi_Filter **pNextFilter, Slapi_Filter *filterToAppend );
193 extern int slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
195 extern int slapi_filter_apply( Slapi_Filter *f, FILTER_APPLY_FN fn, void *arg, int *error_code );
196 extern int slapi_filter_test_simple( Slapi_Entry *e, Slapi_Filter *f);
197 extern void slapi_free_search_results_internal(Slapi_PBlock *pb);
198 extern int slapi_is_connection_ssl(Slapi_PBlock *pPB, int *isSSL);
199 extern int slapi_get_client_port(Slapi_PBlock *pPB, int *fromPort);
200 extern int slapi_get_num_be(char *type);
201 extern unsigned long slapi_timer_current_time();
202 extern unsigned long slapi_timer_get_time(char *label);
203 extern void slapi_timer_elapsed_time(char *label,unsigned long start);
204 extern int slapi_audit_init_header( Connection *conn, Operation *op,
205 Audit_record **arp, void **audit_op_str,
206 int audit_op, int audit_ext_op, int audit_op_str_len);
207 extern int slapi_audit_send_record( Slapi_PBlock *pb, Connection *conn,
208 Operation *op, int rc);
210 extern int slapi_x_pblock_set_operation( Slapi_PBlock *pb, Operation *op );
212 extern LDAPMod **slapi_x_modifications2ldapmods(Modifications **);
213 extern Modifications *slapi_x_ldapmods2modifications(LDAPMod **);
214 extern void slapi_x_free_ldapmods(LDAPMod **);
216 extern int slapi_compute_add_evaluator(slapi_compute_callback_t function);
217 extern int slapi_compute_add_search_rewriter(slapi_search_rewrite_callback_t function);
218 extern int compute_rewrite_search_filter(Slapi_PBlock *pb);
219 extern int compute_evaluator(computed_attr_context *c, char *type, Slapi_Entry *e, slapi_compute_output_t outputfn);
220 extern int slapi_x_compute_output_ber(computed_attr_context *c, Slapi_Attr *a, Slapi_Entry *e);
221 extern int slapi_x_compute_get_pblock(computed_attr_context *c, Slapi_PBlock **pb);
223 extern int slapi_x_access_allowed(Operation *op, Entry *entry, AttributeDescription *desc, struct berval *val, slap_access_t access, AccessControlState *state);
225 extern ldap_pvt_thread_mutex_t slapi_hn_mutex;
226 extern ldap_pvt_thread_mutex_t slapi_time_mutex;
227 extern ldap_pvt_thread_mutex_t slapi_printmessage_mutex;
228 extern char *slapi_log_file;
229 extern int slapi_log_level;
233 * Was: slapi_pblock.h
236 extern Slapi_PBlock *slapi_pblock_new( void );
237 extern void slapi_pblock_destroy( Slapi_PBlock* );
238 extern int slapi_pblock_get( Slapi_PBlock *pb, int arg, void *value );
239 extern int slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value );
240 extern void slapi_pblock_check_params( Slapi_PBlock *pb, int flag );
241 extern int slapi_pblock_delete_param( Slapi_PBlock *p, int param );
242 extern void slapi_pblock_clear( Slapi_PBlock *pb );
245 * OpenLDAP extensions
247 extern int slapi_x_pblock_get_first( Backend *be, Slapi_PBlock **pb );
248 extern int slapi_x_pblock_get_next( Slapi_PBlock **pb );
255 extern Slapi_PBlock *newPlugin ( int type, const char *path, const char *initfunc,
256 int argc, char *argv[] );
257 extern int insertPlugin(Backend *be, Slapi_PBlock *pPB);
258 extern int doPluginFNs(Backend *be, int funcType, Slapi_PBlock * pPB);
259 extern int getAllPluginFuncs(Backend *be, int functype, SLAPI_FUNC **ppFuncPtrs);
260 extern int newExtendedOp(Backend *pBE, ExtendedOp **opList, Slapi_PBlock *pPB);
261 extern int getPluginFunc(struct berval *reqoid, SLAPI_FUNC *pFuncAddr );
262 extern int netscape_plugin(Backend *be, const char *fname, int lineno,
263 int argc, char **argv );
264 extern int slapi_init(void);
271 extern Slapi_PBlock *slapi_search_internal( char *base, int scope, char *filter,
272 LDAPControl **controls, char **attrs, int attrsonly );
273 extern Slapi_PBlock *slapi_search_internal_bind( char *bindDN, char *base,
274 int scope, char *filter, LDAPControl **controls,
275 char **attrs, int attrsonly ); /* d58508 */
276 extern Slapi_PBlock *slapi_modify_internal( char *dn, LDAPMod **mods,
277 LDAPControl **controls, int log_change );
278 extern Slapi_PBlock *slapi_add_entry_internal( Slapi_Entry * e,
279 LDAPControl **controls, int log_change );
280 extern Slapi_PBlock *slapi_add_internal( char * dn, LDAPMod **attrs,
281 LDAPControl **controls, int log_changes );
282 extern Slapi_PBlock *slapi_add_entry_internal( Slapi_Entry * e,
283 LDAPControl **controls, int log_change );
284 extern Slapi_PBlock *slapi_delete_internal( char * dn, LDAPControl **controls,
286 extern Slapi_PBlock *slapi_modrdn_internal( char * olddn, char * newrdn,
287 int deloldrdn, LDAPControl **controls, int log_change);
289 extern Slapi_PBlock *slapi_modrdn_internal( char * olddn, char * newrdn,
290 char *newParent, int deloldrdn, LDAPControl **controls,
293 extern char **slapi_get_supported_extended_ops(void);
294 extern int duplicateBVMod( LDAPMod *pMod, LDAPMod **ppNewMod );
301 extern void slapi_register_changelog_suffix(char *suffix);
302 extern char **slapi_get_changelog_suffixes();
303 extern void slapi_update_changelog_counters(long curNum, long numEntries);
304 extern char *slapi_get_cl_firstNum();
305 extern char *slapi_get_cl_lastNum();
306 extern int slapi_add_to_changelog(Slapi_Entry *ent, char *suffix,
307 char *chNum, Operation* op);
308 extern int slapi_delete_changelog(char *dn, char *suffix,
309 char *chNum, Operation* op);
310 extern int slapi_modify_changelog(char *dn, LDAPMod *mods,char *suffix,
311 char *chNum, Operation* op);
312 extern int slapi_modifyrdn_changelog(char *olddn, char *newRdn, int delRdn,
313 char *suffix, char *chNum, Operation* op);
314 extern Backend * slapi_cl_get_be(char *dn);
316 int slapi_x_init_object_extensions(void);
317 int slapi_x_free_object_extensions(int objecttype, void *object);
318 int slapi_x_create_object_extensions(int objecttype, void *object);
319 int slapi_x_clear_object_extensions(int objecttype, void *object);
323 #endif /* _PROTO_SLAPI_H */