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