home *** CD-ROM | disk | FTP | other *** search
- /* Prints an error message */
- void
- Error(char *str)
- {
- printf("\nError : %s\n\n",str);
- exit(0);
- }
-
- /* checks to see if an error condition exists */
- void CheckError(int num)
- {
- switch (num)
- {
- case TRUE : return;
- case FILE_ERROR : Error("File Error - aborting listing.\n");
- case NOTFOUND : Error("Archive file not found.");
- case WRONG_ARCHIVE : Error("Archive header is invalid.");
- case UNKNOWN : Error("Unknown archive type.");
- }
- }
-
- /* print header for listing archives and reset stat values */
- void
- InitList(ULONG type,UBYTE *infile)
- {
- printf("\n");
- switch (type) {
- case ARC : printf("Arc"); break;
- case ARJ : printf("Arj"); break;
- case CPIO : printf("Cpio"); break;
- case LHA : printf("LHA"); break;
- case LHARC : printf("Lharc"); break;
- case SIT : printf("Sit"); break;
- case TAR : printf("Tar"); break;
- case ZIP : printf("Zip"); break;
- case ZOO : printf("Zoo"); break;
- }
- printf(" Archive: %s\n\n",infile);
- dashes();
- printf(" Original Compress Ratio Date Time Filename\n");
- dashes();
- }
-
- /* print entry in archive listing and update stats */
- void
- PrintList(char *n, ULONG u, ULONG c,ULONG *tfiles,ULONG *tcomp,ULONG *tuncomp,UBYTE *time_str)
- {
- ULONG f;
-
- if ( (c==0) || (u==0) ) f = 0;
- else f = (c * 1000) / u;
- (*tfiles)++; (*tcomp) += c;
- (*tuncomp) += u;
- printf(" %-10ld%-10ld%3ld.%ld%% %-22s%s\n", u, c, f/10,f%10, time_str, n);
- }
-
- /* prints the total statistics on the archive */
- void
- EndStats(ULONG tfiles,ULONG tcomp,ULONG tuncomp)
- {
- ULONG cf;
- char temp[6];
-
- if (tfiles == 1) strcpy(temp, "file");
- else strcpy(temp, "files");
- if (tuncomp == 0) cf = 0;
- else cf = (tcomp * 1000) / tuncomp;
- dashes();
- printf(" %-10ld%-10ld%3ld.%ld%% %d %s processed.\n\n", tuncomp, tcomp,cf/10, cf%10, tfiles, temp);
- }
-
- void dashes(void)
- {
- int i;
- char dash[80];
- for (i=0; i < 75; i++)
- dash[i] = '-';
- dash[i] = 0;
- printf("%s\n",dash);
- }