[Date Prev][Date Next] [Chronological] [Thread] [Top]

RE: String conversions UTF8 <-> ISO-8859-1

Howard Chu writes:
> libldap is not schema-aware, and as Kurt has stated, it is not intended to
> be. Without schema knowledge you can't do this correctly. Perhaps there
> should be a new higher level library to address this issue.
> (...)
> The Unix programming paradigm has always been to create small, efficient,
> single-purpose tools that can be piped together. (...)

The problem with piping it together here is that charset handling calls
must be inserted all over the place in the code calling ldap: Before
operations, after all calls that unpack data, maybe even in calls that
display error messages.

A higher lever library would be better, if it reused the LDAP data
structures that the user provides to LDAP.  (Or it could make it's own
parallell datastructures, but that seems a waste.)  But then the library
would have to unpack the user input, convert it, and re-pack it before
sending it to LDAP.  And it would still have to duplicate the entire
LDAP API of LDAP calls.  Still, maybe that's what we'll have to go for.

However, how about keeping charset handling in a separate library, but
provide it as callbacks from the LDAP library?  Then the entire API
would be an ldap_set_option() call to set two callbacks.  That is,
before the LDAP library sends user data to the server, it calls
something like
  (*send_callback)(operation, "attribute type", "data")
and sends the result value instead of the original data.  Similarly,
it sends data from the server through
  (*receive_callback)(operation, "attribute type", "data")
and provides the user with the result instead of the original data.

Something similar was (or is? I can't find it) in the code once but it
did not provide enough information to handle schema properly.

On the charset handling side, most of it should be straightforward, the
biggest work would be to pick apart filters and put the modified filters
together again.  Maybe code for that can be stolen from back-meta.