home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ldapsdk.zip / include / ldif.h < prev    next >
C/C++ Source or Header  |  2001-06-02  |  3KB  |  110 lines

  1. /* $OpenLDAP: pkg/ldap/include/ldif.h,v 1.9.8.5 2001/06/02 00:33:03 kurt Exp $ */
  2. /*
  3.  * Copyright 1998-2001 The OpenLDAP Foundation, Redwood City, California, USA
  4.  * All rights reserved.
  5.  *
  6.  * Redistribution and use in source and binary forms, with or without
  7.  * modification, are permitted only as authorized by the OpenLDAP
  8.  * Public License.  A copy of this license is available at
  9.  * http://www.OpenLDAP.org/license.html or in file LICENSE in the
  10.  * top-level directory of the distribution.
  11.  */
  12. /* Portions
  13.  * Copyright (c) 1996 Regents of the University of Michigan.
  14.  * All rights reserved.
  15.  *
  16.  * Redistribution and use in source and binary forms are permitted
  17.  * provided that this notice is preserved and that due credit is given
  18.  * to the University of Michigan at Ann Arbor. The name of the University
  19.  * may not be used to endorse or promote products derived from this
  20.  * software without specific prior written permission. This software
  21.  * is provided ``as is'' without express or implied warranty.
  22.  */
  23.  
  24. #ifndef _LDIF_H
  25. #define _LDIF_H
  26.  
  27. #include <ldap_cdefs.h>
  28.  
  29. LDAP_BEGIN_DECL
  30.  
  31. /* This is NOT a bogus extern declaration (unlike ldap_debug) */
  32. LDAP_LDIF_V (int) ldif_debug;
  33.  
  34. #define LDIF_LINE_WIDTH      76      /* maximum length of LDIF lines */
  35.  
  36. /*
  37.  * Macro to calculate maximum number of bytes that the base64 equivalent
  38.  * of an item that is "len" bytes long will take up.  Base64 encoding
  39.  * uses one byte for every six bits in the value plus up to two pad bytes.
  40.  */
  41. #define LDIF_BASE64_LEN(len)    (((len) * 4 / 3 ) + 3)
  42.  
  43. /*
  44.  * Macro to calculate maximum size that an LDIF-encoded type (length
  45.  * tlen) and value (length vlen) will take up:  room for type + ":: " +
  46.  * first newline + base64 value + continued lines.  Each continued line
  47.  * needs room for a newline and a leading space character.
  48.  */
  49. #define LDIF_SIZE_NEEDED(nlen,vlen) \
  50.     ((nlen) + 4 + LDIF_BASE64_LEN(vlen) \
  51.     + ((LDIF_BASE64_LEN(vlen) + (nlen) + 3) / LDIF_LINE_WIDTH * 2 ))
  52.  
  53. LDAP_LDIF_F( int )
  54. ldif_parse_line LDAP_P((
  55.     LDAP_CONST char *line,
  56.     char **name,
  57.     char **value,
  58.     ber_len_t *vlen ));
  59.  
  60. LDAP_LDIF_F( int )
  61. ldif_fetch_url LDAP_P((
  62.     LDAP_CONST char *line,
  63.     char **value,
  64.     ber_len_t *vlen ));
  65.  
  66. LDAP_LDIF_F( char * )
  67. ldif_getline LDAP_P(( char **next ));
  68.  
  69. LDAP_LDIF_F( int )
  70. ldif_read_record LDAP_P((
  71.     FILE *fp,
  72.     int *lineno,
  73.     char **bufp,
  74.     int *buflen ));
  75.  
  76.  
  77. #define LDIF_PUT_NOVALUE    0x0000    /* no value */
  78. #define LDIF_PUT_VALUE        0x0001    /* value w/ auto detection */
  79. #define LDIF_PUT_TEXT        0x0002    /* assume text */
  80. #define    LDIF_PUT_BINARY        0x0004    /* assume binary (convert to base64) */
  81. #define LDIF_PUT_B64        0x0008    /* pre-converted base64 value */
  82.  
  83. #define LDIF_PUT_COMMENT    0x0010    /* comment */
  84. #define LDIF_PUT_URL        0x0020    /* url */
  85. #define LDIF_PUT_SEP        0x0040    /* separator */
  86.  
  87. LDAP_LDIF_F( void )
  88. ldif_sput LDAP_P((
  89.     char **out,
  90.     int type,
  91.     LDAP_CONST char *name,
  92.     LDAP_CONST char *val,
  93.     ber_len_t vlen ));
  94.  
  95. LDAP_LDIF_F( char * )
  96. ldif_put LDAP_P((
  97.     int type,
  98.     LDAP_CONST char *name,
  99.     LDAP_CONST char *val,
  100.     ber_len_t vlen ));
  101.  
  102. LDAP_LDIF_F( int )
  103. ldif_is_not_printable LDAP_P((
  104.     LDAP_CONST char *val,
  105.     ber_len_t vlen ));
  106.  
  107. LDAP_END_DECL
  108.  
  109. #endif /* _LDIF_H */
  110.