summaryrefslogtreecommitdiff
path: root/lib/ZMakeAscii.c
diff options
context:
space:
mode:
authorGravatar Greg Hudson <ghudson@mit.edu>1997-09-14 17:50:06 +0000
committerGravatar Greg Hudson <ghudson@mit.edu>1997-09-14 17:50:06 +0000
commitac16f380e349fa39ec7e26bccb5456cb300006a5 (patch)
treec07ca88af97b4f6b77d28a2dc723d2e4621ed302 /lib/ZMakeAscii.c
parentd33e482744fad80d95cdd89ed380c5b8401e49bf (diff)
Pull in sources from zephyr locker. See /mit/zephyr/repository for
detailed change information.
Diffstat (limited to 'lib/ZMakeAscii.c')
-rw-r--r--lib/ZMakeAscii.c47
1 files changed, 44 insertions, 3 deletions
diff --git a/lib/ZMakeAscii.c b/lib/ZMakeAscii.c
index da88fdd..413c515 100644
--- a/lib/ZMakeAscii.c
+++ b/lib/ZMakeAscii.c
@@ -12,11 +12,14 @@
*/
/* $Header$ */
+#include <internal.h>
+#include <assert.h>
+
#ifndef lint
-static char rcsid_ZMakeAscii_c[] = "$Id$";
+static const char rcsid_ZMakeAscii_c[] = "$Id$";
#endif
-#include <zephyr/zephyr_internal.h>
+static char *itox_chars = "0123456789ABCDEF";
Code_t ZMakeAscii(ptr, len, field, num)
register char *ptr;
@@ -25,7 +28,6 @@ Code_t ZMakeAscii(ptr, len, field, num)
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 */
@@ -51,3 +53,42 @@ Code_t ZMakeAscii(ptr, len, field, num)
*ptr = '\0';
return ZERR_NONE;
}
+
+Code_t ZMakeAscii32(ptr, len, value)
+ register char *ptr;
+ 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)
+ register char *ptr;
+ 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;
+}
+