Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/ldap/include/ldif.h
4394 views
1
/* $OpenLDAP$ */
2
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3
*
4
* Copyright 1998-2024 The OpenLDAP Foundation.
5
* All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted only as authorized by the OpenLDAP
9
* Public License.
10
*
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>.
14
*/
15
/* Portions Copyright (c) 1996 Regents of the University of Michigan.
16
* All rights reserved.
17
*
18
* Redistribution and use in source and binary forms are permitted
19
* provided that this notice is preserved and that due credit is given
20
* to the University of Michigan at Ann Arbor. The name of the University
21
* may not be used to endorse or promote products derived from this
22
* software without specific prior written permission. This software
23
* is provided ``as is'' without express or implied warranty.
24
*/
25
26
#ifndef _LDIF_H
27
#define _LDIF_H
28
29
#include <ldap_cdefs.h>
30
31
LDAP_BEGIN_DECL
32
33
/* This is NOT a bogus extern declaration (unlike ldap_debug) */
34
LDAP_LDIF_V (int) ldif_debug;
35
36
#define LDIF_LINE_WIDTH 78 /* default maximum length of LDIF lines */
37
#define LDIF_LINE_WIDTH_MAX ((ber_len_t)-1) /* maximum length of LDIF lines */
38
#define LDIF_LINE_WIDTH_WRAP(wrap) ((wrap) == 0 ? LDIF_LINE_WIDTH : (wrap))
39
40
/*
41
* Macro to calculate maximum number of bytes that the base64 equivalent
42
* of an item that is "len" bytes long will take up. Base64 encoding
43
* uses one byte for every six bits in the value plus up to two pad bytes.
44
*/
45
#define LDIF_BASE64_LEN(len) (((len) * 4 / 3 ) + 3)
46
47
/*
48
* Macro to calculate maximum size that an LDIF-encoded type (length
49
* tlen) and value (length vlen) will take up: room for type + ":: " +
50
* first newline + base64 value + continued lines. Each continued line
51
* needs room for a newline and a leading space character.
52
*/
53
#define LDIF_SIZE_NEEDED(nlen,vlen) LDIF_SIZE_NEEDED_WRAP(nlen, vlen, 0)
54
55
#define LDIF_SIZE_NEEDED_WRAP(nlen,vlen,wrap) \
56
((nlen) + 4 + LDIF_BASE64_LEN(vlen) \
57
+ ((wrap) == 0 ? ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / ( LDIF_LINE_WIDTH-1 ) * 2 ) : \
58
((wrap) == LDIF_LINE_WIDTH_MAX ? 0 : ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / (wrap-1) * 2 ))))
59
60
LDAP_LDIF_F( int )
61
ldif_parse_line LDAP_P((
62
LDAP_CONST char *line,
63
char **name,
64
char **value,
65
ber_len_t *vlen ));
66
67
LDAP_LDIF_F( int )
68
ldif_parse_line2 LDAP_P((
69
char *line,
70
struct berval *type,
71
struct berval *value,
72
int *freeval ));
73
74
LDAP_LDIF_F( FILE * )
75
ldif_open_url LDAP_P(( LDAP_CONST char *urlstr ));
76
77
LDAP_LDIF_F( int )
78
ldif_fetch_url LDAP_P((
79
LDAP_CONST char *line,
80
char **value,
81
ber_len_t *vlen ));
82
83
LDAP_LDIF_F( char * )
84
ldif_getline LDAP_P(( char **next ));
85
86
LDAP_LDIF_F( int )
87
ldif_countlines LDAP_P(( LDAP_CONST char *line ));
88
89
/* ldif_ropen, rclose, read_record - just for reading LDIF files,
90
* no special open/close needed to write LDIF files.
91
*/
92
typedef struct LDIFFP {
93
FILE *fp;
94
struct LDIFFP *prev;
95
} LDIFFP;
96
97
LDAP_LDIF_F( LDIFFP * )
98
ldif_open LDAP_P(( LDAP_CONST char *file, LDAP_CONST char *mode ));
99
100
/* ldif_open equivalent that opens ldif stream in memory rather than from file */
101
LDAP_LDIF_F( LDIFFP * )
102
ldif_open_mem LDAP_P(( char *ldif, size_t size, LDAP_CONST char *mode ));
103
104
LDAP_LDIF_F( void )
105
ldif_close LDAP_P(( LDIFFP * ));
106
107
LDAP_LDIF_F( int )
108
ldif_read_record LDAP_P((
109
LDIFFP *fp,
110
unsigned long *lineno,
111
char **bufp,
112
int *buflen ));
113
114
LDAP_LDIF_F( int )
115
ldif_must_b64_encode_register LDAP_P((
116
LDAP_CONST char *name,
117
LDAP_CONST char *oid ));
118
119
LDAP_LDIF_F( void )
120
ldif_must_b64_encode_release LDAP_P(( void ));
121
122
#define LDIF_PUT_NOVALUE 0x0000 /* no value */
123
#define LDIF_PUT_VALUE 0x0001 /* value w/ auto detection */
124
#define LDIF_PUT_TEXT 0x0002 /* assume text */
125
#define LDIF_PUT_BINARY 0x0004 /* assume binary (convert to base64) */
126
#define LDIF_PUT_B64 0x0008 /* pre-converted base64 value */
127
128
#define LDIF_PUT_COMMENT 0x0010 /* comment */
129
#define LDIF_PUT_URL 0x0020 /* url */
130
#define LDIF_PUT_SEP 0x0040 /* separator */
131
132
LDAP_LDIF_F( void )
133
ldif_sput LDAP_P((
134
char **out,
135
int type,
136
LDAP_CONST char *name,
137
LDAP_CONST char *val,
138
ber_len_t vlen ));
139
140
LDAP_LDIF_F( void )
141
ldif_sput_wrap LDAP_P((
142
char **out,
143
int type,
144
LDAP_CONST char *name,
145
LDAP_CONST char *val,
146
ber_len_t vlen,
147
ber_len_t wrap ));
148
149
LDAP_LDIF_F( char * )
150
ldif_put LDAP_P((
151
int type,
152
LDAP_CONST char *name,
153
LDAP_CONST char *val,
154
ber_len_t vlen ));
155
156
LDAP_LDIF_F( char * )
157
ldif_put_wrap LDAP_P((
158
int type,
159
LDAP_CONST char *name,
160
LDAP_CONST char *val,
161
ber_len_t vlen,
162
ber_len_t wrap ));
163
164
LDAP_LDIF_F( int )
165
ldif_is_not_printable LDAP_P((
166
LDAP_CONST char *val,
167
ber_len_t vlen ));
168
169
LDAP_END_DECL
170
171
#endif /* _LDIF_H */
172
173