From 54434e98961a9e37b865e670970312c81259c3b4 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 21 Aug 2012 20:39:46 +0000 Subject: [PATCH] Monotone-Parent: c61e2dc9a2d1575387224156c338b5517bdcbae1 Monotone-Revision: f878485f243e179600dcdcf48b5dffc712d954ca Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-08-21T20:39:46 Monotone-Branch: ca.inverse.sogo --- OpenChange/NSData+MAPIStore.h | 2 ++ OpenChange/NSData+MAPIStore.m | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/OpenChange/NSData+MAPIStore.h b/OpenChange/NSData+MAPIStore.h index 20409c1ac..5715b9128 100644 --- a/OpenChange/NSData+MAPIStore.h +++ b/OpenChange/NSData+MAPIStore.h @@ -45,6 +45,8 @@ + (id) dataWithChangeKeyGUID: (NSString *) guidString andCnt: (NSData *) globCnt; +- (void) hexDumpWithLineSize: (NSUInteger) lineSize; + @end @interface NSMutableData (MAPIStoreDataTypes) diff --git a/OpenChange/NSData+MAPIStore.m b/OpenChange/NSData+MAPIStore.m index 3ad9afb52..b1200c5f4 100644 --- a/OpenChange/NSData+MAPIStore.m +++ b/OpenChange/NSData+MAPIStore.m @@ -20,6 +20,8 @@ * Boston, MA 02111-1307, USA. */ +#import + #import "NSString+MAPIStore.h" #import "NSData+MAPIStore.h" @@ -185,6 +187,36 @@ static void _fillFlatUIDWithGUID (struct FlatUID_r *flatUID, const struct GUID * return changeKey; } +- (void) hexDumpWithLineSize: (NSUInteger) lineSize +{ + const char *bytes; + NSUInteger lineCount, count, max, charCount, charMax; + NSMutableString *line; + + bytes = [self bytes]; + max = [self length]; + + lineCount = 0; + for (count = 0; count < max; count++) + { + line = [NSMutableString stringWithFormat: @"%d: ", lineCount]; + if (lineSize) + { + if ((max - count) > lineSize) + charMax = lineSize; + else + charMax = max - count; + } + else + charMax = max; + for (charCount = 0; charCount < charMax; charCount++) + [line appendFormat: @" %.2x", *(bytes + count + charCount)]; + [self logWithFormat: @" %@", line]; + count += charMax; + lineCount++; + } +} + @end @implementation NSMutableData (MAPIStoreDataTypes)