diff options
author | rsc <devnull@localhost> | 2004-03-25 23:08:53 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2004-03-25 23:08:53 +0000 |
commit | 70bcc7804e3cac85bd92306668bae053df86a29e (patch) | |
tree | 9701a4fb940e7a1187337b3d89bcf38ac985897c /src/libventi | |
parent | a27e20579cb03a28bd1e1b88e49f80db76e51d68 (diff) | |
download | plan9port-70bcc7804e3cac85bd92306668bae053df86a29e.tar.gz plan9port-70bcc7804e3cac85bd92306668bae053df86a29e.tar.bz2 plan9port-70bcc7804e3cac85bd92306668bae053df86a29e.zip |
More files.
More files.
Diffstat (limited to 'src/libventi')
-rw-r--r-- | src/libventi/parsescore.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/libventi/parsescore.c b/src/libventi/parsescore.c new file mode 100644 index 00000000..2c38808b --- /dev/null +++ b/src/libventi/parsescore.c @@ -0,0 +1,40 @@ +#include <u.h> +#include <libc.h> +#include <venti.h> + +int +vtparsescore(char *s, char **prefix, uchar score[VtScoreSize]) +{ + int i, c; + char *buf, *colon; + + if((colon = strchr(s, ':')) != nil) + buf = colon+1; + else + buf = s; + + if(strlen(buf) != 2*VtScoreSize) + return -1; + + memset(score, 0, VtScoreSize); + for(i=0; i<2*VtScoreSize; i++){ + if(buf[i] >= '0' && buf[i] <= '9') + c = buf[i] - '0'; + else if(buf[i] >= 'a' && buf[i] <= 'z') + c = buf[i] - 'a' + 10; + else if(buf[i] >= 'A' && buf[i] <= 'Z') + c = buf[i] - 'A' + 10; + else + return -1; + + if((i & 1) == 0) + c <<= 4; + score[i>>1] |= c; + } + if(colon){ + *colon = 0; + *prefix = s; + }else + *prefix = nil; + return 0; +} |