about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-09-19 17:31:15 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-09-19 17:31:15 +0000
commit2a4b7ed2c9a770fa70628b0f5eca1b1e96251e1b (patch)
tree07915b54076680711bc270cd7bec98327b5a62aa
parent37e30243c7bee72fd6fc269d8f362b36eee9366c (diff)
downloadnetpbm-mirror-2a4b7ed2c9a770fa70628b0f5eca1b1e96251e1b.tar.gz
netpbm-mirror-2a4b7ed2c9a770fa70628b0f5eca1b1e96251e1b.tar.xz
netpbm-mirror-2a4b7ed2c9a770fa70628b0f5eca1b1e96251e1b.zip
Add pm_readbiglong2, etc.
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1289 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY7
-rw-r--r--lib/pm.h20
-rw-r--r--lib/pmfileio.c35
3 files changed, 62 insertions, 0 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index 2b35a978..befd4d3e 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -6,6 +6,13 @@ CHANGE HISTORY
 
 not yet  BJH  Release 10.52.00
 
+
+              libnetpbm: add pm_readbiglong2, pm_readbiglong2u,
+              pm_readlittlelong2, pm_readlittlelong2u: These use the proper
+              32 bit integer types instead of "long".  (But the old ones
+              still work in legacy code because long is always at least 32
+              bits).
+
               Add pamrecolor.  Thanks Scott Pakin.
 
               anytopnm: Use 'pngtopam' shell command instead of 'pngtopnm'.
diff --git a/lib/pm.h b/lib/pm.h
index 644e2670..7870e1c7 100644
--- a/lib/pm.h
+++ b/lib/pm.h
@@ -273,6 +273,16 @@ pm_readbiglongu(FILE *          const ifP,
 }
 
 int
+pm_readbiglong2(FILE * const ifP, 
+                int32_t * const lP);
+
+static __inline__ int
+pm_readbiglongu2(FILE *     const ifP,
+                 uint32_t * const lP) {
+    return pm_readbiglong2(ifP, (int32_t *) lP);
+}
+
+int
 pm_writebiglong(FILE * const ofP,
                 long   const l);
 
@@ -313,6 +323,16 @@ pm_readlittlelongu(FILE *          const ifP,
 }
 
 int
+pm_readlittlelong2(FILE *    const ifP,
+                   int32_t * const lP);
+
+static __inline__ int
+pm_readlittlelong2u(FILE *     const ifP,
+                    uint32_t * const lP) {
+    return pm_readlittlelong2(ifP, (int32_t *) lP);
+}
+
+int
 pm_writelittlelong(FILE * const ofP,
                    long   const l);
 
diff --git a/lib/pmfileio.c b/lib/pmfileio.c
index 819a0343..dd7e617e 100644
--- a/lib/pmfileio.c
+++ b/lib/pmfileio.c
@@ -29,6 +29,7 @@
     /* This makes the the x64() functions available on AIX */
 
 #include <unistd.h>
+#include <assert.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <stdarg.h>
@@ -524,6 +525,23 @@ pm_readbiglong(FILE * const ifP,
 
 
 int
+pm_readbiglong2(FILE *    const ifP,
+                int32_t * const lP) {
+    int rc;
+    long l;
+
+    rc = pm_readbiglong(ifP, &l);
+
+    assert((int32_t)l == l);
+
+    *lP = (int32_t)l;
+
+    return rc;
+}
+
+
+
+int
 pm_writebiglong(FILE * const ofP, 
                 long   const l) {
 
@@ -582,6 +600,23 @@ pm_readlittlelong(FILE * const ifP,
 
 
 int
+pm_readlittlelong2(FILE *    const ifP,
+                int32_t * const lP) {
+    int rc;
+    long l;
+
+    rc = pm_readlittlelong(ifP, &l);
+
+    assert((int32_t)l == l);
+
+    *lP = (int32_t)l;
+
+    return rc;
+}
+
+
+
+int
 pm_writelittlelong(FILE * const ofP, 
                    long   const l) {