/* List a zoo archive */

BOOL
ListZoo(ULONG type,UBYTE *infile)
{
  int time, date, done;
  ULONG uncomp, comp, pntr, tfiles = 0, tcomp = 0, tuncomp = 0;
  UBYTE name [256], dir[256],together[512], b[200], time_str[25];
  FILE *fp;

  fp = OpenFile(type,infile);

  ReadBuf (35,fp,b);

  /* Determine if it is a Zoo file */
  if (strnicmp(ZOO_SIG,b,4) != 0)
    {
      fclose (fp);
      return (WRONG_ARCHIVE);
    }

  /* Pointer to next header */
  pntr = GetLong (b,27);

  /* Read in the File Info */
  fseek(fp,pntr,SEEK_SET);

  ReadBuf(58,fp,b);

  /* Read in the filename and Directory name */
  fread (name,b[56],1,fp);
  fread (dir,b[57],1,fp);

  /* Check to see if Directory and Long name present */
  if (!b[57] && !b[56]) sprintf(together,"%s",b+38);
   else if (!b[57] && b[56]) sprintf(together,"%s",name);
    else if (b[57] && !b[56]) sprintf(together,"%s/%s",dir,b+38);
     else sprintf(together,"%s/%s",dir,name);

  /* Print out header info to standard output */
  InitList(ZOO,infile);

  done = FALSE;
  pntr = GetLong (b,9);
  while (!done)
   {
     /* Calculate Compressed, Uncompressed, Date,Time, and print it out */
     comp = GetLong(b,27);
     uncomp = GetLong(b,23);
     date = b[15] * 256 + b[14];
     time = b [17] * 256 + b[16];
     if (MSDog (time,date,time_str) == ABORT) break;
     PrintList(together, uncomp, comp,&tfiles,&tcomp,&tuncomp,time_str);

     fseek (fp,pntr,SEEK_SET);

     ReadBuf (51,fp,b);

     pntr = GetLong(b,9);
     if (!pntr) break;

     fread (b+51,7,1,fp);
     /* Read in the filename and Directory name */
     fread (name,b[56],1,fp);
     fread (dir,b[57],1,fp);

     /* Check to see if Directory and Long name present */
     if (!b[57] && !b[56]) sprintf(together,"%s",b+38);
      else if (!b[57] && b[56]) sprintf(together,"%s",name);
       else if (b[57] && !b[56]) sprintf(together,"%s/%s",dir,b+38);
        else sprintf(together,"%s/%s",dir,name);
  }

  fclose (fp);
  /* Print ending stats */
  EndStats(tfiles,tcomp,tuncomp);
  return (TRUE);
}
