Blob
1 #include "stdinc.h"2 #include "dat.h"3 #include "fns.h"5 u8int zeroscore[VtScoreSize];7 /* Call this function to force linking of score.o for zeroscore on OS X */8 void needzeroscore(void) { }10 void11 scoremem(u8int *score, u8int *buf, int n)12 {13 DigestState s;15 memset(&s, 0, sizeof s);16 sha1(buf, n, score, &s);17 }19 static int20 hexv(int c)21 {22 if(c >= '0' && c <= '9')23 return c - '0';24 if(c >= 'a' && c <= 'f')25 return c - 'a' + 10;26 if(c >= 'A' && c <= 'F')27 return c - 'A' + 10;28 return -1;29 }31 int32 strscore(char *s, u8int *score)33 {34 int i, c, d;36 for(i = 0; i < VtScoreSize; i++){37 c = hexv(s[2 * i]);38 if(c < 0)39 return -1;40 d = hexv(s[2 * i + 1]);41 if(d < 0)42 return -1;43 score[i] = (c << 4) + d;44 }45 return s[2 * i] == '\0';46 }