diff options
author | Justus Winter <justus@pep-project.org> | 2017-12-14 11:26:28 +0100 |
---|---|---|
committer | Justus Winter <justus@pep-project.org> | 2017-12-14 12:12:16 +0100 |
commit | 42447a1bd58599643568b0e4885ca4fa4fe7aed9 (patch) | |
tree | 4d2574dadf4bdaba4edafe1a87ec36bcafa224af /examples | |
parent | f9ecc50244ec329461ae3b656551b1c2896a7539 (diff) |
ffi: Move the examples.
- Move the 'example.c' to sequoia-ffi.
- Fix and improve Makefile.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Makefile | 3 | ||||
-rw-r--r-- | examples/example.c | 50 |
2 files changed, 0 insertions, 53 deletions
diff --git a/examples/Makefile b/examples/Makefile deleted file mode 100644 index 59007930..00000000 --- a/examples/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -CFLAGS = -I../src -O0 -g -Wall -LDFLAGS = -L../target/debug -lsequoia -all: example diff --git a/examples/example.c b/examples/example.c deleted file mode 100644 index 5b087c15..00000000 --- a/examples/example.c +++ /dev/null @@ -1,50 +0,0 @@ -#define _GNU_SOURCE -#include <error.h> -#include <errno.h> -#include <fcntl.h> -#include <stdio.h> -#include <sys/mman.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> - -#include <sequoia.h> - -int -main (int argc, char **argv) -{ - struct stat st; - int fd; - char *b; - struct sq_context *ctx; - struct sq_tpk *tpk; - - if (argc != 2) - error (1, 0, "Usage: %s <file>", argv[0]); - - ctx = sq_context_new("org.sequoia-pgp.example"); - if (ctx == NULL) - error (1, 0, "Initializing sequoia failed."); - - if (stat (argv[1], &st)) - error (1, errno, "%s", argv[1]); - - fd = open (argv[1], O_RDONLY); - if (fd == -1) - error (1, errno, "%s", argv[1]); - - b = mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); - if (b == MAP_FAILED) - error (1, errno, "mmap"); - - tpk = sq_tpk_from_bytes (b, st.st_size); - if (tpk == NULL) - error (1, 0, "sq_tpk_from_bytes failed"); - - sq_tpk_dump (tpk); - sq_tpk_free (tpk); - sq_context_free (ctx); - munmap (b, st.st_size); - close (fd); - return 0; -} |