[Pkg-gnupg-commit] [gnupg2] 224/292: gpgscm: Expose seek and associated constants.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Mon Nov 21 06:31:45 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gnupg2.

commit 591d61d80f4f81176f7e236df794922df9e001a1
Author: Justus Winter <justus at g10code.com>
Date:   Tue Nov 8 15:11:12 2016 +0100

    gpgscm: Expose seek and associated constants.
    
    * tests/gpgscm/ffi.c (do_seek): New function.
    (ffi_init): Expose 'seek' and 'SEEK_{SET,CUR,END}'.
    * tests/gpgscm/lib.scm: Document the new function.
    
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 tests/gpgscm/ffi.c   | 19 +++++++++++++++++++
 tests/gpgscm/lib.scm |  8 ++++++++
 2 files changed, 27 insertions(+)

diff --git a/tests/gpgscm/ffi.c b/tests/gpgscm/ffi.c
index add82f7..c91d4aa 100644
--- a/tests/gpgscm/ffi.c
+++ b/tests/gpgscm/ffi.c
@@ -326,6 +326,21 @@ do_close (scheme *sc, pointer args)
 }
 
 static pointer
+do_seek (scheme *sc, pointer args)
+{
+  FFI_PROLOG ();
+  int fd;
+  off_t offset;
+  int whence;
+  FFI_ARG_OR_RETURN (sc, int, fd, number, args);
+  FFI_ARG_OR_RETURN (sc, off_t, offset, number, args);
+  FFI_ARG_OR_RETURN (sc, int, whence, number, args);
+  FFI_ARGS_DONE_OR_RETURN (sc, args);
+  FFI_RETURN_ERR (sc, lseek (fd, offset, whence) == (off_t) -1
+                  ? gpg_error_from_syserror () : 0);
+}
+
+static pointer
 do_mkdtemp (scheme *sc, pointer args)
 {
   FFI_PROLOG ();
@@ -1309,6 +1324,9 @@ ffi_init (scheme *sc, const char *argv0, const char *scriptname,
   ffi_define_constant (sc, STDIN_FILENO);
   ffi_define_constant (sc, STDOUT_FILENO);
   ffi_define_constant (sc, STDERR_FILENO);
+  ffi_define_constant (sc, SEEK_SET);
+  ffi_define_constant (sc, SEEK_CUR);
+  ffi_define_constant (sc, SEEK_END);
 
   ffi_define_function (sc, sleep);
   ffi_define_function (sc, usleep);
@@ -1320,6 +1338,7 @@ ffi_init (scheme *sc, const char *argv0, const char *scriptname,
   ffi_define_function (sc, open);
   ffi_define_function (sc, fdopen);
   ffi_define_function (sc, close);
+  ffi_define_function (sc, seek);
   ffi_define_function_name (sc, "_mkdtemp", mkdtemp);
   ffi_define_function (sc, unlink);
   ffi_define_function (sc, unlink_recursively);
diff --git a/tests/gpgscm/lib.scm b/tests/gpgscm/lib.scm
index 27779e2..4e19eae 100644
--- a/tests/gpgscm/lib.scm
+++ b/tests/gpgscm/lib.scm
@@ -204,6 +204,14 @@
 ;; Libc functions.
 ;;
 
+;; Change the read/write offset.
+(ffi-define (seek fd offset whence))
+
+;; Constants for WHENCE.
+(ffi-define SEEK_SET)
+(ffi-define SEEK_CUR)
+(ffi-define SEEK_END)
+
 ;; Get our process id.
 (ffi-define (getpid))
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list