1 /* 2 * 3 * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved. 4 * Use is subject to license terms. 5 * 6 */ 7 8 #pragma ident "%Z%%M% %I% %E% SMI" 9 10 /* 11 * Copyright (c) 1996 Regents of the University of Michigan. 12 * All rights reserved. 13 * 14 * Redistribution and use in source and binary forms are permitted 15 * provided that this notice is preserved and that due credit is given 16 * to the University of Michigan at Ann Arbor. The name of the University 17 * may not be used to endorse or promote products derived from this 18 * software without specific prior written permission. This software 19 * is provided ``as is'' without express or implied warranty. 20 */ 21 22 #ifndef _LDIF_H 23 #define _LDIF_H 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 #define LINE_WIDTH 76 /* maximum length of LDIF lines */ 30 31 /* 32 * Macro to calculate maximum number of bytes that the base64 equivalent 33 * of an item that is "vlen" bytes long will take up. Base64 encoding 34 * uses one byte for every six bits in the value plus up to two pad bytes. 35 */ 36 #define LDIF_BASE64_LEN(vlen) (((vlen) * 4 / 3 ) + 3) 37 38 /* 39 * Macro to calculate maximum size that an LDIF-encoded type (length 40 * tlen) and value (length vlen) will take up: room for type + ":: " + 41 * first newline + base64 value + continued lines. Each continued line 42 * needs room for a newline and a leading space character. 43 */ 44 #define LDIF_SIZE_NEEDED(tlen,vlen) \ 45 ((tlen) + 4 + LDIF_BASE64_LEN(vlen) \ 46 + ((LDIF_BASE64_LEN(vlen) + tlen + 3) / LINE_WIDTH * 2 )) 47 48 49 #ifdef NEEDPROTOS 50 int str_parse_line( char *line, char **type, char **value, int *vlen); 51 char * str_getline( char **next ); 52 void put_type_and_value( char **out, char *t, char *val, int vlen ); 53 char *ldif_type_and_value( char *type, char *val, int vlen ); 54 #else /* NEEDPROTOS */ 55 int str_parse_line(); 56 char * str_getline(); 57 void put_type_and_value(); 58 char *ldif_type_and_value(); 59 #endif /* NEEDPROTOS */ 60 61 #ifdef __cplusplus 62 } 63 #endif 64 65 #endif /* _LDIF_H */ 66