diff options
Diffstat (limited to 'fuzzy.h')
-rw-r--r-- | fuzzy.h | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -30,6 +30,46 @@ extern "C" { #ifndef FUZZY_H #define FUZZY_H +struct fuzzy_state; + +/** + * @brief Construct a fuzzy_state object and return it. + * + * To use it call fuzzy_update and fuzzy_digest on it. It must be disposed + * with fuzzy_free. + * @return the constructed fuzzy_state or NULL on failure + */ +extern /*@only@*/ /*@null@*/ struct fuzzy_state *fuzzy_new(void); + +/** + * @brief Feed the data contained in the given buffer to the state. + * + * When an error occurs, the state is undefined. In that case it must not be + * passed to any function besides fuzzy_free. + * @param buffer The data to be hashes + * @param buffer_size The length of the given buffer + * @return zero on success, non-zero on error + */ +extern int fuzzy_update(struct fuzzy_state *state, const unsigned char *buffer, + size_t buffer_size); + +/** + * @brief Obtain the fuzzy hash from the state. + * + * This operation does not change the state at all. It reports the hash for the + * concatenation of the data previously fed using fuzzy_update. + * @param result Where the fuzzy hash is stored. This variable + * must be allocated to hold at least FUZZY_MAX_RESULT bytes. + * @return zero on success, non-zero on error + */ +extern int fuzzy_digest(const struct fuzzy_state *state, + /*@out@*/ char *result); + +/** + * @brief Dispose a fuzzy state. + */ +extern void fuzzy_free(/*@only@*/ struct fuzzy_state *state); + /** * @brief Compute the fuzzy hash of a buffer * |