]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/crc.h
Daemon: daemon_control() finished
[libucw.git] / ucw / crc.h
index 28d59acf6eba1997f511194ebb33b8af5a8b5c23..73363ddb77ca17ea91552a85b177a18ecdf04917 100644 (file)
--- a/ucw/crc.h
+++ b/ucw/crc.h
@@ -16,6 +16,9 @@
  *     Adapted for LibUCW by Martin Mares <mj@ucw.cz> in 2012.
  */
 
  *     Adapted for LibUCW by Martin Mares <mj@ucw.cz> in 2012.
  */
 
+#ifndef _UCW_CRC_H
+#define _UCW_CRC_H
+
 /**
  * Internal CRC calculator context.
  * You should use it just as an opaque handle only.
 /**
  * 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;
 }
 {
   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