Commits

Anonymous committed b39a6d1

Add two new IO functions to fetch a word or integer when the format is LSB first.

  • Participants
  • Parent commits 483be52
  • Branches GD-2.0

Comments (0)

Files changed (2)

 }
 
 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;
 }
 
 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"));
  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);