summaryrefslogtreecommitdiffstats
path: root/ldap/servers/slapd/proto-slap.h
blob: 61a5fe85d791ffe6bf03d43e100ffe1a9d9c3d35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
/** BEGIN COPYRIGHT BLOCK
 * This Program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; version 2 of the License.
 * 
 * This Program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA.
 * 
 * In addition, as a special exception, Red Hat, Inc. gives You the additional
 * right to link the code of this Program with code not covered under the GNU
 * General Public License ("Non-GPL Code") and to distribute linked combinations
 * including the two, subject to the limitations in this paragraph. Non-GPL Code
 * permitted under this exception must only link to the code of this Program
 * through those well defined interfaces identified in the file named EXCEPTION
 * found in the source code files (the "Approved Interfaces"). The files of
 * Non-GPL Code may instantiate templates or use macros or inline functions from
 * the Approved Interfaces without causing the resulting work to be covered by
 * the GNU General Public License. Only Red Hat, Inc. may make changes or
 * additions to the list of Approved Interfaces. You must obey the GNU General
 * Public License in all respects for all of the Program code and other code used
 * in conjunction with the Program except the Non-GPL Code covered by this
 * exception. If you modify this file, you may extend this exception to your
 * version of the file, but you are not obligated to do so. If you do not wish to
 * provide this exception without modification, you must delete this exception
 * statement from your version and license this file solely under the GPL without
 * exception. 
 * 
 * 
 * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
 * Copyright (C) 2005 Red Hat, Inc.
 * All rights reserved.
 * END COPYRIGHT BLOCK **/

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#ifndef _PROTO_SLAP
#define _PROTO_SLAP

/*
 * Forward structure declarations
 */
struct dse;
struct dsecallback;

/*
 * abandon.c
 */
void do_abandon( Slapi_PBlock *pb );


/*
 * add.c
 */
void do_add( Slapi_PBlock *pb );


/*
 * attr.c
 */
void attr_done(Slapi_Attr *a);
int attr_add_valuearray(Slapi_Attr *a, Slapi_Value **vals, const char *dn);
int attr_replace(Slapi_Attr *a, Slapi_Value **vals);
int attr_check_onoff ( const char *attr_name, char *value, long minval, long maxval, char *errorbuf );
int attr_check_minmax ( const char *attr_name, char *value, long minval, long maxval, char *errorbuf );

/*
 * attrlist.c
 */

void attrlist_free(Slapi_Attr *alist);
int attrlist_find_or_create(Slapi_Attr **alist, const char *type, Slapi_Attr ***a);
int attrlist_find_or_create_locking_optional(Slapi_Attr **alist, const char *type, Slapi_Attr ***a, PRBool use_lock, PRBool ref_count);
void attrlist_merge( Slapi_Attr **alist, const char *type, struct berval **vals );
void attrlist_merge_valuearray( Slapi_Attr **alist, const char *type, Slapi_Value **vals );
int attrlist_delete( Slapi_Attr **attrs, const char *type );
Slapi_Attr *attrlist_find( Slapi_Attr *a, const char *type );
Slapi_Attr *attrlist_remove(Slapi_Attr **attrs, const char *type);
void attrlist_add(Slapi_Attr **attrs, Slapi_Attr *a);
int attrlist_count_subtypes(Slapi_Attr *a, const char *type);
Slapi_Attr *attrlist_find_ex( Slapi_Attr *a, const char *type, int *type_name_disposition, char** actual_type_name, void **hint );
int attrlist_replace(Slapi_Attr **alist, const char *type, struct berval **vals);
int attrlist_replace_with_flags(Slapi_Attr **alist, const char *type, struct berval **vals, int flags);

/*
 * attrsyntax.c
 */
void attr_syntax_read_lock(void);
void attr_syntax_unlock_read(void);
int attr_syntax_exists (const char *attr_name);
void attr_syntax_delete ( struct asyntaxinfo *asip );
#define SLAPI_SYNTAXLENGTH_NONE		(-1)	/* for syntaxlength parameter */
int attr_syntax_create( const char *attr_oid, char *const*attr_names,
		int num_names, const char *attr_desc, const char *attr_superior,
		const char *mr_equality, const char *mr_ordering,
		const char *mr_substring, char *const *attr_origins,
		const char *attr_syntax, int syntaxlength, unsigned long flags,
		struct asyntaxinfo **asip );
void attr_syntax_free( struct asyntaxinfo *a );
int attr_syntax_add( struct asyntaxinfo *asip );
char *attr_syntax_normalize_no_lookup( const char *s );
void attr_syntax_enumerate_attrs(AttrEnumFunc aef, void *arg, PRBool writelock);
void attr_syntax_all_clear_flag( unsigned long flag );
void attr_syntax_delete_all_not_flagged( unsigned long flag );
struct asyntaxinfo *attr_syntax_get_by_oid ( const char *oid );
struct asyntaxinfo *attr_syntax_get_by_name ( const char *name );
struct asyntaxinfo *attr_syntax_get_by_name_locking_optional ( const char *name, PRBool use_lock, PRBool ref_count );
/*
 * Call attr_syntax_return() when you are done using a value returned
 * by attr_syntax_get_by_oid() or attr_syntax_get_by_name().
 */
void attr_syntax_return( struct asyntaxinfo *asi );
void attr_syntax_return_locking_optional( struct asyntaxinfo *asi, PRBool use_lock );
void attr_syntax_delete_all(void);

/*
 * value.c
 */
size_t value_size(const Slapi_Value *v);

/*
 * valueset.c
 */
int valuearray_init_bervalarray(struct berval **bvals, Slapi_Value ***cvals);
int valuearray_init_bervalarray_with_flags(struct berval **bvals, Slapi_Value ***cvals, unsigned long flags);
int valuearray_get_bervalarray(Slapi_Value **cvals, struct berval ***bvals); /* JCM SLOW FUNCTION */
void valuearray_free(Slapi_Value ***va);
Slapi_Value *valuearray_remove_value(const Slapi_Attr *a, Slapi_Value **va, const Slapi_Value *v);
void valuearray_remove_value_atindex(Slapi_Value **va, int index);
int valuearray_isempty( Slapi_Value **va);
void valuearray_update_csn(Slapi_Value **va, CSNType t, const CSN *csn);
int valuearray_count( Slapi_Value **va);
int valuearray_next_value( Slapi_Value **va, int index, Slapi_Value **v);
int valuearray_first_value( Slapi_Value **va, Slapi_Value **v );

void valuearrayfast_init(struct valuearrayfast *vaf,Slapi_Value **va);
void valuearrayfast_done(struct valuearrayfast *vaf);
void valuearrayfast_add_value(struct valuearrayfast *vaf,const Slapi_Value *v);
void valuearrayfast_add_value_passin(struct valuearrayfast *vaf,Slapi_Value *v);
void valuearrayfast_add_valuearrayfast(struct valuearrayfast *vaf,const struct valuearrayfast *vaf_add);

