2 * (C) Copyright 2007-2011 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * This file is released under the GPLv2. See the COPYING file for more
11 char *strdup(char *s
, int flags
)
21 d
= malloc(sizeof(char)*len
, flags
);
25 memcpy(d
, s
, len
*sizeof(char));
30 int hex(char *a
, char *b
, u64
*out
)
43 if ((c
>= '0') && (c
<= '9'))
44 val
= (val
<< 4) | (*a
- '0');
45 else if ((c
>= 'A') && (c
<= 'F'))
46 val
= (val
<< 4) | (*a
- 'A' + 10);
47 else if ((c
>= 'a') && (c
<= 'f'))
48 val
= (val
<< 4) | (*a
- 'a' + 10);
60 int bcd2dec(u64 val
, u64
*out
)
65 for(v
=0,scale
=1; val
; scale
*=10, val
>>=4) {