]> git.sur5r.net Git - openldap/blob - include/lutil.h
Cleanup NT service support declarations
[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 LDAP_LUTIL_F( int )
69 lutil_authpasswd LDAP_P((
70         const struct berval *passwd,    /* stored password */
71         const struct berval *cred,      /* user supplied value */
72         const char **methods ));
73
74 LDAP_LUTIL_F( int )
75 lutil_authpasswd_hash LDAP_P((
76         const struct berval *cred,
77         struct berval **passwd, /* password to store */
78         struct berval **salt,   /* salt to store */
79         const char *method ));
80
81 #if defined( SLAPD_SPASSWD ) && defined( HAVE_CYRUS_SASL )
82         /* cheat to avoid pulling in <sasl.h> */
83 LDAP_LUTIL_V( struct sasl_conn * ) lutil_passwd_sasl_conn;
84 #endif
85
86 LDAP_LUTIL_F( int )
87 lutil_passwd LDAP_P((
88         const struct berval *passwd,    /* stored password */
89         const struct berval *cred,      /* user supplied value */
90         const char **methods ));
91
92 LDAP_LUTIL_F( struct berval * )
93 lutil_passwd_generate LDAP_P(( ber_len_t ));
94
95 LDAP_LUTIL_F( struct berval * )
96 lutil_passwd_hash LDAP_P((
97         const struct berval *passwd,
98         const char *method ));
99
100 LDAP_LUTIL_F( int )
101 lutil_passwd_scheme LDAP_P((
102         const char *scheme ));
103
104 LDAP_LUTIL_F( int )
105 lutil_salt_format LDAP_P((
106         const char *format ));
107
108 /* utils.c */
109 LDAP_LUTIL_F( char* )
110 lutil_progname LDAP_P((
111         const char* name,
112         int argc,
113         char *argv[] ));
114
115 LDAP_LUTIL_F( char* )
116 lutil_strcopy LDAP_P(( char *dst, const char *src ));
117
118 LDAP_LUTIL_F( char* )
119 lutil_strncopy LDAP_P(( char *dst, const char *src, size_t n ));
120
121 struct tm;
122
123 /* use this macro to statically allocate buffer for lutil_gentime */
124 #define LDAP_LUTIL_GENTIME_BUFSIZE      22
125 LDAP_LUTIL_F( size_t )
126 lutil_gentime LDAP_P(( char *s, size_t max, const struct tm *tm ));
127
128 #ifndef HAVE_MKSTEMP
129 LDAP_LUTIL_F( int )
130 mkstemp LDAP_P (( char * template ));
131 #endif
132
133 /* sockpair.c */
134 LDAP_LUTIL_F( int )
135 lutil_pair( ber_socket_t sd[2] );
136
137 /* uuid.c */
138 /* use this macro to allocate buffer for lutil_uuidstr */
139 #define LDAP_LUTIL_UUIDSTR_BUFSIZE      40
140 LDAP_LUTIL_F( size_t )
141 lutil_uuidstr( char *buf, size_t len );
142
143 /* csn.c */
144 /* use this macro to allocate buffer for lutil_csnstr */
145 #define LDAP_LUTIL_CSNSTR_BUFSIZE       64
146 LDAP_LUTIL_F( size_t )
147 lutil_csnstr( char *buf, size_t len, unsigned int replica, unsigned int mod );
148
149 /*
150  * Sometimes not all declarations in a header file are needed.
151  * An indicator to this is whether or not the symbol's type has
152  * been defined. Thus, we don't need to include a symbol if
153  * its type has not been defined through another header file.
154  */
155
156 #ifdef HAVE_NT_SERVICE_MANAGER
157 LDAP_LUTIL_V (int) is_NT_Service;
158
159 #ifdef _LDAP_PVT_THREAD_H
160 LDAP_LUTIL_V (ldap_pvt_thread_cond_t) started_event;
161 #endif /* _LDAP_PVT_THREAD_H */
162
163 /* macros are different between Windows and Mingw */
164 #if defined(_WINSVC_H) || defined(_WINSVC_)
165 LDAP_LUTIL_V (SERVICE_STATUS) lutil_ServiceStatus;
166 LDAP_LUTIL_V (SERVICE_STATUS_HANDLE) hlutil_ServiceStatus;
167 #endif /* _WINSVC_H */
168
169 LDAP_LUTIL_F (void)
170 lutil_CommenceStartupProcessing( char *serverName, void (*stopper)(int)) ;
171
172 LDAP_LUTIL_F (void)
173 lutil_ReportShutdownComplete( void );
174
175 LDAP_LUTIL_F (void *)
176 lutil_getRegParam( char *svc, char *value );
177
178 LDAP_LUTIL_F (int)
179 lutil_srv_install( char* service, char * displayName, char* filename,
180                  int auto_start );
181 LDAP_LUTIL_F (int)
182 lutil_srv_remove ( char* service, char* filename );
183
184 #endif /* HAVE_NT_SERVICE_MANAGER */
185
186 #ifdef HAVE_NT_EVENT_LOG
187 LDAP_LUTIL_F (void)
188 lutil_LogStartedEvent( char *svc, int slap_debug, char *configfile, char *urls );
189
190 LDAP_LUTIL_F (void)
191 lutil_LogStoppedEvent( char *svc );
192 #endif
193
194 #ifdef HAVE_EBCDIC
195 /* Generally this has only been used to put '\n' to stdout. We need to
196  * make sure it is output in EBCDIC.
197  */
198 #undef putchar
199 #undef putc
200 #define putchar(c)     putc((c), stdout)
201 #define putc(c,fp)     do { char x=(c); __atoe_l(&x,1); putc(x,fp); } while(0)
202 #endif
203
204 LDAP_END_DECL
205
206 #endif /* _LUTIL_H */