about summary refs log tree commit diff
path: root/lib/libpbm1.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-08-19 03:12:28 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-08-19 03:12:28 +0000
commit1fd361a1ea06e44286c213ca1f814f49306fdc43 (patch)
tree64c8c96cf54d8718847339a403e5e67b922e8c3f /lib/libpbm1.c
downloadnetpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.gz
netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.xz
netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.zip
Create Subversion repository
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/libpbm1.c')
-rw-r--r--lib/libpbm1.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/libpbm1.c b/lib/libpbm1.c
new file mode 100644
index 00000000..8dd491a7
--- /dev/null
+++ b/lib/libpbm1.c
@@ -0,0 +1,62 @@
+/* libpbm1.c - pbm utility library part 1
+**
+** Copyright (C) 1988 by Jef Poskanzer.
+**
+** Permission to use, copy, modify, and distribute this software and its
+** documentation for any purpose and without fee is hereby granted, provided
+** that the above copyright notice appear in all copies and that both that
+** copyright notice and this permission notice appear in supporting
+** documentation.  This software is provided "as is" without express or
+** implied warranty.
+*/
+
+/* See libpm.c for the complicated explanation of this 32/64 bit file
+   offset stuff.
+*/
+#define _FILE_OFFSET_BITS 64
+#define _LARGE_FILES  
+
+#include <stdio.h>
+#include "pbm.h"
+#include "libpbm.h"
+#include "shhopt.h"
+
+void
+pbm_init(int *argcP, char *argv[]) {
+    pm_proginit(argcP, argv);
+}
+
+
+
+void
+pbm_nextimage(FILE *file, int * const eofP) {
+    pm_nextimage(file, eofP);
+}
+
+
+
+void
+pbm_check(FILE * file, const enum pm_check_type check_type, 
+          const int format, const int cols, const int rows,
+          enum pm_check_code * const retval_p) {
+
+    if (rows < 0)
+        pm_error("Invalid number of rows passed to pbm_check(): %d", rows);
+    if (cols < 0)
+        pm_error("Invalid number of columns passed to pbm_check(): %d", cols);
+    
+    if (check_type != PM_CHECK_BASIC) {
+        if (retval_p) *retval_p = PM_CHECK_UNKNOWN_TYPE;
+    } else if (format != RPBM_FORMAT) {
+        if (retval_p) *retval_p = PM_CHECK_UNCHECKABLE;
+    } else {        
+        pm_filepos const bytes_per_row = (cols+7)/8;
+        pm_filepos const need_raster_size = rows * bytes_per_row;
+#ifdef LARGEFILEDEBUG
+        pm_message("pm_filepos passed to pm_check() is %u bytes",
+                   sizeof(pm_filepos));
+#endif
+        pm_check(file, check_type, need_raster_size, retval_p);
+    }
+}
+