Hi!
I'm developing kldap, a Qt wrapper for LDAP-functions. When I tested ber_scanf and ber_printf functions, I found this strangeness: Encode a sequence of octet strings via ber_printf ber_printf(ber,"{v}",list_of_strings); But decoding only succeeds if I use the following scanf formats: ber_scanf(ber,"v",...) - yes, without '{}', or ber_scanf(ber,"{ooo}") As I read the ber_scanf man page, 'v' format actually decodes a sequence of octet strings, so my examples are correct according to these. But the code example on the end shows that '{v}' should be used. So what is the right way?
Regards, György
Szombathelyi György wrote:
Hi!
I'm developing kldap, a Qt wrapper for LDAP-functions. When I tested ber_scanf and ber_printf functions, I found this strangeness: Encode a sequence of octet strings via ber_printf ber_printf(ber,"{v}",list_of_strings); But decoding only succeeds if I use the following scanf formats: ber_scanf(ber,"v",...) - yes, without '{}', or ber_scanf(ber,"{ooo}") As I read the ber_scanf man page, 'v' format actually decodes a sequence of octet strings, so my examples are correct according to these. But the code example on the end shows that '{v}' should be used. So what is the right way?
It looks like the manpage example is wrong.
Howard Chu wrote:
Szombathelyi György wrote:
Hi!
I'm developing kldap, a Qt wrapper for LDAP-functions. When I tested ber_scanf and ber_printf functions, I found this strangeness: Encode a sequence of octet strings via ber_printf ber_printf(ber,"{v}",list_of_strings); But decoding only succeeds if I use the following scanf formats: ber_scanf(ber,"v",...) - yes, without '{}', or ber_scanf(ber,"{ooo}") As I read the ber_scanf man page, 'v' format actually decodes a sequence of octet strings, so my examples are correct according to these. But the code example on the end shows that '{v}' should be used. So what is the right way?
It looks like the manpage example is wrong.
I take that back. The example matches the ldap-c-api draft document. The liblber code matches as well.
Seems your version of liblber is broken, or you're not calling ber_scanf with the right arguments.
Hello,
On Thursday 24 May 2007 00:17:37 Howard Chu wrote:
Howard Chu wrote:
Szombathelyi György wrote:
Hi!
I'm developing kldap, a Qt wrapper for LDAP-functions. When I tested ber_scanf and ber_printf functions, I found this strangeness: Encode a sequence of octet strings via ber_printf ber_printf(ber,"{v}",list_of_strings); But decoding only succeeds if I use the following scanf formats: ber_scanf(ber,"v",...) - yes, without '{}', or ber_scanf(ber,"{ooo}") As I read the ber_scanf man page, 'v' format actually decodes a sequence of octet strings, so my examples are correct according to these. But the code example on the end shows that '{v}' should be used. So what is the right way?
It looks like the manpage example is wrong.
I take that back. The example matches the ldap-c-api draft document. The liblber code matches as well.
I assembled a small test program, to demonstrate the problem. As I wrapping the ber functions into a C++ class, I cannot pass the variadic parameters "as is", instead I call repeatedly ber_scanf with only one argument at a time.
So the encoding: ber_printf(ber,"i{v}",integer param,list param);
can be decoded with: ber_scanf(ber,"i{v}",integer,list); and ber_scanf(ber,"i",integer); ber_scanf(ber,"v",list); But NOT with: ber_scanf(ber,"i",integer); ber_scanf(ber,"{"); ber_scanf(ber,"v",list); ber_scanf(ber,"}");
Attached the .c file, where there are 3 methods of decoding, and the second one is failing, but it seems to logical to me that it should work.
Seems your version of liblber is broken, or you're not calling ber_scanf with the right arguments.
Using OpenLDAP 2.3.30.
Thanks, György
openldap-software@openldap.org