home *** CD-ROM | disk | FTP | other *** search
- /*
- * store/unstore archive file
- *
- * $Header: store.c 1.4 93/08/20 $
- * $Log: store.c,v $
- * Revision 1.4 93/08/20 11:50:20 arb
- * Do not print "unstored" if in quiet mode
- *
- * Revision 1.3 92/12/07 17:19:39 duplain
- * reformatted source.
- *
- * Revision 1.2 92/10/01 11:22:46 duplain
- * Added check for EOF.
- *
- * Revision 1.1 92/09/29 18:02:26 duplain
- * Initial revision
- *
- */
-
- #include <stdio.h>
- #include "spark.h"
- #include "main.h"
- #include "crc.h"
- #include "io.h"
-
- #ifdef UNIX
- static char rcsid[] = "$Header: store.c 1.4 93/08/20 $";
- #endif /* UNIX */
-
- Status
- unstore(header, ifp, ofp)
- Header *header;
- FILE *ifp, *ofp;
- {
- register len = header->complen;
- register Byte byte;
-
- crc = 0;
- while (len--) {
- if (check_stream(ifp) != FNOERR)
- break;
- byte = read_byte(ifp);
- calccrc(byte);
- if (!testing)
- write_byte(ofp, byte);
- }
-
- if (check_stream(ifp) == FRWERR)
- return (RERR);
- if (!testing && check_stream(ofp) == FRWERR)
- return (WERR);
- if ((Halfword)crc != header->crc)
- return (CRCERR);
- if (testing)
- {
- if (!quiet) printf("OK (stored)");
- }
- else
- if (!quiet) printf("unstored");
- return (NOERR);
- }
-