X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=inline;f=contrib%2Fsb-posix%2Finterface.lisp;h=6d6d72c0b5c8b89e3cc3b000a67cd0f24c1fc627;hb=6c849ec3769e576fdc8b15caeb7c1fda6d7a651b;hp=aef75cde42a166bcc57679668863a78a1a430c4f;hpb=8e9908b6f79b7bb52a281cfcbf0712d4b914f3cf;p=sbcl.git diff --git a/contrib/sb-posix/interface.lisp b/contrib/sb-posix/interface.lisp index aef75cd..6d6d72c 100644 --- a/contrib/sb-posix/interface.lisp +++ b/contrib/sb-posix/interface.lisp @@ -126,7 +126,7 @@ (define-call "fchdir" int minusp (fd file-descriptor)) (define-call "fchmod" int minusp (fd file-descriptor) (mode mode-t)) (define-call "fchown" int minusp (fd file-descriptor) - (owner uid-t) (group gid-t)) + (owner uid-t) (group gid-t)) (define-call "fdatasync" int minusp (fd file-descriptor)) (define-call ("ftruncate" :options :largefile) int minusp (fd file-descriptor) (length off-t)) @@ -141,7 +141,24 @@ int minusp (pathname filename) (length off-t)) ;; FIXME: Windows does have _mktemp, which has a slightlty different ;; interface - (define-call "mkstemp" int minusp (template c-string)) + (defun mkstemp (template) + ;; we are emulating sb-alien's charset conversion for strings + ;; here, to accommodate for the call-by-reference nature of + ;; mkstemp's template strings. + (let ((arg (sb-ext:string-to-octets + (filename template) + :external-format sb-alien::*default-c-string-external-format*))) + (sb-sys:with-pinned-objects (arg) + (let ((result (alien-funcall (extern-alien "mkstemp" + (function int c-string)) + (sap-alien (sb-alien::vector-sap arg) + (* char))))) + (when (minusp result) + (syscall-error)) + (values result + (sb-ext:octets-to-string + arg + :external-format sb-alien::*default-c-string-external-format*)))))) (define-call-internally ioctl-without-arg "ioctl" int minusp (fd file-descriptor) (cmd int)) (define-call-internally ioctl-with-int-arg "ioctl" int minusp @@ -535,3 +552,25 @@ (unless (null-alien r) (cast r c-string)))) (define-call "putenv" int minusp (string c-string)) + +;;; syslog +#-win32 +(progn + (export 'openlog :sb-posix) + (export 'syslog :sb-posix) + (export 'closelog :sb-posix) + (defun openlog (ident options &optional (facility log-user)) + (alien-funcall (extern-alien + "openlog" (function void c-string int int)) + ident options facility)) + (defun syslog (priority format &rest args) + "Send a message to the syslog facility, with severity level +PRIORITY. The message will be formatted as by CL:FORMAT (rather +than C's printf) with format string FORMAT and arguments ARGS." + (flet ((syslog1 (priority message) + (alien-funcall (extern-alien + "syslog" (function void int c-string c-string)) + priority "%s" message))) + (syslog1 priority (apply #'format nil format args)))) + (define-call "closelog" void never-fails)) +