2 * Copyright (c) 1996 Regents of the University of Michigan.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of Michigan at Ann Arbor. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
16 #include <ldap_cdefs.h>
20 extern int ldif_debug;
22 #define LINE_WIDTH 76 /* maximum length of LDIF lines */
25 * Macro to calculate maximum number of bytes that the base64 equivalent
26 * of an item that is "vlen" bytes long will take up. Base64 encoding
27 * uses one byte for every six bits in the value plus up to two pad bytes.
29 #define LDIF_BASE64_LEN(vlen) (((vlen) * 4 / 3 ) + 3)
32 * Macro to calculate maximum size that an LDIF-encoded type (length
33 * tlen) and value (length vlen) will take up: room for type + ":: " +
34 * first newline + base64 value + continued lines. Each continued line
35 * needs room for a newline and a leading space character.
37 #define LDIF_SIZE_NEEDED(tlen,vlen) \
38 ((tlen) + 4 + LDIF_BASE64_LEN(vlen) \
39 + ((LDIF_BASE64_LEN(vlen) + (tlen) + 3) / LINE_WIDTH * 2 ))
41 int ldif_parse_line LDAP_P(( char *line, char **type, char **value, int *vlen));
42 char * ldif_getline LDAP_P(( char **next ));
43 void ldif_put_type_and_value LDAP_P(( char **out, char *t, char *val, int vlen ));
44 char *ldif_type_and_value LDAP_P(( char *type, char *val, int vlen ));