]> git.sur5r.net Git - openldap/blob - include/ldif.h
a28dd3044fe635abe657ada6cb6e48297a6d2f29
[openldap] / include / ldif.h
1 /*
2  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted only
6  * as authorized by the OpenLDAP Public License.  A copy of this
7  * license is available at http://www.OpenLDAP.org/license.html or
8  * in file LICENSE in the top-level directory of the distribution.
9  */
10
11 /* Portions
12  * Copyright (c) 1996 Regents of the University of Michigan.
13  * All rights reserved.
14  *
15  * Redistribution and use in source and binary forms are permitted
16  * provided that this notice is preserved and that due credit is given
17  * to the University of Michigan at Ann Arbor. The name of the University
18  * may not be used to endorse or promote products derived from this
19  * software without specific prior written permission. This software
20  * is provided ``as is'' without express or implied warranty.
21  */
22
23 #ifndef _LDIF_H
24 #define _LDIF_H
25
26 #include <ldap_cdefs.h>
27
28 LDAP_BEGIN_DECL
29
30 extern int ldif_debug;
31
32 #define LDIF_LINE_WIDTH      76      /* maximum length of LDIF lines */
33
34 /*
35  * Macro to calculate maximum number of bytes that the base64 equivalent
36  * of an item that is "len" bytes long will take up.  Base64 encoding
37  * uses one byte for every six bits in the value plus up to two pad bytes.
38  */
39 #define LDIF_BASE64_LEN(len)    (((len) * 4 / 3 ) + 3)
40
41 /*
42  * Macro to calculate maximum size that an LDIF-encoded type (length
43  * tlen) and value (length vlen) will take up:  room for type + ":: " +
44  * first newline + base64 value + continued lines.  Each continued line
45  * needs room for a newline and a leading space character.
46  */
47 #define LDIF_SIZE_NEEDED(nlen,vlen) \
48     ((nlen) + 4 + LDIF_BASE64_LEN(vlen) \
49     + ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / LDIF_LINE_WIDTH * 2 ))
50
51 LDAP_F( int )
52 ldif_parse_line LDAP_P((
53         LDAP_CONST char *line,
54         char **name,
55         char **value,
56         ber_len_t *vlen ));
57
58 LDAP_F( int )
59 ldif_fetch_url LDAP_P((
60         LDAP_CONST char *line,
61         char **value,
62         ber_len_t *vlen ));
63
64 LDAP_F( char * )
65 ldif_getline LDAP_P(( char **next ));
66
67 #define LDIF_PUT_NOVALUE        0x0000  /* no value */
68 #define LDIF_PUT_VALUE          0x0001  /* value w/ auto detection */
69 #define LDIF_PUT_TEXT           0x0002  /* assume text */
70 #define LDIF_PUT_BINARY         0x0004  /* assume binary (convert to base64) */
71 #define LDIF_PUT_B64            0x0008  /* pre-converted base64 value */
72
73 #define LDIF_PUT_COMMENT        0x0010  /* comment */
74 #define LDIF_PUT_URL            0x0020  /* url */
75 #define LDIF_PUT_SEP            0x0040  /* separator */
76
77 LDAP_F( void )
78 ldif_sput LDAP_P((
79         char **out,
80         int type,
81         LDAP_CONST char *name,
82         LDAP_CONST char *val,
83         ber_len_t vlen ));
84
85 LDAP_F( char * )
86 ldif_put LDAP_P((
87         int type,
88         LDAP_CONST char *name,
89         LDAP_CONST char *val,
90         ber_len_t vlen ));
91
92 LDAP_F( int )
93 ldif_is_not_printable LDAP_P((
94         LDAP_CONST char *val,
95         ber_len_t vlen ));
96
97 LDAP_END_DECL
98
99 #endif /* _LDIF_H */