[Top][All Lists]

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

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

From: Graham Fawcett
Subject: [Chicken-users] lolevel help: array of c-pointers from string-list?
Date: Tue, 26 Sep 2006 16:44:21 -0400

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.

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.

Regardless, I'm stuck, and could use help. :-) Advice, anyone?


reply via email to

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