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