]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/charset.c
Fix ldap_rename parameter order (ITS#387)
[openldap] / libraries / libldap / charset.c
index 1052c19ab6880c0bf659fb3e1fcce8b592d1d250..1f348dc2093bf514f755ebbdbd4cdf6791c6d81b 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 #ifdef STR_TRANSLATION
 
 #include <stdio.h>
-#include <stdlib.h>
 
+#include <ac/stdlib.h>
+
+#include <ac/param.h>
 #include <ac/socket.h>
 #include <ac/string.h>
 #include <ac/time.h>
 
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
 
 #include "ldap-int.h"
 
@@ -39,9 +39,9 @@ ldap_set_string_translators( LDAP *ld, BERTranslateProc encode_proc,
 void
 ldap_enable_translation( LDAP *ld, LDAPMessage *entry, int enable )
 {
-       short   *optionsp;
+       unsigned short  *optionsp;
 
-       optionsp = ( entry == NULLMSG ) ? &ld->ld_lberoptions :
+       optionsp = ( entry == NULL ) ? &ld->ld_lberoptions :
            &entry->lm_ber->ber_options;
                
        if ( enable ) {
@@ -53,7 +53,7 @@ ldap_enable_translation( LDAP *ld, LDAPMessage *entry, int enable )
 
 
 int
-ldap_translate_from_t61( LDAP *ld, char **bufp, unsigned long *lenp,
+ldap_translate_from_t61( LDAP *ld, char **bufp, ber_len_t *lenp,
     int free_input )
 {
        if ( ld->ld_lber_decode_translate_proc == 0 ) {
@@ -65,7 +65,7 @@ ldap_translate_from_t61( LDAP *ld, char **bufp, unsigned long *lenp,
 
 
 int
-ldap_translate_to_t61( LDAP *ld, char **bufp, unsigned long *lenp,
+ldap_translate_to_t61( LDAP *ld, char **bufp, ber_len_t *lenp,
     int free_input )
 {
        if ( ld->ld_lber_encode_translate_proc == 0 ) {
@@ -147,7 +147,7 @@ ldap_translate_to_t61( LDAP *ld, char **bufp, unsigned long *lenp,
 
 
 #include <stdio.h>
-#include <stdlib.h>
+#include <ac/stdlib.h>
 #include <ac/string.h>
 
 /* Character set used: ISO 8859-1, ISO 8859-2, ISO 8859-3, ... */
@@ -1021,12 +1021,12 @@ c_to_cc( Byte *o, const Couple *cc, Byte c )
 /* --- routine to convert from T.61 to ISO 8859-n --- */
 
 int
-ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input )
+ldap_t61_to_8859( char **bufp, ber_len_t *buflenp, int free_input )
 {
   Byte         *s, *oo, *o;
   unsigned int  n;
   int           c;
-  unsigned long len;
+  ber_len_t len;
 
   Debug( LDAP_DEBUG_TRACE, "ldap_t61_to_8859 input length: %ld\n",
        *buflenp, 0, 0 );
@@ -1034,7 +1034,7 @@ ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input )
   len = *buflenp;
   s = (Byte *) *bufp;
 
-  if ( (o = oo = (Byte *)malloc( 2 * len + 64 )) == NULL ) {
+  if ( (o = oo = (Byte *)LDAP_MALLOC( 2 * len + 64 )) == NULL ) {
         return( 1 );
   }
 
@@ -1136,13 +1136,13 @@ ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input )
   len = o - oo;
   o = oo;
 
-  if ( (oo = (Byte *)realloc( o, len )) == NULL ) {
-    free( o );
+  if ( (oo = (Byte *)LDAP_REALLOC( o, len )) == NULL ) {
+    LDAP_FREE( o );
     return( 1 );
   }
 
   if ( free_input ) {
-    free( *bufp );
+    LDAP_FREE( *bufp );
   }
   *bufp = (char *) oo;
   *buflenp = len;
@@ -1558,11 +1558,11 @@ cc_to_t61( Byte *o, const Byte *s )
 /* --- routine to convert from ISO 8859-n to T.61 --- */
 
 int
-ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input )
+ldap_8859_to_t61( char **bufp, ber_len_t *buflenp, int free_input )
 {
   Byte         *s, *oo, *o, *aux;
   int          c;
-  unsigned long len; 
+  ber_len_t len; 
   const Couple *cc;
 
   Debug( LDAP_DEBUG_TRACE, "ldap_8859_to_t61 input length: %ld\n",
@@ -1571,7 +1571,7 @@ ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input )
   len = *buflenp;
   s = (Byte *) *bufp;
 
-  if ( (o = oo = (Byte *)malloc( 2 * len + 64 )) == NULL ) {
+  if ( (o = oo = (Byte *)LDAP_MALLOC( 2 * len + 64 )) == NULL ) {
         return( 1 );
   }
 
@@ -1650,13 +1650,13 @@ ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input )
   len = o - oo;
   o = oo;
 
-  if ( (oo = (Byte *)realloc( o, len )) == NULL ) {
-    free( o );
+  if ( (oo = (Byte *)LDAP_REALLOC( o, len )) == NULL ) {
+    LDAP_FREE( o );
     return( 1 );
   }
 
   if ( free_input ) {
-    free( *bufp );
+    LDAP_FREE( *bufp );
   }
   *bufp = (char *) oo;
   *buflenp = len;
@@ -1694,7 +1694,7 @@ const Byte  *s;
   Byte *o, *oo;
   Byte n;
 
-  if ( (o = oo = (Byte *)malloc( 2 * strlen( s ) + 64 )) == NULL ) {
+  if ( (o = oo = (Byte *)LDAP_MALLOC( 2 * strlen( s ) + 64 )) == NULL ) {
         return( NULL );
   }
 
@@ -1713,8 +1713,8 @@ const Byte  *s;
 
   o = oo;
 
-  if ( (oo = (Byte *)realloc( o, strlen( o ) + 1 )) == NULL ) {
-    free( o );
+  if ( (oo = (Byte *)LDAP_REALLOC( o, strlen( o ) + 1 )) == NULL ) {
+    LDAP_FREE( o );
     return( NULL );
   }
 
@@ -1748,7 +1748,7 @@ Byte  *s;
   Byte   n;
   const Couple *cc;
 
-  if ( (o = oo = (Byte *)malloc( 2 * strlen( s ) + 64 )) == NULL ) {
+  if ( (o = oo = (Byte *)LDAP_MALLOC( 2 * strlen( s ) + 64 )) == NULL ) {
         return( NULL );
   }
 
@@ -1791,8 +1791,8 @@ Byte  *s;
 
   o = oo;
 
-  if ( (oo = (Byte *)realloc( o, strlen( o ) + 1 )) == NULL ) {
-    free( o );
+  if ( (oo = (Byte *)LDAP_REALLOC( o, strlen( o ) + 1 )) == NULL ) {
+    LDAP_FREE( o );
     return( NULL );
   }