cvs: gd /libgd/src gd_io.c gd_io.h

[email protected] ("Scott MacVicar") Tue, 09 Oct 2007 11:13:56 -0000
Newsgroups php.gd.cvs
Message-ID <cvsscottmac1191928436@cvsserver>
scottmac		Tue Oct  9 11:13:56 2007 UTC

  Modified files:              
    /gd/libgd/src	gd_io.c gd_io.h 
  Log:
  Add two new IO functions to fetch a word or integer when the format is LSB first.
  
http://cvs.php.net/viewvc.cgi/gd/libgd/src/gd_io.c?r1=1.6&r2=1.7&diff_format=u
Index: gd/libgd/src/gd_io.c
diff -u gd/libgd/src/gd_io.c:1.6 gd/libgd/src/gd_io.c:1.7
--- gd/libgd/src/gd_io.c:1.6	Sun Oct  7 19:41:52 2007
+++ gd/libgd/src/gd_io.c	Tue Oct  9 11:13:56 2007
@@ -116,6 +116,27 @@
 }
 
 int
+gdGetWordLSB (int *result, gdIOCtx * ctx)
+{
+	int high = 0, low = 0;
+	low = (ctx->getC) (ctx);
+	if (low == EOF) {
+ 		return 0;
+	}
+
+	high = (ctx->getC) (ctx);
+	if (high == EOF) {
+ 		return 0;
+	}
+
+	if (result) {
+		*result = (high << 8) | low;
+	}
+
+	return 1;
+}
+
+int
 gdGetInt (int *result, gdIOCtx * ctx)
 {
   int r;
@@ -151,6 +172,44 @@
 }
 
 int
+gdGetIntLSB (int *result, gdIOCtx * ctx)
+{
+	int c = 0, r = 0;
+	c = (ctx->getC) (ctx);
+	if (c == EOF) {
+ 		return 0;
+	}
+	r |= (c << 24);
+	r >>= 8;
+
+	c = (ctx->getC) (ctx);
+	if (c == EOF) {
+ 		return 0;
+	}
+	r |= (c << 24);
+	r >>= 8;
+
+	c = (ctx->getC) (ctx);
+	if (c == EOF) {
+ 		return 0;
+	}
+	r |= (c << 24);
+	r >>= 8;
+
+	c = (ctx->getC) (ctx);
+	if (c == EOF) {
+ 		return 0;
+	}
+	r |= (c << 24);
+
+	if (result) {
+		*result = r;
+	}
+
+	return 1;
+}
+
+int
 gdPutBuf (const void *buf, int size, gdIOCtx * ctx)
 {
   IO_DBG (printf ("Putting buf...\n"));
http://cvs.php.net/viewvc.cgi/gd/libgd/src/gd_io.h?r1=1.8&r2=1.9&diff_format=u
Index: gd/libgd/src/gd_io.h
diff -u gd/libgd/src/gd_io.h:1.8 gd/libgd/src/gd_io.h:1.9
--- gd/libgd/src/gd_io.h:1.8	Wed Jan  3 21:50:39 2007
+++ gd/libgd/src/gd_io.h	Tue Oct  9 11:13:56 2007
@@ -43,7 +43,9 @@
  int gdGetBuf (void *, int, gdIOCtx *);
  int gdGetByte (int *result, gdIOCtx * ctx);
  int gdGetWord (int *result, gdIOCtx * ctx);
+ int gdGetWordLSB (int *result, gdIOCtx * ctx);
  int gdGetInt (int *result, gdIOCtx * ctx);
+ int gdGetIntLSB (int *result, gdIOCtx * ctx);
 
  int gdSeek (gdIOCtx * ctx, const int offset);
  long gdTell (gdIOCtx * ctx);