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
f4ae099c
Commit
f4ae099c
authored
19 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
New function (fcrc32) to calculate CRC32 of byte range from file stream.
parent
0c80d4c1
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
+13
-0
13 additions, 0 deletions
src/hash/crc32.c
src/hash/crc32.h
+3
-0
3 additions, 0 deletions
src/hash/crc32.h
with
16 additions
and
0 deletions
src/hash/crc32.c
+
13
−
0
View file @
f4ae099c
...
...
@@ -89,5 +89,18 @@ unsigned long crc32(char *buf, unsigned long len)
return
(
~
crc
);
}
unsigned
long
fcrc32
(
FILE
*
fp
,
unsigned
long
len
)
{
int
ch
;
unsigned
long
l
,
crc
=
0xffffffff
;
rewind
(
fp
);
for
(
l
=
0
;(
len
==
0
||
l
<
len
)
&&
!
feof
(
fp
);
l
++
)
{
if
((
ch
=
fgetc
(
fp
))
==
EOF
)
break
;
crc
=
ucrc32
(
ch
,
crc
);
}
return
(
~
crc
);
}
This diff is collapsed.
Click to expand it.
src/hash/crc32.h
+
3
−
0
View file @
f4ae099c
...
...
@@ -38,6 +38,8 @@
#ifndef _CRC32_H_
#define _CRC32_H_
#include
<stdio.h>
/* FILE */
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
@@ -45,6 +47,7 @@ extern "C" {
extern
long
crc32tbl
[];
unsigned
long
crc32
(
char
*
buf
,
unsigned
long
len
);
unsigned
long
fcrc32
(
FILE
*
fp
,
unsigned
long
len
);
#ifdef __cplusplus
}
...
...
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