diff options
Diffstat (limited to 'ffi/examples/example.c')
-rw-r--r-- | ffi/examples/example.c | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/ffi/examples/example.c b/ffi/examples/example.c deleted file mode 100644 index 8636d011..00000000 --- a/ffi/examples/example.c +++ /dev/null @@ -1,45 +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; - uint8_t *b; - sq_error_t err; - sq_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 = sq_tpk_from_bytes (&err, b, st.st_size); - if (tpk == NULL) - error (1, 0, "sq_tpk_from_bytes: %s", sq_error_string (err)); - - sq_tpk_dump (tpk); - sq_tpk_free (tpk); - munmap (b, st.st_size); - close (fd); - return 0; -} |