• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: looking for a crc code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: looking for a crc code


  • Subject: Re: looking for a crc code
  • From: Tommy Nordgren <email@hidden>
  • Date: Sat, 14 Jun 2008 22:29:34 +0200


On 14 jun 2008, at 19.49, Michael Hall wrote:


...snip

#import <Cocoa/Cocoa.h>
# include <sys/types.h>
#include <zlib.h>

int main(int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    unsigned long crc = crc32(0L, Z_NULL, 0);
    char * test = "TEST";

    crc = crc32(crc,test,4);
	 fprintf(stdout,"crc=%i\n",crc);
}

compiled with...
gcc -framework Cocoa -lz -o testcrc testcrc.m
(Note the -lz for zlib also find some copy of zlib.h for more info on the crc32() method or a adler or other zlib supported alternative)


Unfortunately, testing got sort of inconsistent results.
./testcrc
crc=-286616648

doesn't seem to work out quite the same as...
crc32 test.txt
f783d7be
(man crc32, it appears to be the tcl version mentioned in the blog above.).


The crc's as far as I know should be the same here, so not quite sure what the deal is there, but zlib crc's I think should always be available.

Mike Hall        hallmike at att dot net
http://www.geocities.com/mik3hall
http://sourceforge.net/projects/macnative


The problem is 1: You have inserted a newline or a return character in the file you use for testing
2: In order to compare your code should print with the %x command line directive , since the
command line tool you compare with uses hexadecimal
------
What is a woman that you forsake her, and the hearth fire and the home acre,
to go with the old grey Widow Maker. --Kipling, harp song of the Dane women
Tommy Nordgren
email@hidden




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >looking for a crc code (From: Angelo Chen <email@hidden>)
 >Re: looking for a crc code (From: Graham Cox <email@hidden>)
 >Re: looking for a crc code (From: Ilan Volow <email@hidden>)
 >Re: looking for a crc code (From: Jens Alfke <email@hidden>)
 >Re: looking for a crc code (From: Michael Hall <email@hidden>)

  • Prev by Date: Transparent content view of NSWindow clicks through
  • Next by Date: Re: ObjectController and ArrayController tutorials
  • Previous by thread: Re: looking for a crc code
  • Next by thread: Re: looking for a crc code
  • Index(es):
    • Date
    • Thread