]> git.sur5r.net Git - openldap/blob - servers/slapd/slapi/slapi_utils.h
Confusingly, make SLAPI_OPERATION_AUTHTYPE return a pointer to
[openldap] / servers / slapd / slapi / slapi_utils.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 _SLAPI_UTILS_H
14 #define _SLAPI_UTILS_H
15
16 LDAP_BEGIN_DECL
17
18 struct _Audit_record;
19 typedef struct _Audit_record Audit_record;
20
21 #define SLAPI_CONTROL_MANAGEDSAIT_OID "2.16.840.1.113730.3.4.2"
22 #define SLAPI_CONTROL_SORTEDSEARCH_OID "1.2.840.113556.1.4.473"
23 #define SLAPI_CONTROL_PAGED_RESULTS_OID "1.2.840.113556.1.4.319"
24
25 typedef int (*SLAPI_FUNC)(Slapi_PBlock *pb);
26
27 #define MAX_HOSTNAME 512
28
29 #define DOMAIN "Domain"
30 #define TCPIPPATH "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"
31
32 typedef struct _slapi_control {
33         int                     s_ctrl_num;
34         char                    **s_ctrl_oids;
35         unsigned long           *s_ctrl_ops;
36 } Slapi_Control;
37
38 typedef struct _ExtendedOp {
39         struct berval           ext_oid;
40         SLAPI_FUNC              ext_func;
41         Backend                 *ext_be;
42         struct _ExtendedOp      *ext_next;
43 } ExtendedOp;
44
45 int slapi_log_error( int severity, char *subsystem, char *fmt, ... );
46 Slapi_Entry *slapi_str2entry( char *s, int flags );
47 char *slapi_entry2str( Slapi_Entry *e, int *len );
48 int slapi_entry_attr_merge( Slapi_Entry *e, char *type, struct berval **vals );
49 int slapi_entry_attr_find( Slapi_Entry *e, char *type, Slapi_Attr **attr );
50 int slapi_entry_attr_delete( Slapi_Entry *e, char *type );
51 char *slapi_entry_get_dn( Slapi_Entry *e );
52 void slapi_entry_set_dn( Slapi_Entry *e, char *dn );
53 Slapi_Entry *slapi_entry_dup( Slapi_Entry *e );
54 Slapi_Entry *slapi_entry_alloc();
55 void slapi_entry_free( Slapi_Entry *e );
56 int slapi_attr_get_values( Slapi_Attr *attr, struct berval ***vals );
57 char *slapi_ch_malloc( unsigned long size );
58 void slapi_ch_free( void **ptr );
59 char *slapi_ch_calloc( unsigned long nelem, unsigned long size );
60 char *slapi_ch_realloc( char *block, unsigned long size );
61 char *slapi_ch_strdup( char *s );
62 /*
63  * FIXME: these two were missing, but widely used in a couple of .c files
64  */
65 size_t slapi_strlen(char *s );
66 #define slapi_ch_stlen(s)       slapi_strlen(s)
67 /* end of FIXME */
68 char *slapi_dn_normalize( char *dn );
69 char *slapi_dn_normalize_case( char *dn );
70 char * slapi_esc_dn_normalize( char *dn );
71 char * slapi_esc_dn_normalize_case( char *dn );
72 int slapi_dn_isroot( Slapi_PBlock *pb, char *dn );
73 int slapi_dn_issuffix( char *dn, char *suffix );
74 char *slapi_dn_ignore_case( char *dn );
75 char *slapi_get_hostname();
76 void slapi_register_supported_saslmechanism( char *mechanism );
77 void slapi_send_ldap_result( Slapi_PBlock *pb, int err, 
78         char *matched, char *text, int nentries, struct berval **urls );
79 int slapi_send_ldap_extended_response(Connection *conn, Operation *op, 
80                         int errornum, char *respName, struct berval *response);
81 int slapi_send_ldap_search_entry( Slapi_PBlock *pb, Slapi_Entry *e, 
82                         LDAPControl **ectrls, char **attrs, int attrsonly ); 
83 void slapi_register_supported_control(char *controloid, 
84                                         unsigned long controlops);
85 int slapi_get_supported_controls(char ***ctrloidsp, unsigned long **ctrlopsp);
86 int slapi_control_present( LDAPControl **controls, char *oid, 
87                                 struct berval **val, int *iscritical);
88 void slapi_register_supported_saslmechanism(char *mechanism);
89 char **slapi_get_supported_saslmechanisms();
90 char **slapi_get_supported_extended_ops(void);
91 int checkControlHonored(LDAPControl **controls, char *pControlOid, 
92                                 unsigned long operation, int *isHonored );
93 void slapi_broadcast_be(int funcType, Slapi_PBlock *pPB);
94 Slapi_Filter *slapi_str2filter( char *str );
95 void slapi_filter_free( Slapi_Filter *f, int recurse );
96 int slapi_filter_get_choice( Slapi_Filter *f);
97 int slapi_filter_get_ava( Slapi_Filter *f, char **type, struct berval **bval );
98 Slapi_Filter *slapi_filter_list_first( Slapi_Filter *f );
99 Slapi_Filter *slapi_filter_list_next( Slapi_Filter *f, Slapi_Filter *fprev );
100 void slapi_free_search_results_internal(Slapi_PBlock *pb);
101 int slapi_is_connection_ssl(Slapi_PBlock *pPB, int *isSSL);
102 int slapi_get_client_port(Slapi_PBlock *pPB, int *fromPort);
103 int slapi_get_num_be(char *type);
104 unsigned long slapi_timer_current_time();
105 unsigned long slapi_timer_get_time(char *label);
106 void slapi_timer_elapsed_time(char *label,unsigned long start);
107 int slapi_audit_init_header( Connection *conn, Operation *op, 
108                 Audit_record **arp, void **audit_op_str,        
109                 int audit_op, int audit_ext_op, int audit_op_str_len); 
110 int slapi_audit_send_record( Slapi_PBlock *pb, Connection *conn, 
111                                                 Operation *op, int rc);
112
113 int slapi_x_backend_set_pb( Slapi_PBlock *pb, Backend *be );
114 int slapi_x_connection_set_pb( Slapi_PBlock *pb, Connection *conn );
115 int slapi_x_operation_set_pb( Slapi_PBlock *pb, Operation *op );
116
117 extern ldap_pvt_thread_mutex_t  slapi_hn_mutex;
118 extern ldap_pvt_thread_mutex_t  slapi_time_mutex;
119 extern ldap_pvt_thread_mutex_t  slapi_printmessage_mutex; 
120 extern char                     *slapi_log_file;
121 extern int                      slapi_log_level;
122
123 LDAP_END_DECL
124
125 #endif /* _SLAPI_UTILS_H */
126