]> git.sur5r.net Git - openldap/blob - include/lutil.h
Fix version check in previous
[openldap] / include / lutil.h
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2003 The OpenLDAP Foundation, Redwood City, California, USA
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted only as authorized by the OpenLDAP
8  * Public License.  A copy of this license is available at
9  * http://www.OpenLDAP.org/license.html or in file LICENSE in the
10  * top-level directory of the distribution.
11  */
12
13 #ifndef _LUTIL_H
14 #define _LUTIL_H 1
15
16 #include <ldap_cdefs.h>
17 #include <lber_types.h>
18
19 /*
20  * Include file for LDAP utility routine
21  */
22
23 LDAP_BEGIN_DECL
24
25 /* n octets encode into ceiling(n/3) * 4 bytes */
26 /* Avoid floating point math through extra padding */
27
28 #define LUTIL_BASE64_ENCODE_LEN(n)      (((n)+2)/3 * 4)
29 #define LUTIL_BASE64_DECODE_LEN(n)      (((n)+3)/4 * 3)
30
31 /* ISC Base64 Routines */
32 /* base64.c */
33
34 LDAP_LUTIL_F( int )
35 lutil_b64_ntop LDAP_P((
36         unsigned char const *,
37         size_t,
38         char *,
39         size_t));
40
41 LDAP_LUTIL_F( int )
42 lutil_b64_pton LDAP_P((
43         char const *,
44         unsigned char *,
45         size_t));
46
47 /* detach.c */
48 LDAP_LUTIL_F( void )
49 lutil_detach LDAP_P((
50         int debug,
51         int do_close));
52
53 /* entropy.c */
54 LDAP_LUTIL_F( int )
55 lutil_entropy LDAP_P((
56         unsigned char *buf,
57         ber_len_t nbytes ));
58
59 /* passfile.c */
60 struct berval;  /* avoid pulling in lber.h */
61
62 LDAP_LUTIL_F( int )
63 lutil_get_filed_password LDAP_P((
64         const char *filename,
65         struct berval * ));
66
67 /* passwd.c */
68 struct lutil_pw_scheme;
69
70 typedef int (LUTIL_PASSWD_CHK_FUNC)(
71         const struct berval *scheme,
72         const struct berval *passwd,
73         const struct berval *cred );
74
75 typedef struct berval * (LUTIL_PASSWD_HASH_FUNC) (
76         const struct berval *scheme,
77         const struct berval *passwd );
78
79 LDAP_LUTIL_F( int )
80 lutil_passwd_add LDAP_P((
81         struct berval *scheme,
82         LUTIL_PASSWD_CHK_FUNC *chk_fn,
83         LUTIL_PASSWD_HASH_FUNC *hash_fn ));
84
85 LDAP_LUTIL_F( void )
86 lutil_passwd_init LDAP_P(( void ));
87
88 LDAP_LUTIL_F( void )
89 lutil_passwd_destroy LDAP_P(( void ));
90
91 LDAP_LUTIL_F( int )
92 lutil_authpasswd LDAP_P((
93         const struct berval *passwd,    /* stored password */
94         const struct berval *cred,      /* user supplied value */
95         const char **methods ));
96
97 LDAP_LUTIL_F( int )
98 lutil_authpasswd_hash LDAP_P((
99         const struct berval *cred,
100         struct berval **passwd, /* password to store */
101         struct berval **salt,   /* salt to store */
102         const char *method ));
103
104 #if defined( SLAPD_SPASSWD ) && defined( HAVE_CYRUS_SASL )
105         /* cheat to avoid pulling in <sasl.h> */
106 LDAP_LUTIL_V( struct sasl_conn * ) lutil_passwd_sasl_conn;
107 #endif
108
109 LDAP_LUTIL_F( int )
110 lutil_passwd LDAP_P((
111         const struct berval *passwd,    /* stored password */
112         const struct berval *cred,      /* user supplied value */
113         const char **methods ));
114
115 LDAP_LUTIL_F( struct berval * )
116 lutil_passwd_generate LDAP_P(( ber_len_t ));
117
118 LDAP_LUTIL_F( struct berval * )
119 lutil_passwd_hash LDAP_P((
120         const struct berval *passwd,
121         const char *method ));
122
123 LDAP_LUTIL_F( int )
124 lutil_passwd_scheme LDAP_P((
125         const char *scheme ));
126
127 LDAP_LUTIL_F( int )
128 lutil_salt_format LDAP_P((
129         const char *format ));
130
131 /* utils.c */
132 LDAP_LUTIL_F( char* )
133 lutil_progname LDAP_P((
134         const char* name,
135         int argc,
136         char *argv[] ));
137
138 LDAP_LUTIL_F( char* )
139 lutil_strcopy LDAP_P(( char *dst, const char *src ));
140
141 LDAP_LUTIL_F( char* )
142 lutil_strncopy LDAP_P(( char *dst, const char *src, size_t n ));
143
144 struct tm;
145
146 /* use this macro to statically allocate buffer for lutil_gentime */
147 #define LDAP_LUTIL_GENTIME_BUFSIZE      22
148 LDAP_LUTIL_F( size_t )
149 lutil_gentime LDAP_P(( char *s, size_t max, const struct tm *tm ));
150
151 #ifndef HAVE_MKSTEMP
152 LDAP_LUTIL_F( int )
153 mkstemp LDAP_P (( char * template ));
154 #endif
155
156 /* sockpair.c */
157 LDAP_LUTIL_F( int )
158 lutil_pair( ber_socket_t sd[2] );
159
160 /* uuid.c */
161 /* use this macro to allocate buffer for lutil_uuidstr */
162 #define LDAP_LUTIL_UUIDSTR_BUFSIZE      40
163 LDAP_LUTIL_F( size_t )
164 lutil_uuidstr( char *buf, size_t len );
165
166 /* csn.c */
167 /* use this macro to allocate buffer for lutil_csnstr */
168 #define LDAP_LUTIL_CSNSTR_BUFSIZE       64
169 LDAP_LUTIL_F( size_t )
170 lutil_csnstr( char *buf, size_t len, unsigned int replica, unsigned int mod );
171
172 /*
173  * Sometimes not all declarations in a header file are needed.
174  * An indicator to this is whether or not the symbol's type has
175  * been defined. Thus, we don't need to include a symbol if
176  * its type has not been defined through another header file.
177  */
178
179 #ifdef HAVE_NT_SERVICE_MANAGER
180 LDAP_LUTIL_V (int) is_NT_Service;
181
182 #ifdef _LDAP_PVT_THREAD_H
183 LDAP_LUTIL_V (ldap_pvt_thread_cond_t) started_event;
184 #endif /* _LDAP_PVT_THREAD_H */
185
186 /* macros are different between Windows and Mingw */
187 #if defined(_WINSVC_H) || defined(_WINSVC_)
188 LDAP_LUTIL_V (SERVICE_STATUS) lutil_ServiceStatus;
189 LDAP_LUTIL_V (SERVICE_STATUS_HANDLE) hlutil_ServiceStatus;
190 #endif /* _WINSVC_H */
191
192 LDAP_LUTIL_F (void)
193 lutil_CommenceStartupProcessing( char *serverName, void (*stopper)(int)) ;
194
195 LDAP_LUTIL_F (void)
196 lutil_ReportShutdownComplete( void );
197
198 LDAP_LUTIL_F (void *)
199 lutil_getRegParam( char *svc, char *value );
200
201 LDAP_LUTIL_F (int)
202 lutil_srv_install( char* service, char * displayName, char* filename,
203                  int auto_start );
204 LDAP_LUTIL_F (int)
205 lutil_srv_remove ( char* service, char* filename );
206
207 #endif /* HAVE_NT_SERVICE_MANAGER */
208
209 #ifdef HAVE_NT_EVENT_LOG
210 LDAP_LUTIL_F (void)
211 lutil_LogStartedEvent( char *svc, int slap_debug, char *configfile, char *urls );
212
213 LDAP_LUTIL_F (void)
214 lutil_LogStoppedEvent( char *svc );
215 #endif
216
217 #ifdef HAVE_EBCDIC
218 /* Generally this has only been used to put '\n' to stdout. We need to
219  * make sure it is output in EBCDIC.
220  */
221 #undef putchar
222 #undef putc
223 #define putchar(c)     putc((c), stdout)
224 #define putc(c,fp)     do { char x=(c); __atoe_l(&x,1); putc(x,fp); } while(0)
225 #endif
226
227 LDAP_END_DECL
228
229 #endif /* _LUTIL_H */