chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] lolevel help: array of c-pointers from string-list?


From: Hans Bulfone
Subject: Re: [Chicken-users] lolevel help: array of c-pointers from string-list?
Date: Tue, 26 Sep 2006 23:48:36 +0200
User-agent: Mutt/1.5.9i

hi,

On Tue, Sep 26, 2006 at 04:44:21PM -0400, Graham Fawcett wrote:
> Hi folks,
> 
> I'm writing a basic openldap egg; it's going well, but I've hit a
> small snag. The ldap_search() function takes a null-terminated array
> of C strings -- char *attrs[] -- to specify the record attributes
> you're interested in. (You can provide NULL instead if you want all
> the attributes.) I'd like to be able to create such an array
> dynamically, from a list of strings.

some time ago i've also started with a openldap binding, but i didn't
finish it and so far it only has support for ldap_search_s()
(but that worked iirc)

anyways, my solution to the attrs problem was to pass a list of
strings as scheme-object and walk that list in c using C_u_i_car,
C_u_i_cdr etc.

i've attached my code, feel free to do whatever you want with it.
(but if you use it you should replace the exit(1) with code that
properly signals a type error :)

> Given a list of attributes, e.g. (define attribs (list "name" "mail"
> "phone")), my plan was to create a byte-vector,
> 
> (define vec (string->byte-vector
>             (conc (string-intersperse attribs "\x00") "\x00")))
> 
> and then use (map string-length attribs) and (make-locative vec N) to
> derive a list of pointers to the the strings in the byte-vector, and
> then copy the list of pointers into a malloc'd array of pointers. I'm
> not actually sure that's possible, though it seems like it might just
> work, with sufficient effort.

that also sounds like a good idea

bye,
hans.

Attachment: ldap.scm
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]