From: Hallvard Furuseth Date: Mon, 2 Aug 1999 01:50:08 +0000 (+0000) Subject: Remove unsigned long: Change to ber_len_t or ber_tag_t. X-Git-Tag: TWEB_OL_BASE~332 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2d4f915de9a491109a1789464a81e3f02128072e;p=openldap Remove unsigned long: Change to ber_len_t or ber_tag_t. Remove sizeof(long). Change ber_getnint to return ber_len_t instead of ber_tag_t. --- diff --git a/libraries/liblber/decode.c b/libraries/liblber/decode.c index 246a315ae2..6b029b3cd6 100644 --- a/libraries/liblber/decode.c +++ b/libraries/liblber/decode.c @@ -30,7 +30,7 @@ #include "lber-int.h" -static ber_tag_t ber_getnint LDAP_P(( +static ber_len_t ber_getnint LDAP_P(( BerElement *ber, ber_int_t *num, ber_len_t len )); @@ -107,7 +107,7 @@ ber_skip_tag( BerElement *ber, ber_len_t *len ) * Next, read the length. The first byte contains the length of * the length. If bit 8 is set, the length is the long form, * otherwise it's the short form. We don't allow a length that's - * greater than what we can hold in an unsigned long. + * greater than what we can hold in a ber_len_t. */ *len = netlen = 0; @@ -154,7 +154,7 @@ ber_peek_tag( return( tag ); } -static ber_tag_t +static ber_len_t ber_getnint( BerElement *ber, ber_int_t *num, @@ -215,7 +215,7 @@ ber_get_int( if ( (tag = ber_skip_tag( ber, &len )) == LBER_DEFAULT ) return( LBER_DEFAULT ); - if ( (unsigned long) ber_getnint( ber, num, len ) != len ) + if ( ber_getnint( ber, num, len ) != len ) return( LBER_DEFAULT ); else return( tag ); @@ -242,7 +242,7 @@ ber_get_stringb( if ( datalen > (*len - 1) ) return( LBER_DEFAULT ); - if ( (unsigned long) ber_read( ber, buf, datalen ) != datalen ) + if ( (ber_len_t) ber_read( ber, buf, datalen ) != datalen ) return( LBER_DEFAULT ); buf[datalen] = '\0'; @@ -289,7 +289,7 @@ ber_get_stringa( BerElement *ber, char **buf ) if ( (*buf = (char *) LBER_MALLOC( datalen + 1 )) == NULL ) return( LBER_DEFAULT ); - if ( (unsigned long) ber_read( ber, *buf, datalen ) != datalen ) { + if ( (ber_len_t) ber_read( ber, *buf, datalen ) != datalen ) { LBER_FREE( *buf ); *buf = NULL; return( LBER_DEFAULT ); @@ -393,7 +393,7 @@ ber_get_bitstringa( return( LBER_DEFAULT ); } - if ( (unsigned long) ber_read( ber, *buf, datalen ) != datalen ) { + if ( (ber_len_t) ber_read( ber, *buf, datalen ) != datalen ) { LBER_FREE( buf ); *buf = NULL; return( LBER_DEFAULT ); diff --git a/libraries/liblber/dtest.c b/libraries/liblber/dtest.c index 8ca5b33f0e..30d803eb93 100644 --- a/libraries/liblber/dtest.c +++ b/libraries/liblber/dtest.c @@ -41,7 +41,8 @@ main( int argc, char **argv ) char *s; int rc; - unsigned long tag, len; + ber_tag_t tag; + ber_len_t len; BerElement *ber; Sockbuf *sb; @@ -73,7 +74,7 @@ main( int argc, char **argv ) } printf("decode: message tag 0x%lx and length %ld\n", - tag, len ); + (unsigned long) tag, (long) len ); for( s = argv[1]; *s; s++ ) { char buf[128]; diff --git a/libraries/liblber/encode.c b/libraries/liblber/encode.c index f8aa0e887d..90f39d6ab2 100644 --- a/libraries/liblber/encode.c +++ b/libraries/liblber/encode.c @@ -131,9 +131,8 @@ ber_put_len( BerElement *ber, ber_len_t len, int nosos ) */ if ( len <= 127 ) { - netlen = LBER_LEN_HTON( len ); - return( ber_write( ber, (char *) &netlen + sizeof(long) - 1, - 1, nosos ) ); + char length_byte = (char) len; + return( ber_write( ber, &length_byte, 1, nosos ) ); } /* @@ -293,7 +292,7 @@ ber_put_ostring( #endif /* STR_TRANSLATION */ if ( (lenlen = ber_put_len( ber, len, 0 )) == -1 || - (unsigned long) ber_write( ber, str, len, 0 ) != len ) { + (ber_len_t) ber_write( ber, str, len, 0 ) != len ) { rc = -1; } else { /* return length of tag + length + contents */ @@ -539,7 +538,7 @@ ber_put_seqorset( BerElement *ber ) return( -1 ); /* the length itself */ - if ( ber_write( ber, (char *) &netlen + sizeof(long) + if ( ber_write( ber, (char *) (&netlen + 1) - (FOUR_BYTE_LEN - 1), FOUR_BYTE_LEN - 1, 1 ) != FOUR_BYTE_LEN - 1 ) return( -1 );