Revision: 4936
http://skim-app.svn.sourceforge.net/skim-app/?rev=4936&view=rev
Author: hofman
Date: 2008-11-10 18:14:59 +0000 (Mon, 10 Nov 2008)
Log Message:
-----------
Use md5 as hex string for fallback keychain identifier
Modified Paths:
--------------
trunk/NSData_SKExtensions.h
trunk/NSData_SKExtensions.m
trunk/SKPDFDocument.m
Modified: trunk/NSData_SKExtensions.h
===================================================================
--- trunk/NSData_SKExtensions.h 2008-11-10 13:31:26 UTC (rev 4935)
+++ trunk/NSData_SKExtensions.h 2008-11-10 18:14:59 UTC (rev 4936)
@@ -46,7 +46,7 @@
- (unsigned)indexOfBytes:(const void *)patternBytes length:(unsigned
int)patternLength options:(int)mask range:(NSRange)searchRange;
- (NSData *)md5Signature;
-
+- (NSString *)hexString;
- (NSString *)xmlString;
+ (NSData *)dataWithPointAsQDPoint:(NSPoint)point;
Modified: trunk/NSData_SKExtensions.m
===================================================================
--- trunk/NSData_SKExtensions.m 2008-11-10 13:31:26 UTC (rev 4935)
+++ trunk/NSData_SKExtensions.m 2008-11-10 18:14:59 UTC (rev 4936)
@@ -112,6 +112,38 @@
return [NSData dataWithBytes:signature length:MD5_SIGNATURE_LENGTH];
}
+- (NSString *)hexString {
+ const char *inputBytes, *inputBytesPtr;
+ unsigned int inputBytesLength, outputBufferLength;
+ unichar *outputBuffer, *outputBufferEnd;
+ unichar *outputBufferPtr;
+ const char hexChars[] = "0123456789abcdef";
+ NSString *hexString;
+
+ inputBytes = [self bytes];
+ inputBytesLength = [self length];
+ outputBufferLength = inputBytesLength * 2;
+ outputBuffer = NSZoneMalloc(NULL, outputBufferLength * sizeof(unichar));
+ outputBufferEnd = outputBuffer + outputBufferLength;
+
+ inputBytesPtr = inputBytes;
+ outputBufferPtr = outputBuffer;
+
+ while (outputBufferPtr < outputBufferEnd) {
+ unsigned char inputByte;
+
+ inputByte = *inputBytesPtr++;
+ *outputBufferPtr++ = hexChars[(inputByte & 0xf0) >> 4];
+ *outputBufferPtr++ = hexChars[inputByte & 0x0f];
+ }
+
+ hexString = [[NSString allocWithZone:[self zone]]
initWithCharacters:outputBuffer length:outputBufferLength];
+
+ NSZoneFree(NULL, outputBuffer);
+
+ return [hexString autorelease];
+}
+
#pragma mark Templating support
- (NSString *)xmlString {
Modified: trunk/SKPDFDocument.m
===================================================================
--- trunk/SKPDFDocument.m 2008-11-10 13:31:26 UTC (rev 4935)
+++ trunk/SKPDFDocument.m 2008-11-10 18:14:59 UTC (rev 4936)
@@ -1694,9 +1694,9 @@
NSArray *fileIDStrings = [self fileIDStrings];
if ([fileIDStrings count])
return [[@"Skim - " stringByAppendingString:[fileIDStrings
objectAtIndex:0]] UTF8String];
- NSString *md5Signature = [[[NSString alloc] initWithData:[pdfData
md5Signature] encoding:NSUTF8StringEncoding] autorelease];
- if (md5Signature)
- return [[@"Skim - " stringByAppendingString:md5Signature] UTF8String];
+ NSString *md5HexString = [[pdfData md5Signature] hexString];
+ if (md5HexString)
+ return [[@"Skim - " stringByAppendingString:md5HexString] UTF8String];
return NULL;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit