substdio_copy.c
author tomas@localhost
Thu, 01 Nov 2007 14:46:11 +0100
changeset 0 c045670f36e9
permissions -rw-r--r--
Imported queue-fix-1.4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     1
#include "substdio.h"
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     2
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     3
int substdio_copy(ssout,ssin)
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     4
register substdio *ssout;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     5
register substdio *ssin;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     6
{
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     7
  register int n;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     8
  register char *x;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     9
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    10
  for (;;) {
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    11
    n = substdio_feed(ssin);
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    12
    if (n < 0) return -2;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    13
    if (!n) return 0;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    14
    x = substdio_PEEK(ssin);
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    15
    if (substdio_put(ssout,x,n) == -1) return -3;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    16
    substdio_SEEK(ssin,n);
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    17
  }
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    18
}