+/*
+ * When didfds is set, we do I/O from 0, 1, 2 otherwise from 15, 16, 17
+ * We alsocheck if the shell has already chenged the decriptor to point to
+ * 0, 1, 2 when didfds is set.
+ */
+#define DESC(a) (*((int *) (a)) - (didfds && *((int *) a) >= FSHIN ? FSHIN : 0))
+
+static int
+readf(oreo, buf, siz)
+ void *oreo;
+ char *buf;
+ int siz;
+{
+ return read(DESC(oreo), buf, siz);
+}
+
+
+static int
+writef(oreo, buf, siz)
+ void *oreo;
+ const char *buf;
+ int siz;
+{
+ return write(DESC(oreo), buf, siz);
+}
+
+static fpos_t
+seekf(oreo, off, whence)
+ void *oreo;
+ fpos_t off;
+ int whence;
+{
+ return lseek(DESC(oreo), off, whence);
+}
+
+
+static int
+closef(oreo)
+ void *oreo;
+{
+ return close(DESC(oreo));
+}
+
+