Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
a6a3a742
Commit
a6a3a742
authored
22 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Moved crc32 function here from misc.c.
parent
6ee7eb44
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/hash/crc32.c
+19
-0
19 additions, 0 deletions
src/hash/crc32.c
src/hash/crc32.h
+5
-0
5 additions, 0 deletions
src/hash/crc32.h
with
24 additions
and
0 deletions
src/hash/crc32.c
+
19
−
0
View file @
a6a3a742
...
...
@@ -35,6 +35,9 @@
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
#include
<string.h>
/* strlen */
#include
"crc32.h"
long
crc32tbl
[]
=
{
/* CRC polynomial 0xedb88320 */
0x00000000
,
0x77073096
,
0xee0e612c
,
0x990951ba
,
0x076dc419
,
0x706af48f
,
0xe963a535
,
0x9e6495a3
,
0x0edb8832
,
0x79dcb8a4
,
0xe0d5e91e
,
0x97d2d988
,
0x09b64c2b
,
0x7eb17cbd
,
0xe7b82d07
,
0x90bf1d91
,
...
...
@@ -70,5 +73,21 @@ long crc32tbl[]={ /* CRC polynomial 0xedb88320 */
0xb3667a2e
,
0xc4614ab8
,
0x5d681b02
,
0x2a6f2b94
,
0xb40bbe37
,
0xc30c8ea1
,
0x5a05df1b
,
0x2d02ef8d
};
/****************************************************************************/
/* Returns CRC-32 of sequence of bytes (binary or ASCIIZ) */
/* Pass len of 0 to auto-determine ASCIIZ string length */
/* or non-zero for arbitrary binary data */
/****************************************************************************/
unsigned
long
crc32
(
char
*
buf
,
unsigned
long
len
)
{
unsigned
long
l
,
crc
=
0xffffffff
;
if
(
len
==
0
)
len
=
strlen
(
buf
);
for
(
l
=
0
;
l
<
len
;
l
++
)
crc
=
ucrc32
(
buf
[
l
],
crc
);
return
(
~
crc
);
}
This diff is collapsed.
Click to expand it.
src/hash/crc32.h
+
5
−
0
View file @
a6a3a742
...
...
@@ -35,8 +35,13 @@
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
#ifndef _CRC32_H_
#define _CRC32_H_
extern
long
crc32tbl
[];
#define ucrc32(ch,crc) (crc32tbl[(crc^ch)&0xff]^(crc>>8))
unsigned
long
crc32
(
char
*
buf
,
unsigned
long
len
);
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment