1N/A/*
1N/A * Copyright (c) 2001 by Sun Microsystems, Inc.
1N/A * All rights reserved.
1N/A */
1N/A
1N/A#pragma ident "%Z%%M% %I% %E% SMI"
1N/A
1N/A/*
1N/A * The contents of this file are subject to the Netscape Public
1N/A * License Version 1.1 (the "License"); you may not use this file
1N/A * except in compliance with the License. You may obtain a copy of
1N/A * the License at http://www.mozilla.org/NPL/
1N/A *
1N/A * Software distributed under the License is distributed on an "AS
1N/A * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
1N/A * implied. See the License for the specific language governing
1N/A * rights and limitations under the License.
1N/A *
1N/A * The Original Code is Mozilla Communicator client code, released
1N/A * March 31, 1998.
1N/A *
1N/A * The Initial Developer of the Original Code is Netscape
1N/A * Communications Corporation. Portions created by Netscape are
1N/A * Copyright (C) 1998-1999 Netscape Communications Corporation. All
1N/A * Rights Reserved.
1N/A *
1N/A * Contributor(s):
1N/A */
1N/A
1N/A/*
1N/A * Copyright (c) 1996 Regents of the University of Michigan.
1N/A * All rights reserved.
1N/A *
1N/A * Redistribution and use in source and binary forms are permitted
1N/A * provided that this notice is preserved and that due credit is given
1N/A * to the University of Michigan at Ann Arbor. The name of the University
1N/A * may not be used to endorse or promote products derived from this
1N/A * software without specific prior written permission. This software
1N/A * is provided ``as is'' without express or implied warranty.
1N/A */
1N/A
1N/A#ifndef _LDIF_H
1N/A#define _LDIF_H
1N/A
1N/A#ifdef __cplusplus
1N/Aextern "C" {
1N/A#endif
1N/A
1N/A#define LDIF_VERSION_ONE 1 /* LDIF standard version */
1N/A
1N/A#define LDIF_MAX_LINE_WIDTH 76 /* maximum length of LDIF lines */
1N/A
1N/A/*
1N/A * Macro to calculate maximum number of bytes that the base64 equivalent
1N/A * of an item that is "vlen" bytes long will take up. Base64 encoding
1N/A * uses one byte for every six bits in the value plus up to two pad bytes.
1N/A */
1N/A#define LDIF_BASE64_LEN(vlen) (((vlen) * 4 / 3 ) + 3)
1N/A
1N/A/*
1N/A * Macro to calculate maximum size that an LDIF-encoded type (length
1N/A * tlen) and value (length vlen) will take up: room for type + ":: " +
1N/A * first newline + base64 value + continued lines. Each continued line
1N/A * needs room for a newline and a leading space character.
1N/A */
1N/A#define LDIF_SIZE_NEEDED(tlen,vlen) \
1N/A ((tlen) + 4 + LDIF_BASE64_LEN(vlen) \
1N/A + ((LDIF_BASE64_LEN(vlen) + tlen + 3) / LDIF_MAX_LINE_WIDTH * 2 ))
1N/A
1N/A/*
1N/A * Options for ldif_put_type_and_value_with_options() and
1N/A * ldif_type_and_value_with_options().
1N/A */
1N/A#define LDIF_OPT_NOWRAP 0x01UL
1N/A#define LDIF_OPT_VALUE_IS_URL 0x02UL
1N/A#define LDIF_OPT_MINIMAL_ENCODING 0x04UL
1N/A
1N/Aint str_parse_line( char *line, char **type, char **value, int *vlen);
1N/Achar * str_getline( char **next );
1N/Avoid ldif_put_type_and_value( char **out, char *t, char *val, int vlen );
1N/Avoid ldif_put_type_and_value_nowrap( char **out, char *t, char *val, int vlen );
1N/Avoid ldif_put_type_and_value_with_options( char **out, char *t, char *val,
1N/A int vlen, unsigned long options );
1N/Achar *ldif_type_and_value( char *type, char *val, int vlen );
1N/Achar *ldif_type_and_value_nowrap( char *type, char *val, int vlen );
1N/Achar *ldif_type_and_value_with_options( char *type, char *val, int vlen,
1N/A unsigned long options );
1N/Aint ldif_base64_decode( char *src, unsigned char *dst );
1N/Aint ldif_base64_encode( unsigned char *src, char *dst, int srclen,
1N/A int lenused );
1N/Aint ldif_base64_encode_nowrap( unsigned char *src, char *dst, int srclen,
1N/A int lenused );
1N/Achar *ldif_get_entry( FILE *fp, int *lineno );
1N/A
1N/A#ifdef __cplusplus
1N/A}
1N/A#endif
1N/A
1N/A#endif /* _LDIF_H */