1999-08-31 09:17:01 +08:00
|
|
|
/* $OpenLDAP$ */
|
2003-11-26 15:16:36 +08:00
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2017-01-04 04:36:47 +08:00
|
|
|
* Copyright 1998-2017 The OpenLDAP Foundation.
|
1998-12-29 03:51:35 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2001-05-29 11:29:53 +08:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
2003-11-26 15:16:36 +08:00
|
|
|
* Public License.
|
|
|
|
*
|
|
|
|
* A copy of this license is available in file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
1998-12-29 03:51:35 +08:00
|
|
|
*/
|
2003-11-26 15:16:36 +08:00
|
|
|
/* Portions Copyright (c) 1996 Regents of the University of Michigan.
|
1998-08-09 08:43:13 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted
|
|
|
|
* provided that this notice is preserved and that due credit is given
|
|
|
|
* to the University of Michigan at Ann Arbor. The name of the University
|
|
|
|
* may not be used to endorse or promote products derived from this
|
|
|
|
* software without specific prior written permission. This software
|
|
|
|
* is provided ``as is'' without express or implied warranty.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LDIF_H
|
|
|
|
#define _LDIF_H
|
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#include <ldap_cdefs.h>
|
|
|
|
|
|
|
|
LDAP_BEGIN_DECL
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1999-11-28 07:40:08 +08:00
|
|
|
/* This is NOT a bogus extern declaration (unlike ldap_debug) */
|
2000-06-20 11:53:12 +08:00
|
|
|
LDAP_LDIF_V (int) ldif_debug;
|
1998-12-22 09:34:01 +08:00
|
|
|
|
2010-12-07 18:14:51 +08:00
|
|
|
#define LDIF_LINE_WIDTH 76 /* default maximum length of LDIF lines */
|
|
|
|
#define LDIF_LINE_WIDTH_MAX ((ber_len_t)-1) /* maximum length of LDIF lines */
|
|
|
|
#define LDIF_LINE_WIDTH_WRAP(wrap) ((wrap) == 0 ? LDIF_LINE_WIDTH : (wrap))
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Macro to calculate maximum number of bytes that the base64 equivalent
|
1999-07-31 07:00:02 +08:00
|
|
|
* of an item that is "len" bytes long will take up. Base64 encoding
|
1998-08-09 08:43:13 +08:00
|
|
|
* uses one byte for every six bits in the value plus up to two pad bytes.
|
|
|
|
*/
|
1999-07-31 07:00:02 +08:00
|
|
|
#define LDIF_BASE64_LEN(len) (((len) * 4 / 3 ) + 3)
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Macro to calculate maximum size that an LDIF-encoded type (length
|
|
|
|
* tlen) and value (length vlen) will take up: room for type + ":: " +
|
|
|
|
* first newline + base64 value + continued lines. Each continued line
|
|
|
|
* needs room for a newline and a leading space character.
|
|
|
|
*/
|
1999-07-31 07:00:02 +08:00
|
|
|
#define LDIF_SIZE_NEEDED(nlen,vlen) \
|
|
|
|
((nlen) + 4 + LDIF_BASE64_LEN(vlen) \
|
2014-12-15 22:36:55 +08:00
|
|
|
+ ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / (LDIF_LINE_WIDTH-1) * 2 ))
|
1998-08-09 08:43:13 +08:00
|
|
|
|
2010-12-07 18:14:51 +08:00
|
|
|
#define LDIF_SIZE_NEEDED_WRAP(nlen,vlen,wrap) \
|
|
|
|
((nlen) + 4 + LDIF_BASE64_LEN(vlen) \
|
2014-12-15 22:36:55 +08:00
|
|
|
+ ((wrap) == 0 ? ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / ( LDIF_LINE_WIDTH-1 ) * 2 ) : \
|
|
|
|
((wrap) == LDIF_LINE_WIDTH_MAX ? 0 : ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / (wrap-1) * 2 ))))
|
2010-12-07 18:14:51 +08:00
|
|
|
|
2000-06-19 03:48:07 +08:00
|
|
|
LDAP_LDIF_F( int )
|
1999-05-19 09:12:33 +08:00
|
|
|
ldif_parse_line LDAP_P((
|
|
|
|
LDAP_CONST char *line,
|
1999-07-31 07:00:02 +08:00
|
|
|
char **name,
|
|
|
|
char **value,
|
1999-07-31 10:17:26 +08:00
|
|
|
ber_len_t *vlen ));
|
|
|
|
|
2005-01-19 13:05:53 +08:00
|
|
|
LDAP_LDIF_F( int )
|
|
|
|
ldif_parse_line2 LDAP_P((
|
2005-01-19 20:07:06 +08:00
|
|
|
char *line,
|
|
|
|
struct berval *type,
|
|
|
|
struct berval *value,
|
|
|
|
int *freeval ));
|
2005-01-19 13:05:53 +08:00
|
|
|
|
2005-05-12 08:46:39 +08:00
|
|
|
LDAP_LDIF_F( FILE * )
|
|
|
|
ldif_open_url LDAP_P(( LDAP_CONST char *urlstr ));
|
|
|
|
|
2000-06-19 03:48:07 +08:00
|
|
|
LDAP_LDIF_F( int )
|
1999-07-31 10:17:26 +08:00
|
|
|
ldif_fetch_url LDAP_P((
|
|
|
|
LDAP_CONST char *line,
|
|
|
|
char **value,
|
|
|
|
ber_len_t *vlen ));
|
1999-01-28 12:34:55 +08:00
|
|
|
|
2000-06-19 03:48:07 +08:00
|
|
|
LDAP_LDIF_F( char * )
|
1999-01-28 12:34:55 +08:00
|
|
|
ldif_getline LDAP_P(( char **next ));
|
|
|
|
|
2005-01-24 11:40:29 +08:00
|
|
|
LDAP_LDIF_F( int )
|
|
|
|
ldif_countlines LDAP_P(( LDAP_CONST char *line ));
|
|
|
|
|
2005-05-12 08:46:39 +08:00
|
|
|
/* ldif_ropen, rclose, read_record - just for reading LDIF files,
|
|
|
|
* no special open/close needed to write LDIF files.
|
|
|
|
*/
|
|
|
|
typedef struct LDIFFP {
|
|
|
|
FILE *fp;
|
|
|
|
struct LDIFFP *prev;
|
|
|
|
} LDIFFP;
|
|
|
|
|
|
|
|
LDAP_LDIF_F( LDIFFP * )
|
2005-07-06 18:50:03 +08:00
|
|
|
ldif_open LDAP_P(( LDAP_CONST char *file, LDAP_CONST char *mode ));
|
2005-05-12 08:46:39 +08:00
|
|
|
|
|
|
|
LDAP_LDIF_F( void )
|
|
|
|
ldif_close LDAP_P(( LDIFFP * ));
|
|
|
|
|
2000-06-19 03:48:07 +08:00
|
|
|
LDAP_LDIF_F( int )
|
1999-08-18 03:00:59 +08:00
|
|
|
ldif_read_record LDAP_P((
|
2005-05-12 08:46:39 +08:00
|
|
|
LDIFFP *fp,
|
2013-01-23 10:19:02 +08:00
|
|
|
unsigned long *lineno,
|
1999-08-18 03:00:59 +08:00
|
|
|
char **bufp,
|
|
|
|
int *buflen ));
|
|
|
|
|
2005-04-09 23:19:36 +08:00
|
|
|
LDAP_LDIF_F( int )
|
|
|
|
ldif_must_b64_encode_register LDAP_P((
|
|
|
|
LDAP_CONST char *name,
|
|
|
|
LDAP_CONST char *oid ));
|
|
|
|
|
|
|
|
LDAP_LDIF_F( void )
|
|
|
|
ldif_must_b64_encode_release LDAP_P(( void ));
|
1999-08-18 03:00:59 +08:00
|
|
|
|
1999-07-31 07:00:02 +08:00
|
|
|
#define LDIF_PUT_NOVALUE 0x0000 /* no value */
|
|
|
|
#define LDIF_PUT_VALUE 0x0001 /* value w/ auto detection */
|
|
|
|
#define LDIF_PUT_TEXT 0x0002 /* assume text */
|
|
|
|
#define LDIF_PUT_BINARY 0x0004 /* assume binary (convert to base64) */
|
|
|
|
#define LDIF_PUT_B64 0x0008 /* pre-converted base64 value */
|
|
|
|
|
|
|
|
#define LDIF_PUT_COMMENT 0x0010 /* comment */
|
|
|
|
#define LDIF_PUT_URL 0x0020 /* url */
|
|
|
|
#define LDIF_PUT_SEP 0x0040 /* separator */
|
|
|
|
|
2000-06-19 03:48:07 +08:00
|
|
|
LDAP_LDIF_F( void )
|
1999-07-31 07:00:02 +08:00
|
|
|
ldif_sput LDAP_P((
|
1999-05-19 09:12:33 +08:00
|
|
|
char **out,
|
1999-07-31 07:00:02 +08:00
|
|
|
int type,
|
|
|
|
LDAP_CONST char *name,
|
1999-05-19 09:12:33 +08:00
|
|
|
LDAP_CONST char *val,
|
1999-07-31 07:00:02 +08:00
|
|
|
ber_len_t vlen ));
|
1999-01-28 12:34:55 +08:00
|
|
|
|
2010-12-07 18:14:51 +08:00
|
|
|
LDAP_LDIF_F( void )
|
|
|
|
ldif_sput_wrap LDAP_P((
|
|
|
|
char **out,
|
|
|
|
int type,
|
|
|
|
LDAP_CONST char *name,
|
|
|
|
LDAP_CONST char *val,
|
|
|
|
ber_len_t vlen,
|
|
|
|
ber_len_t wrap ));
|
|
|
|
|
2000-06-19 03:48:07 +08:00
|
|
|
LDAP_LDIF_F( char * )
|
1999-07-31 07:00:02 +08:00
|
|
|
ldif_put LDAP_P((
|
|
|
|
int type,
|
|
|
|
LDAP_CONST char *name,
|
1999-05-19 09:12:33 +08:00
|
|
|
LDAP_CONST char *val,
|
1999-07-31 07:00:02 +08:00
|
|
|
ber_len_t vlen ));
|
1998-08-09 08:43:13 +08:00
|
|
|
|
2010-12-07 18:14:51 +08:00
|
|
|
LDAP_LDIF_F( char * )
|
|
|
|
ldif_put_wrap LDAP_P((
|
|
|
|
int type,
|
|
|
|
LDAP_CONST char *name,
|
|
|
|
LDAP_CONST char *val,
|
|
|
|
ber_len_t vlen,
|
|
|
|
ber_len_t wrap ));
|
|
|
|
|
2000-06-19 03:48:07 +08:00
|
|
|
LDAP_LDIF_F( int )
|
1999-07-31 07:00:02 +08:00
|
|
|
ldif_is_not_printable LDAP_P((
|
|
|
|
LDAP_CONST char *val,
|
|
|
|
ber_len_t vlen ));
|
1998-12-21 06:28:33 +08:00
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
LDAP_END_DECL
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
#endif /* _LDIF_H */
|