2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 2002-2004 The OpenLDAP Foundation.
5 * Portions Copyright 1997,2002-2003 IBM Corporation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
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>.
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:
23 #ifndef _PROTO_SLAPI_H
24 #define _PROTO_SLAPI_H
32 extern int slapi_log_error( int severity, char *subsystem, char *fmt, ... );
33 extern Slapi_Entry *slapi_str2entry( char *s, int flags );
34 extern char *slapi_entry2str( Slapi_Entry *e, int *len );
35 extern int slapi_entry_attr_merge( Slapi_Entry *e, char *type, struct berval **vals );
36 extern int slapi_entry_attr_find( Slapi_Entry *e, char *type, Slapi_Attr **attr );
37 extern char *slapi_entry_attr_get_charptr( const Slapi_Entry *e, const char *type );
38 extern int slapi_entry_attr_delete( Slapi_Entry *e, char *type );
39 extern int slapi_entry_attr_get_int( const Slapi_Entry *e, const char *type );
40 extern long slapi_entry_attr_get_long( const Slapi_Entry *e, const char *type );
41 extern unsigned int slapi_entry_attr_get_uint( const Slapi_Entry *e, const char *type );
42 extern unsigned long slapi_entry_attr_get_ulong( const Slapi_Entry *e, const char *type );
43 extern int slapi_entry_attr_hasvalue( Slapi_Entry *e, const char *type, const char *value );
44 extern int slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
45 extern void slapi_entry_attr_set_charptr(Slapi_Entry* e, const char *type, const char *value);
46 extern void slapi_entry_attr_set_int( Slapi_Entry* e, const char *type, int l);
47 extern void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type, unsigned int l);
48 extern void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l);
49 extern void slapi_entry_attr_set_ulong(Slapi_Entry* e, const char *type, unsigned long l);
50 extern int slapi_is_rootdse( const char *dn );
51 extern int slapi_entry_has_children(const Slapi_Entry *e);
52 size_t slapi_entry_size(Slapi_Entry *e);
53 extern int slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
54 extern int slapi_entry_add_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
55 extern int slapi_entry_add_valueset(Slapi_Entry *e, const char *type, Slapi_ValueSet *vs);
56 extern int slapi_entry_delete_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
57 extern int slapi_entry_merge_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
58 extern int slapi_entry_attr_replace_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
59 extern int slapi_entry_add_value(Slapi_Entry *e, const char *type, const Slapi_Value *value);
60 extern int slapi_entry_add_string(Slapi_Entry *e, const char *type, const char *value);
61 extern int slapi_entry_delete_string(Slapi_Entry *e, const char *type, const char *value);
62 extern int slapi_entry_first_attr( const Slapi_Entry *e, Slapi_Attr **attr );
63 extern int slapi_entry_next_attr( const Slapi_Entry *e, Slapi_Attr *prevattr, Slapi_Attr **attr );
64 extern const char *slapi_entry_get_uniqueid( const Slapi_Entry *e );
65 extern void slapi_entry_set_uniqueid( Slapi_Entry *e, char *uniqueid );
66 extern int slapi_entry_schema_check( Slapi_PBlock *pb, Slapi_Entry *e );
67 extern int slapi_entry_rdn_values_present( const Slapi_Entry *e );
68 extern int slapi_entry_add_rdn_values( Slapi_Entry *e );
70 extern char *slapi_entry_get_dn( Slapi_Entry *e );
71 extern int slapi_x_entry_get_id( Slapi_Entry *e );
72 extern void slapi_entry_set_dn( Slapi_Entry *e, char *dn );
73 extern Slapi_Entry *slapi_entry_dup( Slapi_Entry *e );
74 extern Slapi_Entry *slapi_entry_alloc();
75 extern void slapi_entry_free( Slapi_Entry *e );
76 extern int slapi_attr_get_values( Slapi_Attr *attr, struct berval ***vals );
79 extern int slapi_access_allowed( Slapi_PBlock *pb, Slapi_Entry *e, char *attr,
80 struct berval *val, int access );
81 extern int slapi_acl_check_mods( Slapi_PBlock *pb, Slapi_Entry *e, LDAPMod **mods,
83 extern Slapi_Attr *slapi_attr_new( void );
84 extern Slapi_Attr *slapi_attr_init( Slapi_Attr *a, const char *type );
85 extern void slapi_attr_free( Slapi_Attr **a );
86 extern Slapi_Attr *slapi_attr_dup( const Slapi_Attr *attr );
87 extern int slapi_attr_add_value( Slapi_Attr *a, const Slapi_Value *v );
88 extern int slapi_attr_type2plugin( const char *type, void **pi );
89 extern int slapi_attr_get_type( const Slapi_Attr *attr, char **type );
90 extern int slapi_attr_get_oid_copy( const Slapi_Attr *attr, char **oidp );
91 extern int slapi_attr_get_flags( const Slapi_Attr *attr, unsigned long *flags );
92 extern int slapi_attr_flag_is_set( const Slapi_Attr *attr, unsigned long flag );
93 extern int slapi_attr_value_cmp( const Slapi_Attr *attr, const struct berval *v1,
94 const struct berval *v2 );
95 extern int slapi_attr_value_find( const Slapi_Attr *a, struct berval *v );
97 #define SLAPI_TYPE_CMP_EXACT 0
98 #define SLAPI_TYPE_CMP_BASE 1
99 #define SLAPI_TYPE_CMP_SUBTYPE 2
101 extern int slapi_attr_type_cmp( const char *t1, const char *t2, int opt );
102 extern int slapi_attr_types_equivalent( const char *t1, const char *t2 );
103 extern int slapi_attr_first_value( Slapi_Attr *a, Slapi_Value **v );
104 extern int slapi_attr_next_value( Slapi_Attr *a, int hint, Slapi_Value **v );
105 extern int slapi_attr_get_numvalues( const Slapi_Attr *a, int *numValues );
106 extern int slapi_attr_get_valueset( const Slapi_Attr *a, Slapi_ValueSet **vs );
107 extern int slapi_attr_get_bervals_copy( Slapi_Attr *a, struct berval ***vals );
108 extern char *slapi_attr_syntax_normalize( const char *s );
110 extern Slapi_Value *slapi_value_new( void );
111 extern Slapi_Value *slapi_value_new_berval(const struct berval *bval);
112 extern Slapi_Value *slapi_value_new_value(const Slapi_Value *v);
113 extern Slapi_Value *slapi_value_new_string(const char *s);
114 extern Slapi_Value *slapi_value_init(Slapi_Value *v);
115 extern Slapi_Value *slapi_value_init_berval(Slapi_Value *v, struct berval *bval);
116 extern Slapi_Value *slapi_value_init_string(Slapi_Value *v,const char *s);
117 extern Slapi_Value *slapi_value_dup(const Slapi_Value *v);
118 extern void slapi_value_free(Slapi_Value **value);
119 extern const struct berval *slapi_value_get_berval( const Slapi_Value *value );
120 extern Slapi_Value *slapi_value_set_berval( Slapi_Value *value, const struct berval *bval );
121 extern Slapi_Value *slapi_value_set_value( Slapi_Value *value, const Slapi_Value *vfrom);
122 extern Slapi_Value *slapi_value_set( Slapi_Value *value, void *val, unsigned long len);
123 extern int slapi_value_set_string(Slapi_Value *value, const char *strVal);
124 extern int slapi_value_set_int(Slapi_Value *value, int intVal);
125 extern const char*slapi_value_get_string(const Slapi_Value *value);
126 extern int slapi_value_get_int(const Slapi_Value *value);
127 extern unsigned int slapi_value_get_uint(const Slapi_Value *value);
128 extern long slapi_value_get_long(const Slapi_Value *value);
129 extern unsigned long slapi_value_get_ulong(const Slapi_Value *value);
130 extern size_t slapi_value_get_length(const Slapi_Value *value);
131 extern int slapi_value_compare(const Slapi_Attr *a,const Slapi_Value *v1,const Slapi_Value *v2);
133 extern Slapi_ValueSet *slapi_valueset_new( void );
134 extern void slapi_valueset_free(Slapi_ValueSet *vs);
135 extern void slapi_valueset_init(Slapi_ValueSet *vs);
136 extern void slapi_valueset_done(Slapi_ValueSet *vs);
137 extern void slapi_valueset_add_value(Slapi_ValueSet *vs, const Slapi_Value *addval);
138 extern int slapi_valueset_first_value( Slapi_ValueSet *vs, Slapi_Value **v );
139 extern int slapi_valueset_next_value( Slapi_ValueSet *vs, int index, Slapi_Value **v);
140 extern int slapi_valueset_count( const Slapi_ValueSet *vs);
141 extern void slapi_valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
143 extern Slapi_Mutex *slapi_new_mutex( void );
144 extern void slapi_destroy_mutex( Slapi_Mutex *mutex );
145 extern void slapi_lock_mutex( Slapi_Mutex *mutex );
146 extern int slapi_unlock_mutex( Slapi_Mutex *mutex );
147 extern Slapi_CondVar *slapi_new_condvar( Slapi_Mutex *mutex );
148 extern void slapi_destroy_condvar( Slapi_CondVar *cvar );
149 extern int slapi_wait_condvar( Slapi_CondVar *cvar, struct timeval *timeout );
150 extern int slapi_notify_condvar( Slapi_CondVar *cvar, int notify_all );
152 extern LDAP *slapi_ldap_init( char *ldaphost, int ldapport, int secure, int shared );
153 extern void slapi_ldap_unbind( LDAP *ld );
155 extern char *slapi_ch_malloc( unsigned long size );
156 extern void slapi_ch_free( void **ptr );
157 extern void slapi_ch_free_string( char **s );
158 extern char *slapi_ch_calloc( unsigned long nelem, unsigned long size );
159 extern char *slapi_ch_realloc( char *block, unsigned long size );
160 extern char *slapi_ch_strdup( char *s );
161 extern void slapi_ch_array_free( char **arrayp );
162 extern struct berval *slapi_ch_bvdup(const struct berval *v);
163 extern struct berval **slapi_ch_bvecdup(const struct berval **v);
166 * FIXME: these two were missing, but widely used in a couple of .c files
168 extern size_t slapi_strlen(char *s );
169 #define slapi_ch_stlen(s) slapi_strlen(s)
173 extern char *slapi_dn_normalize( char *dn );
174 extern char *slapi_dn_normalize_case( char *dn );
175 extern char * slapi_esc_dn_normalize( char *dn );
176 extern char * slapi_esc_dn_normalize_case( char *dn );
177 extern int slapi_dn_isroot( Slapi_PBlock *pb, char *dn );
178 extern int slapi_dn_issuffix( char *dn, char *suffix );
179 char *slapi_dn_beparent( Slapi_PBlock *pb, const char *dn );
180 char *slapi_dn_parent( const char *dn );
181 int slapi_dn_isparent( const char *parentdn, const char *childdn );
182 extern char *slapi_dn_ignore_case( char *dn );
183 extern char *slapi_get_hostname();
184 extern void slapi_register_supported_saslmechanism( char *mechanism );
185 extern void slapi_send_ldap_result( Slapi_PBlock *pb, int err,
186 char *matched, char *text, int nentries, struct berval **urls );
187 extern int slapi_send_ldap_extended_response(Connection *conn, Operation *op,
188 int errornum, char *respName, struct berval *response);
189 extern int slapi_send_ldap_search_entry( Slapi_PBlock *pb, Slapi_Entry *e,
190 LDAPControl **ectrls, char **attrs, int attrsonly );
191 extern int slapi_send_ldap_search_reference( Slapi_PBlock *pb, Slapi_Entry *e,
192 struct berval **references, LDAPControl **ectrls, struct berval **v2refs );
194 extern void slapi_register_supported_control(char *controloid,
195 unsigned long controlops);
196 extern int slapi_get_supported_controls(char ***ctrloidsp, unsigned long **ctrlopsp);
197 extern int slapi_control_present( LDAPControl **controls, char *oid,
198 struct berval **val, int *iscritical);
199 extern LDAPControl *slapi_dup_control(LDAPControl *control);
200 extern void slapi_register_supported_saslmechanism(char *mechanism);
201 extern char **slapi_get_supported_saslmechanisms();
202 extern char **slapi_get_supported_extended_ops(void);
203 extern int checkControlHonored(LDAPControl **controls, char *pControlOid,
204 unsigned long operation, int *isHonored );
205 extern void slapi_broadcast_be(int funcType, Slapi_PBlock *pPB);
206 extern Slapi_Filter *slapi_str2filter( char *str );
207 extern Slapi_Filter *slapi_filter_dup( Slapi_Filter *f );
208 extern void slapi_filter_free( Slapi_Filter *f, int recurse );
209 extern int slapi_filter_get_choice( Slapi_Filter *f);
210 extern int slapi_filter_get_ava( Slapi_Filter *f, char **type, struct berval **bval );
211 extern Slapi_Filter *slapi_filter_list_first( Slapi_Filter *f );
212 extern Slapi_Filter *slapi_filter_list_next( Slapi_Filter *f, Slapi_Filter *fprev );
213 extern int slapi_filter_get_attribute_type( Slapi_Filter *f, char **type );
214 extern int slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial,
215 char ***any, char **final );
216 extern Slapi_Filter *slapi_filter_join( int ftype, Slapi_Filter *f1, Slapi_Filter *f2);
217 extern int slapi_x_filter_append( int choice, Slapi_Filter **pContainingFilter,
218 Slapi_Filter **pNextFilter, Slapi_Filter *filterToAppend );
219 extern int slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
221 extern int slapi_filter_apply( Slapi_Filter *f, FILTER_APPLY_FN fn, void *arg, int *error_code );
222 extern int slapi_filter_test_simple( Slapi_Entry *e, Slapi_Filter *f);
223 extern void slapi_free_search_results_internal(Slapi_PBlock *pb);
224 extern int slapi_is_connection_ssl(Slapi_PBlock *pPB, int *isSSL);
225 extern int slapi_get_client_port(Slapi_PBlock *pPB, int *fromPort);
226 extern int slapi_get_num_be(char *type);
227 extern unsigned long slapi_timer_current_time();
228 extern unsigned long slapi_timer_get_time(char *label);
229 extern void slapi_timer_elapsed_time(char *label,unsigned long start);
230 extern int slapi_audit_init_header( Connection *conn, Operation *op,
231 Audit_record **arp, void **audit_op_str,
232 int audit_op, int audit_ext_op, int audit_op_str_len);
233 extern int slapi_audit_send_record( Slapi_PBlock *pb, Connection *conn,
234 Operation *op, int rc);
236 extern int slapi_int_pblock_set_operation( Slapi_PBlock *pb, Operation *op );
238 extern LDAPMod **slapi_int_modifications2ldapmods(Modifications **);
239 extern Modifications *slapi_int_ldapmods2modifications(LDAPMod **);
240 extern void slapi_int_free_ldapmods(LDAPMod **);
242 extern int slapi_compute_add_evaluator(slapi_compute_callback_t function);
243 extern int slapi_compute_add_search_rewriter(slapi_search_rewrite_callback_t function);
244 extern int compute_rewrite_search_filter(Slapi_PBlock *pb);
245 extern int compute_evaluator(computed_attr_context *c, char *type, Slapi_Entry *e, slapi_compute_output_t outputfn);
246 extern int slapi_int_compute_output_ber(computed_attr_context *c, Slapi_Attr *a, Slapi_Entry *e);
247 extern int slapi_x_compute_get_pblock(computed_attr_context *c, Slapi_PBlock **pb);
249 extern int slapi_int_access_allowed(Operation *op, Entry *entry, AttributeDescription *desc, struct berval *val, slap_access_t access, AccessControlState *state);
251 extern ldap_pvt_thread_mutex_t slapi_hn_mutex;
252 extern ldap_pvt_thread_mutex_t slapi_time_mutex;
253 extern ldap_pvt_thread_mutex_t slapi_printmessage_mutex;
254 extern char *slapi_log_file;
255 extern int slapi_log_level;
259 * Was: slapi_pblock.h
262 extern Slapi_PBlock *slapi_pblock_new( void );
263 extern void slapi_pblock_destroy( Slapi_PBlock* );
264 extern int slapi_pblock_get( Slapi_PBlock *pb, int arg, void *value );
265 extern int slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value );
266 extern void slapi_pblock_check_params( Slapi_PBlock *pb, int flag );
267 extern int slapi_pblock_delete_param( Slapi_PBlock *p, int param );
268 extern void slapi_pblock_clear( Slapi_PBlock *pb );
271 * OpenLDAP extensions
273 extern int slapi_int_pblock_get_first( Backend *be, Slapi_PBlock **pb );
274 extern int slapi_int_pblock_get_next( Slapi_PBlock **pb );
281 extern int slapi_int_register_plugin(Backend *be, Slapi_PBlock *pPB);
282 extern int slapi_int_call_plugins(Backend *be, int funcType, Slapi_PBlock * pPB);
283 extern int slapi_int_get_plugins(Backend *be, int functype, SLAPI_FUNC **ppFuncPtrs);
284 extern int slapi_int_register_extop(Backend *pBE, ExtendedOp **opList, Slapi_PBlock *pPB);
285 extern int slapi_int_get_extop_plugin(struct berval *reqoid, SLAPI_FUNC *pFuncAddr );
286 extern int slapi_int_read_config(Backend *be, const char *fname, int lineno,
287 int argc, char **argv );
288 extern int slapi_int_initialize(void);
295 extern Slapi_PBlock *slapi_search_internal( char *base, int scope, char *filter,
296 LDAPControl **controls, char **attrs, int attrsonly );
297 extern Slapi_PBlock *slapi_modify_internal( char *dn, LDAPMod **mods,
298 LDAPControl **controls, int log_change );
299 extern Slapi_PBlock *slapi_add_entry_internal( Slapi_Entry * e,
300 LDAPControl **controls, int log_change );
301 extern Slapi_PBlock *slapi_add_internal( char * dn, LDAPMod **attrs,
302 LDAPControl **controls, int log_changes );
303 extern Slapi_PBlock *slapi_add_entry_internal( Slapi_Entry * e,
304 LDAPControl **controls, int log_change );
305 extern Slapi_PBlock *slapi_delete_internal( char * dn, LDAPControl **controls,
307 extern Slapi_PBlock *slapi_modrdn_internal( char * olddn, char * newrdn,
308 int deloldrdn, LDAPControl **controls, int log_change);
309 extern char **slapi_get_supported_extended_ops(void);
310 extern struct berval *slapi_int_get_supported_extop( int );
311 extern Connection *slapi_int_init_connection(char *DN, int OpType);
312 extern void slapi_int_connection_destroy( Connection **pConn );
318 extern void slapi_register_changelog_suffix(char *suffix);
319 extern char **slapi_get_changelog_suffixes();
320 extern void slapi_update_changelog_counters(long curNum, long numEntries);
321 extern char *slapi_get_cl_firstNum();
322 extern char *slapi_get_cl_lastNum();
323 extern int slapi_add_to_changelog(Slapi_Entry *ent, char *suffix,
324 char *chNum, Operation* op);
325 extern int slapi_delete_changelog(char *dn, char *suffix,
326 char *chNum, Operation* op);
327 extern int slapi_modify_changelog(char *dn, LDAPMod *mods,char *suffix,
328 char *chNum, Operation* op);
329 extern int slapi_modifyrdn_changelog(char *olddn, char *newRdn, int delRdn,
330 char *suffix, char *chNum, Operation* op);
331 extern Backend * slapi_cl_get_be(char *dn);
333 int slapi_int_init_object_extensions(void);
334 int slapi_int_free_object_extensions(int objecttype, void *object);
335 int slapi_int_create_object_extensions(int objecttype, void *object);
336 int slapi_int_clear_object_extensions(int objecttype, void *object);
340 #endif /* _PROTO_SLAPI_H */