X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=ucw%2Fcrc.h;h=73363ddb77ca17ea91552a85b177a18ecdf04917;hb=244c4fe7e6cf5ae78cbe6343fe7f9b6dfc29b11a;hp=28d59acf6eba1997f511194ebb33b8af5a8b5c23;hpb=078dd50e9e9d322db3f5ac8d0c434ebeeac10a79;p=libucw.git diff --git a/ucw/crc.h b/ucw/crc.h index 28d59acf..73363ddb 100644 --- a/ucw/crc.h +++ b/ucw/crc.h @@ -16,6 +16,9 @@ * Adapted for LibUCW by Martin Mares in 2012. */ +#ifndef _UCW_CRC_H +#define _UCW_CRC_H + /** * Internal CRC calculator context. * You should use it just as an opaque handle only. @@ -54,3 +57,16 @@ static inline u32 crc32_final(crc32_context *ctx) { return ctx->state ^ 0xffffffff; } + +/** + * A convenience one-shot function for CRC. + * It is equivalent to this snippet of code: + * + * crc32_context ctx; + * crc32_init(&ctx, CRC_MODE_DEFAULT); + * crc32_update(&ctx, buf, len); + * return crc32_final(&ctx); + */ +u32 crc32_hash_buffer(const byte *buf, uns len); + +#endif