version 1.106, 2007/01/02 19:00:57
|
version 1.107, 2007/03/20 14:10:16
|
Line 1
|
Line 1
|
/* decode.c - ber input decoding routines */ |
/* decode.c - ber input decoding routines */ |
/* $OpenLDAP: pkg/ldap/libraries/liblber/decode.c,v 1.105 2006/02/14 22:18:12 kurt Exp $ */ |
/* $OpenLDAP: pkg/ldap/libraries/liblber/decode.c,v 1.106 2007/01/02 19:00:57 kurt Exp $ */ |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
* |
* |
* Copyright 1998-2007 The OpenLDAP Foundation. |
* Copyright 1998-2007 The OpenLDAP Foundation. |
Line 45 static ber_len_t ber_getnint LDAP_P((
|
Line 45 static ber_len_t ber_getnint LDAP_P((
|
ber_int_t *num, |
ber_int_t *num, |
ber_len_t len )); |
ber_len_t len )); |
|
|
|
/* out->bv_len should be the buffer size on input */ |
|
int |
|
ber_decode_oid( BerValue *in, BerValue *out ) |
|
{ |
|
unsigned char *der = in->bv_val; |
|
unsigned long val, val1; |
|
int i, len; |
|
char *ptr; |
|
|
|
assert( in != NULL ); |
|
assert( out != NULL ); |
|
|
|
/* expands by 5/2, and we add dots - call it 3 */ |
|
if ( !out->bv_val || out->bv_len < in->bv_len * 3 ) |
|
return -1; |
|
|
|
val1 = der[0] / 40; |
|
val = der[0] - val1 * 40; |
|
|
|
len = sprintf( out->bv_val, "%ld.%ld", val1, val ); |
|
ptr = out->bv_val + len; |
|
val = 0; |
|
for ( i=1; i<in->bv_len; i++ ) { |
|
val = val << 7; |
|
val |= der[i] & 0x7f; |
|
if ( !( der[i] & 0x80 )) { |
|
ptr += sprintf( ptr, ".%ld", val ); |
|
val = 0; |
|
} |
|
} |
|
out->bv_len = ptr - out->bv_val; |
|
return 0; |
|
} |
|
|
/* return the tag - LBER_DEFAULT returned means trouble */ |
/* return the tag - LBER_DEFAULT returned means trouble */ |
ber_tag_t |
ber_tag_t |
ber_get_tag( BerElement *ber ) |
ber_get_tag( BerElement *ber ) |