diff options
author | Helmut Grohne <helmut@subdivi.de> | 2013-03-24 18:05:24 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2013-03-24 18:05:24 +0100 |
commit | 5ba224a5aa2c8adb662136e2b8838d1cb0d32f27 (patch) | |
tree | ce9d5fa5aeb138cc24736d193005aa26a40fc0aa /fuzzy.h | |
parent | 614d6dd08948f25e86911e08efae53bf530d82d5 (diff) | |
download | ssdeep-5ba224a5aa2c8adb662136e2b8838d1cb0d32f27.tar.gz |
rename functions and export them
Use fuzzy_ as a prefix like all of the previous ones. Export fuzzy_new,
fuzzy_update, fuzzy_digest and fuzzy_free. These functions are
sufficient to put the caller in control and build an API similar to
Python's hashlib.
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 * |