home *** CD-ROM | disk | FTP | other *** search
- /* lists an StuffIt file's contents */
- BOOL
- ListSit(ULONG type,UBYTE *infile)
- {
- int ct, counter, max;
- ULONG uncomp, comp, time, tfiles = 0, tcomp = 0, tuncomp = 0;
- UBYTE b[200],time_str[25];
- struct tm *tm;
- FILE *fp;
-
- fp = OpenFile(type,infile);
- ct = fread(b, 22, 1, fp);
-
- /* check SIT signature and fread status */
- if ((strnicmp(SIT_SIG,b,4) != 0) || ct != 1)
- {
- /* skip that part and read next section in case of MacBinary header */
- fread(b, 106, 1, fp);
- ct = fread(b, 22, 1, fp);
- if ((strnicmp(SIT_SIG,b,4) != 0) || ct != 1)
- {
- fclose(fp);
- return (WRONG_ARCHIVE);
- }
- }
-
- /* reader first header */
- max = b[4] * 256 + b[5];
- fread(b, 122, 1, fp);
- counter = 1;
-
- /* start listing */
- InitList(SIT,infile);
-
- /* parse each header block until done */
- while ( counter <= max) {
- comp = b[92] * 16777216 + b[93] * 65536 + b[94] * 256 +
- b[95] + b[96] * 16777216 + b[97] * 65536 + b[98] * 256
- + b[99];
- uncomp = b[84] * 16777216 + b[85] * 65536 + b[86] * 256 +
- b[87] + b[88] * 16777216 + b[89] * 65536 + b[90] * 256
- + b[91];
-
- /* get Un*x stored time and subtract Mac time difference */
- time = b[76] * 16777216 + b[77] * 65536 + b[78] * 256 + b[79];
- time -= 0x7c25b080;
- tm = localtime (&time);
- sprintf (time_str,"%02d-%s-19%d %02d:%02d:%02d",
- tm->tm_mday,months[tm->tm_mon],tm->tm_year,tm->tm_hour,
- tm->tm_min,tm->tm_sec);
-
- /* print and get next record */
- b[b[2] + 3] = '\0';
- PrintList(b+3, uncomp, comp,&tfiles,&tcomp,&tuncomp,time_str);
- fseek(fp, (comp-10), SEEK_CUR);
- ct = fread(b, 122, 1, fp);
- if (ct < 1) break;
- counter ++;
- }
-
- fclose(fp);
- EndStats(tfiles,tcomp,tuncomp);
- return(TRUE);
- }
-