blob: ea84650567e61fedd3e01f71c646242e5dfb0308 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/* This file is part of the Project Athena Zephyr Notification System.
* It contains source for the ZReadAscii function.
*
* Created by: Robert French
*
* $Source$
* $Author$
*
* Copyright (c) 1987 by the Massachusetts Institute of Technology.
* For copying and distribution information, see the file
* "mit-copyright.h".
*/
/* $Header$ */
#include <zephyr/mit-copyright.h>
#include <zephyr/zephyr_internal.h>
int ZReadAscii(ptr,len,field,num)
char *ptr;
int len;
char *field;
int num;
{
int i;
char bfr[3];
for (i=0;i<num;i++) {
if (*ptr == ' ') {
ptr++;
if (--len < 1)
return (ZERR_BADFIELD);
}
if (ptr[0] == '0' && ptr[1] == 'x') {
ptr += 2;
len -= 2;
if (len < 1)
return (ZERR_BADFIELD);
}
bfr[0] = ptr[0];
bfr[1] = ptr[1];
bfr[2] = '\0';
if (!bfr[0] || !bfr[1])
return (ZERR_BADFIELD);
(void) sscanf(bfr,"%x",field+i);
ptr += 2;
len -= 2;
if (len < 1)
return (ZERR_BADFIELD);
}
if (*ptr)
return (ZERR_BADFIELD);
return (ZERR_NONE);
}
|