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