Skip to content

Commit 3a13c72

Browse files
author
brad
committed
fixed endian bug in server.c, status code
now seems to pull in files correctly
1 parent 35d35d1 commit 3a13c72

File tree

4 files changed

+10
-22
lines changed

4 files changed

+10
-22
lines changed

chaos/FILE.c

-16
Original file line numberDiff line numberDiff line change
@@ -2558,22 +2558,14 @@ struct xfer *ax;
25582558
#endif
25592559
if (protocol > 0)
25602560
(void)sprintf(response,
2561-
#ifdef OSX
25622561
"%02d/%02d/%02d %02d:%02d:%02d %lld%c%s%c",
2563-
#else
2564-
"%02d/%02d/%02d %02d:%02d:%02d %ld%c%s%c",
2565-
#endif
25662562
tm->tm_mon+1, tm->tm_mday, tm->tm_year,
25672563
tm->tm_hour, tm->tm_min, tm->tm_sec,
25682564
sbuf.st_size, CHNL,
25692565
x->x_realname, CHNL);
25702566
else
25712567
(void)sprintf(response,
2572-
#ifdef OSX
25732568
"%d %02d/%02d/%02d %02d:%02d:%02d %lld%c%s%c",
2574-
#else
2575-
"%d %02d/%02d/%02d %02d:%02d:%02d %ld%c%s%c",
2576-
#endif
25772569
-1, tm->tm_mon+1, tm->tm_mday,
25782570
tm->tm_year, tm->tm_hour, tm->tm_min,
25792571
tm->tm_sec, sbuf.st_size, CHNL,
@@ -3556,11 +3548,7 @@ char *cp;
35563548
static char *
35573549
xgetbsize(struct stat *s, char *cp)
35583550
{
3559-
#ifdef OSX
35603551
(void)sprintf(cp, "%lld", (s->st_size + FSBSIZE - 1) / FSBSIZE);
3561-
#else
3562-
(void)sprintf(cp, "%ld", (s->st_size + FSBSIZE - 1) / FSBSIZE);
3563-
#endif
35643552

35653553
while (*cp)
35663554
cp++;
@@ -3581,11 +3569,7 @@ getsize(s, cp)
35813569
register struct stat *s;
35823570
register char *cp;
35833571
{
3584-
#ifdef OSX
35853572
(void)sprintf(cp, "%lld", s->st_size);
3586-
#else
3587-
(void)sprintf(cp, "%ld", s->st_size);
3588-
#endif
35893573
while (*cp)
35903574
cp++;
35913575
return cp;

chaos/client.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ main()
136136
for (i = 0; i < 5; i++) {
137137
send_chaos(n++);
138138
}
139-
sleep(1);
139+
sleep(5);
140140
}
141141

142142
exit(0);

chaos/endian.h

+4
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@
2828
#ifdef __BIG_ENDIAN__
2929
#define LE_TO_SHORT(s) (SWAP_SHORT(s))
3030
#define LE_TO_LONG(l) (SWAP_LONG(l))
31+
#define SHORT_TO_LE(s) (SWAP_SHORT(s))
32+
#define LONG_TO_LE(l) (SWAP_LONG(l))
3133
#elif defined(__LITTLE_ENDIAN__)
3234
#define LE_TO_SHORT(s) (s)
3335
#define LE_TO_LONG(l) (l)
36+
#define SHORT_TO_LE(s) (s)
37+
#define LONG_TO_LE(l) (l)
3438
#else
3539
#error "No _ENDIAN__ macro defined."
3640
#endif

chaos/server.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -521,16 +521,16 @@ read_child_ctl(void)
521521

522522
chst.st_fhost = CH_ADDR_SHORT(conn->cn_faddr);
523523
chst.st_cnum = conn->cn_ltidx;
524-
chst.st_rwsize = conn->cn_rwsize;
525-
chst.st_twsize = conn->cn_twsize;
524+
chst.st_rwsize = SHORT_TO_LE(conn->cn_rwsize);
525+
chst.st_twsize = SHORT_TO_LE(conn->cn_twsize);
526526
chst.st_state = conn->cn_state;
527527
chst.st_cmode = conn->cn_mode;
528-
chst.st_oroom = conn->cn_twsize -
529-
(conn->cn_tlast - conn->cn_tacked);
528+
chst.st_oroom = SHORT_TO_LE(conn->cn_twsize -
529+
(conn->cn_tlast - conn->cn_tacked));
530530

531531
if ((pkt = conn->cn_rhead) != NOPKT) {
532532
chst.st_ptype = pkt->pk_op;
533-
chst.st_plength = PH_LEN(pkt->pk_phead);
533+
chst.st_plength = SHORT_TO_LE(PH_LEN(pkt->pk_phead));
534534
} else {
535535
chst.st_ptype = 0;
536536
chst.st_plength = 0;

0 commit comments

Comments
 (0)