2 * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
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.
11 * Copyright (c) 1996 Regents of the University of Michigan.
12 * All rights reserved.
14 * Redistribution and use in source and binary forms are permitted
15 * provided that this notice is preserved and that due credit is given
16 * to the University of Michigan at Ann Arbor. The name of the University
17 * may not be used to endorse or promote products derived from this
18 * software without specific prior written permission. This software
19 * is provided ``as is'' without express or implied warranty.
25 #include <ldap_cdefs.h>
29 extern int ldif_debug;
31 #define LINE_WIDTH 76 /* maximum length of LDIF lines */
34 * Macro to calculate maximum number of bytes that the base64 equivalent
35 * of an item that is "vlen" bytes long will take up. Base64 encoding
36 * uses one byte for every six bits in the value plus up to two pad bytes.
38 #define LDIF_BASE64_LEN(vlen) (((vlen) * 4 / 3 ) + 3)
41 * Macro to calculate maximum size that an LDIF-encoded type (length
42 * tlen) and value (length vlen) will take up: room for type + ":: " +
43 * first newline + base64 value + continued lines. Each continued line
44 * needs room for a newline and a leading space character.
46 #define LDIF_SIZE_NEEDED(tlen,vlen) \
47 ((tlen) + 4 + LDIF_BASE64_LEN(vlen) \
48 + ((LDIF_BASE64_LEN(vlen) + (tlen) + 3) / LINE_WIDTH * 2 ))
51 ldif_parse_line LDAP_P(( char *line, char **type, char **value, int *vlen));
54 ldif_getline LDAP_P(( char **next ));
57 ldif_put_type_and_value LDAP_P(( char **out, char *t, char *val, int vlen ));
60 *ldif_type_and_value LDAP_P(( char *type, char *val, int vlen ));