1.0.1.14: Make sb-posix:mkstemp return both the FD and the file name.
authorAndreas Fuchs <asf@boinkor.net>
Mon, 8 Jan 2007 14:29:41 +0000 (14:29 +0000)
committerAndreas Fuchs <asf@boinkor.net>
Mon, 8 Jan 2007 14:29:41 +0000 (14:29 +0000)
mkstemp(3) takes a template string as an "out" parameter. The sb-posix
README states that this should be returned as a second value, so we do that.
(From a user report that the template string would not get properly
clobbered in post-1.0 sbcls. Ow.)

contrib/sb-posix/interface.lisp
version.lisp-expr

index aef75cd..349c74d 100644 (file)
   (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))
       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
index 0020338..5479fa1 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.1.13"
+"1.0.1.14"