rd_arhdr.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* $Header$ */
  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 <arch.h>
  7. #include "object.h"
  8. int
  9. rd_arhdr(fd, arhdr)
  10. register struct ar_hdr *arhdr;
  11. {
  12. #if WORDS_REVERSED && ! BYTES_REVERSED
  13. if (sizeof (struct ar_hdr) != AR_TOTAL)
  14. #endif
  15. {
  16. char buf[AR_TOTAL];
  17. register char *c = buf;
  18. register char *p = arhdr->ar_name;
  19. register int i;
  20. i = read(fd, c, AR_TOTAL);
  21. if (i == 0) return 0;
  22. if (i < 0 || i != AR_TOTAL) {
  23. rd_fatal();
  24. }
  25. i = 14;
  26. while (i--) {
  27. *p++ = *c++;
  28. }
  29. arhdr->ar_date = get2(c) << 16; c += 2;
  30. arhdr->ar_date |= get2(c) & 0xffff; c += 2;
  31. arhdr->ar_uid = *c++;
  32. arhdr->ar_gid = *c++;
  33. arhdr->ar_mode = get2(c); c += 2;
  34. arhdr->ar_size = get2(c) << 16; c += 2;
  35. arhdr->ar_size |= get2(c) & 0xffff;
  36. }
  37. #if WORDS_REVERSED && !BYTES_REVERSED
  38. else {
  39. register int i;
  40. i = read(fd, (char *) arhdr, AR_TOTAL);
  41. if (i == 0) return 0;
  42. if (i < 0 || i != AR_TOTAL) rd_fatal();
  43. }
  44. #endif
  45. return 1;
  46. }