ack/modules/src/object/rd_arhdr.c

48 lines
1 KiB
C
Raw Normal View History

1987-03-09 15:15:03 +00:00
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
1987-01-05 17:31:38 +00:00
#include <arch.h>
#include "object.h"
int
1987-01-05 17:31:38 +00:00
rd_arhdr(fd, arhdr)
register struct ar_hdr *arhdr;
{
#if WORDS_REVERSED && ! BYTES_REVERSED
1987-01-05 17:31:38 +00:00
if (sizeof (struct ar_hdr) != AR_TOTAL)
#endif
{
char buf[AR_TOTAL];
register char *c = buf;
register char *p = arhdr->ar_name;
register int i;
1987-01-05 17:31:38 +00:00
i = read(fd, c, AR_TOTAL);
if (i == 0) return 0;
if (i < 0 || i != AR_TOTAL) {
rd_fatal();
}
i = 14;
1987-01-05 17:31:38 +00:00
while (i--) {
*p++ = *c++;
}
arhdr->ar_date = get2(c) << 16; c += 2;
arhdr->ar_date |= get2(c) & 0xffff; c += 2;
1987-01-05 17:31:38 +00:00
arhdr->ar_uid = *c++;
arhdr->ar_gid = *c++;
arhdr->ar_mode = get2(c); c += 2;
arhdr->ar_size = get2(c) << 16; c += 2;
arhdr->ar_size |= get2(c) & 0xffff;
1987-01-05 17:31:38 +00:00
}
#if WORDS_REVERSED && !BYTES_REVERSED
else {
register int i;
i = read(fd, (char *) arhdr, AR_TOTAL);
if (i == 0) return 0;
if (i < 0 || i != AR_TOTAL) rd_fatal();
}
1987-01-05 17:31:38 +00:00
#endif
return 1;
1987-01-05 17:31:38 +00:00
}