Blob


1 #include "stdinc.h"
2 #include "dat.h"
3 #include "fns.h"
5 u8int zeroscore[VtScoreSize];
7 void
8 scoremem(u8int *score, u8int *buf, int n)
9 {
10 DigestState s;
12 memset(&s, 0, sizeof s);
13 sha1(buf, n, score, &s);
14 }
16 static int
17 hexv(int c)
18 {
19 if(c >= '0' && c <= '9')
20 return c - '0';
21 if(c >= 'a' && c <= 'f')
22 return c - 'a' + 10;
23 if(c >= 'A' && c <= 'F')
24 return c - 'A' + 10;
25 return -1;
26 }
28 int
29 strscore(char *s, u8int *score)
30 {
31 int i, c, d;
33 for(i = 0; i < VtScoreSize; i++){
34 c = hexv(s[2 * i]);
35 if(c < 0)
36 return -1;
37 d = hexv(s[2 * i + 1]);
38 if(d < 0)
39 return -1;
40 score[i] = (c << 4) + d;
41 }
42 return s[2 * i] == '\0';
43 }