/*
* cpydgst.c -- copy from one fd to another in encapsulating mode
* -- (do dashstuffing of input data).
*
/*
* cpydgst.c -- copy from one fd to another in encapsulating mode
* -- (do dashstuffing of input data).
*
-#define output(c) if (bp >= dp) {flush(); *bp++ = c;} else *bp++ = c
-#define flush() if ((j = bp - outbuf) && write (out, outbuf, j) != j) \
- adios (ofile, "error writing"); \
- else \
- bp = outbuf
+#define output(c) if (bp >= dp) {flush(); *bp++ = c;} else *bp++ = c
+#define flush() if ((j = bp - outbuf) && write (out, outbuf, j) != j) \
+ adios (ofile, "error writing"); \
+ else \
+ bp = outbuf
void
cpydgst (int in, int out, char *ifile, char *ofile)
{
void
cpydgst (int in, int out, char *ifile, char *ofile)
{
- register int i, j, state;
- register char *cp, *ep;
- register char *bp, *dp;
- char buffer[BUFSIZ], outbuf[BUFSIZ];
+ register int i, j, state;
+ register char *cp, *ep;
+ register char *bp, *dp;
+ char buffer[BUFSIZ], outbuf[BUFSIZ];
- dp = (bp = outbuf) + sizeof outbuf;
- for (state = S1; (i = read (in, buffer, sizeof buffer)) > 0;)
- for (ep = (cp = buffer) + i; cp < ep; cp++) {
- if (*cp == '\0')
- continue;
- switch (state) {
- case S1:
- if (*cp == '-') {
- output ('-');
- output (' ');
- }
- state = S2; /* fall */
+ dp = (bp = outbuf) + sizeof outbuf;
+ for (state = S1; (i = read (in, buffer, sizeof buffer)) > 0;)
+ for (ep = (cp = buffer) + i; cp < ep; cp++) {
+ if (*cp == '\0')
+ continue;
+ switch (state) {
+ case S1:
+ if (*cp == '-') {
+ output ('-');
+ output (' ');
+ }
+ state = S2; /* fall */