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 PROTECTED]



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to