10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * 3*3857Sstevel * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved. 4*3857Sstevel * Use is subject to license terms. 50Sstevel@tonic-gate * 60Sstevel@tonic-gate */ 70Sstevel@tonic-gate 80Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 90Sstevel@tonic-gate 100Sstevel@tonic-gate /* 110Sstevel@tonic-gate * Copyright (c) 1996 Regents of the University of Michigan. 120Sstevel@tonic-gate * All rights reserved. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * Redistribution and use in source and binary forms are permitted 150Sstevel@tonic-gate * provided that this notice is preserved and that due credit is given 160Sstevel@tonic-gate * to the University of Michigan at Ann Arbor. The name of the University 170Sstevel@tonic-gate * may not be used to endorse or promote products derived from this 180Sstevel@tonic-gate * software without specific prior written permission. This software 190Sstevel@tonic-gate * is provided ``as is'' without express or implied warranty. 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate 220Sstevel@tonic-gate #ifndef _LDIF_H 230Sstevel@tonic-gate #define _LDIF_H 240Sstevel@tonic-gate 250Sstevel@tonic-gate #ifdef __cplusplus 260Sstevel@tonic-gate extern "C" { 270Sstevel@tonic-gate #endif 280Sstevel@tonic-gate 290Sstevel@tonic-gate #define LINE_WIDTH 76 /* maximum length of LDIF lines */ 300Sstevel@tonic-gate 310Sstevel@tonic-gate /* 320Sstevel@tonic-gate * Macro to calculate maximum number of bytes that the base64 equivalent 330Sstevel@tonic-gate * of an item that is "vlen" bytes long will take up. Base64 encoding 340Sstevel@tonic-gate * uses one byte for every six bits in the value plus up to two pad bytes. 350Sstevel@tonic-gate */ 360Sstevel@tonic-gate #define LDIF_BASE64_LEN(vlen) (((vlen) * 4 / 3 ) + 3) 370Sstevel@tonic-gate 380Sstevel@tonic-gate /* 390Sstevel@tonic-gate * Macro to calculate maximum size that an LDIF-encoded type (length 400Sstevel@tonic-gate * tlen) and value (length vlen) will take up: room for type + ":: " + 410Sstevel@tonic-gate * first newline + base64 value + continued lines. Each continued line 420Sstevel@tonic-gate * needs room for a newline and a leading space character. 430Sstevel@tonic-gate */ 440Sstevel@tonic-gate #define LDIF_SIZE_NEEDED(tlen,vlen) \ 450Sstevel@tonic-gate ((tlen) + 4 + LDIF_BASE64_LEN(vlen) \ 460Sstevel@tonic-gate + ((LDIF_BASE64_LEN(vlen) + tlen + 3) / LINE_WIDTH * 2 )) 470Sstevel@tonic-gate 480Sstevel@tonic-gate 490Sstevel@tonic-gate #ifdef NEEDPROTOS 500Sstevel@tonic-gate int str_parse_line( char *line, char **type, char **value, int *vlen); 510Sstevel@tonic-gate char * str_getline( char **next ); 520Sstevel@tonic-gate void put_type_and_value( char **out, char *t, char *val, int vlen ); 530Sstevel@tonic-gate char *ldif_type_and_value( char *type, char *val, int vlen ); 540Sstevel@tonic-gate #else /* NEEDPROTOS */ 550Sstevel@tonic-gate int str_parse_line(); 560Sstevel@tonic-gate char * str_getline(); 570Sstevel@tonic-gate void put_type_and_value(); 580Sstevel@tonic-gate char *ldif_type_and_value(); 590Sstevel@tonic-gate #endif /* NEEDPROTOS */ 600Sstevel@tonic-gate 610Sstevel@tonic-gate #ifdef __cplusplus 620Sstevel@tonic-gate } 630Sstevel@tonic-gate #endif 640Sstevel@tonic-gate 650Sstevel@tonic-gate #endif /* _LDIF_H */ 66