From db17872dd64cd1ac7771181e6066f1f9a94aeac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20J=2E=20Hern=C3=A1ndez=20Blasco?= Date: Mon, 14 Dec 2015 23:39:32 +0100 Subject: [PATCH] oc: Dump property canonical name in dbmsgreader --- OpenChange/GNUmakefile | 3 ++- OpenChange/dbmsgreader.m | 47 +++++++++++++++++++++++++++++++++++----- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/OpenChange/GNUmakefile b/OpenChange/GNUmakefile index 8006b21b9..4fc207904 100644 --- a/OpenChange/GNUmakefile +++ b/OpenChange/GNUmakefile @@ -145,7 +145,8 @@ $(DBMSGREADER_TOOL)_LIB_DIRS += \ -L../SoObjects/SOGo/SOGo.framework/sogo -lSOGo \ -L../SOPE/GDLContentStore/obj/ -lGDLContentStore \ -L../SOPE/NGCards/obj/ -lNGCards \ - -lNGObjWeb + -lNGObjWeb \ + $(LIBMAPI_LIBS) TEST_TOOL_NAME += $(PLREADER_TOOL) $(DBMSGREADER_TOOL) diff --git a/OpenChange/dbmsgreader.m b/OpenChange/dbmsgreader.m index 3d892ca34..5ad74b82b 100644 --- a/OpenChange/dbmsgreader.m +++ b/OpenChange/dbmsgreader.m @@ -1,8 +1,8 @@ /* dbmsgreader.m - this file is part of SOGo * * Copyright (C) 2011-2012 Inverse inc + * 2015 Enrique J. Hernandez * - * Author: Wolfgang Sourdeau * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,21 +33,58 @@ #import #import +#import + #import "MAPIStoreUserContext.h" #import #import #import "NSObject+PropertyList.h" -Class MAPIStoreUserContextK, SOGoCacheGCSObjectK; + +Class MAPIStoreUserContextK, SOGoCacheGCSObjectK, NSStringK; static void DumpBSONData(NSData *data) { + id key, value; + NSEnumerator *dictEnum; NSDictionary *dvalue; + NSMutableString *outStr; + NSUInteger max; + dvalue = [data BSONValue]; - [dvalue displayWithIndentation:0]; - printf("\n"); + max = [dvalue count]; + dictEnum = [dvalue keyEnumerator]; + NSStringK = [NSString class]; + outStr = [NSMutableString stringWithFormat: @"{ %d items\n", max]; + while ((key = [dictEnum nextObject])) + { + uint32_t proptag = 0; + if ([key isKindOfClass: NSStringK] && [(NSString *)key intValue] > 0) + proptag = [(NSString *)key intValue]; + + if (proptag > 0) + { + const char *propTagName = get_proptag_name (proptag); + NSString *propName; + + if (propTagName) + propName = [NSString stringWithCString: propTagName + encoding: NSUTF8StringEncoding]; + else + propName = [NSString stringWithFormat: @"0x%.4x", [key unsignedLongValue]]; + + [outStr appendFormat: @" %@ = ", propName]; + } + else + [outStr appendFormat: @" %@ = ", key]; + + value = [dvalue objectForKey: key]; + [outStr appendFormat: @"(%@) %@,\n", NSStringFromClass ([value class]), value]; + } + [outStr appendFormat: @"}\n"]; + printf ("%s\n", [outStr UTF8String]); } static void @@ -67,7 +104,7 @@ DbDumpObject (NSString *username, NSString *path) { printf("record found: %p\n", record); content = [[record objectForKey: @"c_content"] dataByDecodingBase64]; - DumpBSONData(content); + DumpBSONData (content); } else NSLog (@"record not found");