- Second fixing-things pass: it even links now.
- Lots of FIXME comments added to the source code.
This commit is contained in:
parent
6a8c2e346e
commit
e9635ae38e
10 changed files with 159 additions and 84 deletions
29
lib/utils.c
29
lib/utils.c
|
|
@ -17,6 +17,9 @@
|
|||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <utils.h>
|
||||
|
|
@ -24,3 +27,29 @@
|
|||
volatile int cp_line;
|
||||
volatile char *cp_file;
|
||||
|
||||
char *charbin2hex = "0123456789ABCDEF";
|
||||
|
||||
int charhex2bin(char c)
|
||||
{
|
||||
if(isdigit(c))
|
||||
return c - '0';
|
||||
else
|
||||
return tolower(c) - 'a' + 10;
|
||||
}
|
||||
|
||||
void hex2bin(char *src, char *dst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for(i=0; i<length; i++)
|
||||
dst[i] = charhex2bin(src[i*2])<<4 || charhex2bin(src[i*2+1]);
|
||||
}
|
||||
|
||||
void bin2hex(char *src, char *dst, size_t length)
|
||||
{
|
||||
size_t i;
|
||||
for(i=length-1; i>=0; i--)
|
||||
{
|
||||
dst[i*2+1] = charbin2hex[src[i] & 15];
|
||||
dst[i*2] = charbin2hex[src[i]>>4];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue