Skip to content

Commit

Permalink
Revert "Functions for encoding reversed hex"
Browse files Browse the repository at this point in the history
This reverts commit ef56789.
  • Loading branch information
rustyrussell committed Dec 21, 2017
1 parent 553ebc9 commit ed2158c
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 48 deletions.
18 changes: 0 additions & 18 deletions ccan/ccan/str/hex/hex.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,3 @@ bool hex_encode(const void *buf, size_t bufsize, char *dest, size_t destsize)

return true;
}

bool hex_encode_reversed(const void *buf, size_t bufsize, char *dest, size_t destsize)
{
size_t i;

if (destsize < hex_str_size(bufsize))
return false;

// Start at end of data, go to index 0.
for (i = bufsize; i--;) {
unsigned int c = ((const unsigned char *)buf)[i];
*(dest++) = hexchar(c >> 4);
*(dest++) = hexchar(c & 0xF);
}
*dest = '\0';

return true;
}
18 changes: 0 additions & 18 deletions ccan/ccan/str/hex/hex.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,6 @@ bool hex_decode(const char *str, size_t slen, void *buf, size_t bufsize);
*/
bool hex_encode(const void *buf, size_t bufsize, char *dest, size_t destsize);

/**
* hex_encode_reversed - Create a nul-terminated reversed hex string
* @buf: the buffer to read the data from
* @bufsize: the length of @buf
* @dest: the string to fill
* @destsize: the max size of the string
*
* Returns true if the string, including terminator, fit in @destsize;
*
* Example:
* unsigned char buf[] = { 0x1F, 0x2F };
* char str[5];
*
* if (!hex_encode(buf, sizeof(buf), str, sizeof(str)))
* abort();
*/
bool hex_encode_reversed(const void *buf, size_t bufsize, char *dest, size_t destsize);

/**
* hex_str_size - Calculate how big a nul-terminated hex string is
* @bytes: bytes of data to represent
Expand Down
9 changes: 0 additions & 9 deletions common/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,15 +471,6 @@ void json_add_hex(struct json_result *result, const char *fieldname,
json_add_string(result, fieldname, hex);
}

void json_add_hex_reversed(struct json_result *result, const char *fieldname,
const void *data, size_t len)
{
char hex[hex_str_size(len)];

hex_encode_reversed(data, len, hex, sizeof(hex));
json_add_string(result, fieldname, hex);
}

void json_add_object(struct json_result *result, ...)
{
va_list ap;
Expand Down
3 changes: 0 additions & 3 deletions common/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ void json_add_null(struct json_result *result, const char *fieldname);
/* '"fieldname" : "0189abcdef..."' or "0189abcdef..." if fieldname is NULL */
void json_add_hex(struct json_result *result, const char *fieldname,
const void *data, size_t len);
/* '"fieldname" : "0189abcdef..."' or "0189abcdef..." if fieldname is NULL */
void json_add_hex_reversed(struct json_result *result, const char *fieldname,
const void *data, size_t len);
void json_add_object(struct json_result *result, ...);

const char *json_result_string(const struct json_result *result);
Expand Down

0 comments on commit ed2158c

Please sign in to comment.