diff options
Diffstat (limited to 'openpgp-ffi/examples')
-rw-r--r-- | openpgp-ffi/examples/armor.c | 10 | ||||
-rw-r--r-- | openpgp-ffi/examples/decrypt-with.c | 11 | ||||
-rw-r--r-- | openpgp-ffi/examples/encrypt-for.c | 12 | ||||
-rw-r--r-- | openpgp-ffi/examples/example.c | 11 | ||||
-rw-r--r-- | openpgp-ffi/examples/immutable-reference-demo.c | 10 | ||||
-rw-r--r-- | openpgp-ffi/examples/parser.c | 12 | ||||
-rw-r--r-- | openpgp-ffi/examples/reader.c | 11 | ||||
-rw-r--r-- | openpgp-ffi/examples/type-safety-demo.c | 10 | ||||
-rw-r--r-- | openpgp-ffi/examples/use-after-free-demo.c | 10 |
9 files changed, 88 insertions, 9 deletions
diff --git a/openpgp-ffi/examples/armor.c b/openpgp-ffi/examples/armor.c index 42395811..49ed533c 100644 --- a/openpgp-ffi/examples/armor.c +++ b/openpgp-ffi/examples/armor.c @@ -1,6 +1,14 @@ #define _GNU_SOURCE #include <assert.h> -#include <error.h> +/* Roughly glibc compatible error reporting. */ +#define error(S, E, F, ...) do { \ + fprintf (stderr, (F), __VA_ARGS__); \ + int s = (S), e = (E); \ + if (e) { fprintf (stderr, ": %s", strerror (e)); } \ + fprintf (stderr, "\n"); \ + fflush (stderr); \ + if (s) { exit (s); } \ + } while (0) #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/openpgp-ffi/examples/decrypt-with.c b/openpgp-ffi/examples/decrypt-with.c index ae5e871d..d30b2d52 100644 --- a/openpgp-ffi/examples/decrypt-with.c +++ b/openpgp-ffi/examples/decrypt-with.c @@ -3,10 +3,19 @@ #define _GNU_SOURCE #include <assert.h> -#include <error.h> +/* Roughly glibc compatible error reporting. */ +#define error(S, E, F, ...) do { \ + fprintf (stderr, (F), __VA_ARGS__); \ + int s = (S), e = (E); \ + if (e) { fprintf (stderr, ": %s", strerror (e)); } \ + fprintf (stderr, "\n"); \ + fflush (stderr); \ + if (s) { exit (s); } \ + } while (0) #include <errno.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <sequoia/openpgp.h> diff --git a/openpgp-ffi/examples/encrypt-for.c b/openpgp-ffi/examples/encrypt-for.c index 4a92d023..de2abd64 100644 --- a/openpgp-ffi/examples/encrypt-for.c +++ b/openpgp-ffi/examples/encrypt-for.c @@ -2,9 +2,19 @@ encrypt a file. */ #define _GNU_SOURCE -#include <error.h> +/* Roughly glibc compatible error reporting. */ +#define error(S, E, F, ...) do { \ + fprintf (stderr, (F), __VA_ARGS__); \ + int s = (S), e = (E); \ + if (e) { fprintf (stderr, ": %s", strerror (e)); } \ + fprintf (stderr, "\n"); \ + fflush (stderr); \ + if (s) { exit (s); } \ + } while (0) #include <errno.h> #include <stdio.h> +#include <stdlib.h> +#include <string.h> #include <sequoia/openpgp.h> diff --git a/openpgp-ffi/examples/example.c b/openpgp-ffi/examples/example.c index 46a45529..3c561761 100644 --- a/openpgp-ffi/examples/example.c +++ b/openpgp-ffi/examples/example.c @@ -1,8 +1,17 @@ #define _GNU_SOURCE #include <errno.h> -#include <error.h> +/* Roughly glibc compatible error reporting. */ +#define error(S, E, F, ...) do { \ + fprintf (stderr, (F), __VA_ARGS__); \ + int s = (S), e = (E); \ + if (e) { fprintf (stderr, ": %s", strerror (e)); } \ + fprintf (stderr, "\n"); \ + fflush (stderr); \ + if (s) { exit (s); } \ + } while (0) #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <sequoia/openpgp.h> diff --git a/openpgp-ffi/examples/immutable-reference-demo.c b/openpgp-ffi/examples/immutable-reference-demo.c index a0ada27b..47efbdd6 100644 --- a/openpgp-ffi/examples/immutable-reference-demo.c +++ b/openpgp-ffi/examples/immutable-reference-demo.c @@ -1,6 +1,14 @@ #define _GNU_SOURCE #include <errno.h> -#include <error.h> +/* Roughly glibc compatible error reporting. */ +#define error(S, E, F, ...) do { \ + fprintf (stderr, (F), __VA_ARGS__); \ + int s = (S), e = (E); \ + if (e) { fprintf (stderr, ": %s", strerror (e)); } \ + fprintf (stderr, "\n"); \ + fflush (stderr); \ + if (s) { exit (s); } \ + } while (0) #include <fcntl.h> #include <stdio.h> #include <stdlib.h> diff --git a/openpgp-ffi/examples/parser.c b/openpgp-ffi/examples/parser.c index 5ded2de2..dc404fec 100644 --- a/openpgp-ffi/examples/parser.c +++ b/openpgp-ffi/examples/parser.c @@ -2,10 +2,20 @@ * also serves as a simple benchmark. */ #define _GNU_SOURCE -#include <error.h> +/* Roughly glibc compatible error reporting. */ +#define error(S, E, F, ...) do { \ + fprintf (stderr, (F), __VA_ARGS__); \ + int s = (S), e = (E); \ + if (e) { fprintf (stderr, ": %s", strerror (e)); } \ + fprintf (stderr, "\n"); \ + fflush (stderr); \ + if (s) { exit (s); } \ + } while (0) #include <errno.h> #include <stdio.h> #include <time.h> +#include <string.h> +#include <stdlib.h> #include <sequoia/openpgp.h> diff --git a/openpgp-ffi/examples/reader.c b/openpgp-ffi/examples/reader.c index b0273ebb..13c47f69 100644 --- a/openpgp-ffi/examples/reader.c +++ b/openpgp-ffi/examples/reader.c @@ -1,8 +1,17 @@ #define _GNU_SOURCE -#include <error.h> +/* Roughly glibc compatible error reporting. */ +#define error(S, E, F, ...) do { \ + fprintf (stderr, (F), __VA_ARGS__); \ + int s = (S), e = (E); \ + if (e) { fprintf (stderr, ": %s", strerror (e)); } \ + fprintf (stderr, "\n"); \ + fflush (stderr); \ + if (s) { exit (s); } \ + } while (0) #include <errno.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <sequoia/openpgp.h> diff --git a/openpgp-ffi/examples/type-safety-demo.c b/openpgp-ffi/examples/type-safety-demo.c index ad4870e2..d2bc523e 100644 --- a/openpgp-ffi/examples/type-safety-demo.c +++ b/openpgp-ffi/examples/type-safety-demo.c @@ -1,6 +1,14 @@ #define _GNU_SOURCE #include <errno.h> -#include <error.h> +/* Roughly glibc compatible error reporting. */ +#define error(S, E, F, ...) do { \ + fprintf (stderr, (F), __VA_ARGS__); \ + int s = (S), e = (E); \ + if (e) { fprintf (stderr, ": %s", strerror (e)); } \ + fprintf (stderr, "\n"); \ + fflush (stderr); \ + if (s) { exit (s); } \ + } while (0) #include <fcntl.h> #include <stdio.h> #include <stdlib.h> diff --git a/openpgp-ffi/examples/use-after-free-demo.c b/openpgp-ffi/examples/use-after-free-demo.c index e64a3c1f..30863c81 100644 --- a/openpgp-ffi/examples/use-after-free-demo.c +++ b/openpgp-ffi/examples/use-after-free-demo.c @@ -1,6 +1,14 @@ #define _GNU_SOURCE #include <errno.h> -#include <error.h> +/* Roughly glibc compatible error reporting. */ +#define error(S, E, F, ...) do { \ + fprintf (stderr, (F), __VA_ARGS__); \ + int s = (S), e = (E); \ + if (e) { fprintf (stderr, ": %s", strerror (e)); } \ + fprintf (stderr, "\n"); \ + fflush (stderr); \ + if (s) { exit (s); } \ + } while (0) #include <fcntl.h> #include <stdio.h> #include <stdlib.h> |