home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************************
- * *
- * ARC Processing Functions *
- * *
- **************************************************************************/
-
- #include <stdio.h>
-
- #include "fff.h"
- #include "arc.h"
-
- int Match (char *Str, char *Pat);
- void PrtVerbose (char *Path, char *Name, unsigned Time, unsigned Date,
- long Size);
- void ChkPage (void);
-
- extern char Pattern[66];
-
- void
- DoArc (char *Path) {
- extern int Level;
- extern int TotalMatch, VerboseSwt, Spaced, PageSwt;
- extern ARC_TYPE ArcType;
- extern int Lnno;
- extern S[6][3];
-
- FILE *ArcFile;
- int Status, Printed;
- ARCHIVE_HEADER ArchiveHead;
-
- Printed = 0;
- if ( (ArcFile = fopen(Path, "rb")) == NULL) perror(Path);
- else {
- while ( (Status = GetEntry(ArcFile, &ArchiveHead)) != 0 ) {
- if (Status < 0) {
- printf("%s\n", Path);
- break;
- }
- else {
- ++S[ArcType][1];
- if ( Match(ArchiveHead.Name, Pattern) ) {
- ++S[ArcType][2];
- ++TotalMatch;
- if (PageSwt) ChkPage();
- if (VerboseSwt) {
- if (!Printed) {
- if (!Spaced) {
- if (PageSwt) ChkPage();
- printf("\n");
- ++Lnno;
- }
- if (PageSwt) ChkPage();
- printf("%s\n", Path);
- ++Lnno;
- Printed = 1;
- }
- fputs("* ", stdout);
- PrtVerbose("", ArchiveHead.Name, ArchiveHead.Time.u,
- ArchiveHead.Date.u, ArchiveHead.Length);
- }
- else {
- fputs(Path, stdout);
- fputs("--> (", stdout);
- fputs(ArchiveHead.Name, stdout);
- puts(")");
- }
- ++Lnno;
- }
- }
- }
- fclose(ArcFile);
- }
- if (Printed) {
- if (PageSwt) ChkPage();
- printf("\n");
- ++Lnno;
- Spaced = 1;
- }
- }
-
- static int
- GetEntry (FILE *ArcFile, ARCHIVE_HEADER *ArchiveDir) {
-
- if (fread(ArchiveDir, sizeof(char), sizeof(ARCHIVE_HEADER), ArcFile) < 2) {
- printf("couldn't read header: ");
- return(-1);
- }
- if (ArchiveDir->ArcMark != 0x1A) {
- printf("invalid ArcMark: ");
- return(-1);
- }
- if (ArchiveDir->HeaderVersion == 0) return(0);
-
- fseek(ArcFile, ArchiveDir->Size, SEEK_CUR);
- return(1);
- }