+bool read_int2 (int fd, unsigned short int& n)
+{
+ unsigned char tmp1;
+ unsigned int tmp2;
+ if (read (fd, &tmp1, 1) != 1)
+ return false;
+ tmp2 = tmp1;
+ if (read (fd, &tmp1, 1) != 1)
+ return false;
+
+ n = tmp2 + (tmp1 * 256);
+ return true;
+}
+
+bool read_int4 (int fd, unsigned int& n)
+{
+ unsigned int tmp4;
+ unsigned short int tmp2;
+ if (! read_int2 (fd, tmp2))
+ return false;
+ tmp4 = tmp2;
+ if (! read_int2 (fd, tmp2))
+ return false;
+
+ n = tmp4 + (tmp2 * 65536);
+ return true;
+}
+
+bool read_float8 (int fd, double& f)
+{
+ unsigned char buf[8];
+ if (read (fd, &buf, 8) != 8)
+ return false;
+
+#if WORDS_BIG_ENDIAN
+ unsigned char c;
+ c = buf[0]; buf[0] = buf[7]; buf[7] = c;
+ c = buf[1]; buf[1] = buf[6]; buf[6] = c;
+ c = buf[2]; buf[2] = buf[5]; buf[5] = c;
+ c = buf[3]; buf[3] = buf[4]; buf[4] = c;
+#endif
+
+ f = *(reinterpret_cast<double*>(buf));
+
+ return true;
+}
+