2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2004 The OpenLDAP Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
11 * A copy of this license is available in file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
19 #include <ldap_cdefs.h>
20 #include <lber_types.h>
23 * Include file for LDAP utility routine
28 /* n octets encode into ceiling(n/3) * 4 bytes */
29 /* Avoid floating point math through extra padding */
31 #define LUTIL_BASE64_ENCODE_LEN(n) (((n)+2)/3 * 4)
32 #define LUTIL_BASE64_DECODE_LEN(n) ((n)/4*3)
34 /* ISC Base64 Routines */
38 lutil_b64_ntop LDAP_P((
39 unsigned char const *,
45 lutil_b64_pton LDAP_P((
58 lutil_entropy LDAP_P((
63 struct berval; /* avoid pulling in lber.h */
66 lutil_get_filed_password LDAP_P((
71 struct lutil_pw_scheme;
73 #define LUTIL_PASSWD_OK (0)
74 #define LUTIL_PASSWD_ERR (-1)
76 typedef int (LUTIL_PASSWD_CHK_FUNC)(
77 const struct berval *scheme,
78 const struct berval *passwd,
79 const struct berval *cred,
82 typedef int (LUTIL_PASSWD_HASH_FUNC) (
83 const struct berval *scheme,
84 const struct berval *passwd,
89 lutil_passwd_add LDAP_P((
90 struct berval *scheme,
91 LUTIL_PASSWD_CHK_FUNC *chk_fn,
92 LUTIL_PASSWD_HASH_FUNC *hash_fn ));
95 lutil_passwd_init LDAP_P(( void ));
98 lutil_passwd_destroy LDAP_P(( void ));
101 lutil_authpasswd LDAP_P((
102 const struct berval *passwd, /* stored password */
103 const struct berval *cred, /* user supplied value */
104 const char **methods ));
107 lutil_authpasswd_hash LDAP_P((
108 const struct berval *cred,
109 struct berval **passwd, /* password to store */
110 struct berval **salt, /* salt to store */
111 const char *method ));
113 #if defined( SLAPD_SPASSWD ) && defined( HAVE_CYRUS_SASL )
114 /* cheat to avoid pulling in <sasl.h> */
115 LDAP_LUTIL_V( struct sasl_conn * ) lutil_passwd_sasl_conn;
119 lutil_passwd LDAP_P((
120 const struct berval *passwd, /* stored password */
121 const struct berval *cred, /* user supplied value */
122 const char **methods,
123 const char **text )); /* error message */
126 lutil_passwd_generate LDAP_P(( struct berval *pw, ber_len_t ));
129 lutil_passwd_hash LDAP_P((
130 const struct berval *passwd,
133 const char **text ));
136 lutil_passwd_scheme LDAP_P((
137 const char *scheme ));
140 lutil_salt_format LDAP_P((
141 const char *format ));
144 LDAP_LUTIL_F( char* )
145 lutil_progname LDAP_P((
152 lutil_slashpath LDAP_P(( char* path ));
153 #define LUTIL_SLASHPATH(p) lutil_slashpath(p)
155 #define LUTIL_SLASHPATH(p)
158 LDAP_LUTIL_F( char* )
159 lutil_strcopy LDAP_P(( char *dst, const char *src ));
161 LDAP_LUTIL_F( char* )
162 lutil_strncopy LDAP_P(( char *dst, const char *src, size_t n ));
166 /* use this macro to statically allocate buffer for lutil_gentime */
167 #define LDAP_LUTIL_GENTIME_BUFSIZE 22
168 #define lutil_gentime(s,m,t) lutil_localtime((s),(m),(t),0)
169 LDAP_LUTIL_F( size_t )
170 lutil_localtime LDAP_P(( char *s, size_t smax, const struct tm *tm,
175 mkstemp LDAP_P (( char * template ));
180 lutil_pair( ber_socket_t sd[2] );
183 /* use this macro to allocate buffer for lutil_uuidstr */
184 #define LDAP_LUTIL_UUIDSTR_BUFSIZE 40
185 LDAP_LUTIL_F( size_t )
186 lutil_uuidstr( char *buf, size_t len );
189 /* use this macro to allocate buffer for lutil_csnstr */
190 #define LDAP_LUTIL_CSNSTR_BUFSIZE 64
191 LDAP_LUTIL_F( size_t )
192 lutil_csnstr( char *buf, size_t len, unsigned int replica, unsigned int mod );
195 * Sometimes not all declarations in a header file are needed.
196 * An indicator to this is whether or not the symbol's type has
197 * been defined. Thus, we don't need to include a symbol if
198 * its type has not been defined through another header file.
201 #ifdef HAVE_NT_SERVICE_MANAGER
202 LDAP_LUTIL_V (int) is_NT_Service;
204 #ifdef _LDAP_PVT_THREAD_H
205 LDAP_LUTIL_V (ldap_pvt_thread_cond_t) started_event;
206 #endif /* _LDAP_PVT_THREAD_H */
208 /* macros are different between Windows and Mingw */
209 #if defined(_WINSVC_H) || defined(_WINSVC_)
210 LDAP_LUTIL_V (SERVICE_STATUS) lutil_ServiceStatus;
211 LDAP_LUTIL_V (SERVICE_STATUS_HANDLE) hlutil_ServiceStatus;
212 #endif /* _WINSVC_H */
215 lutil_CommenceStartupProcessing( char *serverName, void (*stopper)(int)) ;
218 lutil_ReportShutdownComplete( void );
220 LDAP_LUTIL_F (void *)
221 lutil_getRegParam( char *svc, char *value );
224 lutil_srv_install( char* service, char * displayName, char* filename,
227 lutil_srv_remove ( char* service, char* filename );
229 #endif /* HAVE_NT_SERVICE_MANAGER */
231 #ifdef HAVE_NT_EVENT_LOG
233 lutil_LogStartedEvent( char *svc, int slap_debug, char *configfile, char *urls );
236 lutil_LogStoppedEvent( char *svc );
240 /* Generally this has only been used to put '\n' to stdout. We need to
241 * make sure it is output in EBCDIC.
245 #define putchar(c) putc((c), stdout)
246 #define putc(c,fp) do { char x=(c); __atoe_l(&x,1); putc(x,fp); } while(0)
251 #endif /* _LUTIL_H */