]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
(read_file): Display a message if fopen fails.
authorNiels Möller <nisse@lysator.liu.se>
Thu, 18 Mar 2004 15:11:22 +0000 (16:11 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Thu, 18 Mar 2004 15:11:22 +0000 (16:11 +0100)
Rev: src/nettle/examples/io.c:1.8

examples/io.c

index 148615960bb3938d945e0f8910503bcea8391d21..601b19a44e2d39f7007c69130b8c94da88919702 100644 (file)
 #include <stdarg.h>
 #include <stdlib.h>
 
+/* For errno and strerror */
+#include <errno.h>
+#include <string.h>
+
 #include "io.h"
 
 #define RANDOM_DEVICE "/dev/urandom"
@@ -74,8 +78,10 @@ read_file(const char *name, unsigned max_size, char **contents)
     
   f = fopen(name, "rb");
   if (!f)
-    return 0;
-
+    {
+      werror("Opening `%s' falied: %s\n", name, strerror(errno));
+      return 0;
+    }
   buffer = NULL;
 
   if (max_size && max_size < 100)