]> git.sur5r.net Git - openldap/blob - include/lutil.h
Add back-bdb module
[openldap] / include / lutil.h
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2002 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 by through extra padding */
27
28 #define LUTIL_BASE64_ENCODE_LEN(n)      ((n)/3 * 4 + 4)
29 #define LUTIL_BASE64_DECODE_LEN(n)      ((n)/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 /* passwd.c */
60 struct berval; /* avoid pulling in lber.h */
61
62 LDAP_LUTIL_F( int )
63 lutil_authpasswd LDAP_P((
64         const struct berval *passwd,    /* stored password */
65         const struct berval *cred,      /* user supplied value */
66         const char **methods ));
67
68 LDAP_LUTIL_F( int )
69 lutil_authpasswd_hash LDAP_P((
70         const struct berval *cred,
71         struct berval **passwd, /* password to store */
72         struct berval **salt,   /* salt to store */
73         const char *method ));
74
75 #if defined( SLAPD_SPASSWD ) && defined( HAVE_CYRUS_SASL )
76         /* cheat to avoid pulling in <sasl.h> */
77 LDAP_LUTIL_V( struct sasl_conn * ) lutil_passwd_sasl_conn;
78 #endif
79
80 LDAP_LUTIL_F( int )
81 lutil_passwd LDAP_P((
82         const struct berval *passwd,    /* stored password */
83         const struct berval *cred,      /* user supplied value */
84         const char **methods ));
85
86 LDAP_LUTIL_F( struct berval * )
87 lutil_passwd_generate LDAP_P(( ber_len_t ));
88
89 LDAP_LUTIL_F( struct berval * )
90 lutil_passwd_hash LDAP_P((
91         const struct berval *passwd,
92         const char *method ));
93
94 LDAP_LUTIL_F( int )
95 lutil_passwd_scheme LDAP_P((
96         const char *scheme ));
97
98 LDAP_LUTIL_F( int )
99 lutil_salt_format LDAP_P((
100         const char *format ));
101
102 /* utils.c */
103 LDAP_LUTIL_F( char* )
104 lutil_progname LDAP_P((
105         const char* name,
106         int argc,
107         char *argv[] ));
108
109 LDAP_LUTIL_F( char* )
110 lutil_strcopy LDAP_P(( char *dst, const char *src ));
111
112 LDAP_LUTIL_F( char* )
113 lutil_strncopy LDAP_P(( char *dst, const char *src, size_t n ));
114
115 struct tm;
116
117 LDAP_LUTIL_F( size_t )
118 lutil_gentime LDAP_P(( char *s, size_t max, const struct tm *tm ));
119
120 #ifndef HAVE_MKSTEMP
121 LDAP_LUTIL_F( int )
122 mkstemp LDAP_P (( char * template ));
123 #endif
124
125 /* sockpair.c */
126 LDAP_LUTIL_F( int )
127 lutil_pair( ber_socket_t sd[2] );
128
129 /* uuid.c */
130 LDAP_LUTIL_F( size_t )
131 lutil_uuidstr( char *buf, size_t len );
132
133 /* csn.c */
134 LDAP_LUTIL_F( size_t )
135 lutil_csnstr( char *buf, size_t len, unsigned int replica, unsigned int mod );
136
137 /*
138  * Sometimes not all declarations in a header file are needed.
139  * An indicator to this is whether or not the symbol's type has
140  * been defined. Thus, we don't need to include a symbol if
141  * its type has not been defined through another header file.
142  */
143
144 #ifdef HAVE_NT_SERVICE_MANAGER
145 LDAP_LUTIL_V (int) is_NT_Service;
146
147 #ifdef _LDAP_PVT_THREAD_H
148 LDAP_LUTIL_V (ldap_pvt_thread_cond_t) started_event;
149 #endif /* _LDAP_PVT_THREAD_H */
150
151 /* macros are different between Windows and Mingw */
152 #if defined(_WINSVC_H) || defined(_WINSVC_)
153 LDAP_LUTIL_V (SERVICE_STATUS) SLAPDServiceStatus;
154 LDAP_LUTIL_V (SERVICE_STATUS_HANDLE) hSLAPDServiceStatus;
155 #endif /* _WINSVC_H */
156
157 #endif /* HAVE_NT_SERVICE_MANAGER */
158
159 #ifdef HAVE_EBCDIC
160 /* Generally this has only been used to put '\n' to stdout. We need to
161  * make sure it is output in EBCDIC.
162  */
163 #undef putchar
164 #undef putc
165 #define putchar(c)     putc((c), stdout)
166 #define putc(c,fp)     do { char x=(c); __atoe_l(&x,1); putc(x,fp); } while(0)
167 #endif
168
169 LDAP_END_DECL
170
171 #endif /* _LUTIL_H */