1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains source for the ZReadAscii function.
4 * Created by: Robert French
6 * $Id: ZReadAscii.c,v 1.18 1999/01/22 23:19:21 ghudson Exp $
8 * Copyright (c) 1987, 1990 by the Massachusetts Institute of Technology.
9 * For copying and distribution information, see the file
14 static char rcsid_ZReadAscii_c[] = "$Id: ZReadAscii.c,v 1.18 1999/01/22 23:19:21 ghudson Exp $";
35 #define Z_cnvt_xtoi(c) ((temp=(c)-'0'),(temp<10)?temp:((temp-='A'-'9'-1),(temp<16)?temp:-1))
37 Code_t ZReadAscii(ptr, len, field, num)
46 register unsigned int temp;
54 if (ptr[0] == '0' && ptr[1] == 'x') {
60 c1 = Z_cnvt_xtoi(ptr[0]);
63 c2 = Z_cnvt_xtoi(ptr[1]);
66 hexbyte = (c1 << 4) | c2;
74 return *ptr ? ZERR_BADFIELD : ZERR_NONE;
77 Code_t ZReadAscii32(ptr, len, value_ptr)
80 unsigned long *value_ptr;
85 retval = ZReadAscii(ptr, len, buf, 4);
86 if (retval != ZERR_NONE)
88 *value_ptr = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
92 Code_t ZReadAscii16(ptr, len, value_ptr)
95 unsigned short *value_ptr;
100 retval = ZReadAscii(ptr, len, buf, 2);
101 if (retval != ZERR_NONE)
103 *value_ptr = (buf[0] << 8) | buf[1];