looking for a complete CRC32 program

U

UnixUser

I am looking for some source code to run on Linux that will enable me
to calculate and return a CRC32 value from a string of text. I have
found one from snippets.org, but I cannot get it to compile. Please
help me find something that is simple to install, includes all header
and language files and that will compile.
 
G

grobbeltje

UnixUser said:
I am looking for some source code to run on Linux that will enable me
to calculate and return a CRC32 value from a string of text. I have
found one from snippets.org, but I cannot get it to compile. Please
help me find something that is simple to install, includes all header
and language files and that will compile.

try seraching for "Gary S. Brown" in combination with crc32.
if you have some sources with your linux distro, you probably
already have a few crc32.c's handy though.

anyway, google handed me this site:
http://mia.ece.uic.edu/cgi-bin/lxr/http/source/crc32.c?v=openssh-3.5p1
which seems to work fine for me.

good luck!
grobbeltje.
 
U

UnixUser

grobbeltje said:
try seraching for "Gary S. Brown" in combination with crc32.
if you have some sources with your linux distro, you probably
already have a few crc32.c's handy though.

anyway, google handed me this site:
http://mia.ece.uic.edu/cgi-bin/lxr/http/source/crc32.c?v=openssh-3.5p1
which seems to work fine for me.

good luck!
grobbeltje.

Thanks so much for your reply. This site is to difficult to assemble.
To try to bring the include files and the "c" source file together
will take more time than I have. I downloaded the program and the
crc32.h file, but when I went to bring in the other include file I ran
into much more crap than I can handle. I am not indending on being a
checksum expert I only need a routine as part of a larger project.
 
M

Mac

I am looking for some source code to run on Linux that will enable me
to calculate and return a CRC32 value from a string of text. I have
found one from snippets.org, but I cannot get it to compile. Please
help me find something that is simple to install, includes all header
and language files and that will compile.

Yeah, that code is full of windows-isms.

You can search and replace DWORD with unsigned long. Then supply a working
macro for UPDC32. I found one by searching on the WWW. Put the macro in
"crc.h"

Then you will have a piece of code that should compile. If, at that point,
you still have problems, post the code here and someone will help you out.
Make sure you post everything needed to try the compilation.

Note that this is not a sources wanted newsgroup, but one for questions about
ISO C.

good luck!

Mac
 
C

CBFalconer

UnixUser said:
.... snip ...

Thanks so much for your reply. This site is to difficult to assemble.
To try to bring the include files and the "c" source file together
will take more time than I have. I downloaded the program and the
crc32.h file, but when I went to bring in the other include file I ran
into much more crap than I can handle. I am not indending on being a
checksum expert I only need a routine as part of a larger project.

Then I suggest you look around here for available programmers who
can handle the problem, and hire one or more of them. You will
have to generate some interface specifications, or require a
consultant for that phase in addition.
 
G

grobbeltje

UnixUser said:
This site is to difficult to assemble.
To try to bring the include files and the "c" source file together
will take more time than I have.
i'm a beginner at c, and it took me less time to get it
to work than it took to check my spelling for this reply,
so it can't be very hard...

what exactly is going wrong?

greetings, grobbeltje.
 
T

Tom Torfs

I am looking for some source code to run on Linux that will enable me
to calculate and return a CRC32 value from a string of text.

I once wrote this, I don't know if it's quite what you're looking for though :)

#include <stdio.h>
#include <stdlib.h>

int main(int a,char **A){FILE*B;typedef unsigned long C;C b
[8]; if(!(a==7&&(B= fopen(1[A],"rb")))) return 1;for(7=0
;7<5;7++)b[7[ b]]=strtoul(A[2+7[b ]],0,16-!7*6);5[
b]=3 ; while ((6= getc(B)
)!=(C)- 1){if(2 )for (7=0
;7<4 ;7++ )if(((6 >>7[
b])^(6[ b]>>(7-7)))&1)6[ b] ^=(1
<<7) ^(1<<(7-7));5 ^= 6
<<(0 -8);for(7=0;7 <8;7
++)if(( 5>>(0- 1))&1)5
=(5[ b]<<1)^ 1; else 5[
b]<<=1; }5&=((((C)1 <<(0
-1))-1) <<1)|1; if(2 )for(7[
b]=0;7[ b]<(0[b ]>>1);7 ++)
if(((5>>7)^(5 >>(0 -1-7 )))&1)5^=((C)
1<<7)^((C)1<<(0[ b]-1-7[ b]));5[ b]^=4;fclose(B);
printf("%0*lX\n", ( int)(0[ b]+3)>> 2,5); return 0;}

For CRC-32, invoke with the following arguments:
filename 32 04C11DB7 1 FFFFFFFF FFFFFFFF

greetings,
Tom
 
U

UnixUser

Mac said:
Yeah, that code is full of windows-isms.

You can search and replace DWORD with unsigned long. Then supply a working
macro for UPDC32. I found one by searching on the WWW. Put the macro in
"crc.h"

Then you will have a piece of code that should compile. If, at that point,
you still have problems, post the code here and someone will help you out.
Make sure you post everything needed to try the compilation.

Note that this is not a sources wanted newsgroup, but one for questions about
ISO C.

good luck!

Mac

Thanks for your kind reply. Replacing the macro "UPDC32" is a little
bit over my head at this point in time.
 
M

Mac

Thanks for your kind reply. Replacing the macro "UPDC32" is a little
bit over my head at this point in time.

Oh, no, you wouldn't be replacing it. What I had in mind was cutting and
pasting a definition from the internet into your own code. One of the
reasons the snippet doesn't compile is that this macro isn't defined
anywhere in the snippet.

For example at this URL:

http://cctr.umkc.edu/ftp/anon_ftp/pub/SRC/ZMODEM/CRC.C

I found this:

#define UPDC32(octet, crc) (crc_32_tab[((crc) ^ (octet)) & 0xff] ^ ((crc) >> 8))

(sorry, it's a long line. If it breaks, reconstruct it manually)

The code seems to obviously be from the snippet code, so I imagine that
the macro definition will work.

Anyway, good luck.

Mac
--
 
R

Randy Howard

Thanks for your kind reply. Replacing the macro "UPDC32" is a little
bit over my head at this point in time.

Save yourself some time and google for "Hacker's Delight". It's a great
book, but from your own definition above, probably too deep in general
to purchase right now anyway. However, the author has a website, and
there are several different fully implemented CRC implementations
available.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top