summaryrefslogtreecommitdiffstats
path: root/ffi/examples
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2018-03-15 12:13:04 +0100
committerJustus Winter <justus@sequoia-pgp.org>2018-03-15 12:13:04 +0100
commit8e7d1fb864520425006363fbfdff6b96a5015ed2 (patch)
tree75bd927c22936a51d2f7b3a8ab7bee7085926a79 /ffi/examples
parentdd257663217d6d2c098d5a57d8a3f8c5a830310f (diff)
ffi: Improve error reporting when creating contexts.
- Usually, we report complex errors by attaching them to the ffi context. However, when we create the contexts, there is no context to attach the error to. Therefore, we add an explicit error argument here.
Diffstat (limited to 'ffi/examples')
-rw-r--r--ffi/examples/configure.c6
-rw-r--r--ffi/examples/example.c6
-rw-r--r--ffi/examples/keyserver.c6
-rw-r--r--ffi/examples/reader.c6
4 files changed, 16 insertions, 8 deletions
diff --git a/ffi/examples/configure.c b/ffi/examples/configure.c
index 731d7a4c..45c56ff1 100644
--- a/ffi/examples/configure.c
+++ b/ffi/examples/configure.c
@@ -9,15 +9,17 @@
int
main (int argc, char **argv)
{
+ sq_error_t err;
sq_config_t cfg;
sq_context_t ctx;
sq_keyserver_t ks;
cfg = sq_context_configure ("org.sequoia-pgp.example");
sq_config_network_policy (cfg, SQ_NETWORK_POLICY_OFFLINE);
- ctx = sq_config_build (cfg);
+ ctx = sq_config_build (cfg, &err);
if (ctx == NULL)
- error (1, 0, "Initializing sequoia failed.");
+ error (1, 0, "Initializing sequoia failed: %s",
+ sq_error_string (err));
ks = sq_keyserver_sks_pool (ctx);
if (ks == NULL)
diff --git a/ffi/examples/example.c b/ffi/examples/example.c
index ed4789ca..eac7d817 100644
--- a/ffi/examples/example.c
+++ b/ffi/examples/example.c
@@ -16,15 +16,17 @@ main (int argc, char **argv)
struct stat st;
int fd;
char *b;
+ sq_error_t err;
sq_context_t ctx;
sq_tpk_t tpk;
if (argc != 2)
error (1, 0, "Usage: %s <file>", argv[0]);
- ctx = sq_context_new("org.sequoia-pgp.example");
+ ctx = sq_context_new("org.sequoia-pgp.example", &err);
if (ctx == NULL)
- error (1, 0, "Initializing sequoia failed.");
+ error (1, 0, "Initializing sequoia failed: %s",
+ sq_error_string (err));
if (stat (argv[1], &st))
error (1, errno, "%s", argv[1]);
diff --git a/ffi/examples/keyserver.c b/ffi/examples/keyserver.c
index 343ee163..fbc6fe9a 100644
--- a/ffi/examples/keyserver.c
+++ b/ffi/examples/keyserver.c
@@ -8,14 +8,16 @@
int
main (int argc, char **argv)
{
+ sq_error_t err;
sq_context_t ctx;
sq_keyid_t id;
sq_keyserver_t ks;
sq_tpk_t tpk;
- ctx = sq_context_new ("org.sequoia-pgp.example");
+ ctx = sq_context_new ("org.sequoia-pgp.example", &err);
if (ctx == NULL)
- error (1, 0, "Initializing sequoia failed.");
+ error (1, 0, "Initializing sequoia failed: %s",
+ sq_error_string (err));
ks = sq_keyserver_sks_pool (ctx);
if (ks == NULL)
diff --git a/ffi/examples/reader.c b/ffi/examples/reader.c
index 439d6510..1587979b 100644
--- a/ffi/examples/reader.c
+++ b/ffi/examples/reader.c
@@ -16,6 +16,7 @@ main (int argc, char **argv)
struct stat st;
int fd;
uint8_t *b;
+ sq_error_t err;
sq_context_t ctx;
sq_reader_t reader;
sq_tpk_t tpk;
@@ -23,9 +24,10 @@ main (int argc, char **argv)
if (argc != 2)
error (1, 0, "Usage: %s <file>", argv[0]);
- ctx = sq_context_new("org.sequoia-pgp.example");
+ ctx = sq_context_new("org.sequoia-pgp.example", &err);
if (ctx == NULL)
- error (1, 0, "Initializing sequoia failed.");
+ error (1, 0, "Initializing sequoia failed: %s",
+ sq_error_string (err));
if (stat (argv[1], &st))
error (1, errno, "%s", argv[1]);