"Fossies" - the Fresh Open Source Software Archive 
Member "xorriso-1.5.4/libjte/rsync.c" (30 Jan 2021, 4536 Bytes) of package /linux/misc/xorriso-1.5.4.pl02.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "rsync.c" see the
Fossies "Dox" file reference documentation and the last
Fossies "Diffs" side-by-side code changes report:
1.5.2_vs_1.5.4.
1 /*
2 * This file has been modified for the libjte suite.
3 *
4 * The behaviour and appearance of the program code below can differ to a major
5 * extent from the version distributed by the original author(s).
6 *
7 * For details, see Changelog file distributed with the libjte package. If you
8 * received this file from another source then ask the distributing person for
9 * a log of modifications.
10 *
11 */
12
13 #ifdef HAVE_CONFIG_H
14 #include "../config.h"
15 #endif
16
17 #include <ctype.h>
18
19 #ifdef HAVE_STDINT_H
20 #include <stdint.h>
21 #else
22 #ifdef HAVE_INTTYPES_H
23 #include <inttypes.h>
24 #endif
25 #endif
26
27 #include <string.h>
28
29 #include "rsync.h"
30
31 /* Borrowed from jigdo; original notice:
32
33 These are purely random, no patterns or anything... (I hope)
34
35 I do not claim copyright for the actual numbers below, you may use them
36 for a re-implementation of the algorithm under a license of your choice.
37 -- Richard Atterer. */
38 static uint32_t charTable[256] = {
39 0x51d65c0f, 0x083cd94b, 0x77f73dd8, 0xa0187d36,
40 0x29803d07, 0x7ea8ac0e, 0xea4c16c9, 0xfc576443,
41 0x6213df29, 0x1c012392, 0xb38946ae, 0x2e20ca31,
42 0xe4dc532f, 0xcb281c47, 0x8508b6a5, 0xb93c210d,
43 0xef02b5f3, 0x66548c74, 0x9ae2deab, 0x3b59f472,
44 0x4e546447, 0x45232d1f, 0x0ac0a4b1, 0x6c4c264b,
45 0x5d24ce84, 0x0f2752cc, 0xa35c7ac7, 0x3e31af51,
46 0x79675a59, 0x581f0e81, 0x49053122, 0x7339c9d8,
47 0xf9833565, 0xa3dbe5b3, 0xcc06eeb9, 0x92d0671c,
48 0x3eb220a7, 0x64864eae, 0xca100872, 0xc50977a1,
49 0xd90378e1, 0x7a36cab9, 0x15c15f4b, 0x8b9ef749,
50 0xcc1432dc, 0x1ec578ed, 0x27e6e092, 0xbb06db8f,
51 0x67f661ac, 0x8dd1a3db, 0x2a0ca16b, 0xb229ab84,
52 0x127a3337, 0x347d846f, 0xe1ea4b50, 0x008dbb91,
53 0x414c1426, 0xd2be76f0, 0x08789a39, 0xb4d93e30,
54 0x61667760, 0x8871bee9, 0xab7da12d, 0xe3c58620,
55 0xe9fdfbbe, 0x64fb04f7, 0x8cc5bbf0, 0xf5272d30,
56 0x8f161b50, 0x11122b05, 0x7695e72e, 0xa1c5d169,
57 0x1bfd0e20, 0xef7e6169, 0xf652d08e, 0xa9d0f139,
58 0x2f70aa04, 0xae2c7d6d, 0xa3cb9241, 0x3ae7d364,
59 0x348788f8, 0xf483b8f1, 0x55a011da, 0x189719dc,
60 0xb0c5d723, 0x8b344e33, 0x300d46eb, 0xd44fe34f,
61 0x1a2016c1, 0x66ce4cd7, 0xa45ea5e3, 0x55cb708a,
62 0xbce430df, 0xb01ae6e0, 0x3551163b, 0x2c5b157a,
63 0x574c4209, 0x430fd0e4, 0x3387e4a5, 0xee1d7451,
64 0xa9635623, 0x873ab89b, 0xb96bc6aa, 0x59898937,
65 0xe646c6e7, 0xb79f8792, 0x3f3235d8, 0xef1b5acf,
66 0xd975b22b, 0x427acce6, 0xe47a2411, 0x75f8c1e8,
67 0xa63f799d, 0x53886ad8, 0x9b2d6d32, 0xea822016,
68 0xcdee2254, 0xd98bcd98, 0x2933a544, 0x961f379f,
69 0x49219792, 0xc61c360f, 0x77cc0c64, 0x7b872046,
70 0xb91c7c12, 0x7577154b, 0x196573be, 0xf788813f,
71 0x41e2e56a, 0xec3cd244, 0x8c7401f1, 0xc2e805fe,
72 0xe8872fbe, 0x9e2faf7d, 0x6766456b, 0x888e2197,
73 0x28535c6d, 0x2ce45f3f, 0x24261d2a, 0xd6faab8b,
74 0x7a7b42b8, 0x15f0f6fa, 0xfe1711df, 0x7e5685a6,
75 0x00930268, 0x74755331, 0x1998912c, 0x7b60498b,
76 0x501a5786, 0x92ace0f6, 0x1d9752fe, 0x5a731add,
77 0x5b3b44fc, 0x473673f9, 0xa42c0321, 0xd82f9f18,
78 0xb4b225da, 0xfc89ece2, 0x072e1130, 0x5772aae3,
79 0x29010857, 0x542c970c, 0x94f67fe5, 0x71209e9b,
80 0xdb97ea39, 0x2689b41b, 0xae815804, 0xfc5e2651,
81 0xd4521674, 0x48ed979a, 0x2f617da3, 0xc350353d,
82 0xc3accd94, 0xbd8d313a, 0xc61a8e77, 0xf34940a4,
83 0x8d2c6b0f, 0x0f0e7225, 0x39e183db, 0xd19ebba9,
84 0x6a0f37b9, 0xd18922f3, 0x106420c5, 0xaa5a640b,
85 0x7cf0d273, 0xcf3238a7, 0x3b33204f, 0x476be7bb,
86 0x09d23bca, 0xbe84b2f7, 0xb7a3bace, 0x2528cee1,
87 0x3dcaa1dd, 0x900ad31a, 0xf21dea6d, 0x9ce51463,
88 0xf1540bba, 0x0fab1bdd, 0x89cfb79a, 0x01a2a6e6,
89 0x6f85d67c, 0xd1669ec4, 0x355db722, 0x00ebd5c4,
90 0x926eb385, 0x69ead869, 0x0da2b122, 0x402779fe,
91 0xdaed92d0, 0x57e9aabb, 0x3df64854, 0xfcc774b5,
92 0x2e1740ed, 0xa615e024, 0xf7bac938, 0x377dfd1a,
93 0xd0559d66, 0x25499be8, 0x2d8f2006, 0xfaa9e486,
94 0x95e980e7, 0x82aeba67, 0x5a7f2561, 0xbc60dff6,
95 0x6c8739a2, 0x7ec59a8b, 0x9998f265, 0xdfe37e5e,
96 0xb47cee1e, 0x4dd8bc9e, 0x35c57e09, 0x07850b63,
97 0x06eadbcb, 0x6c1f2956, 0x01685c2c, 0xf5725eef,
98 0xf13b98b5, 0xaab739c2, 0x200b1da2, 0xa716b98b,
99 0xd9ee3058, 0x76acf20b, 0x2f259e04, 0xed11658b,
100 0x1532b331, 0x0ab43204, 0xf0beb023, 0xb1685483,
101 0x58cbdc4f, 0x079384d3, 0x049b141c, 0xc38184b9,
102 0xaf551d9a, 0x66222560, 0x059deeca, 0x535f99e2
103 };
104
105 uint64_t rsync64(unsigned char *mem, size_t size)
106 {
107 uint32_t a = 0;
108 uint32_t b = 0;
109 unsigned char *limit = mem + size;
110 uint64_t result = 0;
111
112 while (mem < limit)
113 {
114 a += charTable[*mem++];
115 b += a;
116 }
117
118 a = a & 0xffffffff; /* Just in case uint32 can be 64 bits */
119 b = b & 0xffffffff;
120
121 result = ((uint64_t)b << 32) | a;
122
123 return result;
124 }
125