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
7 * $Author: warmenhoven $
9 * Copyright (c) 1987, 1990 by the Massachusetts Institute of Technology.
10 * For copying and distribution information, see the file
16 static char rcsid_ZReadAscii_c
[] = "$Header$";
37 #define Z_cnvt_xtoi(c) ((temp=(c)-'0'),(temp<10)?temp:((temp-='A'-'9'-1),(temp<16)?temp:-1))
39 Code_t
ZReadAscii(ptr
, len
, field
, num
)
48 register unsigned int temp
;
56 if (ptr
[0] == '0' && ptr
[1] == 'x') {
62 c1
= Z_cnvt_xtoi(ptr
[0]);
65 c2
= Z_cnvt_xtoi(ptr
[1]);
68 hexbyte
= (c1
<< 4) | c2
;
76 return *ptr
? ZERR_BADFIELD
: ZERR_NONE
;
79 Code_t
ZReadAscii32(ptr
, len
, value_ptr
)
82 unsigned long *value_ptr
;
87 retval
= ZReadAscii(ptr
, len
, buf
, 4);
88 if (retval
!= ZERR_NONE
)
90 *value_ptr
= (buf
[0] << 24) | (buf
[1] << 16) | (buf
[2] << 8) | buf
[3];
94 Code_t
ZReadAscii16(ptr
, len
, value_ptr
)
97 unsigned short *value_ptr
;
102 retval
= ZReadAscii(ptr
, len
, buf
, 2);
103 if (retval
!= ZERR_NONE
)
105 *value_ptr
= (buf
[0] << 8) | buf
[1];