On Jun 28, 2011, at 6:23 AM, Kevin Muldoon wrote: > As you can see from the output, the 'version' & 'reserved' isn't being read > at all. Must I coerce/parse something here? Much thanks…
I’m not familiar with the PSD format, but aren’t ‘version’ and ‘reserved’ binary? You’re printing them as C strings. Assuming ‘version’ is a 16-bit big-endian integer, you could read it like this: const uint8_t* bytes = [signature bytes]; uint16_t version = *(const uint16_t*)(bytes + 2); version = NSSwapBigShortToHost(version); Another way (that I often use) is to define a C struct that matches the fields and layout of the header, then cast the bytes to a pointer to that struct and read the fields. It makes your code look a lot cleaner, but you have to be careful to (a) make sure the compiler packs the struct fields properly, and (b) you byte-swap all integer/float fields appropriately. —Jens
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ 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 arch...@mail-archive.com