17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * Copyright (c) 2001 by Sun Microsystems, Inc. 37c478bd9Sstevel@tonic-gate * All rights reserved. 47c478bd9Sstevel@tonic-gate */ 57c478bd9Sstevel@tonic-gate 67c478bd9Sstevel@tonic-gate /* 77c478bd9Sstevel@tonic-gate * The contents of this file are subject to the Netscape Public 87c478bd9Sstevel@tonic-gate * License Version 1.1 (the "License"); you may not use this file 97c478bd9Sstevel@tonic-gate * except in compliance with the License. You may obtain a copy of 107c478bd9Sstevel@tonic-gate * the License at http://www.mozilla.org/NPL/ 117c478bd9Sstevel@tonic-gate * 127c478bd9Sstevel@tonic-gate * Software distributed under the License is distributed on an "AS 137c478bd9Sstevel@tonic-gate * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 147c478bd9Sstevel@tonic-gate * implied. See the License for the specific language governing 157c478bd9Sstevel@tonic-gate * rights and limitations under the License. 167c478bd9Sstevel@tonic-gate * 177c478bd9Sstevel@tonic-gate * The Original Code is Mozilla Communicator client code, released 187c478bd9Sstevel@tonic-gate * March 31, 1998. 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * The Initial Developer of the Original Code is Netscape 217c478bd9Sstevel@tonic-gate * Communications Corporation. Portions created by Netscape are 227c478bd9Sstevel@tonic-gate * Copyright (C) 1998-1999 Netscape Communications Corporation. All 237c478bd9Sstevel@tonic-gate * Rights Reserved. 247c478bd9Sstevel@tonic-gate * 257c478bd9Sstevel@tonic-gate * Contributor(s): 267c478bd9Sstevel@tonic-gate */ 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate /* 297c478bd9Sstevel@tonic-gate * Copyright (c) 1996 Regents of the University of Michigan. 307c478bd9Sstevel@tonic-gate * All rights reserved. 317c478bd9Sstevel@tonic-gate * 327c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms are permitted 337c478bd9Sstevel@tonic-gate * provided that this notice is preserved and that due credit is given 347c478bd9Sstevel@tonic-gate * to the University of Michigan at Ann Arbor. The name of the University 357c478bd9Sstevel@tonic-gate * may not be used to endorse or promote products derived from this 367c478bd9Sstevel@tonic-gate * software without specific prior written permission. This software 377c478bd9Sstevel@tonic-gate * is provided ``as is'' without express or implied warranty. 387c478bd9Sstevel@tonic-gate */ 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifndef _LDIF_H 417c478bd9Sstevel@tonic-gate #define _LDIF_H 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #ifdef __cplusplus 447c478bd9Sstevel@tonic-gate extern "C" { 457c478bd9Sstevel@tonic-gate #endif 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate #define LDIF_VERSION_ONE 1 /* LDIF standard version */ 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #define LDIF_MAX_LINE_WIDTH 76 /* maximum length of LDIF lines */ 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate /* 527c478bd9Sstevel@tonic-gate * Macro to calculate maximum number of bytes that the base64 equivalent 537c478bd9Sstevel@tonic-gate * of an item that is "vlen" bytes long will take up. Base64 encoding 547c478bd9Sstevel@tonic-gate * uses one byte for every six bits in the value plus up to two pad bytes. 557c478bd9Sstevel@tonic-gate */ 567c478bd9Sstevel@tonic-gate #define LDIF_BASE64_LEN(vlen) (((vlen) * 4 / 3 ) + 3) 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* 597c478bd9Sstevel@tonic-gate * Macro to calculate maximum size that an LDIF-encoded type (length 607c478bd9Sstevel@tonic-gate * tlen) and value (length vlen) will take up: room for type + ":: " + 617c478bd9Sstevel@tonic-gate * first newline + base64 value + continued lines. Each continued line 627c478bd9Sstevel@tonic-gate * needs room for a newline and a leading space character. 637c478bd9Sstevel@tonic-gate */ 647c478bd9Sstevel@tonic-gate #define LDIF_SIZE_NEEDED(tlen,vlen) \ 657c478bd9Sstevel@tonic-gate ((tlen) + 4 + LDIF_BASE64_LEN(vlen) \ 667c478bd9Sstevel@tonic-gate + ((LDIF_BASE64_LEN(vlen) + tlen + 3) / LDIF_MAX_LINE_WIDTH * 2 )) 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* 69*1da57d55SToomas Soome * Options for ldif_put_type_and_value_with_options() and 707c478bd9Sstevel@tonic-gate * ldif_type_and_value_with_options(). 717c478bd9Sstevel@tonic-gate */ 727c478bd9Sstevel@tonic-gate #define LDIF_OPT_NOWRAP 0x01UL 737c478bd9Sstevel@tonic-gate #define LDIF_OPT_VALUE_IS_URL 0x02UL 747c478bd9Sstevel@tonic-gate #define LDIF_OPT_MINIMAL_ENCODING 0x04UL 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate int str_parse_line( char *line, char **type, char **value, int *vlen); 777c478bd9Sstevel@tonic-gate char * str_getline( char **next ); 787c478bd9Sstevel@tonic-gate void ldif_put_type_and_value( char **out, char *t, char *val, int vlen ); 797c478bd9Sstevel@tonic-gate void ldif_put_type_and_value_nowrap( char **out, char *t, char *val, int vlen ); 807c478bd9Sstevel@tonic-gate void ldif_put_type_and_value_with_options( char **out, char *t, char *val, 817c478bd9Sstevel@tonic-gate int vlen, unsigned long options ); 827c478bd9Sstevel@tonic-gate char *ldif_type_and_value( char *type, char *val, int vlen ); 837c478bd9Sstevel@tonic-gate char *ldif_type_and_value_nowrap( char *type, char *val, int vlen ); 847c478bd9Sstevel@tonic-gate char *ldif_type_and_value_with_options( char *type, char *val, int vlen, 857c478bd9Sstevel@tonic-gate unsigned long options ); 867c478bd9Sstevel@tonic-gate int ldif_base64_decode( char *src, unsigned char *dst ); 877c478bd9Sstevel@tonic-gate int ldif_base64_encode( unsigned char *src, char *dst, int srclen, 887c478bd9Sstevel@tonic-gate int lenused ); 897c478bd9Sstevel@tonic-gate int ldif_base64_encode_nowrap( unsigned char *src, char *dst, int srclen, 907c478bd9Sstevel@tonic-gate int lenused ); 917c478bd9Sstevel@tonic-gate char *ldif_get_entry( FILE *fp, int *lineno ); 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate #ifdef __cplusplus 947c478bd9Sstevel@tonic-gate } 957c478bd9Sstevel@tonic-gate #endif 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate #endif /* _LDIF_H */ 98