about summary refs log tree commit diff
path: root/converter/other/cameratopam/stdio_nofail.c
diff options
context:
space:
mode:
Diffstat (limited to 'converter/other/cameratopam/stdio_nofail.c')
-rw-r--r--converter/other/cameratopam/stdio_nofail.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/converter/other/cameratopam/stdio_nofail.c b/converter/other/cameratopam/stdio_nofail.c
new file mode 100644
index 00000000..0ccfc5b4
--- /dev/null
+++ b/converter/other/cameratopam/stdio_nofail.c
@@ -0,0 +1,75 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include <netpbm/pm.h>
+
+#include "stdio_nofail.h"
+
+
+
+size_t
+fread_nofail(void * const ptr,
+             size_t const size,
+             size_t const nmemb,
+             FILE * const streamP) {
+
+    size_t rc;
+
+    rc = fread(ptr, size, nmemb, streamP);
+
+    if (rc < 0)
+        pm_error("File read failed.  Errno=%d (%s)", errno, strerror(errno));
+
+    return rc;
+}
+
+
+
+int
+fgetc_nofail(FILE * streamP) {
+
+    int rc;
+
+    rc = fgetc(streamP);
+
+    if (rc < 0)
+        pm_error("File read failed.  Errno=%d (%s)", errno, strerror(errno));
+
+    return rc;
+}
+
+
+
+int
+fseek_nofail(FILE * const streamP,
+             long   const offset,
+             int    const whence) {
+
+    int rc;
+
+    rc = fseek(streamP, offset, whence);
+
+    if (rc < 0)
+        pm_error("File read failed.  Errno=%d (%s)", errno, strerror(errno));
+
+    return rc;
+}
+
+
+
+long
+ftell_nofail(FILE * const streamP) {
+
+    long rc;
+
+    rc = ftell(streamP);
+
+    if (rc < 0)
+        pm_error("File read failed.  Errno=%d (%s)", errno, strerror(errno));
+
+    return rc;
+}
+
+
+