UFFI-izing varargs
- From: Frank Goenninger DG1SBG <frank_goenninger@xxxxxxxxxxx>
- Date: Mon, 30 May 2005 20:28:28 +0200
While trying to write a (working) interface to the syslog
family of C functions I came across the varargs problem:
The C function is defined as:
void syslog( int priority, const char *messae, ...)
Hm - how to transform this into a suitable UFFI definition
and how to call it then ?
I have so far:
###
;; FUNCTION DEFINITION
(uffi:def-function ("syslog" _syslog)
((priority :int)
(message :cstring))
:returning :void)
;; SYSLOG: CALLING THE C FUNCTION
(defun syslog (priority message &rest args)
(declare (ignorable args))
;; write message to syslog
(with-cstring (c-message message)
(_syslog priority c-message))
)
###
That's obviously only half of the thing I want. So,
my questions are:
1. How to deal with the &rest args ?
Is this the right approach ?
2. How to call `format' to transform the args into one
string which can then be passed to syslog ?
I see that using approach 2) properly there's no need
for a varargs definition any more. So, 2) means how to
loop ober the args ... Oh, wait, that should be easy ;-)
It once again shows that I am still a newbie.
Thanks for any input and feedback.
Frank
--
Frank, the Ham DG1SBG
.
- Follow-Ups:
- Re: UFFI-izing varargs
- From: Kenny Tilton
- Re: UFFI-izing varargs
- Prev by Date: open source e-commerce
- Next by Date: Re: Practical Common Lisp going into 2nd printing
- Previous by thread: open source e-commerce
- Next by thread: Re: UFFI-izing varargs
- Index(es):
Relevant Pages
|
|