rd_arhdr.c 773 B

12345678910111213141516171819202122232425262728293031323334
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. #include "obj.h"
  7. int
  8. rd_arhdr(fd, arhdr)
  9. register struct ar_hdr *arhdr;
  10. {
  11. char buf[AR_TOTAL];
  12. register char *c = buf;
  13. register char *p = arhdr->ar_name;
  14. register int i;
  15. i = read(fd, c, AR_TOTAL);
  16. if (i == 0) return 0;
  17. if (i != AR_TOTAL) {
  18. rd_fatal();
  19. }
  20. i = 14;
  21. while (i--) {
  22. *p++ = *c++;
  23. }
  24. arhdr->ar_date = ((long) get2(c)) << 16; c += 2;
  25. arhdr->ar_date |= ((long) get2(c)) & 0xffff; c += 2;
  26. arhdr->ar_uid = *c++;
  27. arhdr->ar_gid = *c++;
  28. arhdr->ar_mode = get2(c); c += 2;
  29. arhdr->ar_size = (long) get2(c) << 16; c += 2;
  30. arhdr->ar_size |= (long) get2(c) & 0xffff;
  31. return 1;
  32. }