summary history branches tags files
commit:42741af2fd10b03f8a2645c701a387766a74c08f
author:mrmekon
committer:mrmekon
date:Mon Nov 14 01:29:57 2011 -0500
parents:2dacd7d53aba27df15082c06d57d49286cd91f6e
Build doesn't fail on examples anymore.  Examples built and executed by make's 'installcheck' rule.  Example tests literal data.
diff --git a/Makefile.am b/Makefile.am
line changes: +6/-2
index a909d26..af1f94f
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,3 @@
-SUBDIRS = examples/01_decrypt
-
 pkglib_LTLIBRARIES = libsimplepgp.la
 pkginclude_HEADERS = src/simplepgp.h
 
@@ -13,6 +11,12 @@ libsimplepgp_la_SOURCES = \
 	src/util.c \
 	src/mpi.c 
 
+installcheck-local:
+	make -C examples/01_decrypt
+	pushd `pwd`/examples/01_decrypt ;\
+	./decrypt ;\
+	popd
+
 clean-local:
 	-rm -rf build
 

diff --git a/examples/01_decrypt/decrypt.c b/examples/01_decrypt/decrypt.c
line changes: +12/-0
index f78b0f6..407622c
--- a/examples/01_decrypt/decrypt.c
+++ b/examples/01_decrypt/decrypt.c
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <fcntl.h>
 #include <string.h>
+#include <stdint.h>
 
 #include <simplepgp.h>
 
@@ -15,6 +16,8 @@ int main(int argc, char **argv) {
   int fd;
   int seckey_len, ctext_len;
   spgp_packet_t *pkt;
+  char *data, *filename;
+  uint32_t datalen, filenamelen;
 
   printf("simplepgp decrypt example.\n");
 
@@ -56,6 +59,15 @@ int main(int argc, char **argv) {
     return 1;
   }
 
+  data = spgp_get_literal_data(pkt, &datalen,
+			       &filename, &filenamelen);
+  if (NULL == data) {
+    fprintf(stderr, "error: %s\n", spgp_err_str(spgp_err()));
+    return 1;
+  }
+  printf("Filename length: %u\n", filenamelen);
+  printf("Data length: %u\n", datalen);
+
   spgp_close();
 
   return 0;