added a chunk_printable() function (replaces sanitize_chunk)

This commit is contained in:
Martin Willi
2009-07-06 13:15:29 +02:00
parent d692557298
commit f48c3c72f4
2 changed files with 40 additions and 0 deletions
+13
View File
@@ -231,6 +231,19 @@ static inline bool chunk_equals(chunk_t a, chunk_t b)
a.len == b.len && memeq(a.ptr, b.ptr, a.len);
}
/**
* Check if a chunk has printable characters only.
*
* If sane is given, chunk is cloned into sane and all non printable characters
* get replaced by "replace".
*
* @param chunk chunk to check for printability
* @param sane pointer where sane version is allocated, or NULL
* @param replace character to use for replaceing unprintable characters
* @return TRUE if all characters in chunk are printable
*/
bool chunk_printable(chunk_t chunk, chunk_t *sane, char replace);
/**
* Computes a 32 bit hash of the given chunk.
* Note: This hash is only intended for hash tables not for cryptographic purposes.