int valuetree_add_value( const char *type, struct slapdplugin *pi, const Slapi_Value *va, Avlnode **valuetreep);
int valuetree_add_valuearray( const char *type, struct slapdplugin *pi, Slapi_Value **va, Avlnode **valuetreep, int *duplicate_index);
void valuetree_free( Avlnode **valuetreep );

/* Valueset functions */

int valueset_isempty( const Slapi_ValueSet *vs);
Slapi_Value *valueset_find(const Slapi_Attr *a, const Slapi_ValueSet *vs, const Slapi_Value *v);
Slapi_Value *valueset_remove_value(const Slapi_Attr *a, Slapi_ValueSet *vs, const Slapi_Value *v);
int valueset_remove_valuearray(Slapi_ValueSet *vs, const Slapi_Attr *a, Slapi_Value **valuestodelete, int flags, Slapi_Value ***va_out);
int valueset_purge(Slapi_ValueSet *vs, const CSN *csn);
Slapi_Value **valueset_get_valuearray(const Slapi_ValueSet *vs);
size_t valueset_size(const Slapi_ValueSet *vs);
void valueset_add_valuearray(Slapi_ValueSet *vs, Slapi_Value **addvals);
void valueset_add_valuearray_ext(Slapi_ValueSet *vs, Slapi_Value **addvals, PRUint32 flags);
void valueset_add_string(Slapi_ValueSet *vs, const char *s, CSNType t, const CSN *csn);
void valueset_update_csn(Slapi_ValueSet *vs, CSNType t, const CSN *csn);
void valueset_add_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
int valueset_intersectswith_valuearray(Slapi_ValueSet *vs, const Slapi_Attr *a, Slapi_Value **values, int *duplicate_index);
Slapi_ValueSet *valueset_dup(const Slapi_ValueSet *dupee);
void valueset_remove_string(const Slapi_Attr *a, Slapi_ValueSet *vs, const char *s);
int valueset_replace(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value **vals);
void valueset_update_csn_for_valuearray(Slapi_ValueSet *vs, const Slapi_Attr *a, Slapi_Value **valuestoupdate, CSNType t, const CSN *csn, Slapi_Value ***valuesupdated);
void valueset_set_valuearray_byval(Slapi_ValueSet *vs, Slapi_Value **addvals);
void valueset_set_valuearray_passin(Slapi_ValueSet *vs, Slapi_Value **addvals);


/*
 * ava.c
 */
int get_ava( BerElement *ber, struct ava *ava );
void ava_done( struct ava *ava );
int rdn2ava( char *rdn, struct ava *ava );

/*
 * backend.c
 */
void be_init(Slapi_Backend *be, const char *type, const char *name, int isprivate, int logchanges, int sizelimit, int timelimit );
void be_done(Slapi_Backend *be);
void be_addsuffix(Slapi_Backend *be,const Slapi_DN *suffix);
Slapi_DN *be_getconfigdn(Slapi_Backend *be,Slapi_DN *dn);
Slapi_DN *be_getmonitordn(Slapi_Backend *be,Slapi_DN *dn);
int be_writeconfig (Slapi_Backend *be);

/*
 * backend_manager.c
 */
Slapi_Backend *be_new_internal(struct dse *pdse, const char *type, const char *name);
void be_replace_dse_internal(Slapi_Backend *be, struct dse *pdse);
int fedse_create_startOK(char *filename,  char *startokfilename, const char *configdir);
void be_cleanupall();
void be_flushall();
int be_remove( Slapi_Backend *be );
void g_set_defsize(int val);
void g_set_deftime(int val);
Slapi_Backend *g_get_user_backend( int n );
int g_get_defsize();
int g_get_deftime();
void be_unbindall( Connection *conn, Operation *op); 
int be_nbackends_public();
void g_incr_active_threadcnt();
void g_decr_active_threadcnt();
int g_get_active_threadcnt();

/*
 * bind.c
 */
void do_bind( Slapi_PBlock *pb );
void init_saslmechanisms( void );


/*
 * compare.c
 */
void do_compare( Slapi_PBlock *pb );

/*
 * computed.c
 */
int compute_attribute(char *type, Slapi_PBlock *pb,BerElement *ber,Slapi_Entry *e,int attrsonly,char *requested_type);
int compute_init();
int compute_terminate();


/*
 * config.c
 */
