]> git.sur5r.net Git - openldap/blob - include/ldif.h
LDAPv3 Referrals (using old style referral entries) initial commit.
[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 #ifdef __cplusplus
17 extern "C" {
18 #endif
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
40 #ifdef NEEDPROTOS
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 */
46 int str_parse_line();
47 char * str_getline();
48 void put_type_and_value();
49 char *ldif_type_and_value();
50 #endif /* NEEDPROTOS */
51
52 #ifdef __cplusplus
53 }
54 #endif
55
56 #endif /* _LDIF_H */