summaryrefslogtreecommitdiff
path: root/src/lib/eina/eina_crc.h
diff options
context:
space:
mode:
authorvivek <vivek.ellur@samsung.com>2015-04-22 15:34:33 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-05-07 09:53:09 +0200
commita2f2d942c6e49e74990a0c56d38de343cf42d696 (patch)
tree3cb848ee047a279d4bf3ae8914a9dd522ffd3af5 /src/lib/eina/eina_crc.h
parent04038dfaefa81e39988b3dc90b84da73dfea5e1f (diff)
eina: add CRC implementation to Eina module.
Summary: Added eina_crc function in eina to calculate crc for the key passed and added eina_hash_crc function for hashing using crc Signed-off-by: vivek <vivek.ellur@samsung.com> Reviewers: Sergeant_Whitespace, cedric Reviewed By: cedric Subscribers: Sergeant_Whitespace, cedric Differential Revision: https://phab.enlightenment.org/D2260 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to '')
-rw-r--r--src/lib/eina/eina_crc.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/lib/eina/eina_crc.h b/src/lib/eina/eina_crc.h
new file mode 100644
index 0000000000..58d702415b
--- /dev/null
+++ b/src/lib/eina/eina_crc.h
@@ -0,0 +1,43 @@
1#ifndef EINA_CRC_H_
2#define EINA_CRC_H_
3
4#include <stdlib.h>
5
6#include "eina_config.h"
7
8#include "eina_types.h"
9#include "eina_error.h"
10#include "eina_iterator.h"
11#include "eina_accessor.h"
12#include "eina_magic.h"
13
14/**
15 * @brief Generate a crc checksum for the given data using crc-32 algorithm.
16 *
17 * @param key The data for which crc checksum has to be generated.
18 * @param len The length of the data.
19 * @param seed The seed used to calculate crc checksum. The value will be 0xffffffff
20 * for the initial data and for the remaining stream data, it will be crc value from the
21 * previous call to the eina_crc function.
22 * @param start_stream EINA_TRUE for the initial call and EINA_FALSE for the remaining stream data.
23 * @return 32 bit crc checksum for the given data.
24 *
25 * This function generates 32 bit crc checksum using crc-32 algorithm and 0xEDB88320 polynomial
26 * for the data which is passed to the function. Seed has to be passed which will
27 * be used in calculating checksum. For normal data 0xffffffff has to be passed as seed along with
28 * EINA_TRUE for start_stream parameter. For streaming data, initial call will be similar to normal
29 * data and for the rest of data, seed will be the crc returned from previous call to eina_crc
30 * and start_stream parameter will be EINA_FALSE
31 * API usage for normal data
32 * char *tmp = "hello world";
33 * unsigned int crc = eina_crc(tmp, strlen(tmp), 0xffffffff, EINA_TRUE);
34 *
35 * API usage for streaming data
36 * char *tmp1 = "hello "
37 * char *tmp2 = "world"
38 * unsigned int crc = eina_crc(tmp1, strlen(tmp1), 0xffffffff, EINA_TRUE);
39 * crc = eina_crc(tmp2, strlen(tmp2), crc, EINA_FALSE);
40 */
41EAPI unsigned int eina_crc(const char *key, int len, unsigned int seed, Eina_Bool start_stream) EINA_ARG_NONNULL(2, 3);
42
43#endif