UFFI-izing varargs




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
.



Relevant Pages

  • [UNIX] Remote Format String Vulnerability in Tanne
    ... Tanne is a small, secure session-management ... exploiting a format string vulnerability. ... vsnprintf(txt, 511, str, args); ... syslog(LOG_INFO, "%s", txt); ...
    (Securiteam)
  • Re: UFFI-izing varargs
    ... C functions I came across the varargs problem: The C function is defined as: void syslog(int priority, const char *messae, ...) ... Then you just populate the Lisp array and pass that. ...
    (comp.lang.lisp)
  • iptables not logging via syslog-ng
    ... in syslog.. ... # the "none" priority found in the original syslogd configuration is ... filter f_auth {facility(auth, authpriv);}; ... filter f_syslog; ...
    (Debian-User)
  • Re: iptables not logging via syslog-ng
    ... in syslog.. ... # the "none" priority found in the original syslogd configuration is ... filter f_auth {facility(auth, authpriv);}; ... filter f_syslog; ...
    (Debian-User)
  • Re: syslogd quesstion
    ... If I really care what facility and priority something is logged ... I can separate all the messages into separate log files based on ... priority of messages logged to syslog was particularly useful... ...
    (Fedora)