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