]> git.sur5r.net Git - openldap/blob - include/ldif.h
Fixes for NT dynamic linking.
[openldap] / include / ldif.h
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms are permitted only
7  * as authorized by the OpenLDAP Public License.  A copy of this
8  * license is available at http://www.OpenLDAP.org/license.html or
9  * in file LICENSE in the top-level directory of the distribution.
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 /* This is NOT a bogus extern declaration (unlike ldap_debug) */
31 LIBLDIF_F (int) ldif_debug;
32
33 #define LDIF_LINE_WIDTH      76      /* maximum length of LDIF lines */
34
35 /*
36  * Macro to calculate maximum number of bytes that the base64 equivalent
37  * of an item that is "len" bytes long will take up.  Base64 encoding
38  * uses one byte for every six bits in the value plus up to two pad bytes.
39  */
40 #define LDIF_BASE64_LEN(len)    (((len) * 4 / 3 ) + 3)
41
42 /*
43  * Macro to calculate maximum size that an LDIF-encoded type (length
44  * tlen) and value (length vlen) will take up:  room for type + ":: " +
45  * first newline + base64 value + continued lines.  Each continued line
46  * needs room for a newline and a leading space character.
47  */
48 #define LDIF_SIZE_NEEDED(nlen,vlen) \
49     ((nlen) + 4 + LDIF_BASE64_LEN(vlen) \
50     + ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / LDIF_LINE_WIDTH * 2 ))
51
52 LIBLDIF_F( int )
53 ldif_parse_line LDAP_P((
54         LDAP_CONST char *line,
55         char **name,
56         char **value,
57         ber_len_t *vlen ));
58
59 LIBLDIF_F( int )
60 ldif_fetch_url LDAP_P((
61         LDAP_CONST char *line,
62         char **value,
63         ber_len_t *vlen ));
64
65 LIBLDIF_F( char * )
66 ldif_getline LDAP_P(( char **next ));
67
68 LIBLDIF_F( int )
69 ldif_read_record LDAP_P((
70         FILE *fp,
71         int *lineno,
72         char **bufp,
73         int *buflen ));
74
75
76 #define LDIF_PUT_NOVALUE        0x0000  /* no value */
77 #define LDIF_PUT_VALUE          0x0001  /* value w/ auto detection */
78 #define LDIF_PUT_TEXT           0x0002  /* assume text */
79 #define LDIF_PUT_BINARY         0x0004  /* assume binary (convert to base64) */
80 #define LDIF_PUT_B64            0x0008  /* pre-converted base64 value */
81
82 #define LDIF_PUT_COMMENT        0x0010  /* comment */
83 #define LDIF_PUT_URL            0x0020  /* url */
84 #define LDIF_PUT_SEP            0x0040  /* separator */
85
86 LIBLDIF_F( void )
87 ldif_sput LDAP_P((
88         char **out,
89         int type,
90         LDAP_CONST char *name,
91         LDAP_CONST char *val,
92         ber_len_t vlen ));
93
94 LIBLDIF_F( char * )
95 ldif_put LDAP_P((
96         int type,
97         LDAP_CONST char *name,
98         LDAP_CONST char *val,
99         ber_len_t vlen ));
100
101 LIBLDIF_F( int )
102 ldif_is_not_printable LDAP_P((
103         LDAP_CONST char *val,
104         ber_len_t vlen ));
105
106 LDAP_END_DECL
107
108 #endif /* _LDIF_H */