(cffi:defcfun "nl_langinfo" :string
(item :int))
For example:
(nl-langinfo 14) ; 14 = CODESET
=> "UTF-8"
The parameter for POSIX nl_langinfo() function is called "item" and it's
an integer. C programmer's use constants defined in langinfo.h. Is it
possible to access those constants through Common Lisp CFFI interface?
How? I can check those constants with a simple C program but it would be
nicer to refer directly to langinfo.h constants in Lisp program.
I don't really know, but I guess the groveller may be able to collect
these constant definitions and generate them in lisp.
http://common-lisp.net/project/cffi/manual/html_node/The-Groveller.html
--
__Pascal Bourguignon__ http://www.informatimago.com/
> I don't really know, but I guess the groveller may be able to collect
> these constant definitions and generate them in lisp.
>
> http://common-lisp.net/project/cffi/manual/html_node/The-Groveller.html
You guessed right. In short, one has to create a grovel definition file
like this:
;;;; langinfo.lisp
(include "langinfo.h")
(constant (+codeset+ "CODESET"))
(constant (+month-10+ "MON_10"))
Then
(cffi-grovel:process-grovel-file (merge-pathnames "langinfo.lisp"))
will create file "langinfo.grovel-tmp.lisp" with the following content:
;;;; This file has been automatically generated by cffi-grovel.
;;;; Do not edit it by hand.
(cl:defconstant +codeset+ 14)
(cl:defconstant +month-10+ 131107)
CFFI-GROVEL has some kind of ASDF system integration but I don't know
yet how it works.