Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-17 09:55:46

0001 /* $OpenLDAP$ */
0002 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
0003  *
0004  * Copyright 1998-2024 The OpenLDAP Foundation.
0005  * All rights reserved.
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted only as authorized by the OpenLDAP
0009  * Public License.
0010  *
0011  * A copy of this license is available in file LICENSE in the
0012  * top-level directory of the distribution or, alternatively, at
0013  * <http://www.OpenLDAP.org/license.html>.
0014  */
0015 /* Portions Copyright (c) 1996 Regents of the University of Michigan.
0016  * All rights reserved.
0017  *
0018  * Redistribution and use in source and binary forms are permitted
0019  * provided that this notice is preserved and that due credit is given
0020  * to the University of Michigan at Ann Arbor. The name of the University
0021  * may not be used to endorse or promote products derived from this
0022  * software without specific prior written permission. This software
0023  * is provided ``as is'' without express or implied warranty.
0024  */
0025 
0026 #ifndef _LDIF_H
0027 #define _LDIF_H
0028 
0029 #include <ldap_cdefs.h>
0030 
0031 LDAP_BEGIN_DECL
0032 
0033 /* This is NOT a bogus extern declaration (unlike ldap_debug) */
0034 LDAP_LDIF_V (int) ldif_debug;
0035 
0036 #define LDIF_LINE_WIDTH      78      /* default maximum length of LDIF lines */
0037 #define LDIF_LINE_WIDTH_MAX  ((ber_len_t)-1) /* maximum length of LDIF lines */
0038 #define LDIF_LINE_WIDTH_WRAP(wrap) ((wrap) == 0 ? LDIF_LINE_WIDTH : (wrap))
0039 
0040 /*
0041  * Macro to calculate maximum number of bytes that the base64 equivalent
0042  * of an item that is "len" bytes long will take up.  Base64 encoding
0043  * uses one byte for every six bits in the value plus up to two pad bytes.
0044  */
0045 #define LDIF_BASE64_LEN(len)    (((len) * 4 / 3 ) + 3)
0046 
0047 /*
0048  * Macro to calculate maximum size that an LDIF-encoded type (length
0049  * tlen) and value (length vlen) will take up:  room for type + ":: " +
0050  * first newline + base64 value + continued lines.  Each continued line
0051  * needs room for a newline and a leading space character.
0052  */
0053 #define LDIF_SIZE_NEEDED(nlen,vlen) LDIF_SIZE_NEEDED_WRAP(nlen, vlen, 0)
0054 
0055 #define LDIF_SIZE_NEEDED_WRAP(nlen,vlen,wrap) \
0056     ((nlen) + 4 + LDIF_BASE64_LEN(vlen) \
0057     + ((wrap) == 0 ? ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / ( LDIF_LINE_WIDTH-1 ) * 2 ) : \
0058     ((wrap) == LDIF_LINE_WIDTH_MAX ? 0 : ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / (wrap-1) * 2 ))))
0059 
0060 LDAP_LDIF_F( int )
0061 ldif_parse_line LDAP_P((
0062     LDAP_CONST char *line,
0063     char **name,
0064     char **value,
0065     ber_len_t *vlen ));
0066 
0067 LDAP_LDIF_F( int )
0068 ldif_parse_line2 LDAP_P((
0069     char *line,
0070     struct berval *type,
0071     struct berval *value,
0072     int *freeval ));
0073 
0074 LDAP_LDIF_F( FILE * )
0075 ldif_open_url LDAP_P(( LDAP_CONST char *urlstr ));
0076 
0077 LDAP_LDIF_F( int )
0078 ldif_fetch_url LDAP_P((
0079     LDAP_CONST char *line,
0080     char **value,
0081     ber_len_t *vlen ));
0082 
0083 LDAP_LDIF_F( char * )
0084 ldif_getline LDAP_P(( char **next ));
0085 
0086 LDAP_LDIF_F( int )
0087 ldif_countlines LDAP_P(( LDAP_CONST char *line ));
0088 
0089 /* ldif_ropen, rclose, read_record - just for reading LDIF files,
0090  * no special open/close needed to write LDIF files.
0091  */
0092 typedef struct LDIFFP {
0093     FILE *fp;
0094     struct LDIFFP *prev;
0095 } LDIFFP;
0096 
0097 LDAP_LDIF_F( LDIFFP * )
0098 ldif_open LDAP_P(( LDAP_CONST char *file, LDAP_CONST char *mode ));
0099 
0100 /* ldif_open equivalent that opens ldif stream in memory rather than from file */
0101 LDAP_LDIF_F( LDIFFP * )
0102 ldif_open_mem LDAP_P(( char *ldif, size_t size, LDAP_CONST char *mode ));
0103 
0104 LDAP_LDIF_F( void )
0105 ldif_close LDAP_P(( LDIFFP * ));
0106 
0107 LDAP_LDIF_F( int )
0108 ldif_read_record LDAP_P((
0109     LDIFFP *fp,
0110     unsigned long *lineno,
0111     char **bufp,
0112     int *buflen ));
0113 
0114 LDAP_LDIF_F( int )
0115 ldif_must_b64_encode_register LDAP_P((
0116     LDAP_CONST char *name,
0117     LDAP_CONST char *oid ));
0118 
0119 LDAP_LDIF_F( void )
0120 ldif_must_b64_encode_release LDAP_P(( void ));
0121 
0122 #define LDIF_PUT_NOVALUE    0x0000  /* no value */
0123 #define LDIF_PUT_VALUE      0x0001  /* value w/ auto detection */
0124 #define LDIF_PUT_TEXT       0x0002  /* assume text */
0125 #define LDIF_PUT_BINARY     0x0004  /* assume binary (convert to base64) */
0126 #define LDIF_PUT_B64        0x0008  /* pre-converted base64 value */
0127 
0128 #define LDIF_PUT_COMMENT    0x0010  /* comment */
0129 #define LDIF_PUT_URL        0x0020  /* url */
0130 #define LDIF_PUT_SEP        0x0040  /* separator */
0131 
0132 LDAP_LDIF_F( void )
0133 ldif_sput LDAP_P((
0134     char **out,
0135     int type,
0136     LDAP_CONST char *name,
0137     LDAP_CONST char *val,
0138     ber_len_t vlen ));
0139 
0140 LDAP_LDIF_F( void )
0141 ldif_sput_wrap LDAP_P((
0142     char **out,
0143     int type,
0144     LDAP_CONST char *name,
0145     LDAP_CONST char *val,
0146     ber_len_t vlen,
0147         ber_len_t wrap ));
0148 
0149 LDAP_LDIF_F( char * )
0150 ldif_put LDAP_P((
0151     int type,
0152     LDAP_CONST char *name,
0153     LDAP_CONST char *val,
0154     ber_len_t vlen ));
0155 
0156 LDAP_LDIF_F( char * )
0157 ldif_put_wrap LDAP_P((
0158     int type,
0159     LDAP_CONST char *name,
0160     LDAP_CONST char *val,
0161     ber_len_t vlen,
0162     ber_len_t wrap ));
0163 
0164 LDAP_LDIF_F( int )
0165 ldif_is_not_printable LDAP_P((
0166     LDAP_CONST char *val,
0167     ber_len_t vlen ));
0168 
0169 LDAP_END_DECL
0170 
0171 #endif /* _LDIF_H */