xref: /onnv-gate/usr/src/lib/libldap5/include/ldap/ldif.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * Copyright (c) 2001 by Sun Microsystems, Inc.
3*0Sstevel@tonic-gate  * All rights reserved.
4*0Sstevel@tonic-gate  */
5*0Sstevel@tonic-gate 
6*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
7*0Sstevel@tonic-gate 
8*0Sstevel@tonic-gate /*
9*0Sstevel@tonic-gate  * The contents of this file are subject to the Netscape Public
10*0Sstevel@tonic-gate  * License Version 1.1 (the "License"); you may not use this file
11*0Sstevel@tonic-gate  * except in compliance with the License. You may obtain a copy of
12*0Sstevel@tonic-gate  * the License at http://www.mozilla.org/NPL/
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * Software distributed under the License is distributed on an "AS
15*0Sstevel@tonic-gate  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
16*0Sstevel@tonic-gate  * implied. See the License for the specific language governing
17*0Sstevel@tonic-gate  * rights and limitations under the License.
18*0Sstevel@tonic-gate  *
19*0Sstevel@tonic-gate  * The Original Code is Mozilla Communicator client code, released
20*0Sstevel@tonic-gate  * March 31, 1998.
21*0Sstevel@tonic-gate  *
22*0Sstevel@tonic-gate  * The Initial Developer of the Original Code is Netscape
23*0Sstevel@tonic-gate  * Communications Corporation. Portions created by Netscape are
24*0Sstevel@tonic-gate  * Copyright (C) 1998-1999 Netscape Communications Corporation. All
25*0Sstevel@tonic-gate  * Rights Reserved.
26*0Sstevel@tonic-gate  *
27*0Sstevel@tonic-gate  * Contributor(s):
28*0Sstevel@tonic-gate  */
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate /*
31*0Sstevel@tonic-gate  * Copyright (c) 1996 Regents of the University of Michigan.
32*0Sstevel@tonic-gate  * All rights reserved.
33*0Sstevel@tonic-gate  *
34*0Sstevel@tonic-gate  * Redistribution and use in source and binary forms are permitted
35*0Sstevel@tonic-gate  * provided that this notice is preserved and that due credit is given
36*0Sstevel@tonic-gate  * to the University of Michigan at Ann Arbor. The name of the University
37*0Sstevel@tonic-gate  * may not be used to endorse or promote products derived from this
38*0Sstevel@tonic-gate  * software without specific prior written permission. This software
39*0Sstevel@tonic-gate  * is provided ``as is'' without express or implied warranty.
40*0Sstevel@tonic-gate  */
41*0Sstevel@tonic-gate 
42*0Sstevel@tonic-gate #ifndef _LDIF_H
43*0Sstevel@tonic-gate #define _LDIF_H
44*0Sstevel@tonic-gate 
45*0Sstevel@tonic-gate #ifdef __cplusplus
46*0Sstevel@tonic-gate extern "C" {
47*0Sstevel@tonic-gate #endif
48*0Sstevel@tonic-gate 
49*0Sstevel@tonic-gate #define LDIF_VERSION_ONE        1	/* LDIF standard version */
50*0Sstevel@tonic-gate 
51*0Sstevel@tonic-gate #define LDIF_MAX_LINE_WIDTH      76      /* maximum length of LDIF lines */
52*0Sstevel@tonic-gate 
53*0Sstevel@tonic-gate /*
54*0Sstevel@tonic-gate  * Macro to calculate maximum number of bytes that the base64 equivalent
55*0Sstevel@tonic-gate  * of an item that is "vlen" bytes long will take up.  Base64 encoding
56*0Sstevel@tonic-gate  * uses one byte for every six bits in the value plus up to two pad bytes.
57*0Sstevel@tonic-gate  */
58*0Sstevel@tonic-gate #define LDIF_BASE64_LEN(vlen)	(((vlen) * 4 / 3 ) + 3)
59*0Sstevel@tonic-gate 
60*0Sstevel@tonic-gate /*
61*0Sstevel@tonic-gate  * Macro to calculate maximum size that an LDIF-encoded type (length
62*0Sstevel@tonic-gate  * tlen) and value (length vlen) will take up:  room for type + ":: " +
63*0Sstevel@tonic-gate  * first newline + base64 value + continued lines.  Each continued line
64*0Sstevel@tonic-gate  * needs room for a newline and a leading space character.
65*0Sstevel@tonic-gate  */
66*0Sstevel@tonic-gate #define LDIF_SIZE_NEEDED(tlen,vlen) \
67*0Sstevel@tonic-gate     ((tlen) + 4 + LDIF_BASE64_LEN(vlen) \
68*0Sstevel@tonic-gate     + ((LDIF_BASE64_LEN(vlen) + tlen + 3) / LDIF_MAX_LINE_WIDTH * 2 ))
69*0Sstevel@tonic-gate 
70*0Sstevel@tonic-gate /*
71*0Sstevel@tonic-gate  * Options for ldif_put_type_and_value_with_options() and
72*0Sstevel@tonic-gate  * ldif_type_and_value_with_options().
73*0Sstevel@tonic-gate  */
74*0Sstevel@tonic-gate #define LDIF_OPT_NOWRAP			0x01UL
75*0Sstevel@tonic-gate #define LDIF_OPT_VALUE_IS_URL		0x02UL
76*0Sstevel@tonic-gate #define LDIF_OPT_MINIMAL_ENCODING	0x04UL
77*0Sstevel@tonic-gate 
78*0Sstevel@tonic-gate int str_parse_line( char *line, char **type, char **value, int *vlen);
79*0Sstevel@tonic-gate char * str_getline( char **next );
80*0Sstevel@tonic-gate void ldif_put_type_and_value( char **out, char *t, char *val, int vlen );
81*0Sstevel@tonic-gate void ldif_put_type_and_value_nowrap( char **out, char *t, char *val, int vlen );
82*0Sstevel@tonic-gate void ldif_put_type_and_value_with_options( char **out, char *t, char *val,
83*0Sstevel@tonic-gate 	int vlen, unsigned long options );
84*0Sstevel@tonic-gate char *ldif_type_and_value( char *type, char *val, int vlen );
85*0Sstevel@tonic-gate char *ldif_type_and_value_nowrap( char *type, char *val, int vlen );
86*0Sstevel@tonic-gate char *ldif_type_and_value_with_options( char *type, char *val, int vlen,
87*0Sstevel@tonic-gate 	unsigned long options );
88*0Sstevel@tonic-gate int ldif_base64_decode( char *src, unsigned char *dst );
89*0Sstevel@tonic-gate int ldif_base64_encode( unsigned char *src, char *dst, int srclen,
90*0Sstevel@tonic-gate 	int lenused );
91*0Sstevel@tonic-gate int ldif_base64_encode_nowrap( unsigned char *src, char *dst, int srclen,
92*0Sstevel@tonic-gate 	int lenused );
93*0Sstevel@tonic-gate char *ldif_get_entry( FILE *fp, int *lineno );
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate #ifdef __cplusplus
96*0Sstevel@tonic-gate }
97*0Sstevel@tonic-gate #endif
98*0Sstevel@tonic-gate 
99*0Sstevel@tonic-gate #endif /* _LDIF_H */
100