int slapd_bootstrap_config(const char *configdir);
int config_set_storagescheme();
int get_netsite_root_path(char *pathname);
int slapd_write_config ();
int config_set_port( const char *attrname, char *port, char *errorbuf, int apply );
int config_set_secureport( const char *attrname, char *port, char *errorbuf, int apply );
int config_set_SSLclientAuth( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_ssl_check_hostname( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_SSL3ciphers( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_localhost( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_listenhost( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_securelistenhost( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_ldapi_filename( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_ldapi_switch( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_ldapi_bind_switch( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_ldapi_root_dn( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_ldapi_map_entries( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_ldapi_uidnumber_type( const char *attrname, char *value, char *errorbuf, int apply );    
int config_set_ldapi_gidnumber_type( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_ldapi_search_base_dn( const char *attrname, char *value, char *errorbuf, int apply );
#if defined(ENABLE_AUTO_DN_SUFFIX)
int config_set_ldapi_auto_dn_suffix( const char *attrname, char *value, char *errorbuf, int apply );   
#endif
int config_set_slapi_counters( const char *attrname, char *value, char *errorbuf, int apply );   
int config_set_srvtab( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_sizelimit( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_lastmod( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_nagle( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_accesscontrol( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_security( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_readonly( const char *attrname, char *value, 	char *errorbuf, int apply );
int config_set_schemacheck( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_ds4_compatible_schema( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_schema_ignore_trailing_spaces( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_rootdn( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_rootpw( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_rootpwstoragescheme( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_workingdir( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_encryptionalias( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_threadnumber( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_maxthreadsperconn( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_reservedescriptors( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_ioblocktimeout( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_idletimeout( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_max_filter_nest_level( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_groupevalnestlevel( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_defaultreferral( const char *attrname, struct berval **value, char *errorbuf, int apply );
int config_set_timelimit(const char *attrname, char *value, char *errorbuf, int apply );
int config_set_errorlog_level(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_accesslog_level(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_auditlog(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_userat(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_accesslog(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_errorlog(const char *attrname, char *value, char *errorbuf, int apply );
int config_set_pw_change(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_must_change(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pwpolicy_local(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_syntax(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_minlength(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_mindigits(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_minalphas(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_minuppers(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_minlowers(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_minspecials(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_min8bit(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_maxrepeats(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_mincategories(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_mintokenlength(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_exp(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_maxage(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_minage(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_warning(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_history(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_inhistory(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_lockout(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_storagescheme(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_maxfailure(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_unlock(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_lockduration(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_resetfailurecount(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_is_global_policy(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_pw_gracelimit(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_useroc(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_return_exact_case(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_result_tweak(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_referral_mode(const char *attrname, char *url, char *errorbuf, int apply);
int config_set_conntablesize(const char *attrname, char *url, char *errorbuf, int apply);
int config_set_maxbersize(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_versionstring(const char *attrname,  char *versionstring, char *errorbuf, int apply );
int config_set_enquote_sup_oc(const char *attrname,  char *value, char *errorbuf, int apply );
int config_set_basedn( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_configdir( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_instancedir( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_schemadir( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_lockdir( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_tmpdir( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_certdir( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_ldifdir( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_bakdir( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_rundir( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_saslpath( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_attrname_exceptions( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_hash_filters( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_rewrite_rfc1274( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_outbound_ldap_io_timeout( const char *attrname, char *value,
		char *errorbuf, int apply );
int config_set_accesslogbuffering(const char *attrname, char *value, char *errorbuf, int apply);
int config_set_csnlogging(const char *attrname, char *value, char *errorbuf, int apply);

#if !defined(_WIN32) && !defined(AIX)
int config_set_maxdescriptors( const char *attrname, char *value, char *errorbuf, int apply );
#endif /* !_WIN_32 && !AIX */

#ifndef _WIN32
int config_set_localuser( const char *attrname, char *value, char *errorbuf, int apply );
#endif /* !_WIN32 */

#ifdef MEMPOOL_EXPERIMENTAL
int config_set_mempool_switch( const char *attrname, char *value, char *errorbuf, int apply );
int config_set_mempool_maxfreelist( const char *attrname, char *value, char *errorbuf, int apply );
#endif /* MEMPOOL_EXPERIMENTAL */

int config_get_SSLclientAuth();
int config_get_ssl_check_hostname();
char *config_get_SSL3ciphers();
char *config_get_localhost();
char *config_get_listenhost();
char *config_get_securelistenhost();
char *config_get_ldapi_filename();
int config_get_ldapi_switch(); 
int config_get_ldapi_bind_switch();
char *config_get_ldapi_root_dn(); 
int config_get_ldapi_map_entries(); 
char *config_get_ldapi_uidnumber_type(); 
char *config_get_ldapi_gidnumber_type(); 
char *config_get_ldapi_search_base_dn(); 
#if defined(ENABLE_AUTO_DN_SUFFIX)
char *config_get_ldapi_auto_dn_suffix(); 
#endif
int config_get_slapi_counters(); 
char *config_get_srvtab();
int config_get_sizelimit();
char *config_get_pw_storagescheme();
int config_get_pw_change();
int config_get_pw_history();
int config_get_pw_must_change();
int config_get_pw_syntax();
int config_get_pw_minlength();
int config_get_pw_mindigits();
int config_get_pw_minalphas();
int config_get_pw_minuppers();
int config_get_pw_minlowers();
int config_get_pw_minspecials();
int config_get_pw_min8bit();
int config_get_pw_maxrepeats();
int config_get_pw_mincategories();
int config_get_pw_mintokenlength();
int config_get_pw_maxfailure();
int config_get_pw_inhistory();
long config_get_pw_lockduration();
long config_get_pw_resetfailurecount();
int config_get_pw_exp();
int config_get_pw_unlock();
int config_get_pw_lockout();
int config_get_pw_gracelimit();
int config_get_lastmod();
int config_get_nagle();
int config_get_accesscontrol();
int config_get_return_exact_case();
int config_get_result_tweak();
int config_get_security();
int config_get_schemacheck();
int config_get_ds4_compatible_schema();
int config_get_schema_ignore_trailing_spaces();
char *config_get_rootdn();
char *config_get_rootpw();
char *config_get_rootpwstoragescheme();
#ifndef _WIN32
char *config_get_localuser();
#endif /* _WIN32 */
char *config_get_workingdir();
char *config_get_encryptionalias();
int config_get_threadnumber();
int config_get_maxthreadsperconn();
#if !defined(_WIN32) && !defined(AIX)
int config_get_maxdescriptors();
#endif /* !_WIN32 && !AIX */
int config_get_reservedescriptors();
int config_get_ioblocktimeout();
int config_get_idletimeout();
int config_get_max_filter_nest_level();
int config_get_groupevalnestlevel();
struct berval **config_get_defaultreferral();
char *config_get_userat();
int config_get_timelimit();
char* config_get_useroc();
char *config_get_accesslog();
char *config_get_errorlog();
char *config_get_auditlog();
long config_get_pw_maxage();
long config_get_pw_minage();
long config_get_pw_warning();
int config_get_errorlog_level();
int config_get_accesslog_level();
int config_get_auditlog_logging_enabled();
char *config_get_referral_mode(void);
int config_get_conntablesize(void);
int config_check_referral_mode(void);
ber_len_t config_get_maxbersize();
char *config_get_versionstring();
char *config_get_buildnum(void);
int config_get_enquote_sup_oc();
char *config_get_basedn();
char *config_get_configdir();
char *config_get_schemadir();
char *config_get_lockdir();
char *config_get_tmpdir();
char *config_get_certdir();
char *config_get_ldifdir();
char *config_get_bakdir();
char *config_get_rundir();
char *config_get_saslpath();
char **config_get_errorlog_list();
char **config_get_accesslog_list();
char **config_get_auditlog_list();
int config_get_attrname_exceptions();
int config_get_hash_filters();
int config_get_rewrite_rfc1274();
int config_get_outbound_ldap_io_timeout(void);
int config_get_csnlogging();
#ifdef MEMPOOL_EXPERIMENTAL
int config_get_mempool_switch();
int config_get_mempool_maxfreelist();
long config_get_system_page_size();
int config_get_system_page_bits();
#endif

int is_abspath(const char *);
char* rel2abspath( char * );
char* rel2abspath_ext( char *, char * );

/*
 * configdse.c
 */
int read_config_dse (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
int load_config_dse(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
int modify_config_dse(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
int postop_modify_config_dse(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
int add_root_dse( Slapi_PBlock *pb );
int load_plugin_entry(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);


/*
 * controls.c
 */
void init_controls( void );
int get_ldapmessage_controls( Slapi_PBlock *pb, BerElement *ber,
	LDAPControl ***controls );
int write_controls( BerElement *ber, LDAPControl **ctrls );
void add_control( LDAPControl ***ctrlsp, LDAPControl *newctrl );


/*
 * delete.c
 */
void do_delete( Slapi_PBlock *pb );


/*
 * detach.c
 */
void detach( int slapd_exemode, int importexport_encrypt,
             int s_port, daemon_ports_t *ports_info );
#ifndef _WIN32
void close_all_files( void );
#endif
void raise_process_limits( void );


/*
 * dn.c
 */
char *substr_dn_normalize( char *dn, char *end );
int hexchar2int( char c );


/*
 * dynalib.c
 */
void *sym_load( char *libpath, char *symbol, char *plugin, int report_errors );
/* same as above but
 * load_now - use PR_LD_NOW so that all referenced symbols are loaded immediately
 *            default is PR_LD_LAZY which only loads symbols as they are referenced
 * load_global - use PR_LD_GLOBAL so that all loaded symbols are made available globally
 *               to all other dynamically loaded libraries - default is PR_LD_LOCAL
 *               which only makes symbols visible to the executable
 */
void *sym_load_with_flags( char *libpath, char *symbol, char *plugin, int report_errors, PRBool load_now, PRBool load_global );


/*
 * filter.c
 */
int get_filter( Connection *conn, BerElement *ber, int scope,
	struct slapi_filter **filt, char **fstr );
void filter_print( struct slapi_filter *f );
void filter_normalize( struct slapi_filter *f );


/*
 * filtercmp.c
 */
void filter_compute_hash(struct slapi_filter *f);
void set_hash_filters(int i);


/*
 * filterentry.c
 */
void filter_strcpy_special( char *d, char *s );


/*
 * entry.c
 */
int is_rootdse( const char *dn );
int get_entry_object_type();
int entry_computed_attr_init();
void send_referrals_from_entry(Slapi_PBlock *pb, Slapi_Entry *referral);


/*
 * dse.c
 */
#define DSE_OPERATION_READ 0x100
#define DSE_OPERATION_WRITE 0x200

#define DSE_BACKEND             "frontend-internal"
#define DSE_SCHEMA              "schema-internal"

struct dse *dse_new( char *filename, char *tmpfilename, char *backfilename, char *startokfilename, const char *configdir);
struct dse *dse_new_with_filelist(char *filename, char *tmpfilename, char *backfilename, char *startokfilename, const char *configdir, char **filelist);
int dse_deletedse(Slapi_PBlock *pb);
int dse_destroy(struct dse *pdse);
int dse_read_file(struct dse *pdse, Slapi_PBlock *pb);
int dse_bind( Slapi_PBlock *pb );
int dse_unbind( Slapi_PBlock *pb );
int dse_search(Slapi_PBlock *pb);
int dse_modify(Slapi_PBlock *pb);
int dse_add(Slapi_PBlock *pb);
int dse_delete(Slapi_PBlock *pb);
struct dse_callback *dse_register_callback(struct dse* pdse, int operation, int flags, const Slapi_DN *base, int scope, const char *filter, dseCallbackFn fn, void *fn_arg);
void dse_remove_callback(struct dse* pdse, int operation, int flags, const Slapi_DN *base, int scope, const char *filter, dseCallbackFn fn);
void dse_set_dont_ever_write_dse_files(void);
void dse_unset_dont_ever_write_dse_files(void);
int dse_next_search_entry (Slapi_PBlock *pb);
char *dse_read_next_entry( char *buf, char **lastp );


/*
 * fedse.c
 */

int setup_internal_backends();


/*
 * extendedop.c
 */
void ldapi_init_extended_ops( void );
void ldapi_register_extended_op( char **opoids );
void do_extended( Slapi_PBlock *pb );


/*
 * house.c
 */
PRThread* housekeeping_start(time_t cur_time, void *arg);
void housekeeping_stop();

/*
 * lock.c
 */
FILE * lock_fopen( char *fname, char *type, FILE **lfp );
int lock_fclose( FILE *fp, FILE *lfp );


/*
 * log.c
 */
int slapd_log_error_proc( char *subsystem, char *fmt, ... );

int slapi_log_access( int level, char *fmt, ... )
#ifdef __GNUC__ 
        __attribute__ ((format (printf, 2, 3)));
#else
        ;
#endif
int slapd_log_audit_proc(char *buffer, int buf_len);
void log_access_flush();


int access_log_openf( char *pathname, int locked);
int error_log_openf( char *pathname, int locked);
int audit_log_openf( char *pathname, int locked);

void g_set_detached(int);
void g_log_init(int log_enabled);
char *g_get_access_log();
char *g_get_error_log();
char *g_get_audit_log();
void g_set_accesslog_level(int val);

int log_set_mode(const char *attrname, char *mode_str, int logtype, char *errorbuf, int apply);
int log_set_numlogsperdir(const char *attrname, char *numlogs_str, int logtype, char *errorbuf, int apply);
int log_set_logsize(const char *attrname, char *logsize_str, int logtype, char *errorbuf, int apply);
int log_set_rotationsync_enabled(const char *attrname, char *rsync_str, int logtype, char *errorbuf, int apply);
int log_set_rotationsynchour(const char *attrname, char *rhour_str, int logtype, char *errorbuf, int apply);
int log_set_rotationsyncmin(const char *attrname, char *rmin_str, int logtype, char *errorbuf, int apply);
int log_set_rotationtime(const char *attrname, char *rtime_str, int logtype, char *errorbuf, int apply);
int log_set_rotationtimeunit(const char *attrname, char *runit, int logtype, char *errorbuf, int apply);
int log_set_maxdiskspace(const char *attrname, char *maxdiskspace_str, int logtype, char *errorbuf, int apply);
int log_set_mindiskspace(const char *attrname, char *minfreespace_str, int logtype, char *errorbuf, int apply);
int log_set_expirationtime(const char *attrname, char *exptime_str , int logtype, char *errorbuf, int apply);
int log_set_expirationtimeunit(const char *attrname, char *expunit, int logtype, char *errorbuf, int apply);
char **log_get_loglist(int logtype);
int  log_update_accesslogdir(char *pathname, int apply);
int  log_update_errorlogdir(char *pathname, int apply);
int  log_update_auditlogdir(char *pathname, int apply);
int  log_set_logging (const char *attrname, char *value, int logtype, char *errorbuf, int apply);
int check_log_max_size(
                    char *maxdiskspace_str,
                    char *mlogsize_str,
                    int maxdiskspace,
                    int mlogsize,
					char * returntext,
                    int logtype);
 

void g_set_accesslog_level(int val);


/*
 * util.c
 */
void slapd_nasty(char* str, int c, int err);
int strarray2str( char **a, char *buf, size_t buflen, int include_quotes );
#ifndef _WIN32
int slapd_chown_if_not_owner(const char *filename, uid_t uid, gid_t gid);
#endif
int slapd_comp_path(char *p0, char *p1);


/*
 * modify.c
 */
void do_modify( Slapi_PBlock *pb );

/*
 * modrdn.c
 */
void do_modrdn( Slapi_PBlock *pb );


/*
 * modutil.c
 */
int entry_replace_values( Slapi_Entry *e, const char *type, struct berval **vals );
int entry_replace_values_with_flags( Slapi_Entry *e, const char *type, struct berval **vals, int flags );
int entry_apply_mods( Slapi_Entry *e, LDAPMod **mods );
int entry_apply_mod( Slapi_Entry *e, const LDAPMod *mod );
void freepmods( LDAPMod **pmods );


/*
 * monitor.c
 */
int monitor_info( Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry *entryAfter, int *returncode, char *returntext, void *arg);
char *slapd_get_version_value( void );



/*
 * operation.c
 */
Slapi_Operation *operation_new(int flags);
void operation_free( Slapi_Operation **op, Connection *conn );
int slapi_op_abandoned( Slapi_PBlock *pb );
void operation_out_of_disk_space();
int get_operation_object_type();
Slapi_DN* operation_get_target_spec (Slapi_Operation *op);
void operation_set_target_spec (Slapi_Operation *op, const Slapi_DN *target_spec);
void operation_set_target_spec_str (Slapi_Operation *op, const char *target_spec);
unsigned long operation_get_abandoned_op (const Slapi_Operation *op);
void operation_set_abandoned_op (Slapi_Operation *op, unsigned long abndoned_op);
void operation_set_type(Slapi_Operation *op, unsigned long type);


/*
 * plugin.c
 */
int plugin_call_plugins( Slapi_PBlock *, int );
int plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid *group,
	slapi_plugin_init_fnptr initfunc, int add_to_dit);
int plugin_call_exop_plugins( Slapi_PBlock *pb, char *oid );
const char *plugin_extended_op_oid2string( const char *oid );
void plugin_closeall(int close_backends, int close_globals);
void plugin_startall(int argc,char **argv,int start_backends, int start_global);
struct slapdplugin *get_plugin_list(int plugin_list_index);
PRBool plugin_invoke_plugin_sdn (struct slapdplugin *plugin, int operation, Slapi_PBlock *pb, Slapi_DN *target_spec);
struct slapdplugin *plugin_get_by_name(char *name);
struct slapdplugin *plugin_get_pwd_storage_scheme(char *name, int len, int index);
char *plugin_get_pwd_storage_scheme_list(int index);
int plugin_add_descriptive_attributes( Slapi_Entry *e,
		struct slapdplugin *plugin );
void plugin_call_entryfetch_plugins(char **entrystr, uint *size);
void plugin_call_entrystore_plugins(char **entrystr, uint *size);
void plugin_print_versions(void);

/*
 * plugin_mr.c
 */
struct slapdplugin *slapi_get_global_mr_plugins();
int plugin_mr_filter_create (mr_filter_t* f);

/*
 * plugin_syntax.c
 */
struct slapdplugin *slapi_get_global_syntax_plugins();
int plugin_call_syntax_filter_ava( const Slapi_Attr *a, int ftype, struct ava *ava );
int plugin_call_syntax_filter_ava_sv( const Slapi_Attr *a, int ftype, struct ava *ava, Slapi_Value **retVal, int useDeletedValues );
int plugin_call_syntax_filter_sub( Slapi_PBlock *pb, Slapi_Attr *a, struct subfilt *fsub );
int plugin_call_syntax_filter_sub_sv( Slapi_PBlock *pb, Slapi_Attr *a, struct subfilt *fsub );
int plugin_call_syntax_get_compare_fn(void *vpi, value_compare_fn_type *compare_fn);
struct slapdplugin *plugin_syntax_find( const char *nameoroid );
void plugin_syntax_enumerate( SyntaxEnumFunc sef, void *arg );
char *plugin_syntax2oid( struct slapdplugin *pi );

/*
 * plugin_acl.c
 */
int plugin_call_acl_plugin ( Slapi_PBlock *pb, Slapi_Entry *e,
	char **attrs, struct berval *val, int access, int flags, char **errbuf);
int plugin_call_acl_mods_access ( Slapi_PBlock *pb, Slapi_Entry *e, LDAPMod **mods, char **errbuf );
int plugin_call_acl_mods_update ( Slapi_PBlock *pb, int optype );
int plugin_call_acl_verify_syntax ( Slapi_PBlock *pb, Slapi_Entry *e, char **errbuf );

/*
 * pw_mgmt.c
 */
void pw_init( void );
int need_new_pw( Slapi_PBlock *pb, long *t,  Slapi_Entry *e, int pwresponse_req );
int update_pw_info( Slapi_PBlock *pb , char *old_pw );
int check_pw_syntax( Slapi_PBlock *pb, const Slapi_DN *sdn, Slapi_Value **vals, 
	char **old_pw, Slapi_Entry *e, int mod_op );
int check_pw_syntax_ext( Slapi_PBlock *pb, const Slapi_DN *sdn, Slapi_Value **vals,
	char **old_pw, Slapi_Entry *e, int mod_op, Slapi_Mods *smods );
int check_account_lock( Slapi_PBlock *pb, Slapi_Entry * bind_target_entry, int pwresponse_req, int account_inactivation_only /*no wire/no pw policy*/);
int check_pw_minage( Slapi_PBlock *pb, const Slapi_DN *sdn, struct berval **vals) ;
void add_password_attrs( Slapi_PBlock *pb, Operation *op, Slapi_Entry *e );
void mod_allowchange_aci(char *val);
void pw_mod_allowchange_aci(int pw_prohibit_change);
void pw_add_allowchange_aci(Slapi_Entry *e, int pw_prohibit_change);

/*
 * pw_retry.c
 */
int update_pw_retry ( Slapi_PBlock *pb );
void pw_apply_mods(const char *dn, Slapi_Mods *mods);
void pw_set_componentID(struct slapi_componentid * cid);
struct slapi_componentid * pw_get_componentID();

/*
 * referral.c
 */
void referrals_free ();
struct berval **ref_adjust( Slapi_PBlock *pb, struct berval **urls, const Slapi_DN *refcontainerdn, int is_reference );
/* GGOODREPL temporarily in slapi-plugin.h struct berval **get_data_source( char *dn, int orc, Ref_Array * ); */


/*
 * resourcelimit.c
 */
int reslimit_update_from_dn( Slapi_Connection *conn, Slapi_DN *dn );
int reslimit_update_from_entry( Slapi_Connection *conn, Slapi_Entry *e );
void reslimit_cleanup( void );


/*
 * result.c
 */
void g_set_num_entries_sent( Slapi_Counter *counter );
PRUint64 g_get_num_entries_sent();
void g_set_num_bytes_sent( Slapi_Counter *counter );
PRUint64 g_get_num_bytes_sent();
void g_set_default_referral( struct berval **ldap_url );
struct berval	**g_get_default_referral();
void disconnect_server( Connection *conn, PRUint64 opconnid, int opid, PRErrorCode reason, PRInt32 error );
int send_ldap_search_entry( Slapi_PBlock *pb, Slapi_Entry *e, LDAPControl **ectrls,
	char **attrs, int attrsonly );
void send_ldap_result( Slapi_PBlock *pb, int err, char *matched, char *text,
	int nentries, struct berval **urls );
int send_ldap_search_entry_ext( Slapi_PBlock *pb, Slapi_Entry *e, LDAPControl **ectrls,
	char **attrs, int attrsonly, int send_result, int nentries, struct berval **urls );
void send_ldap_result_ext( Slapi_PBlock *pb, int err, char *matched, char *text,
	int nentries, struct berval **urls, BerElement	*ber );
void send_nobackend_ldap_result( Slapi_PBlock *pb );
int send_ldap_referral( Slapi_PBlock *pb, Slapi_Entry *e, struct berval **refs,
	struct berval ***urls );
int send_ldapv3_referral( Slapi_PBlock *pb, struct berval **urls );
int set_db_default_result_handlers(Slapi_PBlock *pb);
void disconnect_server_nomutex( Connection *conn, PRUint64 opconnid, int opid, PRErrorCode reason, PRInt32 error );
long g_get_current_conn_count();
void g_increment_current_conn_count();
void g_decrement_current_conn_count();
void g_set_current_conn_count_mutex( PRLock *plock );
PRLock *g_get_current_conn_count_mutex();
int encode_attr(Slapi_PBlock *pb,BerElement *ber,Slapi_Entry *e,Slapi_Attr *a,int attrsonly,char *type);


/*
 * schema.c
 */
int init_schema_dse(const char *configdir);
char *oc_find_name( const char *name_or_oid );
int oc_schema_check( Slapi_Entry *e );
int modify_schema_dse (Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry *entryAfter, int *returncode, char *returntext, void *arg);
int read_schema_dse ( Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry *entryAfter, int *returncode, char *returntext, void *arg);
void oc_lock_read( void );
void oc_lock_write( void );
void oc_unlock( void );
/* Note: callers of g_get_global_oc_nolock() must hold a read or write lock */
struct objclass* g_get_global_oc_nolock();
/* Note: callers of g_set_global_oc_nolock() must hold a write lock */
void g_set_global_oc_nolock(struct objclass *newglobaloc);
/* Note: callers of g_get_global_schema_csn() must hold a read lock */
const CSN *g_get_global_schema_csn();
/* Note: callers of g_set_global_schema_csn() must hold a write lock. */
/* csn is consumed. */
void g_set_global_schema_csn(CSN *csn);
void slapi_schema_expand_objectclasses( Slapi_Entry *e );
/* API to validate the schema files */
int slapi_validate_schema_files(char *schemadir);
/* API to reload the schema files */
int slapi_reload_schema_files(char *schemadir);

/*
 * schemaparse.c
 */
void normalize_oc( void );
void normalize_oc_nolock( void );
/* Note: callers of oc_update_inheritance_nolock() must hold a write lock */
void oc_update_inheritance_nolock( struct objclass *oc );

/*
 * search.c
 */
void do_search( Slapi_PBlock *pb );


/*
 * ssl.c
 */
int slapd_SSL_client_init();
int slapd_SSL_client_bind_s( LDAP* ld, char* DN, char* pw, int use_SSL, int LDAPv);
int slapd_sasl_ext_client_bind( LDAP* ld, int **msgid);
int slapd_nss_init(int init_ssl, int config_available);
int slapd_ssl_init();
int slapd_ssl_init2(PRFileDesc **fd, int startTLS);
int slapd_security_library_is_initialized();
int slapd_ssl_listener_is_initialized();
int sasl_io_cleanup(Connection *c);
int slapd_SSL_client_auth (LDAP* ld);

/*
 * security_wrappers.c
 */
int slapd_ssl_handshakeCallback(PRFileDesc *fd, void * callback, void * client_data);
int slapd_ssl_badCertHook(PRFileDesc *fd, void * callback, void * client_data);
CERTCertificate * slapd_ssl_peerCertificate(PRFileDesc *fd);
SECStatus slapd_ssl_getChannelInfo(PRFileDesc *fd, SSLChannelInfo *sinfo, PRUintn len);
SECStatus slapd_ssl_getCipherSuiteInfo(PRUint16 ciphersuite, SSLCipherSuiteInfo *cinfo, PRUintn len);
PRFileDesc * slapd_ssl_importFD(PRFileDesc *model, PRFileDesc *fd);
SECStatus slapd_ssl_resetHandshake(PRFileDesc *fd, PRBool asServer);
void slapd_pk11_configurePKCS11(char *man, char *libdes, char *tokdes, char *ptokdes,
				char *slotdes, char *pslotdes, char *fslotdes, 
				char *fpslotdes, int minPwd,
				int pwdRequired);
void slapd_pk11_freeSlot(PK11SlotInfo *slot);
void slapd_pk11_freeSymKey(PK11SymKey *key);
PK11SlotInfo *slapd_pk11_findSlotByName(char *name);
SECAlgorithmID *slapd_pk11_createPBEAlgorithmID(SECOidTag algorithm, int iteration, SECItem *salt);
PK11SymKey *slapd_pk11_pbeKeyGen(PK11SlotInfo *slot, SECAlgorithmID *algid,  SECItem *pwitem,
				 PRBool faulty3DES, void *wincx);
CK_MECHANISM_TYPE slapd_pk11_algtagToMechanism(SECOidTag algTag);
SECItem *slapd_pk11_paramFromAlgid(SECAlgorithmID *algid);
CK_RV slapd_pk11_mapPBEMechanismToCryptoMechanism(CK_MECHANISM_PTR pPBEMechanism,
						  CK_MECHANISM_PTR pCryptoMechanism,
						  SECItem *pbe_pwd, PRBool bad3DES);
int slapd_pk11_getBlockSize(CK_MECHANISM_TYPE type,SECItem *params);
PK11Context * slapd_pk11_createContextBySymKey(CK_MECHANISM_TYPE type,
					       CK_ATTRIBUTE_TYPE operation, 
					       PK11SymKey *symKey, SECItem *param);
SECStatus slapd_pk11_cipherOp(PK11Context *context, unsigned char * out, int *outlen,
			      int maxout, unsigned char *in, int inlen);
SECStatus slapd_pk11_finalize(PK11Context *context);
PK11SlotInfo *slapd_pk11_getInternalKeySlot();
PK11SlotInfo *slapd_pk11_getInternalSlot();
SECStatus slapd_pk11_authenticate(PK11SlotInfo *slot, PRBool loadCerts, void *wincx);
void slapd_pk11_setSlotPWValues(PK11SlotInfo *slot,int askpw, int timeout);
PRBool slapd_pk11_isFIPS();
CERTCertificate *slapd_pk11_findCertFromNickname(char *nickname, void *wincx);
SECKEYPrivateKey *slapd_pk11_findKeyByAnyCert(CERTCertificate *cert, void *wincx);
PRBool slapd_pk11_fortezzaHasKEA(CERTCertificate *cert);
void slapd_pk11_destroyContext(PK11Context *context, PRBool freeit);
void secoid_destroyAlgorithmID(SECAlgorithmID *algid, PRBool freeit);
void slapd_pk11_CERT_DestroyCertificate(CERTCertificate *cert);
SECKEYPublicKey *slapd_CERT_ExtractPublicKey(CERTCertificate *cert);
SECKEYPrivateKey * slapd_pk11_FindPrivateKeyFromCert(PK11SlotInfo *slot,CERTCertificate *cert, void *wincx);
PK11SlotInfo *slapd_pk11_GetInternalKeySlot(void);
SECStatus slapd_pk11_PubWrapSymKey(CK_MECHANISM_TYPE type, SECKEYPublicKey *pubKey,PK11SymKey *symKey, SECItem *wrappedKey);
PK11SymKey *slapd_pk11_KeyGen(PK11SlotInfo *slot,CK_MECHANISM_TYPE type,SECItem *param, int keySize,void *wincx);
void slapd_pk11_FreeSlot(PK11SlotInfo *slot);
void slapd_pk11_FreeSymKey(PK11SymKey *key);
void slapd_pk11_DestroyContext(PK11Context *context, PRBool freeit);
SECItem *slapd_pk11_ParamFromIV(CK_MECHANISM_TYPE type,SECItem *iv);
PK11SymKey *slapd_pk11_PubUnwrapSymKey(SECKEYPrivateKey *wrappingKey, SECItem *wrappedKey,CK_MECHANISM_TYPE target, CK_ATTRIBUTE_TYPE operation, int keySize);
unsigned slapd_SECKEY_PublicKeyStrength(SECKEYPublicKey *pubk);
SECStatus slapd_pk11_Finalize(PK11Context *context);
SECStatus slapd_pk11_DigestFinal(PK11Context *context, unsigned char *data,unsigned int *outLen, unsigned int length);
void slapd_SECITEM_FreeItem (SECItem *zap, PRBool freeit);
void slapd_pk11_DestroyPrivateKey(SECKEYPrivateKey *key);
void slapd_pk11_DestroyPublicKey(SECKEYPublicKey *key);

/*
 * start_tls_extop.c
 */
int start_tls( Slapi_PBlock *pb );
int start_tls_graceful_closure( Connection *conn, Slapi_PBlock *pb, int is_initiator );
int start_tls_register_plugin();
int start_tls_init( Slapi_PBlock *pb );

/* passwd_extop.c */
int passwd_modify_register_plugin();

/*
 * slapi_str2filter.c
 */
struct slapi_filter *slapi_str2filter( char *str );
char   *slapi_find_matching_paren( const char *str);
struct slapi_filter    *str2simple();


/*
 * time.c
 */
char *get_timestring(time_t *t);
void free_timestring(char *timestr);
time_t current_time();
time_t poll_current_time();
char* format_localTime (time_t from);
time_t parse_localTime (char* from);

#ifndef HAVE_TIME_R
int gmtime_r( const time_t *timer, struct tm *result );
int localtime_r( const time_t *timer, struct tm *result );
int ctime_r( const time_t *timer, char *buffer, int buflen );
#endif

char *format_genTime (time_t from);
time_t parse_genTime (char *from);

/*
 * unbind.c
 */
void do_unbind( Slapi_PBlock *pb );


/*
 * pblock.c
 */
void pblock_init( Slapi_PBlock *pb );
void pblock_init_common( Slapi_PBlock *pb, Slapi_Backend *be, Connection *conn, Operation *op );
void pblock_done( Slapi_PBlock *pb );
void bind_credentials_set( Connection *conn,
                char *authtype, char *normdn,
                char *extauthtype, char *externaldn, CERTCertificate *clientcert , Slapi_Entry * binded);
void bind_credentials_set_nolock( Connection *conn,
		char *authtype, char *normdn,
		char *extauthtype, char *externaldn, CERTCertificate *clientcert , Slapi_Entry * binded);
void bind_credentials_clear( Connection *conn, PRBool lock_conn,
		PRBool clear_externalcreds );


/* 
 * libglobs.c
 */
void g_set_shutdown( int reason );
int g_get_shutdown();
void c_set_shutdown();
int c_get_shutdown();
int	  g_get_global_lastmod();
/* Ref_Array *g_get_global_referrals(void); */
struct snmp_vars_t * g_get_global_snmp_vars();
void FrontendConfig_init();
int g_get_slapd_security_on();
char *config_get_versionstring();

void libldap_init_debug_level(int *);
int get_entry_point( int, caddr_t* );

int config_set_entry(Slapi_Entry *e);
int config_set(const char *attr_name, struct berval **values, char *errorbuf, int apply);

void free_pw_scheme(struct pw_scheme *pwsp);

/*
 * rootdse.c
 */
int read_root_dse( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *entryAfter, int *returncode, char *returntext, void *arg );
int modify_root_dse( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *entryAfter, int *returncode, char *returntext, void *arg );

/*
 * psearch.c
 */
void ps_init_psearch_system();
void ps_stop_psearch_system();
void ps_add( Slapi_PBlock *pb, ber_int_t changetypes, int send_entchg_controls );
void ps_wakeup_all();
void ps_service_persistent_searches( Slapi_Entry *e, Slapi_Entry *eprev, ber_int_t chgtype,
	ber_int_t chgnum );
int ps_parse_control_value( struct berval *psbvp, ber_int_t *changetypesp,
    int *changesonlyp, int *returnecsp );

/*
 * globals.c
 */
void set_entry_points();

/*
 * defbackend.c
 */
void defbackend_init( void );
Slapi_Backend *defbackend_get_backend( void );

/*
 * plugin_internal_op.c
 */
void do_disconnect_server( Connection *conn, PRUint64 opconnid, int opid );

/*
 * regex.c
 */
int re_init( void );

/*
 * secpwd.c
 */
char* getPassword();

/*
 * match.c
 */
struct matchingRuleList *g_get_global_mrl();
void g_set_global_mrl(struct matchingRuleList *newglobalmrl);

/*
 * lite_entries.c
 */
void lite_entries_init();

/*
 * generation.c
 */

/* 
 * factory.c
 */

int factory_register_type(const char *name,size_t offset);
void *factory_create_extension(int type,void *object,void *parent);
void factory_destroy_extension(int type,void *object,void *parent,void **extension);

/*
 * auditlog.c
 */

void write_audit_log_entry( Slapi_PBlock *pb);

/*
 * eventq.c
 */
void eq_init();
void eq_start();
void eq_stop();

/* 
 * uniqueidgen.c
 */

/* Function:    uniqueIDGenInit
   Description: this function initializes the generator
   Parameters:  configDir - directory in which generators state is stored
				configDN - DIT entry with state information
				mtGen - indicates whether multiple threads will use generator
   Return:      UID_SUCCESS if function succeeds
                UID_BADDATA if invalif directory is passed
                UID_SYSTEM_ERROR if any other failure occurs 
*/
int uniqueIDGenInit (const char *configDir, const Slapi_DN *configDN, PRBool mtGen);      

/* Function:    uniqueIDGenCleanup
   Description: cleanup
   Parameters:  none
   Return:      none
*/
void uniqueIDGenCleanup (); 

/*
 * init.c
 */
void slapd_init();

/*
 * plugin.c
 */

/* this interface is exposed to be used by internal operations. It assumes no dynamic 
   plugin configuration as it provides no data locking. The interface will change once 
   we decide to support dynamic configuration
 */
const char* plugin_get_name (const struct slapdplugin *plugin);
const DataList* plugin_get_target_subtrees (const struct slapdplugin *plugin);
const DataList* plugin_get_bind_subtrees (const struct slapdplugin *plugin);
int plugin_get_schema_check (const struct slapdplugin *plugin);
int plugin_get_log_access (const struct slapdplugin *plugin);
int plugin_get_log_audit (const struct slapdplugin *plugin);

/*
 * getfilelist.c
 */
char **get_filelist(
	const char *dirname, /* directory path; if NULL, uses "." */
	const char *pattern, /* grep (not shell!) file pattern regex */
	int hiddenfiles, /* if true, return hidden files and directories too */
	int nofiles, /* if true, do not return files */
	int nodirs /* if true, do not return directories */
);
void free_filelist(char **filelist);
char **get_priority_filelist(const char *directory, const char *pattern);

/* this interface is exposed to be used by internal operations. 
 */
char* plugin_get_dn (const struct slapdplugin *plugin);
/* determine whether operation should be allowed based on plugin configuration */
PRBool plugin_allow_internal_op (Slapi_DN *target, struct slapdplugin *plugin);
/* build operation action bitmap based on plugin configuration and actions specified for the operation */
int plugin_build_operation_action_bitmap (int input_actions, const struct slapdplugin *plugin);
const struct slapdplugin* plugin_get_server_plg ();

/* opshared.c - functions shared between regular and internal operations */
void op_shared_search (Slapi_PBlock *pb, int send_result);
int op_shared_is_allowed_attr (const char *attr_name, int replicated_op);
void op_shared_log_error_access (Slapi_PBlock *pb, const char *type, const char *dn, const char *msg);
int search_register_reslimits( void );


/* plugin_internal_op.c - functions shared by several internal operations */
LDAPMod **normalize_mods2bvals(const LDAPMod **mods);
Slapi_Operation* internal_operation_new(unsigned long op_type, int flags);
void internal_getresult_callback(struct conn *unused1, struct op *op, int err, char *unused2, 
								 char *unused3, int unused4, struct berval **unused5);
/* allow/disallow operation based of the plugin configuration */
PRBool allow_operation (Slapi_PBlock *pb);
/* set operation configuration based on the plugin configuration */
void set_config_params (Slapi_PBlock *pb);
/* set parameters common for all internal operations */
void set_common_params (Slapi_PBlock *pb);
void do_ps_service(Slapi_Entry *e, Slapi_Entry *eprev, ber_int_t chgtype, ber_int_t chgnum);
void modify_update_last_modified_attr(Slapi_PBlock *pb, Slapi_Mods *smods);

/*
 * debugdump.cpp
 */
void debug_thread_wrapper(void *thread_start_function);

/*
 * counters.c
 */
void counters_as_entry(Slapi_Entry* e);
void counters_to_errors_log(const char *text);

/*
 * ch_malloc.c
 */
void slapi_ch_start_recording();
void slapi_ch_stop_recording();

/*
 * snmpcollator.c
 */
void snmp_as_entry(Slapi_Entry* e);

/*
 * subentry.c
 */
int subentry_check_filter(Slapi_Filter *f);
void subentry_create_filter(Slapi_Filter** filter);

/*
 * vattr.c
 */
void vattr_init();
void vattr_cleanup();
void vattrcache_entry_READ_LOCK(const Slapi_Entry *e);
void vattrcache_entry_READ_UNLOCK(const Slapi_Entry *e);
void vattrcache_entry_WRITE_LOCK(const Slapi_Entry *e);
void vattrcache_entry_WRITE_UNLOCK(const Slapi_Entry *e);

/*
 * slapd_plhash.c - supplement to NSPR plhash
 */
void *PL_HashTableLookup_const(
	void *ht, /* really a PLHashTable */
	const void *key);

/*
 * mapping_tree.c
 */
int mapping_tree_init();
void mapping_tree_free ();
int mapping_tree_get_extension_type ();

/*
 * connection.c
 */
int connection_acquire_nolock (Connection *conn);
int connection_release_nolock (Connection *conn);
int connection_is_free (Connection *conn);
int connection_is_active_nolock (Connection *conn);

/*
 * saslbind.c
 */
int ids_sasl_init(void);
char **ids_sasl_listmech(Slapi_PBlock *pb);
void ids_sasl_check_bind(Slapi_PBlock *pb);
void ids_sasl_server_new(Connection *conn);
int slapd_ldap_sasl_interactive_bind(
    LDAP *ld, /* ldap connection */
    const char *bindid, /* usually a bind DN for simple bind */
    const char *creds, /* usually a password for simple bind */
    const char *mech, /* name of mechanism */
    LDAPControl **serverctrls, /* additional controls to send */
    LDAPControl ***returnedctrls, /* returned controls */
    int *msgidp /* pass in non-NULL for async handling */
);

/*
 * sasl_io.c
 */
/* This function should be called under the connection mutex */
int sasl_io_setup(Connection *c);

/*
 * daemon.c
 */
#ifndef LINUX
void slapd_do_nothing(int);
#endif
#ifndef _WIN32
void slapd_wait4child (int);
#else
void *slapd_service_exit_wait();
#endif

/*
 * main.c
 */
#if ( defined( hpux ) || defined( irix ))
void signal2sigaction( int s, void *a );
#endif
int slapd_do_all_nss_ssl_init(int slapd_exemode, int importexport_encrypt,
                              int s_port, daemon_ports_t *ports_info);

#endif /* _PROTO_SLAP */