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 #define LINE_WIDTH 76 /* maximum length of LDIF lines */
32 * Macro to calculate maximum number of bytes that the base64 equivalent
33 * of an item that is "vlen" bytes long will take up. Base64 encoding
34 * uses one byte for every six bits in the value plus up to two pad bytes.
36 #define LDIF_BASE64_LEN(vlen) (((vlen) * 4 / 3 ) + 3)
39 * Macro to calculate maximum size that an LDIF-encoded type (length
40 * tlen) and value (length vlen) will take up: room for type + ":: " +
41 * first newline + base64 value + continued lines. Each continued line
42 * needs room for a newline and a leading space character.
44 #define LDIF_SIZE_NEEDED(tlen,vlen) \
45 ((tlen) + 4 + LDIF_BASE64_LEN(vlen) \
46 + ((LDIF_BASE64_LEN(vlen) + (tlen) + 3) / LINE_WIDTH * 2 ))
48 int str_parse_line LDAP_P(( char *line, char **type, char **value, int *vlen));
49 char * str_getline LDAP_P(( char **next ));
50 void put_type_and_value LDAP_P(( char **out, char *t, char *val, int vlen ));
51 char *ldif_type_and_value LDAP_P(( char *type, char *val, int vlen ));