]> git.sur5r.net Git - openldap/blob - include/ldif.h
Added lber_get/set_option. Removed lber_debug/ldap_debug.
[openldap] / include / ldif.h
1 /*
2  * Copyright (c) 1996 Regents of the University of Michigan.
3  * All rights reserved.
4  *
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.
11  */
12
13 #ifndef _LDIF_H
14 #define _LDIF_H
15
16 #include <ldap_cdefs.h>
17
18 LDAP_BEGIN_DECL
19
20 extern int ldif_debug;
21
22 #define LINE_WIDTH      76      /* maximum length of LDIF lines */
23
24 /*
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.
28  */
29 #define LDIF_BASE64_LEN(vlen)   (((vlen) * 4 / 3 ) + 3)
30
31 /*
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.
36  */
37 #define LDIF_SIZE_NEEDED(tlen,vlen) \
38     ((tlen) + 4 + LDIF_BASE64_LEN(vlen) \
39     + ((LDIF_BASE64_LEN(vlen) + (tlen) + 3) / LINE_WIDTH * 2 ))
40
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 ));
45
46
47 LDAP_END_DECL
48
49 #endif /* _LDIF_H */