Made to work if BYTES_REVERSED and/or WORDS_REVERSED are not defined
This commit is contained in:
parent
36e47ad79b
commit
8322e2d5d3
|
@ -13,6 +13,14 @@
|
||||||
#define Xchar(ch) ((ch) & 0377)
|
#define Xchar(ch) ((ch) & 0377)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ! defined(BYTES_REVERSED)
|
||||||
|
#define BYTES_REVERSED 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! defined(WORDS_REVERSED)
|
||||||
|
#define WORDS_REVERSED 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#if BYTES_REVERSED
|
#if BYTES_REVERSED
|
||||||
#define uget2(c) (Xchar((c)[0]) | ((unsigned) Xchar((c)[1]) << 8))
|
#define uget2(c) (Xchar((c)[0]) | ((unsigned) Xchar((c)[1]) << 8))
|
||||||
#define Xput2(i, c) (((c)[0] = (i)), ((c)[1] = (i) >> 8))
|
#define Xput2(i, c) (((c)[0] = (i)), ((c)[1] = (i) >> 8))
|
||||||
|
|
|
@ -155,23 +155,21 @@ rd_sect(sect, cnt)
|
||||||
while (cnt--) {
|
while (cnt--) {
|
||||||
sect--;
|
sect--;
|
||||||
#if ! (BYTES_REVERSED || WORDS_REVERSED)
|
#if ! (BYTES_REVERSED || WORDS_REVERSED)
|
||||||
if (sizeof(struct outsect) != SZ_SECT) {
|
if (sizeof(struct outsect) != SZ_SECT)
|
||||||
#endif
|
#endif
|
||||||
c -= 4; sect->os_lign = get4(c);
|
{
|
||||||
c -= 4; sect->os_flen = get4(c);
|
c -= 4; sect->os_lign = get4(c);
|
||||||
c -= 4; sect->os_foff = get4(c);
|
c -= 4; sect->os_flen = get4(c);
|
||||||
#if ! (BYTES_REVERSED || WORDS_REVERSED)
|
c -= 4; sect->os_foff = get4(c);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
offset[--offcnt] = sect->os_foff + rd_base;
|
offset[--offcnt] = sect->os_foff + rd_base;
|
||||||
#if ! (BYTES_REVERSED || WORDS_REVERSED)
|
#if ! (BYTES_REVERSED || WORDS_REVERSED)
|
||||||
if (sizeof(struct outsect) != SZ_SECT) {
|
if (sizeof(struct outsect) != SZ_SECT)
|
||||||
#endif
|
#endif
|
||||||
c -= 4; sect->os_size = get4(c);
|
{
|
||||||
c -= 4; sect->os_base = get4(c);
|
c -= 4; sect->os_size = get4(c);
|
||||||
#if ! (BYTES_REVERSED || WORDS_REVERSED)
|
c -= 4; sect->os_base = get4(c);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,39 +10,26 @@ int
|
||||||
rd_arhdr(fd, arhdr)
|
rd_arhdr(fd, arhdr)
|
||||||
register struct ar_hdr *arhdr;
|
register struct ar_hdr *arhdr;
|
||||||
{
|
{
|
||||||
#if WORDS_REVERSED && ! BYTES_REVERSED
|
char buf[AR_TOTAL];
|
||||||
if (sizeof (struct ar_hdr) != AR_TOTAL)
|
register char *c = buf;
|
||||||
#endif
|
register char *p = arhdr->ar_name;
|
||||||
{
|
register int i;
|
||||||
char buf[AR_TOTAL];
|
|
||||||
register char *c = buf;
|
|
||||||
register char *p = arhdr->ar_name;
|
|
||||||
register int i;
|
|
||||||
|
|
||||||
i = read(fd, c, AR_TOTAL);
|
i = read(fd, c, AR_TOTAL);
|
||||||
if (i == 0) return 0;
|
if (i == 0) return 0;
|
||||||
if (i != AR_TOTAL) {
|
if (i != AR_TOTAL) {
|
||||||
rd_fatal();
|
rd_fatal();
|
||||||
}
|
|
||||||
i = 14;
|
|
||||||
while (i--) {
|
|
||||||
*p++ = *c++;
|
|
||||||
}
|
|
||||||
arhdr->ar_date = ((long) get2(c)) << 16; c += 2;
|
|
||||||
arhdr->ar_date |= ((long) get2(c)) & 0xffff; c += 2;
|
|
||||||
arhdr->ar_uid = *c++;
|
|
||||||
arhdr->ar_gid = *c++;
|
|
||||||
arhdr->ar_mode = get2(c); c += 2;
|
|
||||||
arhdr->ar_size = (long) get2(c) << 16; c += 2;
|
|
||||||
arhdr->ar_size |= (long) get2(c) & 0xffff;
|
|
||||||
}
|
}
|
||||||
#if WORDS_REVERSED && !BYTES_REVERSED
|
i = 14;
|
||||||
else {
|
while (i--) {
|
||||||
register int i;
|
*p++ = *c++;
|
||||||
i = read(fd, (char *) arhdr, AR_TOTAL);
|
|
||||||
if (i == 0) return 0;
|
|
||||||
if (i != AR_TOTAL) rd_fatal();
|
|
||||||
}
|
}
|
||||||
#endif
|
arhdr->ar_date = ((long) get2(c)) << 16; c += 2;
|
||||||
|
arhdr->ar_date |= ((long) get2(c)) & 0xffff; c += 2;
|
||||||
|
arhdr->ar_uid = *c++;
|
||||||
|
arhdr->ar_gid = *c++;
|
||||||
|
arhdr->ar_mode = get2(c); c += 2;
|
||||||
|
arhdr->ar_size = (long) get2(c) << 16; c += 2;
|
||||||
|
arhdr->ar_size |= (long) get2(c) & 0xffff;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,28 +9,20 @@
|
||||||
wr_arhdr(fd, arhdr)
|
wr_arhdr(fd, arhdr)
|
||||||
register struct ar_hdr *arhdr;
|
register struct ar_hdr *arhdr;
|
||||||
{
|
{
|
||||||
#if WORDS_REVERSED && !BYTES_REVERSED
|
char buf[AR_TOTAL];
|
||||||
if (sizeof (struct ar_hdr) != AR_TOTAL)
|
register char *c = buf;
|
||||||
#endif
|
register char *p = arhdr->ar_name;
|
||||||
{
|
register int i = 14;
|
||||||
char buf[AR_TOTAL];
|
|
||||||
register char *c = buf;
|
|
||||||
register char *p = arhdr->ar_name;
|
|
||||||
register int i = 14;
|
|
||||||
|
|
||||||
while (i--) {
|
while (i--) {
|
||||||
*c++ = *p++;
|
*c++ = *p++;
|
||||||
}
|
|
||||||
put2((int)(arhdr->ar_date>>16),c); c += 2;
|
|
||||||
put2((int)(arhdr->ar_date),c); c += 2;
|
|
||||||
*c++ = arhdr->ar_uid;
|
|
||||||
*c++ = arhdr->ar_gid;
|
|
||||||
put2(arhdr->ar_mode,c); c += 2;
|
|
||||||
put2((int)(arhdr->ar_size>>16),c); c += 2;
|
|
||||||
put2((int)(arhdr->ar_size),c);
|
|
||||||
wr_bytes(fd, buf, (long) AR_TOTAL);
|
|
||||||
}
|
}
|
||||||
#if WORDS_REVERSED && !BYTES_REVERSED
|
put2((int)(arhdr->ar_date>>16),c); c += 2;
|
||||||
else wr_bytes(fd, (char *) arhdr, (long) AR_TOTAL);
|
put2((int)(arhdr->ar_date),c); c += 2;
|
||||||
#endif
|
*c++ = arhdr->ar_uid;
|
||||||
|
*c++ = arhdr->ar_gid;
|
||||||
|
put2(arhdr->ar_mode,c); c += 2;
|
||||||
|
put2((int)(arhdr->ar_size>>16),c); c += 2;
|
||||||
|
put2((int)(arhdr->ar_size),c);
|
||||||
|
wr_bytes(fd, buf, (long) AR_TOTAL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue