chiark
/
gitweb
/
~mdw
/
disorder
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lib/configuration.c, lib/home.c: Introduce environment variables.
[disorder]
/
lib
/
hex.c
diff --git
a/lib/hex.c
b/lib/hex.c
index 4ae9d6756f8a2df027628081e6b7fd3e91620bb9..efe842598137376af02e6f5355c354226c729cdd 100644
(file)
--- a/
lib/hex.c
+++ b/
lib/hex.c
@@
-1,6
+1,6
@@
/*
* This file is part of DisOrder
/*
* This file is part of DisOrder
- * Copyright (C) 2004, 2005, 2007
, 2008
Richard Kettlewell
+ * Copyright (C) 2004, 2005, 2007
-9, 2013
Richard Kettlewell
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@
-22,6
+22,7
@@
#include "hex.h"
#include "mem.h"
#include "log.h"
#include "hex.h"
#include "mem.h"
#include "log.h"
+#include "printf.h"
/** @brief Convert a byte sequence to hex
* @param ptr Pointer to first byte
/** @brief Convert a byte sequence to hex
* @param ptr Pointer to first byte
@@
-32,7
+33,7
@@
char *hex(const uint8_t *ptr, size_t n) {
char *buf = xmalloc_noptr(n * 2 + 1), *p = buf;
while(n-- > 0)
char *buf = xmalloc_noptr(n * 2 + 1), *p = buf;
while(n-- > 0)
- p +=
sprintf(p
, "%02x", (unsigned)*ptr++);
+ p +=
byte_snprintf(p, 3
, "%02x", (unsigned)*ptr++);
*p = 0;
return buf;
}
*p = 0;
return buf;
}
@@
-75,7
+76,8
@@
int unhexdigitq(int c) {
int unhexdigit(int c) {
int d;
int unhexdigit(int c) {
int d;
- if((d = unhexdigitq(c)) < 0) error(0, "invalid hex digit");
+ if((d = unhexdigitq(c)) < 0)
+ disorder_error(0, "invalid hex digit");
return d;
}
return d;
}
@@
-96,7
+98,7
@@
uint8_t *unhex(const char *s, size_t *np) {
int d1, d2;
if((l = strlen(s)) & 1) {
int d1, d2;
if((l = strlen(s)) & 1) {
- error(0, "hex string has odd length");
+
disorder_
error(0, "hex string has odd length");
return 0;
}
p = buf = xmalloc_noptr(l / 2);
return 0;
}
p = buf = xmalloc_noptr(l / 2);