Back to index

lightning-sunbird  0.9+nobinonly
ldif.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is Mozilla Communicator client code, released
00015  * March 31, 1998.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998-1999
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /*
00039  * Copyright (c) 1996 Regents of the University of Michigan.
00040  * All rights reserved.
00041  *
00042  * Redistribution and use in source and binary forms are permitted
00043  * provided that this notice is preserved and that due credit is given
00044  * to the University of Michigan at Ann Arbor. The name of the University
00045  * may not be used to endorse or promote products derived from this
00046  * software without specific prior written permission. This software
00047  * is provided ``as is'' without express or implied warranty.
00048  */
00049 
00050 #ifndef _LDIF_H
00051 #define _LDIF_H
00052 
00053 #ifdef __cplusplus
00054 extern "C" {
00055 #endif
00056 
00057 #define LDIF_VERSION_ONE        1  /* LDIF standard version */
00058 
00059 #define LDIF_MAX_LINE_WIDTH      76      /* maximum length of LDIF lines */
00060 
00061 /*
00062  * Macro to calculate maximum number of bytes that the base64 equivalent
00063  * of an item that is "vlen" bytes long will take up.  Base64 encoding
00064  * uses one byte for every six bits in the value plus up to two pad bytes.
00065  */
00066 #define LDIF_BASE64_LEN(vlen)      (((vlen) * 4 / 3 ) + 3)
00067 
00068 /*
00069  * Macro to calculate maximum size that an LDIF-encoded type (length
00070  * tlen) and value (length vlen) will take up:  room for type + ":: " +
00071  * first newline + base64 value + continued lines.  Each continued line
00072  * needs room for a newline and a leading space character.
00073  */
00074 #define LDIF_SIZE_NEEDED(tlen,vlen) \
00075     ((tlen) + 4 + LDIF_BASE64_LEN(vlen) \
00076     + ((LDIF_BASE64_LEN(vlen) + tlen + 3) / LDIF_MAX_LINE_WIDTH * 2 ))
00077 
00078 /*
00079  * Options for ldif_put_type_and_value_with_options() and 
00080  * ldif_type_and_value_with_options().
00081  */
00082 #define LDIF_OPT_NOWRAP                   0x01UL
00083 #define LDIF_OPT_VALUE_IS_URL             0x02UL
00084 #define LDIF_OPT_MINIMAL_ENCODING  0x04UL
00085 
00086 int ldif_parse_line( char *line, char **type, char **value, int *vlen);
00087 char * ldif_getline( char **next );
00088 void ldif_put_type_and_value( char **out, char *t, char *val, int vlen );
00089 void ldif_put_type_and_value_nowrap( char **out, char *t, char *val, int vlen );
00090 void ldif_put_type_and_value_with_options( char **out, char *t, char *val,
00091        int vlen, unsigned long options );
00092 char *ldif_type_and_value( char *type, char *val, int vlen );
00093 char *ldif_type_and_value_nowrap( char *type, char *val, int vlen );
00094 char *ldif_type_and_value_with_options( char *type, char *val, int vlen,
00095        unsigned long options );
00096 int ldif_base64_decode( char *src, unsigned char *dst );
00097 int ldif_base64_encode( unsigned char *src, char *dst, int srclen,
00098        int lenused );
00099 int ldif_base64_encode_nowrap( unsigned char *src, char *dst, int srclen,
00100        int lenused );
00101 char *ldif_get_entry( FILE *fp, int *lineno );
00102 
00103 #ifdef __cplusplus
00104 }
00105 #endif
00106 
00107 #endif /* _LDIF_H */