[654] in Zephyr_Bugs
Re: Zephyr
daemon@ATHENA.MIT.EDU (ghudson@MIT.EDU)
Thu Jul 20 19:46:54 1995
From: ghudson@MIT.EDU
Date: Thu, 20 Jul 95 19:46:41 -0400
To: Greg Hudson <ghudson@MIT.EDU>
Cc: Lew Gramer <dedalus@latrade.com>, zephyr-bugs@MIT.EDU
In-Reply-To: [651]
> zauber:/usr/zephyr/bin 101 => zwgc
> zwgc: Bad packet format while setting location
> zwgc: Bad packet format while subscribing
Okay, I've found the cause of the problem: the ZMakeAscii32() routines
I wrote doesn't work correctly on machines with 32-bit longs, for
reasons I didn't fully explore; I just went ahead and rewrote those
routines in a cleaner fashion. Here's a patch to
lib/zephyr/ZMakeAscii.c which should fix your problem:
Index: ZMakeAscii.c
===================================================================
RCS file: /mit/zephyr/src/CVS/zephyr/lib/zephyr/ZMakeAscii.c,v
retrieving revision 1.15
diff -c -r1.15 ZMakeAscii.c
*** 1.15 1995/07/18 20:28:02
--- ZMakeAscii.c 1995/07/20 23:34:38
***************
*** 19,24 ****
--- 19,26 ----
static const char rcsid_ZMakeAscii_c[] = "$Id: ZMakeAscii.c,v 1.15 1995/07/18 20:28:02 ghudson Exp $";
#endif
+ static char *itox_chars = "0123456789ABCDEF";
+
Code_t ZMakeAscii(ptr, len, field, num)
register char *ptr;
int len;
***************
*** 26,32 ****
int num;
{
int i;
- register char *itox_chars = "0123456789ABCDEF";
for (i=0;i<num;i++) {
/* we need to add "0x" if we are between 4 byte pieces */
--- 28,33 ----
***************
*** 58,66 ****
int len;
unsigned long value;
{
! /* Convert to network byte order and convert last four bytes. */
! value = htonl(value);
! return ZMakeAscii(ptr, len, ((char *)&value) + sizeof(value) - 4, 4);
}
Code_t ZMakeAscii16(ptr, len, value)
--- 59,78 ----
int len;
unsigned long value;
{
! if (len < 11)
! return ZERR_FIELDLEN;
! *ptr++ = '0';
! *ptr++ = 'x';
! *ptr++ = itox_chars[(value >> 28) & 0xf];
! *ptr++ = itox_chars[(value >> 24) & 0xf];
! *ptr++ = itox_chars[(value >> 20) & 0xf];
! *ptr++ = itox_chars[(value >> 16) & 0xf];
! *ptr++ = itox_chars[(value >> 12) & 0xf];
! *ptr++ = itox_chars[(value >> 8) & 0xf];
! *ptr++ = itox_chars[(value >> 4) & 0xf];
! *ptr++ = itox_chars[(value >> 0) & 0xf];
! *ptr = 0;
! return ZERR_NONE;
}
Code_t ZMakeAscii16(ptr, len, value)
***************
*** 68,75 ****
int len;
unsigned int value;
{
! /* Convert to network byte order and convert last two bytes. */
! value = htons((unsigned short) value);
! return ZMakeAscii(ptr, len, ((char *)&value) + sizeof(value) - 2, 2);
}
--- 80,94 ----
int len;
unsigned int value;
{
! if (len < 7)
! return ZERR_FIELDLEN;
! *ptr++ = '0';
! *ptr++ = 'x';
! *ptr++ = itox_chars[(value >> 12) & 0xf];
! *ptr++ = itox_chars[(value >> 8) & 0xf];
! *ptr++ = itox_chars[(value >> 4) & 0xf];
! *ptr++ = itox_chars[(value >> 0) & 0xf];
! *ptr = 0;
! return ZERR_NONE;
}