2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2004 The OpenLDAP Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
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>.
15 /* Portions Copyright (c) 1996 Regents of the University of Michigan.
16 * All rights reserved.
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.
29 #include <ldap_cdefs.h>
33 /* This is NOT a bogus extern declaration (unlike ldap_debug) */
34 LDAP_LDIF_V (int) ldif_debug;
36 #define LDIF_LINE_WIDTH 76 /* maximum length of LDIF lines */
39 * Macro to calculate maximum number of bytes that the base64 equivalent
40 * of an item that is "len" bytes long will take up. Base64 encoding
41 * uses one byte for every six bits in the value plus up to two pad bytes.
43 #define LDIF_BASE64_LEN(len) (((len) * 4 / 3 ) + 3)
46 * Macro to calculate maximum size that an LDIF-encoded type (length
47 * tlen) and value (length vlen) will take up: room for type + ":: " +
48 * first newline + base64 value + continued lines. Each continued line
49 * needs room for a newline and a leading space character.
51 #define LDIF_SIZE_NEEDED(nlen,vlen) \
52 ((nlen) + 4 + LDIF_BASE64_LEN(vlen) \
53 + ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / LDIF_LINE_WIDTH * 2 ))
56 ldif_parse_line LDAP_P((
57 LDAP_CONST char *line,
63 ldif_fetch_url LDAP_P((
64 LDAP_CONST char *line,
69 ldif_getline LDAP_P(( char **next ));
72 ldif_read_record LDAP_P((
79 #define LDIF_PUT_NOVALUE 0x0000 /* no value */
80 #define LDIF_PUT_VALUE 0x0001 /* value w/ auto detection */
81 #define LDIF_PUT_TEXT 0x0002 /* assume text */
82 #define LDIF_PUT_BINARY 0x0004 /* assume binary (convert to base64) */
83 #define LDIF_PUT_B64 0x0008 /* pre-converted base64 value */
85 #define LDIF_PUT_COMMENT 0x0010 /* comment */
86 #define LDIF_PUT_URL 0x0020 /* url */
87 #define LDIF_PUT_SEP 0x0040 /* separator */
93 LDAP_CONST char *name,
100 LDAP_CONST char *name,
101 LDAP_CONST char *val,
105 ldif_is_not_printable LDAP_P((
106 LDAP_CONST char *val,