diff options
Diffstat (limited to 'openpgp-ffi/examples/example.c')
-rw-r--r-- | openpgp-ffi/examples/example.c | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/openpgp-ffi/examples/example.c b/openpgp-ffi/examples/example.c index 5b114d8f..46a45529 100644 --- a/openpgp-ffi/examples/example.c +++ b/openpgp-ffi/examples/example.c @@ -1,49 +1,28 @@ #define _GNU_SOURCE #include <errno.h> #include <error.h> -#include <fcntl.h> #include <stdio.h> #include <stdlib.h> -#include <sys/mman.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> #include <sequoia/openpgp.h> int main (int argc, char **argv) { - struct stat st; - int fd; - uint8_t *b; pgp_error_t err; pgp_tpk_t tpk; if (argc != 2) error (1, 0, "Usage: %s <file>", argv[0]); - 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 = pgp_tpk_from_bytes (&err, b, st.st_size); + tpk = pgp_tpk_from_file (&err, argv[1]); if (tpk == NULL) - error (1, 0, "pgp_tpk_from_bytes: %s", pgp_error_to_string (err)); + error (1, 0, "pgp_tpk_from_file: %s", pgp_error_to_string (err)); char *debug = pgp_tpk_debug (tpk); printf ("%s", debug); free (debug); pgp_tpk_free (tpk); - munmap (b, st.st_size); - close (fd); return 0; } |