]> git.sur5r.net Git - openldap/blob - include/ldif.h
ldif'ize ldif library (ie: everything is now in the ldif_ namespace)
[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 #define LINE_WIDTH      76      /* maximum length of LDIF lines */
21
22 /*
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.
26  */
27 #define LDIF_BASE64_LEN(vlen)   (((vlen) * 4 / 3 ) + 3)
28
29 /*
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.
34  */
35 #define LDIF_SIZE_NEEDED(tlen,vlen) \
36     ((tlen) + 4 + LDIF_BASE64_LEN(vlen) \
37     + ((LDIF_BASE64_LEN(vlen) + (tlen) + 3) / LINE_WIDTH * 2 ))
38
39 int ldif_parse_line LDAP_P(( char *line, char **type, char **value, int *vlen));
40 char * ldif_getline LDAP_P(( char **next ));
41 void ldif_put_type_and_value LDAP_P(( char **out, char *t, char *val, int vlen ));
42 char *ldif_type_and_value LDAP_P(( char *type, char *val, int vlen ));
43
44
45 LDAP_END_DECL
46
47 #endif /* _LDIF_H */