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
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$";
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;
49 if (len >= 1 && *ptr == ' ') {
53 if (len >= 2 && ptr[0] == '0' && ptr[1] == 'x') {
59 c1 = Z_cnvt_xtoi(ptr[0]);
62 c2 = Z_cnvt_xtoi(ptr[1]);
65 hexbyte = (c1 << 4) | c2;
71 return *ptr ? ZERR_BADFIELD : ZERR_NONE;
74 Code_t ZReadAscii32(ptr, len, value_ptr)
77 unsigned long *value_ptr;
82 retval = ZReadAscii(ptr, len, buf, 4);
83 if (retval != ZERR_NONE)
85 *value_ptr = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
89 Code_t ZReadAscii16(ptr, len, value_ptr)
92 unsigned short *value_ptr;
97 retval = ZReadAscii(ptr, len, buf, 2);
98 if (retval != ZERR_NONE)
100 *value_ptr = (buf[0] << 8) | buf[1];