[Pkg-samba-maint] r3046 - in trunk/openchange: . debian doc/man/man1 libmapi libmapi/util libmapi++ libmapi++/tests libmapiadmin libocpf mapiproxy/libmapiserver mapiproxy/libmapistore mapiproxy/servers/default/emsmdb script torture utils utils/backup utils/mapitest utils/mapitest/modules

jelmer at alioth.debian.org jelmer at alioth.debian.org
Sat Sep 12 12:31:49 UTC 2009


Author: jelmer
Date: 2009-09-12 12:31:49 +0000 (Sat, 12 Sep 2009)
New Revision: 3046

Modified:
   trunk/openchange/ChangeLog
   trunk/openchange/README
   trunk/openchange/autogen.sh
   trunk/openchange/config.mk.in
   trunk/openchange/configure.ac
   trunk/openchange/debian/changelog
   trunk/openchange/doc/man/man1/mapitest.1
   trunk/openchange/libmapi++/attachment.h
   trunk/openchange/libmapi++/property_container.h
   trunk/openchange/libmapi++/tests/attach_test.cpp
   trunk/openchange/libmapi++/tests/test.cpp
   trunk/openchange/libmapi.pc.in
   trunk/openchange/libmapi/FXICS.c
   trunk/openchange/libmapi/IMAPIFolder.c
   trunk/openchange/libmapi/IMAPIProp.c
   trunk/openchange/libmapi/IMAPISession.c
   trunk/openchange/libmapi/IMAPITable.c
   trunk/openchange/libmapi/IMSProvider.c
   trunk/openchange/libmapi/IMessage.c
   trunk/openchange/libmapi/IMsgStore.c
   trunk/openchange/libmapi/IProfAdmin.c
   trunk/openchange/libmapi/IStoreFolder.c
   trunk/openchange/libmapi/IStream.c
   trunk/openchange/libmapi/IUnknown.c
   trunk/openchange/libmapi/IXPLogon.c
   trunk/openchange/libmapi/cdo_mapi.c
   trunk/openchange/libmapi/emsmdb.c
   trunk/openchange/libmapi/freebusy.c
   trunk/openchange/libmapi/mapi_nameid.c
   trunk/openchange/libmapi/mapidump.c
   trunk/openchange/libmapi/nspi.c
   trunk/openchange/libmapi/property.c
   trunk/openchange/libmapi/simple_mapi.c
   trunk/openchange/libmapi/util/lcid.c
   trunk/openchange/libmapiadmin.pc.in
   trunk/openchange/libmapiadmin/mapiadmin.c
   trunk/openchange/libmapiadmin/mapiadmin_user.c
   trunk/openchange/libocpf/ocpf_api.c
   trunk/openchange/libocpf/ocpf_dump.c
   trunk/openchange/libocpf/ocpf_dump.h
   trunk/openchange/mapiproxy/libmapiserver/libmapiserver_oxorule.c
   trunk/openchange/mapiproxy/libmapistore/mapistore_processing.c
   trunk/openchange/mapiproxy/libmapistore/mapistore_tdb_wrap.c
   trunk/openchange/mapiproxy/servers/default/emsmdb/emsmdbp_object.c
   trunk/openchange/mapiproxy/servers/default/emsmdb/oxctabl.c
   trunk/openchange/script/samba4_ver.sh
   trunk/openchange/torture/mapi_bookmark.c
   trunk/openchange/torture/mapi_deletemail.c
   trunk/openchange/torture/mapi_fetchattach.c
   trunk/openchange/torture/mapi_restrictions.c
   trunk/openchange/torture/mapi_sendattach.c
   trunk/openchange/torture/mapi_sendmail.c
   trunk/openchange/torture/mapi_sendmail_html.c
   trunk/openchange/torture/mapi_sorttable.c
   trunk/openchange/utils/backup/openchangemapidump.c
   trunk/openchange/utils/mapiprofile.c
   trunk/openchange/utils/mapitest/mapitest.c
   trunk/openchange/utils/mapitest/mapitest_common.c
   trunk/openchange/utils/mapitest/mapitest_suite.c
   trunk/openchange/utils/mapitest/modules/module_errorchecks.c
   trunk/openchange/utils/mapitest/modules/module_oxcfold.c
   trunk/openchange/utils/mapitest/modules/module_oxcprpt.c
   trunk/openchange/utils/mapitest/modules/module_oxomsg.c
   trunk/openchange/utils/openchangeclient.c
Log:
* New upstream snapshot.
* Upload to unstable.

Modified: trunk/openchange/ChangeLog
===================================================================
--- trunk/openchange/ChangeLog	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/ChangeLog	2009-09-12 12:31:49 UTC (rev 3046)
@@ -1,3 +1,231 @@
+2009-09-11
+    bradh
+	[r1500]
+		Only pass "-Wmissing-prototypes -Wstrict-prototypes" to CFLAGS,
+		not to CXXFLAGS as well.
+		
+		Avoids g++ warnings.
+	[r1499]
+		Use enumerated type instead of integer.
+	[r1498]
+		Remove unreachable code.
+	[r1497]
+		Add "static" to avoid the need for additional declarations.
+		
+		Avoids noise from the intel c compiler.
+	[r1496]
+		Namespace variable in macro, so we don't get noise about shadowing a
+		declaration of "i"
+	[r1495]
+		Help icc find comparison_fn_t.
+	[r1494]
+		Match up data types in argument and format string.
+	[r1493]
+		Remove unused variable, and change a name to avoid a "shadowed declaration" 
+		warning.
+
+2009-09-10
+    bradh
+	[r1491]
+		Portability fixes for Intel C Compiler.
+		
+		Set CFLAGS early, otherwise AC_PROG_CC will set
+		CFLAGS to "-O2 -g", which later has -O3 appended, which
+		icc complains about.
+		
+		Check if we're really icc, and if so, turn off some warnings.
+		Also turn off the "FORTIFY_SOURCE" define which causes problems
+		with missing builtins.
+		
+		The warnings can (and should) be turned back on later, after we
+		fix the current issues.
+
+2009-09-02
+    bradh
+	[r1489]
+		Correct diagnostics messages.
+
+2009-08-29
+    bradh
+	[r1487]
+		Remove explicit -Wstrict-aliasing=3 from command line.
+		
+		This is implied by gcc -Wall option, and icc produces nuisance warnings
+		with it enabled (related to the -W option, not the code being compiled).
+	[r1486]
+		Fix some memory leaks and a bug in mapiprofile.
+		
+		I introduced the bug in r1467, there could be others that are similar.
+
+2009-08-24
+    bradh
+	[r1484]
+		Minor rewording of description
+	[r1483]
+		Minor cleanups.
+
+2009-08-18
+    bradh
+	[r1477]
+		Move initialisation up, to make sure everything is valid in the failure paths
+		
+		Patch by Erik Hovland. Thanks once again.
+		
+		This closes out ticket #178.
+	[r1476]
+		Remove unreachable code.
+		
+		Patch by Erik Hovland. Thanks again.
+		
+		This is the second part of ticket #177. This completes the checkin of that ticket.
+	[r1475]
+		Remove unreachable code.
+		
+		Patch by Erik Hovland. Thanks very much.
+		
+		This is the first part of ticket #177.
+
+2009-08-17
+    bradh
+	[r1473]
+		Ensure that we check the result of the operation we just performed.
+		
+		Patch by Erik Hovland. Thanks very much for continuing to provide these.
+		
+		This is the third part of the patch in ticket #177. The first two parts are yet to be addressed.
+	[r1472]
+		Make sure that return values are checked and report that given status if there is an error. 
+		
+		Patch from Erik Hovland, with minor additional changes. Thanks again for the patch.
+		
+		Resolves #176.
+	[r1471]
+		More cleanups of memory leaks for setting up database and an associated failure case.
+	[r1468]
+		fix leak in openchangeclient
+		
+		(as seen with valgrind of "openchangeclient -m")
+	[r1467]
+		Fix memory leak in mapiprofile utility
+
+2009-08-14
+    bradh
+	[r1465]
+		Ensure that when we pass --profile to mapitest, that profile
+		gets used instead of the default.
+		
+		Also fix a small memory leak when using --profile, and add some
+		extra comments.
+	[r1464]
+		Fix error handling case.
+		
+		Patch from Erik Hovland - thanks very much.
+		
+		Resolves ticket #175.
+
+2009-08-13
+    bradh
+	[r1461]
+		Remove unused enum values.
+	[r1460]
+		Remove unused code - no simple tests.
+
+2009-08-09
+    bradh
+	[r1454]
+		Update the script version of samba4 to alpha8.
+
+2009-08-05
+    jelmer
+	[r1450]
+		Add tevent to dependencies.
+
+2009-08-03
+    bradh
+	[r1448]
+		Remove unused headers.
+		
+		Patch by Erik Hovland - thanks very much,
+		
+		Resolves ticket #164.
+	[r1447]
+		Apply patch from Erik Hovland, from ticket #162.
+		
+		From the original patch:
+		"The problem is that when you do stat first w/ a file string anyone can
+		exploit the time in between to do whatever they want with the file that
+		the string is a name for. Instead, try to open straight away. Then fstat
+		w/ the file descriptor."
+		
+		I think the patch is fine, although I didn't run the torture test.
+
+2009-08-02
+    bradh
+	[r1444]
+		Avoid duplicate call to mapi_object_get_logon_id
+		
+		Based on a patch proposed by Erik Hovland, but adapted to follow the
+		pattern used in OpenStream().
+		
+		Resolves issue #163.
+	[r1443]
+		Applied modified version of patch from Erik Hovland to address unused variables.
+		
+		See http://trac.openchange.org/attachment/ticket/160/unused-values for
+		the rationale.
+		
+		This resolves #160.
+		
+		My version removes variables (rather than commenting them out) since we don't need
+		them now. I also updated the documentation for options that are no longer available
+		
+		The origin of the unused PR_FOLDER_CHILD_COUNT is a bit strange. It was introduced
+		in r808 (to resolve #103), and looks like it might have been used for debugging - no
+		impact on the code. I pulled out the whole lot.
+		
+		Tested with openchangeclient --fetchmail --folder="Sent Mail" and mapitest.
+	[r1442]
+		Use array form of delete (error identified with libmapixx-attach test, using valgrind).
+	[r1441]
+		Fix potentially unused variable.
+		
+		Tested with mapitest (even though nothing should have been affected) and
+		with libmapixx-test and libmapixx-attach under valgrind.
+		
+		Patch is remaining part of http://trac.openchange.org/ticket/153
+		
+		Thanks to Erik Hovland for the patch.
+
+2009-07-29
+    bradh
+	[r1433]
+		Remove dead / unused code.
+		
+		See http://trac.openchange.org/ticket/152#comment:1 for rationale.
+		
+		Original patch by Erik Hovland - thanks again.
+	[r1432]
+		Update test case to reflect new behaviour
+
+2009-07-18
+    jelmer
+	[r1423]
+		Link libmapistore against tdb.
+	[r1422]
+		Update copies of config.guess and config.sub.
+	[r1421]
+		Link libmapiproxy against tdb.
+	[r1420]
+		Declare a SOVERSION for libmapistore.
+	[r1419]
+		Use LDFLAGS when linking exchange2ical.
+	[r1418]
+		Create symlink for libmapistore.
+	[r1417]
+		Link libmapi against tevent since it uses tevent_context_init, link ndr_exchange.po into libmapiserver since it uses some ndr_push_* symbols.
+	[r1416]
+		Fix typo in variable name.
+
 2009-06-21
     jelmer
 	[r1365]

Modified: trunk/openchange/README
===================================================================
--- trunk/openchange/README	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/README	2009-09-12 12:31:49 UTC (rev 3046)
@@ -10,7 +10,7 @@
 
 The OpenChange project has three goals:
 * To provide a library for interoperability with Exchange protocols, and
-to assist implementors to use this to create groupware that
+to assist implementers to use this to create groupware that
 interoperates with both Exchange and other OpenChange-based software. 
 
 * To provide an alternative to Microsoft Exchange Server which uses
@@ -45,7 +45,6 @@
 
 
 STRUCTURE
-[TODO: add description of each directory]
 - bin/	This directory is created during the build process. It
 contains the binaries (executable programs) that are compiled during
 the "make" step. The source for most of these is in the utils/
@@ -130,7 +129,7 @@
  - utils/exchange2mbox	two way conversion between Exchange mail and mbox
  - utils/mapiprofile	set up client side profiles (login information)
  - utils/mapitest/	test tools for libmapi functionality
- - utils/mapitrace/
+ - utils/mapitrace/	test tool for tracing MAPI calls
  - utils/openchangeclient	command line client for Exchange RPC
  - utils/openchangepfadmin	Public Folders admin tools and 
 				administration of Exchange users (add/del) 

Modified: trunk/openchange/autogen.sh
===================================================================
--- trunk/openchange/autogen.sh	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/autogen.sh	2009-09-12 12:31:49 UTC (rev 3046)
@@ -55,7 +55,7 @@
 ## do we have it?
 ##
 if test "$AUTOCONFFOUND" = "0" -o "$AUTOHEADERFOUND" = "0"; then
-        echo "$0: need autoconf 2.53 or later to build samba from SVN" >&2
+        echo "$0: need autoconf 2.53 or later to build openchange from SVN" >&2
         exit 1
 fi
 
@@ -80,5 +80,5 @@
 
 rm -rf autom4te*.cache
 
-echo "Now run ./configure and make"
+echo "Now run ./configure and gmake"
 exit 0

Modified: trunk/openchange/config.mk.in
===================================================================
--- trunk/openchange/config.mk.in	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/config.mk.in	2009-09-12 12:31:49 UTC (rev 3046)
@@ -29,11 +29,10 @@
 sambaprefix=@sambaprefix@
 
 DSOOPT=-shared -fPIC
-CFLAGS=@CFLAGS@ -I. -O3 -Wall -Wmissing-prototypes -Wstrict-prototypes -g3 -Wp,-D_FORTIFY_SOURCE=2	\
-	-fstrict-aliasing -Wstrict-aliasing=3	   		       	   				\
-	   -DDEFAULT_LDIF=\"$(datadir)/setup/profiles\"							\
-	   -DMAPISTORE_BACKEND_INSTALLDIR=\"$(libdir)/mapistore_backends\"				\
-	   -DMAPISTORE_MAPPING_PATH=\"$(prefix)/private/mapistore\"	
+CFLAGS=@CFLAGS@ -Wmissing-prototypes -Wstrict-prototypes     \
+       -DDEFAULT_LDIF=\"$(datadir)/setup/profiles\"						\
+       -DMAPISTORE_BACKEND_INSTALLDIR=\"$(libdir)/mapistore_backends\"				\
+       -DMAPISTORE_MAPPING_PATH=\"$(prefix)/private/mapistore\"
 
 # This value should be determined by configure at some point
 SHLIBEXT=so

Modified: trunk/openchange/configure.ac
===================================================================
--- trunk/openchange/configure.ac	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/configure.ac	2009-09-12 12:31:49 UTC (rev 3046)
@@ -9,6 +9,8 @@
 
 PKG_PROG_PKG_CONFIG([0.20])
 
+CFLAGS="-I. -O3 -Wall -g3 -fstrict-aliasing $CFLAGS"
+
 dnl #################################################################
 dnl Check for OS dependent options
 dnl #################################################################
@@ -121,6 +123,22 @@
 ])
 
 dnl ###########################################################################
+dnl _AC_LANG_COMPILER_ICC
+dnl Check whether the compiler for the current language is really ICC.
+dnl ###########################################################################
+m4_define([AC_LANG_COMPILER_ICC],
+[AC_CACHE_CHECK([whether we are really using the Intel _AC_LANG compiler],
+		[ac_cv_[]_AC_LANG_ABBREV[]_compiler_icc],
+[_AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef __INTEL_COMPILER
+       choke me
+#endif
+]])],
+		   [ac_compiler_icc=yes],
+		   [ac_compiler_icc=no])
+ac_cv_[]_AC_LANG_ABBREV[]_compiler_icc=$ac_compiler_icc
+])])
+
+dnl ###########################################################################
 dnl FreeBSD installs some libraries such as libpopt in the non default
 dnl search path /usr/local/{include,lib}. This nasty hack ensures
 dnl configure.ac will find the library if available and additional
@@ -135,7 +153,8 @@
 dnl Check for comparison_fn_t
 dnl ----------------------------------------------------------------------------
 AC_CHECK_TYPE(comparison_fn_t, 
-[AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])])
+[AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])],
+[], [[#include <stdlib.h>]])
 
 
 dnl ###########################################################################
@@ -148,6 +167,19 @@
 AC_PROG_CC
 
 dnl ---------------------------------------------------------------------------
+dnl Check for ICC
+dnl ---------------------------------------------------------------------------
+AC_LANG_COMPILER_ICC
+
+dnl if it isn't icc, then use the gcc options
+dnl otherwise suppress some noise from icc
+if test x"$ac_cv_c_compiler_icc" != x"yes"; then
+    CFLAGS="$CFLAGS -Wp,-D_FORTIFY_SOURCE=2"
+else
+    CFLAGS="$CFLAGS -wd2259,188,593,869,981,181,1419,2218"
+fi
+
+dnl ---------------------------------------------------------------------------
 dnl Check for install
 dnl ---------------------------------------------------------------------------
 AC_PROG_INSTALL

Modified: trunk/openchange/debian/changelog
===================================================================
--- trunk/openchange/debian/changelog	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/debian/changelog	2009-09-12 12:31:49 UTC (rev 3046)
@@ -1,3 +1,10 @@
+openchange (1:0.8.2+svn1509-1) unstable; urgency=low
+
+  * New upstream snapshot.
+  * Upload to unstable.
+
+ -- Jelmer Vernooij <jelmer at debian.org>  Sat, 12 Sep 2009 13:35:58 +0200
+
 openchange (1:0.8.2+svn1423-1) experimental; urgency=low
 
   * New upstream snapshot.

Modified: trunk/openchange/doc/man/man1/mapitest.1
===================================================================
--- trunk/openchange/doc/man/man1/mapitest.1	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/doc/man/man1/mapitest.1	2009-09-12 12:31:49 UTC (rev 3046)
@@ -33,7 +33,7 @@
 .SH SYNOPSIS
 .nf
 mapitest [-?|--help] [--usage] [-f|--database=STRING] [-p|--profile=STRING]
-  [-u|--username=STRING] [-p|--password=STRING] [--confidential] [--color]
+  [-p|--password=STRING] [--confidential] [--color]
   [-o|--outfile=STRING] [--mapi-calls=STRING] [--list-all] [--no-server]
   [--dump-data] [-d|--debuglevel=STRING]
 .fi
@@ -68,12 +68,6 @@
 .B MAPI_E_NOT_FOUND .
 
 .TP
-.B --username
-.TP
-.B -u
-Set the username of the account to use.
-
-.TP
 .B --password
 .TP
 .B -P

Modified: trunk/openchange/libmapi/FXICS.c
===================================================================
--- trunk/openchange/libmapi/FXICS.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/FXICS.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -19,7 +19,6 @@
 
 #include <libmapi/libmapi.h>
 #include <libmapi/proto_private.h>
-#include <gen_ndr/ndr_exchange.h>
 
 
 /**

Modified: trunk/openchange/libmapi/IMAPIFolder.c
===================================================================
--- trunk/openchange/libmapi/IMAPIFolder.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/IMAPIFolder.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -19,7 +19,6 @@
 
 #include <libmapi/libmapi.h>
 #include <libmapi/proto_private.h>
-#include <gen_ndr/ndr_exchange.h>
 
 
 /**
@@ -596,7 +595,7 @@
    \sa OpenFolder, DeleteFolder, EmptyFolder, GetLastError
 */
 _PUBLIC_ enum MAPISTATUS CreateFolder(mapi_object_t *obj_parent, 
-				      uint8_t ulFolderType,
+				      enum FOLDER_TYPE ulFolderType,
 				      const char *name,
 				      const char *comment, 
 				      uint32_t ulFlags,

Modified: trunk/openchange/libmapi/IMAPIProp.c
===================================================================
--- trunk/openchange/libmapi/IMAPIProp.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/IMAPIProp.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -20,7 +20,6 @@
 
 #include <libmapi/libmapi.h>
 #include <libmapi/proto_private.h>
-#include <gen_ndr/ndr_exchange.h>
 
 
 /**

Modified: trunk/openchange/libmapi/IMAPISession.c
===================================================================
--- trunk/openchange/libmapi/IMAPISession.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/IMAPISession.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -19,7 +19,6 @@
 
 #include <libmapi/libmapi.h>
 #include <libmapi/proto_private.h>
-#include <gen_ndr/ndr_exchange.h>
 
 
 /**

Modified: trunk/openchange/libmapi/IMAPITable.c
===================================================================
--- trunk/openchange/libmapi/IMAPITable.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/IMAPITable.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -20,7 +20,6 @@
 
 #include <libmapi/libmapi.h>
 #include <libmapi/proto_private.h>
-#include <gen_ndr/ndr_exchange.h>
 
 /**
    \file IMAPITable.c
@@ -1215,7 +1214,8 @@
  */
 _PUBLIC_ enum MAPISTATUS FindRow(mapi_object_t *obj_table, 
 				 struct mapi_SRestriction *res,
-				 uint32_t bkOrigin, uint8_t ulFlags,
+				 enum BOOKMARK bkOrigin,
+				 enum FindRow_ulFlags ulFlags,
 				 struct SRowSet *SRowSet)
 {
 	struct mapi_request    	*mapi_request;
@@ -1252,7 +1252,7 @@
 	size += sizeof (uint8_t);
 	request.res = *res;
 	size += get_mapi_SRestriction_size(res);
-	request.origin = (bkOrigin > 3) ? 3 : bkOrigin;
+	request.origin = (bkOrigin > BOOKMARK_USER) ? BOOKMARK_USER : bkOrigin;
 	size += sizeof (uint8_t);
 	if (bkOrigin >= 3) {
 		request.bookmark.cb = bin.cb;

Modified: trunk/openchange/libmapi/IMSProvider.c
===================================================================
--- trunk/openchange/libmapi/IMSProvider.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/IMSProvider.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -24,7 +24,6 @@
 #include <gen_ndr/ndr_exchange_c.h>
 #include <core/error.h>
 #include <param.h>
-#include <credentials.h>
 
 
 /**

Modified: trunk/openchange/libmapi/IMessage.c
===================================================================
--- trunk/openchange/libmapi/IMessage.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/IMessage.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -596,7 +596,7 @@
 
 		RecipClass = (const uint32_t *) find_SPropValue_data(aRow, PR_RECIPIENT_TYPE);
 		OPENCHANGE_RETVAL_IF(!RecipClass, MAPI_E_INVALID_PARAMETER, mem_ctx);
-		request.RecipientRow[i_recip].RecipClass = (uint8_t) *RecipClass;
+		request.RecipientRow[i_recip].RecipClass = (enum ulRecipClass) *RecipClass;
 		size += sizeof(uint8_t);
 		
 		RecipientRow->RecipientFlags = mapi_recipients_bitmask(aRow);
@@ -605,7 +605,7 @@
 		switch (RecipientRow->RecipientFlags & 0xB) {
 		case 0x1: 
 			RecipientRow->type.EXCHANGE.organization_length = mapi_recipients_get_org_length(session->profile);
-			RecipientRow->type.EXCHANGE.addr_type = 0;
+			RecipientRow->type.EXCHANGE.addr_type = SINGLE_RECIPIENT;
 			RecipientRow->type.EXCHANGE.username = (const char *) find_SPropValue_data(aRow, PR_7BIT_DISPLAY_NAME);
 			size += sizeof(uint32_t) + strlen(RecipientRow->type.EXCHANGE.username) + 1;
 			break;
@@ -680,8 +680,12 @@
 		for (i_prop = 0; i_prop < request.prop_count; i_prop++) {
 			for (j = 0; j < aRow->cValues; j++) {
 				if (aRow->lpProps[j].ulPropTag == request.properties[i_prop]) {
-					ndr_push_set_switch_value(ndr, &mapi_sprop.value, 
-								  (aRow->lpProps[j].ulPropTag & 0xFFFF));
+					enum ndr_err_code ndr_retval;
+					ndr_retval = ndr_push_set_switch_value(ndr, &mapi_sprop.value, 
+									       (aRow->lpProps[j].ulPropTag & 0xFFFF));
+					if (!NDR_ERR_CODE_IS_SUCCESS(ndr_retval))
+						return MAPI_E_CALL_FAILED;
+
 					cast_mapi_SPropValue(&mapi_sprop, &aRow->lpProps[j]);
 					ndr_push_mapi_SPropValue_CTR(ndr, NDR_SCALARS, &mapi_sprop.value);
 				}
@@ -929,7 +933,7 @@
 	size = 0;
 
 	/* Fill the SubmitMessage operation */
-	request.SubmitFlags = 0x0;
+	request.SubmitFlags = None;
 	size += sizeof(uint8_t);
 
 	/* Fill the MAPI_REQ request */

Modified: trunk/openchange/libmapi/IMsgStore.c
===================================================================
--- trunk/openchange/libmapi/IMsgStore.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/IMsgStore.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -19,7 +19,6 @@
 
 #include <libmapi/libmapi.h>
 #include <libmapi/proto_private.h>
-#include <gen_ndr/ndr_exchange.h>
 
 
 /**

Modified: trunk/openchange/libmapi/IProfAdmin.c
===================================================================
--- trunk/openchange/libmapi/IProfAdmin.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/IProfAdmin.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -1369,7 +1369,6 @@
 	mapi_profile_add_string_attr(profname, "ServerName", nspi->servername);
 	set_profile_attribute(profname, *SRowSet, 0, PR_EMS_AB_HOME_MDB, "HomeMDB");
 	set_profile_mvstr_attribute(profname, *SRowSet, 0, PR_EMS_AB_PROXY_ADDRESSES, "ProxyAddress");
-	MAPIFreeBuffer(SRowSet);
 
 	pNames.Count = 0x1;
 	pNames.Strings = (const char **) talloc_array(nspi->mem_ctx, char **, 1);
@@ -1382,6 +1381,7 @@
 	MAPIFreeBuffer((char **)pNames.Strings);
 	if (retval != MAPI_E_SUCCESS) return retval;
 
+	MAPIFreeBuffer(SRowSet);
 	SRowSet = talloc_zero(nspi->mem_ctx, struct SRowSet);
 	SPropTagArray = set_SPropTagArray(nspi->mem_ctx, 0x1, PR_EMS_AB_NETWORK_ADDRESS);
 	retval = nspi_GetProps(nspi, SPropTagArray, MId_server, &SRowSet);

Modified: trunk/openchange/libmapi/IStoreFolder.c
===================================================================
--- trunk/openchange/libmapi/IStoreFolder.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/IStoreFolder.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -19,7 +19,6 @@
 
 #include <libmapi/libmapi.h>
 #include <libmapi/proto_private.h>
-#include <gen_ndr/ndr_exchange.h>
 
 
 /**

Modified: trunk/openchange/libmapi/IStream.c
===================================================================
--- trunk/openchange/libmapi/IStream.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/IStream.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -19,7 +19,6 @@
 
 #include <libmapi/libmapi.h>
 #include <libmapi/proto_private.h>
-#include <gen_ndr/ndr_exchange.h>
 
 
 /**
@@ -911,6 +910,7 @@
 	enum MAPISTATUS		retval;
 	TALLOC_CTX		*mem_ctx;
 	uint32_t		size;
+	uint8_t			logon_id;
 
 	/* Sanity Check */
 	OPENCHANGE_RETVAL_IF(!global_mapi_ctx, MAPI_E_NOT_INITIALIZED, NULL);
@@ -920,6 +920,8 @@
 	session = mapi_object_get_session(obj_src);
 	OPENCHANGE_RETVAL_IF(!session, MAPI_E_INVALID_PARAMETER, NULL);
 
+	logon_id = mapi_object_get_logon_id(obj_src);
+
 	mem_ctx = talloc_named(NULL, 0, "CloneStream");
 	size = 0;
 
@@ -930,7 +932,7 @@
 	/* Fill the MAPI_REQ request */
 	mapi_req = talloc_zero(mem_ctx, struct EcDoRpc_MAPI_REQ);
 	mapi_req->opnum = op_MAPI_CloneStream;
-	mapi_req->logon_id = mapi_object_get_logon_id(obj_src);
+	mapi_req->logon_id = logon_id;
 	mapi_req->handle_idx = 0;
 	mapi_req->u.mapi_CloneStream = request;
 	size += 5;
@@ -952,7 +954,7 @@
 
 	mapi_object_set_handle(obj_dst, mapi_response->handles[1]);
 	mapi_object_set_session(obj_dst, session);
-	mapi_object_set_logon_id(obj_dst, mapi_object_get_logon_id(obj_src));
+	mapi_object_set_logon_id(obj_dst, logon_id);
 
 	talloc_free(mapi_response);
 	talloc_free(mem_ctx);

Modified: trunk/openchange/libmapi/IUnknown.c
===================================================================
--- trunk/openchange/libmapi/IUnknown.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/IUnknown.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -19,7 +19,6 @@
 
 #include <libmapi/libmapi.h>
 #include <libmapi/proto_private.h>
-#include <gen_ndr/ndr_exchange.h>
 
 
 /**

Modified: trunk/openchange/libmapi/IXPLogon.c
===================================================================
--- trunk/openchange/libmapi/IXPLogon.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/IXPLogon.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -19,7 +19,6 @@
 
 #include <libmapi/libmapi.h>
 #include <libmapi/proto_private.h>
-#include <gen_ndr/ndr_exchange.h>
 
 
 /**
@@ -199,7 +198,7 @@
  */
 _PUBLIC_ enum MAPISTATUS SpoolerLockMessage(mapi_object_t *obj_store,
 					    mapi_object_t *obj_message, 
-					    uint8_t LockState)
+					    enum LockState LockState)
 {
 	struct mapi_request		*mapi_request;
 	struct mapi_response		*mapi_response;

Modified: trunk/openchange/libmapi/cdo_mapi.c
===================================================================
--- trunk/openchange/libmapi/cdo_mapi.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/cdo_mapi.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -22,7 +22,6 @@
 #include <libmapi/proto_private.h>
 #include <libmapi/dlinklist.h>
 #include <param.h>
-#include <ldb_errors.h>
 #include <ldb.h>
 
 struct mapi_ctx *global_mapi_ctx = NULL;

Modified: trunk/openchange/libmapi/emsmdb.c
===================================================================
--- trunk/openchange/libmapi/emsmdb.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/emsmdb.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -25,7 +25,6 @@
 #include <gen_ndr/ndr_misc.h>
 
 #include <param.h>
-#include <credentials.h>
 
 /**
    \file emsmdb.c

Modified: trunk/openchange/libmapi/freebusy.c
===================================================================
--- trunk/openchange/libmapi/freebusy.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/freebusy.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -19,7 +19,6 @@
 
 #include <libmapi/libmapi.h>
 #include <libmapi/proto_private.h>
-#include <gen_ndr/ndr_exchange.h>
 #include <ctype.h>
 #include <time.h>
 
@@ -146,7 +145,7 @@
 	res.res.resProperty.ulPropTag = PR_DISPLAY_NAME;
 	res.res.resProperty.lpProp.ulPropTag = PR_DISPLAY_NAME;
 	res.res.resProperty.lpProp.value.lpszA = folder_name;
-	retval = FindRow(&obj_htable, &res, 0, 0, &SRowSet);
+	retval = FindRow(&obj_htable, &res, BOOKMARK_BEGINNING, DIR_FORWARD, &SRowSet);
 	MAPIFreeBuffer(folder_name);
 	OPENCHANGE_RETVAL_IF(retval, retval, NULL);
 
@@ -190,7 +189,7 @@
 	res.res.resProperty.ulPropTag = PR_NORMALIZED_SUBJECT;
 	res.res.resProperty.lpProp.ulPropTag = PR_NORMALIZED_SUBJECT;
 	res.res.resProperty.lpProp.value.lpszA = message_name;
-	retval = FindRow(&obj_ctable, &res, 0, 0, &SRowSet);
+	retval = FindRow(&obj_ctable, &res, BOOKMARK_BEGINNING, DIR_FORWARD, &SRowSet);
 	MAPIFreeBuffer(message_name);
 	OPENCHANGE_RETVAL_IF(retval, retval, NULL);
 

Modified: trunk/openchange/libmapi/mapi_nameid.c
===================================================================
--- trunk/openchange/libmapi/mapi_nameid.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/mapi_nameid.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -453,8 +453,7 @@
 		}
 	}
 
-	errno = MAPI_E_NOT_FOUND;
-	return -1;
+	OPENCHANGE_RETVAL_ERR(MAPI_E_NOT_FOUND, NULL);
 }
 
 
@@ -490,8 +489,7 @@
 		}
 	}
 
-	errno = MAPI_E_NOT_FOUND;
-	return -1;
+	OPENCHANGE_RETVAL_ERR(MAPI_E_NOT_FOUND, NULL);
 }
 
 
@@ -528,9 +526,8 @@
 			return MAPI_E_SUCCESS;
 		}
 	}
-	
-	errno = MAPI_E_NOT_FOUND;
-	return -1;
+
+	OPENCHANGE_RETVAL_ERR(MAPI_E_NOT_FOUND, NULL);
 }
 
 

Modified: trunk/openchange/libmapi/mapidump.c
===================================================================
--- trunk/openchange/libmapi/mapidump.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/mapidump.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -19,7 +19,6 @@
 
 #include <libmapi/libmapi.h>
 #include <libmapi/mapidump.h>
-#include <libmapi/proto_private.h>
 #include <libmapi/defs_private.h>
 #include <time.h>
 
@@ -301,7 +300,7 @@
 	printf("Body:\n");
 	fflush(0);
 	if (body) {
-		printf("%s\n", body ? body : "");
+		printf("%s\n", body);
 	} else if (html) {
 		len = write(1, html->lpb, html->cb);
 		len = write(1, "\n", 1);

Modified: trunk/openchange/libmapi/nspi.c
===================================================================
--- trunk/openchange/libmapi/nspi.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/nspi.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -21,7 +21,6 @@
 #include <libmapi/proto_private.h>
 #include <gen_ndr/ndr_exchange_c.h>
 #include <param.h>
-#include <credentials.h>
 
 
 /**

Modified: trunk/openchange/libmapi/property.c
===================================================================
--- trunk/openchange/libmapi/property.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/property.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -20,7 +20,6 @@
 
 #include <libmapi/libmapi.h>
 #include <libmapi/proto_private.h>
-#include <libmapi/mapitags.h>
 #include <gen_ndr/ndr_property.h>
 #include <param.h>
 

Modified: trunk/openchange/libmapi/simple_mapi.c
===================================================================
--- trunk/openchange/libmapi/simple_mapi.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/simple_mapi.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -19,7 +19,6 @@
 
 #include <libmapi/libmapi.h>
 #include <libmapi/proto_private.h>
-#include <gen_ndr/ndr_exchange.h>
 
 
 /**

Modified: trunk/openchange/libmapi/util/lcid.c
===================================================================
--- trunk/openchange/libmapi/util/lcid.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi/util/lcid.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -19,7 +19,6 @@
  */
 
 #include <libmapi/libmapi.h>
-#include <libmapi/proto_private.h>
 
 #define	CP_WESTERN_EUROPE_AND_US	1	/* 1  (Western Europe & US) */
 #define	CP_CENTRAL_EUROPE		2	/* 2  (Central Europe) */

Modified: trunk/openchange/libmapi++/attachment.h
===================================================================
--- trunk/openchange/libmapi++/attachment.h	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi++/attachment.h	2009-09-12 12:31:49 UTC (rev 3046)
@@ -142,7 +142,7 @@
 		 */
 		virtual ~attachment() throw()
 		{
-			if (m_bin_data) delete m_bin_data;
+			if (m_bin_data) delete[] m_bin_data;
 		}
 
 	private:

Modified: trunk/openchange/libmapi++/property_container.h
===================================================================
--- trunk/openchange/libmapi++/property_container.h	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi++/property_container.h	2009-09-12 12:31:49 UTC (rev 3046)
@@ -164,8 +164,10 @@
 
 		/// Constructor
 		property_container(TALLOC_CTX* memory_ctx, mapi_object_t& mapi_object) : 
-		m_memory_ctx(memory_ctx), m_mapi_object(mapi_object), m_fetched(false), m_property_tag_array(NULL), m_cn_vals(0), m_property_values()
+		m_memory_ctx(memory_ctx), m_mapi_object(mapi_object), m_fetched(false), m_property_tag_array(NULL), m_cn_vals(0), m_property_values(0)
 		{
+			m_property_value_array.cValues = 0;
+			m_property_value_array.lpProps = NULL;
 		}
 
 		/**

Modified: trunk/openchange/libmapi++/tests/attach_test.cpp
===================================================================
--- trunk/openchange/libmapi++/tests/attach_test.cpp	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi++/tests/attach_test.cpp	2009-09-12 12:31:49 UTC (rev 3046)
@@ -26,13 +26,13 @@
 using namespace std;
 using namespace libmapipp;
 
-uint32_t get_attachment_count(message& mapi_message)
+static uint32_t get_attachment_count(message& mapi_message)
 {
 	message::attachment_container_type attachment_container = mapi_message.fetch_attachments();
 	return attachment_container.size();
 }
 
-void print_messages_with_attachments(folder& up_folder)
+static void print_messages_with_attachments(folder& up_folder)
 {
 	folder::message_container_type messages = up_folder.fetch_messages();
 	for (folder::message_container_type::iterator Iter = messages.begin(); Iter != messages.end(); ++Iter) {
@@ -44,7 +44,7 @@
 	}
 }
 
-void print_folder_tree(folder& up_folder, session& mapi_session, unsigned int deep = 0)
+static void print_folder_tree(folder& up_folder, session& mapi_session, unsigned int deep = 0)
 {
 	property_container up_folder_property_container = up_folder.get_property_container();
 	up_folder_property_container << PR_DISPLAY_NAME << PR_CONTENT_COUNT;

Modified: trunk/openchange/libmapi++/tests/test.cpp
===================================================================
--- trunk/openchange/libmapi++/tests/test.cpp	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi++/tests/test.cpp	2009-09-12 12:31:49 UTC (rev 3046)
@@ -30,13 +30,13 @@
 
 // The best way to get a folder message count is to get property PR_FOLDER_CHILD_COUNT.
 // This is only used to test opening all messages.
-unsigned int get_message_count(folder& the_folder, session& mapi_session)
+static unsigned int get_message_count(folder& the_folder, session& mapi_session)
 {
 	folder::message_container_type messages = the_folder.fetch_messages();
 	return messages.size();
 }
 
-void print_folder_tree(folder& up_folder, session& mapi_session, unsigned int deep = 0)
+static void print_folder_tree(folder& up_folder, session& mapi_session, unsigned int deep = 0)
 {
 	property_container up_folder_property_container = up_folder.get_property_container();
 	up_folder_property_container << PR_DISPLAY_NAME << PR_CONTAINER_CLASS;

Modified: trunk/openchange/libmapi.pc.in
===================================================================
--- trunk/openchange/libmapi.pc.in	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapi.pc.in	2009-09-12 12:31:49 UTC (rev 3046)
@@ -11,5 +11,5 @@
 Libs: -L${libdir} -lmapi
 Libs.private: @LIBS@
 Cflags: -I${includedir}
-Requires: talloc dcerpc ndr ldb
-Requires.private: samba-hostconfig
+Requires: talloc dcerpc ndr tevent
+Requires.private: samba-hostconfig ldb

Modified: trunk/openchange/libmapiadmin/mapiadmin.c
===================================================================
--- trunk/openchange/libmapiadmin/mapiadmin.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapiadmin/mapiadmin.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -18,7 +18,6 @@
  */
 
 #include <libmapiadmin/libmapiadmin.h>
-#include <libmapiadmin/proto_private.h>
 
 /**
 	\file

Modified: trunk/openchange/libmapiadmin/mapiadmin_user.c
===================================================================
--- trunk/openchange/libmapiadmin/mapiadmin_user.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapiadmin/mapiadmin_user.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -25,14 +25,12 @@
  */
 
 #include <libmapiadmin/libmapiadmin.h>
-#include <libmapiadmin/proto_private.h>
 
 #include <param.h>
 #include <credentials.h>
 #include <samba/popt.h>
 #include <ldb_errors.h>
 #include <ldb_wrap.h>
-#include <util_ldb.h>
 #include <ldap_ndr.h>
 
 #include <core/error.h>
@@ -442,7 +440,7 @@
 
 	status = dcerpc_fetch_session_key(mapiadmin_ctx->user_ctx->p, &session_key);
 	if (!NT_STATUS_IS_OK(status)) {
-		DEBUG(3, ("SetUserInfo level %u - no session key - %s\n",
+		DEBUG(3, ("SetUserInfo level %d - no session key - %s\n",
 			  s.in.level, nt_errstr(status)));
 		mapiadmin_user_del(mapiadmin_ctx);
 	        MAPI_RETVAL_IF(1,MAPI_E_CALL_FAILED,mem_ctx);

Modified: trunk/openchange/libmapiadmin.pc.in
===================================================================
--- trunk/openchange/libmapiadmin.pc.in	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libmapiadmin.pc.in	2009-09-12 12:31:49 UTC (rev 3046)
@@ -5,8 +5,8 @@
 datarootdir=@prefix@/share
 datadir=@datadir@
 
-Name: MAPI Administration
-Description: MAPI Administration Implementation
+Name: MAPI admin library
+Description: Library supporting MAPI administration actions
 Version: @PACKAGE_VERSION@
 Libs: @LIBS@
 Cflags: @CFLAGS@

Modified: trunk/openchange/libocpf/ocpf_api.c
===================================================================
--- trunk/openchange/libocpf/ocpf_api.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libocpf/ocpf_api.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -20,11 +20,9 @@
 #include "libocpf/ocpf_private.h"
 #include <libocpf/ocpf.h>
 #include <libocpf/ocpf_api.h>
-#include <libocpf/ocpf.tab.h>
 
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <libgen.h>
 #include <time.h>
 
 /**
@@ -167,7 +165,6 @@
 		OCPF_WARN(("%s (0x%.4x)", OCPF_WARN_PROP_TYPE, proptype));
 		return OCPF_ERROR;
 	}
-	return OCPF_ERROR;
 }
 
 int ocpf_propvalue_free(union SPropValue_CTR lpProp, uint16_t proptype)
@@ -549,9 +546,9 @@
 	int		fd;
 	struct stat	sb;
 
-	OCPF_RETVAL_IF(stat(filename, &sb), OCPF_WARN_FILENAME_STAT, NULL);
 	fd = open(filename, O_RDONLY);
 	OCPF_RETVAL_IF(fd == -1, OCPF_WARN_FILENAME_INVALID, NULL);
+	OCPF_RETVAL_IF(fstat(fd, &sb), OCPF_WARN_FILENAME_STAT, NULL);
 	
 	bin->lpb = talloc_size(ocpf->mem_ctx, sb.st_size);
 	bin->cb = read(fd, bin->lpb, sb.st_size);

Modified: trunk/openchange/libocpf/ocpf_dump.c
===================================================================
--- trunk/openchange/libocpf/ocpf_dump.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libocpf/ocpf_dump.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -20,7 +20,6 @@
 #include "libocpf/ocpf_private.h"
 #include <libocpf/ocpf.h>
 #include <libocpf/ocpf_api.h>
-#include <libocpf/ocpf.tab.h>
 #include <libocpf/ocpf_dump.h>
 
 /**

Modified: trunk/openchange/libocpf/ocpf_dump.h
===================================================================
--- trunk/openchange/libocpf/ocpf_dump.h	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/libocpf/ocpf_dump.h	2009-09-12 12:31:49 UTC (rev 3046)
@@ -34,7 +34,7 @@
 
 #define	OCPF_DUMP_TITLE(indent, txt, type)		\
 do {							\
-	int	i;					\
+	int	odt_i;					\
 	int	txt_len;				\
 							\
 	printf("\n");					\
@@ -43,7 +43,7 @@
 							\
 	INDENT();					\
 	txt_len = strlen(txt) + 1;     			\
-	for (i = 0; i < txt_len; i++) {			\
+	for (odt_i = 0; odt_i < txt_len; odt_i++) {	\
 		printf("%c", type ? '-' : '=');		\
 	}						\
 	printf("\n");					\

Modified: trunk/openchange/mapiproxy/libmapiserver/libmapiserver_oxorule.c
===================================================================
--- trunk/openchange/mapiproxy/libmapiserver/libmapiserver_oxorule.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/mapiproxy/libmapiserver/libmapiserver_oxorule.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -26,8 +26,6 @@
  */
 
 #include "libmapiserver.h"
-#include <libmapi/mapidefs.h>
-#include <gen_ndr/ndr_exchange.h>
 
 /**
    \details Calculate GetRulesTable Rop size

Modified: trunk/openchange/mapiproxy/libmapistore/mapistore_processing.c
===================================================================
--- trunk/openchange/mapiproxy/libmapistore/mapistore_processing.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/mapiproxy/libmapistore/mapistore_processing.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -75,7 +75,7 @@
 
 	/* Step 2. TODO: Check for write permissions */
 
-	if (!closedir(dir) == -1) {
+	if (closedir(dir) == -1) {
 		/* FIXME: Should have a better error name here */
 		return MAPISTORE_ERR_NO_DIRECTORY;
 	}

Modified: trunk/openchange/mapiproxy/libmapistore/mapistore_tdb_wrap.c
===================================================================
--- trunk/openchange/mapiproxy/libmapistore/mapistore_tdb_wrap.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/mapiproxy/libmapistore/mapistore_tdb_wrap.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -24,7 +24,6 @@
 #include <string.h>
 
 #include "mapistore.h"
-#include "mapistore_errors.h"
 #include "mapistore_private.h"
 #include <libmapi/dlinklist.h>
 

Modified: trunk/openchange/mapiproxy/servers/default/emsmdb/emsmdbp_object.c
===================================================================
--- trunk/openchange/mapiproxy/servers/default/emsmdb/emsmdbp_object.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/mapiproxy/servers/default/emsmdb/emsmdbp_object.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -45,8 +45,6 @@
 	default:
 		return "unknown";
 	}
-
-	return "unknown";
 }
 
 

Modified: trunk/openchange/mapiproxy/servers/default/emsmdb/oxctabl.c
===================================================================
--- trunk/openchange/mapiproxy/servers/default/emsmdb/oxctabl.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/mapiproxy/servers/default/emsmdb/oxctabl.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -73,7 +73,7 @@
 	mapi_repl->opnum = mapi_req->opnum;
 	mapi_repl->handle_idx = mapi_req->handle_idx;
 	mapi_repl->error_code = MAPI_E_SUCCESS;
-	mapi_repl->u.mapi_SetColumns.TableStatus = 0;
+	mapi_repl->u.mapi_SetColumns.TableStatus = TBLSTAT_COMPLETE;
 
 	*size += libmapiserver_RopSetColumns_size(mapi_repl);
 
@@ -134,7 +134,7 @@
 	mapi_repl->opnum = mapi_req->opnum;
 	mapi_repl->handle_idx = mapi_req->handle_idx;
 	mapi_repl->error_code = MAPI_E_SUCCESS;
-	mapi_repl->u.mapi_SortTable.TableStatus = 0;
+	mapi_repl->u.mapi_SortTable.TableStatus = TBLSTAT_COMPLETE;
 
 	*size += libmapiserver_RopSortTable_size(mapi_repl);
 
@@ -174,7 +174,7 @@
 	mapi_repl->opnum = mapi_req->opnum;
 	mapi_repl->handle_idx = mapi_req->handle_idx;
 	mapi_repl->error_code = MAPI_E_SUCCESS;
-	mapi_repl->u.mapi_Restrict.TableStatus = 0;
+	mapi_repl->u.mapi_Restrict.TableStatus = TBLSTAT_COMPLETE;
 
 	*size += libmapiserver_RopRestrict_size(mapi_repl);
 

Modified: trunk/openchange/script/samba4_ver.sh
===================================================================
--- trunk/openchange/script/samba4_ver.sh	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/script/samba4_ver.sh	2009-09-12 12:31:49 UTC (rev 3046)
@@ -1,4 +1,4 @@
-SAMBA4_GIT_REV=c3632e4
-SAMBA4_GIT_VER=4.0.0alpha7
-SAMBA4_RELEASE=4.0.0alpha7
+SAMBA4_GIT_REV=4ceae35
+SAMBA4_GIT_VER=4.0.0alpha8
+SAMBA4_RELEASE=4.0.0alpha8
 

Modified: trunk/openchange/torture/mapi_bookmark.c
===================================================================
--- trunk/openchange/torture/mapi_bookmark.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/torture/mapi_bookmark.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -21,7 +21,6 @@
 
 #include <libmapi/libmapi.h>
 #include <libmapi/defs_private.h>
-#include <gen_ndr/ndr_exchange.h>
 #include <param.h>
 #include <credentials.h>
 #include <torture/mapi_torture.h>

Modified: trunk/openchange/torture/mapi_deletemail.c
===================================================================
--- trunk/openchange/torture/mapi_deletemail.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/torture/mapi_deletemail.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -21,7 +21,6 @@
 
 #include <libmapi/libmapi.h>
 #include <libmapi/defs_private.h>
-#include <gen_ndr/ndr_exchange.h>
 #include <param.h>
 #include <credentials.h>
 #include <torture/mapi_torture.h>

Modified: trunk/openchange/torture/mapi_fetchattach.c
===================================================================
--- trunk/openchange/torture/mapi_fetchattach.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/torture/mapi_fetchattach.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -20,7 +20,6 @@
  */
 
 #include <libmapi/libmapi.h>
-#include <gen_ndr/ndr_exchange.h>
 #include <param.h>
 #include <credentials.h>
 #include <torture/mapi_torture.h>
@@ -62,7 +61,7 @@
   *sz_data = (uint32_t)vals[0].value.b;
   *buf_data = talloc_size(ctx_mem, *sz_data);
   if (*buf_data == 0)
-    return -1;
+    return MAPI_E_NOT_ENOUGH_MEMORY;
 
   /* Read attachment
    */

Modified: trunk/openchange/torture/mapi_restrictions.c
===================================================================
--- trunk/openchange/torture/mapi_restrictions.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/torture/mapi_restrictions.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -134,7 +134,7 @@
 	uint32_t			Numerator;
 	uint32_t			Denominator;
 	uint32_t			row_idx;
-	uint32_t			bookmark;
+	enum BOOKMARK			bookmark;
 
 
 	/* init torture */
@@ -325,7 +325,7 @@
 	res.res.resContent.ulPropTag = PR_BODY;
 	res.res.resContent.lpProp.ulPropTag = PR_BODY;
 	res.res.resContent.lpProp.value.lpszA = "openchange";
-	retval = FindRow(&obj_table, &res, 0, 0, &SRowSet);
+	retval = FindRow(&obj_table, &res, BOOKMARK_BEGINNING, DIR_FORWARD, &SRowSet);
 	if (retval != MAPI_E_SUCCESS) return false;
 
 	DEBUG(0, ("\no FindRow: RES_CONTENT\n"));
@@ -336,7 +336,7 @@
 	DEBUG(0, ("\n"));
 	mapi_object_bookmark_debug(&obj_table);
 
-	retval = FindRow(&obj_table, &res, bookmark, 0, &SRowSet);
+	retval = FindRow(&obj_table, &res, bookmark, DIR_FORWARD, &SRowSet);
 	if (retval != MAPI_E_SUCCESS) return false;
 	DEBUG(0, ("\no FindRow: RES_CONTENT BOOKMARK_USER (%.2d)\n", bookmark));
 	DEBUG(0, ("--------------------------------------------\n"));

Modified: trunk/openchange/torture/mapi_sendattach.c
===================================================================
--- trunk/openchange/torture/mapi_sendattach.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/torture/mapi_sendattach.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -21,7 +21,6 @@
  */
 
 #include <libmapi/libmapi.h>
-#include <gen_ndr/ndr_exchange.h>
 #include <param.h>
 #include <credentials.h>
 #include <torture/mapi_torture.h>
@@ -189,12 +188,11 @@
 		uint16_t	buf_readsize;
 		uint8_t		buf[0x7000];
 
-		if (stat(filename, &sb) != 0) return false;
-
 		if ((fd = open(filename, O_RDONLY)) == -1) {
 			DEBUG(0, ("Error while opening %s\n", filename));
 			return false;
 		}
+		if (fstat(fd, &sb) != 0) return false;
 	
 		while (((read_size = read(fd, buf, 0x4000)) != -1) && read_size) {
 			/* We reset errno due to read */

Modified: trunk/openchange/torture/mapi_sendmail.c
===================================================================
--- trunk/openchange/torture/mapi_sendmail.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/torture/mapi_sendmail.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -21,7 +21,6 @@
  */
 
 #include <libmapi/libmapi.h>
-#include <gen_ndr/ndr_exchange.h>
 #include <param.h>
 #include <credentials.h>
 #include <torture/mapi_torture.h>

Modified: trunk/openchange/torture/mapi_sendmail_html.c
===================================================================
--- trunk/openchange/torture/mapi_sendmail_html.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/torture/mapi_sendmail_html.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -20,7 +20,6 @@
  */
 
 #include <libmapi/libmapi.h>
-#include <gen_ndr/ndr_exchange.h>
 #include <param.h>
 #include <credentials.h>
 #include <torture/mapi_torture.h>
@@ -146,11 +145,11 @@
 		struct stat	sb;
 		int		fd;
 
-		if (stat(filename, &sb) != 0) return false;
 		if ((fd = open(filename, O_RDONLY)) == -1) {
 			DEBUG(0, ("Error while opening %s\n", filename));
 			return false;
 		}
+		if (fstat(fd, &sb) != 0) return false;
 		html.lpb = talloc_size(mem_ctx, sb.st_size);
 		html.cb = read(fd, html.lpb, sb.st_size);
 		close(fd);

Modified: trunk/openchange/torture/mapi_sorttable.c
===================================================================
--- trunk/openchange/torture/mapi_sorttable.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/torture/mapi_sorttable.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -20,7 +20,6 @@
  */
 
 #include <libmapi/libmapi.h>
-#include <gen_ndr/ndr_exchange.h>
 #include <param.h>
 #include <credentials.h>
 #include <torture/mapi_torture.h>

Modified: trunk/openchange/utils/backup/openchangemapidump.c
===================================================================
--- trunk/openchange/utils/backup/openchangemapidump.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/utils/backup/openchangemapidump.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -352,7 +352,6 @@
 	const char			*opt_profdb = NULL;
 	char				*opt_profname = NULL;
 	const char			*opt_password = NULL;
-	const char			*opt_config = NULL;
 	const char			*opt_backupdb = NULL;
 	const char			*opt_debug = NULL;
 	bool				opt_dumpdata = false;
@@ -366,7 +365,6 @@
 		{"database", 'f', POPT_ARG_STRING, NULL, OPT_PROFILE_DB, "set the profile database path", NULL},
 		{"profile", 'p', POPT_ARG_STRING, NULL, OPT_PROFILE, "set the profile name", NULL},
 		{"password", 'P', POPT_ARG_STRING, NULL, OPT_PASSWORD, "set the profile password", NULL},
-		{"config", 'c', POPT_ARG_STRING, NULL, OPT_CONFIG, "set openchangebackup configuration file path", NULL},
 		{"backup-db", 'b', POPT_ARG_STRING, NULL, OPT_BACKUPDB, "set the openchangebackup store path", NULL},
 		{"debuglevel", 0, POPT_ARG_STRING, NULL, OPT_DEBUG, "set the debug level", NULL},
 		{"dump-data", 0, POPT_ARG_NONE, NULL, OPT_DUMPDATA, "dump the hex data", NULL},
@@ -395,9 +393,6 @@
 		case OPT_PASSWORD:
 			opt_password = poptGetOptArg(pc);
 			break;
-		case OPT_CONFIG:
-			opt_config = poptGetOptArg(pc);
-			break;
 		case OPT_BACKUPDB:
 			opt_backupdb = poptGetOptArg(pc);
 			break;

Modified: trunk/openchange/utils/mapiprofile.c
===================================================================
--- trunk/openchange/utils/mapiprofile.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/utils/mapiprofile.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -33,20 +33,21 @@
 #define	DEFAULT_PROFDB	"%s/.openchange/profiles.ldb"
 #define	DEFAULT_LCID	"0x409" /* language code ID: en-US */
 
-static void mapiprofile_createdb(const char *profdb, const char *ldif_path)
+static bool mapiprofile_createdb(const char *profdb, const char *ldif_path)
 {
 	enum MAPISTATUS retval;
 	
 	if (access(profdb, F_OK) == 0) {
 		fprintf(stderr, "[ERROR] mapiprofile: %s already exists\n", profdb);
-		exit (1);
+		return false;
 	}
 
 	retval = CreateProfileStore(profdb, ldif_path);
 	if (retval != MAPI_E_SUCCESS) {
 		mapi_errstr("CreateProfileStore", GetLastError());
-		exit (1);
+		return false;
 	}
+	return true;
 }
 
 static uint32_t callback(struct SRowSet *rowset, void *private)
@@ -57,7 +58,6 @@
 	uint32_t		index;
 	char     		entry[10];
 	const char		*label = (const char *)private;
-	char			*s;
 
 	printf("%s:\n", label);
 	for (i = 0; i < rowset->cRows; i++) {
@@ -70,7 +70,11 @@
 	fd = fdopen(0, "r");
 getentry:
 	printf("Enter username id [0]: ");
-	s = fgets(entry, 10, fd);
+	if (fgets(entry, 10, fd) == NULL) {
+		printf("Failed to read string\n");
+		exit(1);
+	}
+
 	index = atoi(entry);
 	if (index > i) {
 		printf("Invalid id - Must be a value between 0 and %u\n", i);
@@ -96,7 +100,7 @@
 	exit (1);
 }
 
-static void mapiprofile_create(const char *profdb, const char *profname,
+static bool mapiprofile_create(const char *profdb, const char *profname,
 			       const char *pattern, const char *username, 
 			       const char *password, const char *address, 
 			       const char *lcid, const char *workstation,
@@ -123,7 +127,8 @@
 	retval = MAPIInitialize(profdb);
 	if (retval != MAPI_E_SUCCESS) {
 		mapi_errstr("MAPIInitialize", GetLastError());
-		exit (1);
+		talloc_free(mem_ctx);
+		return false;
 	}
 
 	/* debug options */
@@ -137,13 +142,16 @@
 	retval = OpenProfile(&profile, profname, NULL);
 	if (retval == MAPI_E_SUCCESS) {
 		fprintf(stderr, "[ERROR] mapiprofile: profile \"%s\" already exists\n", profname);
-		exit (1);
+		MAPIUninitialize();
+		talloc_free(mem_ctx);
+		return false;
 	}
 
 	retval = CreateProfile(profname, username, password, flags);
 	if (retval != MAPI_E_SUCCESS) {
 		mapi_errstr("CreateProfile", GetLastError());
-		exit (1);
+		talloc_free(mem_ctx);
+		return false;
 	}
 
 	mapi_profile_add_string_attr(profname, "binding", address);
@@ -179,7 +187,7 @@
 			mapi_errstr("DeleteProfile", GetLastError());
 		}
 		talloc_free(mem_ctx);
-		exit (1);
+		return false;
 	}
 
 	if (pattern) {
@@ -194,7 +202,7 @@
 			mapi_errstr("DeleteProfile", GetLastError());
 		}
 		talloc_free(mem_ctx);
-		exit (1);
+		return false;
 	}
 
 	printf("Profile %s completed and added to database %s\n", profname, profdb);
@@ -202,6 +210,8 @@
 	talloc_free(mem_ctx);
 
 	MAPIUninitialize();
+
+	return true;
 }
 
 static void mapiprofile_delete(const char *profdb, const char *profname)
@@ -520,8 +530,10 @@
 	const char	*profname = NULL;
 	const char	*rename = NULL;
 	const char	*attribute = NULL;
+	const char	*opt_tmp = NULL;
 	uint32_t	nopass = 0;
 	char		hostname[256];
+	int		retcode = EXIT_SUCCESS;
 
 	enum {OPT_PROFILE_DB=1000, OPT_PROFILE, OPT_ADDRESS, OPT_WORKSTATION,
 	      OPT_DOMAIN, OPT_REALM, OPT_USERNAME, OPT_LCID, OPT_PASSWORD, 
@@ -574,7 +586,10 @@
 			opt_debuglevel = poptGetOptArg(pc);
 			break;
 		case OPT_PROFILE_LDIF:
-			ldif = poptGetOptArg(pc);
+			opt_tmp = poptGetOptArg(pc);
+			ldif = talloc_strdup(mem_ctx, opt_tmp);
+			free((void*)opt_tmp);
+			opt_tmp = NULL;
 			break;
 		case OPT_PROFILE_NEWDB:
 			newdb = true;
@@ -586,7 +601,10 @@
 			getdflt = true;
 			break;
 		case OPT_PROFILE_DB:
-			profdb = poptGetOptArg(pc);
+			opt_tmp = poptGetOptArg(pc);
+			profdb = talloc_strdup(mem_ctx, opt_tmp); 
+			free((void*)opt_tmp);
+			opt_tmp = NULL;
 			break;
 		case OPT_PROFILE:
 			profname = poptGetOptArg(pc);
@@ -595,7 +613,10 @@
 			address = poptGetOptArg(pc);
 			break;
 		case OPT_WORKSTATION:
-			workstation = poptGetOptArg(pc);
+			opt_tmp = poptGetOptArg(pc);
+			workstation = talloc_strdup(mem_ctx, opt_tmp);
+			free((void*)opt_tmp);
+			opt_tmp = NULL;
 			break;
 		case OPT_DOMAIN:
 			domain = poptGetOptArg(pc);
@@ -607,7 +628,10 @@
 			username = poptGetOptArg(pc);
 			break;
 		case OPT_LCID:
-			lcid = poptGetOptArg(pc);
+			opt_tmp = poptGetOptArg(pc);
+			lcid = talloc_strdup(mem_ctx, opt_tmp);
+			free((void*)opt_tmp);
+			opt_tmp = NULL;
 			break;
 		case OPT_PATTERN:
 			pattern = poptGetOptArg(pc);
@@ -652,8 +676,8 @@
 		talloc_free(default_path);
 		if ((error == -1) && (errno != EEXIST)) {
 			perror("mkdir");
-			talloc_free(mem_ctx);
-			exit (1);
+			retcode = EXIT_FAILURE;
+			goto cleanup;
 		}
 		profdb = talloc_asprintf(mem_ctx, DEFAULT_PROFDB, 
 					 getenv("HOME"));
@@ -663,7 +687,8 @@
 	    && (getdflt == false) && (dump == false) && (rename == NULL) && 
 	    (!attribute) && (!profname || !profdb)) {
 		poptPrintUsage(pc, stderr, 0);
-		exit (1);
+		retcode = EXIT_FAILURE;
+		goto cleanup;
 	}
 
 	if (newdb == true) {
@@ -671,7 +696,10 @@
 			ldif = talloc_strdup(mem_ctx, mapi_profile_get_ldif_path());
 		}
 		if (!ldif) show_help(pc, "ldif");
-		mapiprofile_createdb(profdb, ldif);
+		if (!mapiprofile_createdb(profdb, ldif)) {
+			retcode = EXIT_FAILURE;
+			goto cleanup;
+		}
 	}
 
 	/* Process the code here */
@@ -687,14 +715,17 @@
 		if (!password) show_help(pc, "password");
 		if (!username) show_help(pc, "username");
 		if (!address) show_help(pc, "address");
-		if (!workstation) show_help(pc, "workstation");
 		if (!domain) show_help(pc, "domain");
 
 		if (!lcid) {
-		  lcid = talloc_asprintf(mem_ctx, DEFAULT_LCID);
+		  lcid = talloc_strdup(mem_ctx, DEFAULT_LCID);
 		}
-		mapiprofile_create(profdb, profname, pattern, username, password, address,
-				   lcid, workstation, domain, realm, nopass, opt_dumpdata, opt_debuglevel);
+		if (! mapiprofile_create(profdb, profname, pattern, username, password, address,
+					 lcid, workstation, domain, realm, nopass, opt_dumpdata,
+					 opt_debuglevel) ) {
+			retcode = EXIT_FAILURE;
+			goto cleanup;
+		}
 	}
 
 	if (rename) {
@@ -733,7 +764,20 @@
 		mapiprofile_attribute(profdb, profname, attribute);
 	}
 
+cleanup:
+	free((void*)opt_debuglevel);
+	free((void*)profname);
+	free((void*)address);
+	free((void*)domain);
+	free((void*)realm);
+	free((void*)username);
+	free((void*)pattern);
+	free((void*)password);
+	free((void*)rename);
+	free((void*)attribute);
+
+	poptFreeContext(pc);
 	talloc_free(mem_ctx);
 
-	return (0);
+	return retcode;
 }

Modified: trunk/openchange/utils/mapitest/mapitest.c
===================================================================
--- trunk/openchange/utils/mapitest/mapitest.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/utils/mapitest/mapitest.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -86,20 +86,20 @@
 				   const char *parameter)
 {
 	struct mapitest_unit	*el = NULL;
-	char			*tmp = NULL;
+	char			*temptok = NULL;
 
-	if ((tmp = strtok((char *)parameter, ";")) == NULL) {
+	if ((temptok = strtok((char *)parameter, ";")) == NULL) {
 		fprintf(stderr, "Invalid testname list [;]\n");
 		return false;
 	}
 
 	el = talloc_zero(mem_ctx, struct mapitest_unit);
-	el->name = talloc_strdup(mem_ctx, tmp);
+	el->name = talloc_strdup(mem_ctx, temptok);
 	DLIST_ADD(mt->cmdline_calls, el);
 
-	while ((tmp = strtok(NULL, ";")) != NULL) {
+	while ((temptok = strtok(NULL, ";")) != NULL) {
 		el = talloc_zero(mem_ctx, struct mapitest_unit);
-		el->name = talloc_strdup(mem_ctx, tmp);
+		el->name = talloc_strdup(mem_ctx, temptok);
 		DLIST_ADD_END(mt->cmdline_calls, el, struct mapitest_unit *);
 	}
 
@@ -142,22 +142,23 @@
 	enum MAPISTATUS		retval;
 	struct emsmdb_info	*info = NULL;
 	struct mapi_session	*session = NULL;
-	char			*profname = NULL;
 
+	/* if the user explicitly asked for just the no-server tests 
+	to be run, then we're done here */
 	if (mt->no_server == true) return 0;
 
 	mem_ctx = talloc_named(NULL, 0, "mapitest_get_server_info");
 
-	if (!profname) {
-	  retval = GetDefaultProfile(&profname);
+	/* if no profile was specified, get the default */
+	if (!opt_profname) {
+		retval = GetDefaultProfile(&opt_profname);
 		if (retval != MAPI_E_SUCCESS) {
 			mapi_errstr("GetDefaultProfile", retval);
 			talloc_free(mem_ctx);
 			return false;
 		}
-	} else {
-		profname = talloc_strdup(mem_ctx, opt_profname);
 	}
+		
 
 	/* debug options */
 	SetMAPIDumpData(opt_dumpdata);
@@ -166,8 +167,8 @@
 		SetMAPIDebugLevel(atoi(opt_debug));
 	}
 
-	retval = MapiLogonEx(&session, profname, password);
-	MAPIFreeBuffer(profname);
+	retval = MapiLogonEx(&session, opt_profname, password);
+	MAPIFreeBuffer(opt_profname);
 	talloc_free(mem_ctx);
 	if (retval != MAPI_E_SUCCESS) {
 		mapi_errstr("MapiLogonEx", retval);
@@ -203,20 +204,19 @@
 	const char     		*opt_debug = NULL;
 	const char		*opt_profdb = NULL;
 	char			*opt_profname = NULL;
-	const char		*opt_username = NULL;
 	const char		*opt_password = NULL;
 	const char		*opt_outfile = NULL;
+	char			*prof_tmp = NULL;
 
-	enum { OPT_PROFILE_DB=1000, OPT_PROFILE, OPT_USERNAME, OPT_PASSWORD,
-	       OPT_CONFIDENTIAL, OPT_OUTFILE, OPT_MAPI_ALL, OPT_MAPI_CALLS,
-	       OPT_MAPIADMIN_ALL, OPT_NO_SERVER, OPT_LIST_ALL, OPT_DUMP_DATA,
+	enum { OPT_PROFILE_DB=1000, OPT_PROFILE, OPT_PASSWORD,
+	       OPT_CONFIDENTIAL, OPT_OUTFILE, OPT_MAPI_CALLS,
+	       OPT_NO_SERVER, OPT_LIST_ALL, OPT_DUMP_DATA,
 	       OPT_DEBUG, OPT_COLOR };
 
 	struct poptOption long_options[] = {
 		POPT_AUTOHELP
 		{ "database",     'f', POPT_ARG_STRING, NULL, OPT_PROFILE_DB,    "set the profile database", NULL },
 		{ "profile",      'p', POPT_ARG_STRING, NULL, OPT_PROFILE,       "set the profile name", NULL },
-		{ "username",     'u', POPT_ARG_STRING, NULL, OPT_USERNAME,      "set the account username", NULL },
 		{ "password",     'p', POPT_ARG_STRING, NULL, OPT_PASSWORD,      "set the profile or account password", NULL },
 		{ "confidential",  0,  POPT_ARG_NONE,   NULL, OPT_CONFIDENTIAL,  "remove any sensitive data from the report", NULL },
 		{ "color",         0,  POPT_ARG_NONE,   NULL, OPT_COLOR,         "color MAPI retval", NULL },
@@ -248,11 +248,11 @@
 			opt_profdb = poptGetOptArg(pc);
 			break;
 		case OPT_PROFILE:
-		  opt_profname = talloc_strdup(mem_ctx, (char *)poptGetOptArg(pc));
+			prof_tmp = poptGetOptArg(pc);
+			opt_profname = talloc_strdup(mem_ctx, prof_tmp);
+			free(prof_tmp);
+			prof_tmp = NULL;
 			break;
-		case OPT_USERNAME:
-			opt_username = poptGetOptArg(pc);
-			break;
 		case OPT_PASSWORD:
 			opt_password = poptGetOptArg(pc);
 			break;
@@ -311,11 +311,10 @@
 	/* Run custom tests */
 	if (mt.cmdline_calls) {
 		struct mapitest_unit	*el;
-		bool			ret;
 		
 		for (el = mt.cmdline_calls; el; el = el->next) {
 			printf("[*] %s\n", el->name);
-			ret = mapitest_run_test(&mt, el->name);
+			mapitest_run_test(&mt, el->name);
 		}
 	} else {
 		mapitest_run_all(&mt);

Modified: trunk/openchange/utils/mapitest/mapitest_common.c
===================================================================
--- trunk/openchange/utils/mapitest/mapitest_common.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/utils/mapitest/mapitest_common.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -21,7 +21,6 @@
 
 #include <libmapi/libmapi.h>
 
-#include <utils/openchange-tools.h>
 #include <utils/mapitest/mapitest.h>
 
 #include <fcntl.h>
@@ -108,7 +107,7 @@
 	/* Retrieve the contents table */
 	mapi_object_init(&obj_ctable);
 	retval = GetContentsTable(obj_folder, &obj_ctable, 0, &count);
-	if (GetLastError() != MAPI_E_SUCCESS) {
+	if (retval != MAPI_E_SUCCESS) {
 		mapitest_print(mt, "* %-35s: 0x%.8x\n", "GetContentsTable", GetLastError());
 		mapi_object_release(&obj_ctable);
 		return false;
@@ -132,7 +131,12 @@
 				msgids[0] = SRowSet.aRow[i].lpProps[0].value.d;
 				msubject = (const char *)find_SPropValue_data(&SRowSet.aRow[i], PR_SUBJECT);
 				if (msubject && !strncmp(subject, msubject, strlen(subject))) {
-					DeleteMessage(obj_folder, msgids, 1);
+					retval = DeleteMessage(obj_folder, msgids, 1);
+					if (retval != MAPI_E_SUCCESS) {
+						mapitest_print_retval(mt, "DeleteMessage");
+						mapi_object_release(&obj_ctable);
+						return false;
+					}
 				}
 			}
 		}

Modified: trunk/openchange/utils/mapitest/mapitest_suite.c
===================================================================
--- trunk/openchange/utils/mapitest/mapitest_suite.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/utils/mapitest/mapitest_suite.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -100,44 +100,6 @@
 
 
 /**
-   \details add a simple test to the mapitest suite
-
-   \param suite pointer on the parent suite
-   \param name the test name
-   \param run the test function
-
-   \return MAPITEST_SUCCESS on success, otherwise MAPITEST_ERROR
-
-   \sa mapitest_suite_init, mapitest_suite_register
- */
-_PUBLIC_ uint32_t mapitest_suite_add_simple_test(struct mapitest_suite *suite,
-						 const char *name,
-						 bool (*run) (struct mapitest *test))
-{
-	struct mapitest_test	*el = NULL;
-
-	/* Sanity check */
-	if (!suite || !name || !run) return MAPITEST_ERROR;
-
-	/* Ensure the test is not yet registered */
-	for (el = suite->tests; el; el = el->next) {
-		if (el->name && !strcmp(el->name, name)) {
-			return MAPITEST_ERROR;
-		}
-	}
-
-	el = talloc_zero((TALLOC_CTX *) suite, struct mapitest_test);
-	el->name = talloc_asprintf((TALLOC_CTX *)suite, "%s-%s", suite->name, name);
-	el->description = NULL;
-	el->fn = run;
-
-	DLIST_ADD_END(suite->tests, el, struct mapitest_test *);
-
-	return MAPITEST_SUCCESS;
-}
-
-
-/**
    \details add a test to the mapitest suite with description
 
    \param suite pointer on the parent suite

Modified: trunk/openchange/utils/mapitest/modules/module_errorchecks.c
===================================================================
--- trunk/openchange/utils/mapitest/modules/module_errorchecks.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/utils/mapitest/modules/module_errorchecks.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -126,11 +126,11 @@
 	obj_store = &tmp;
 	obj_store->private_data = 0;
 	status = GetDefaultFolder(obj_store, folder, id);
-	if ( ( status != MAPI_E_NOT_INITIALIZED ) || (GetLastError() != MAPI_E_NOT_INITIALIZED) ) {
-		mapitest_print(mt, "* %-35s: [FAILURE] - 0x%x\n", "Step 6 - MAPI_E_NOT_INITIALIZED", status);
+	if ( (status != MAPI_E_INVALID_PARAMETER) || (GetLastError() != MAPI_E_INVALID_PARAMETER) ) {
+		mapitest_print(mt, "* %-35s: [FAILURE] - 0x%x\n", "Step 6 - MAPI_E_INVALID_PARAMETER", status);
 		return false;
 	} else {
-		mapitest_print(mt, "* %-35s: [SUCCESS]\n", "Step 6 - MAPI_E_NOT_INITIALIZED");
+		mapitest_print(mt, "* %-35s: [SUCCESS]\n", "Step 6 - MAPI_E_INVALID_PARAMETER");
 	}
 
 	make_global_ctx_invalid();

Modified: trunk/openchange/utils/mapitest/modules/module_oxcfold.c
===================================================================
--- trunk/openchange/utils/mapitest/modules/module_oxcfold.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/utils/mapitest/modules/module_oxcfold.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -145,7 +145,11 @@
 	mapitest_indent();
 	for (i = 0; inbox_folders[i].name; i++) {
 		mapi_object_init(&obj_folder);
-		GetDefaultFolder(&obj_store, &id_folder, inbox_folders[i].id);
+		retval = GetDefaultFolder(&obj_store, &id_folder, inbox_folders[i].id);
+		mapitest_print_retval_fmt(mt, "GetDefaultFolder", "(%s)", inbox_folders[i].name);
+		if (retval != MAPI_E_SUCCESS) {
+			return false;
+		}
 		retval = OpenFolder(&obj_store, id_folder, &obj_folder);
 		mapitest_print_retval_fmt(mt, "OpenFolder", "(%s)", inbox_folders[i].name);
 		if (retval != MAPI_E_SUCCESS) {
@@ -700,15 +704,18 @@
 
 	retval = Restrict(&(dst_contents), &res, NULL);
 	mapitest_print_retval(mt, "Restrict");
-	if (GetLastError() != MAPI_E_SUCCESS) {
+	if (retval != MAPI_E_SUCCESS) {
 		ret = false;
 	}
 
 	/* Step 7. Get the filtered row */
         SPropTagArray = set_SPropTagArray(mt->mem_ctx, 0x1, PR_MID);
-        SetColumns(&(dst_contents), SPropTagArray);
+        retval = SetColumns(&(dst_contents), SPropTagArray);
 	mapitest_print_retval(mt, "SetColumns");
 	MAPIFreeBuffer(SPropTagArray);
+	if (retval != MAPI_E_SUCCESS) {
+		ret = false;
+	}
 
 	QueryRows(&(dst_contents), 20, TBL_NOADVANCE, &SRowSet);
 	mapitest_print_retval(mt, "QueryRows");
@@ -1005,7 +1012,7 @@
 	}
 
 	mapi_object_init(&(contents));
-	GetContentsTable(&(obj_folder), &(contents), 0, &count);
+	retval = GetContentsTable(&(obj_folder), &(contents), 0, &count);
 	mapitest_print_retval(mt, "GetContentsTable");
 	if (retval != MAPI_E_SUCCESS) {
 		ret = false;
@@ -1056,7 +1063,7 @@
 
 	retval = QueryRows(&(contents), 50, TBL_NOADVANCE, &SRowSet);
 	mapitest_print_retval(mt, "QueryRows");
-	if ( (retval == MAPI_E_SUCCESS) && (SRowSet.cRows >= 0) ) {
+	if (retval == MAPI_E_SUCCESS) {
 		for (i = 0; i < SRowSet.cRows; ++i) {
 			msgid[i] = SRowSet.aRow[i].lpProps[0].value.d;
 		}

Modified: trunk/openchange/utils/mapitest/modules/module_oxcprpt.c
===================================================================
--- trunk/openchange/utils/mapitest/modules/module_oxcprpt.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/utils/mapitest/modules/module_oxcprpt.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -306,7 +306,7 @@
 
 	/* Step 2: Create reference folder */
 	mapi_object_init(&obj_ref_folder);
-        retval = CreateFolder(&obj_top_folder, FOLDER_GENERIC, MT_DIRNAME_TOP, NULL,
+	retval = CreateFolder(&obj_top_folder, FOLDER_GENERIC, MT_DIRNAME_TOP, NULL,
                               OPEN_IF_EXISTS, &obj_ref_folder);
 	mapitest_print_retval_step_fmt(mt, "2.", "CreateFolder", "(%s)", "Create the test folder");
 	if (retval != MAPI_E_SUCCESS) {
@@ -892,34 +892,24 @@
 	/* Step 7. Write the stream */
 	write_len = 0;
 
-	if (stream_len < MT_STREAM_MAX_SIZE) {
-		data.length = stream_len;
-		data.data = (uint8_t *) stream;
+	StreamSize = stream_len;
+
+	for (offset = 0, len = MT_STREAM_MAX_SIZE, i = 0; StreamSize; i++) {
+		data.length = len;
+		data.data = (uint8_t *)stream + offset;
 		retval = WriteStream(&obj_stream, &data, &write_len);
-		mapitest_print_retval_fmt(mt, "WriteStream", "(0x%x bytes written)", write_len);
+		mapitest_print_retval_fmt(mt, "WriteStream", "[%d] (0x%x bytes written)", i, write_len);
 		if (retval != MAPI_E_SUCCESS) {
 			ret = false;
+			break;
 		}
-	} else {
-		uint32_t	StreamSize = stream_len;
 
-		for (offset = 0, len = MT_STREAM_MAX_SIZE, i = 0; StreamSize; i++) {
-			data.length = len;
-			data.data = (uint8_t *)stream + offset;
-			retval = WriteStream(&obj_stream, &data, &write_len);
-			mapitest_print_retval_fmt(mt, "WriteStream", "[%d] (0x%x bytes written)", i, write_len);
-			if (retval != MAPI_E_SUCCESS) {
-				ret = false;
-				break;
-			}
-
-			StreamSize -= write_len;
-			if (StreamSize > MT_STREAM_MAX_SIZE) {
-				offset += MT_STREAM_MAX_SIZE;
-			} else {
-				offset += write_len;
-				len = StreamSize;
-			}
+		StreamSize -= write_len;
+		if (StreamSize > MT_STREAM_MAX_SIZE) {
+			offset += MT_STREAM_MAX_SIZE;
+		} else {
+			offset += write_len;
+			len = StreamSize;
 		}
 	}
 
@@ -1189,30 +1179,20 @@
 	/* Step 7. Write the stream */
 	write_len = 0;
 
-	if (stream_len < MT_STREAM_MAX_SIZE) {
-		data.length = stream_len;
-		data.data = (uint8_t *) stream;
+	StreamSize = stream_len;
+
+	for (offset = 0, len = MT_STREAM_MAX_SIZE, i = 0; StreamSize; i++) {
+		data.length = len;
+		data.data = (uint8_t *)stream + offset;
 		retval = WriteStream(&obj_stream, &data, &write_len);
-		mapitest_print_retval_fmt(mt, "WriteStream", "(0x%x bytes written)", write_len);
-		if (retval != MAPI_E_SUCCESS) {
-			ret = false;
-		}
-	} else {
-		uint32_t	StreamSize = stream_len;
+		mapitest_print_retval_fmt(mt, "WriteStream", "[%d] (0x%x bytes written)", i, write_len);
 
-		for (offset = 0, len = MT_STREAM_MAX_SIZE, i = 0; StreamSize; i++) {
-			data.length = len;
-			data.data = (uint8_t *)stream + offset;
-			retval = WriteStream(&obj_stream, &data, &write_len);
-			mapitest_print_retval_fmt(mt, "WriteStream", "[%d] (0x%x bytes written)", i, write_len);
-
-			StreamSize -= write_len;
-			if (StreamSize > MT_STREAM_MAX_SIZE) {
-				offset += MT_STREAM_MAX_SIZE;
-			} else {
-				offset += write_len;
-				len = StreamSize;
-			}
+		StreamSize -= write_len;
+		if (StreamSize > MT_STREAM_MAX_SIZE) {
+			offset += MT_STREAM_MAX_SIZE;
+		} else {
+			offset += write_len;
+			len = StreamSize;
 		}
 	}
 
@@ -1422,6 +1402,7 @@
 	mapi_object_init(&obj_ref_folder);
 	mapi_object_init(&obj_ref_message);
 	mapi_object_init(&obj_target_message);
+	mapi_object_init(&obj_ref_attach);
 	mapi_object_init(&obj_targ_attach);
 
 	retval = OpenMsgStore(mt->session, &obj_store);
@@ -1793,7 +1774,6 @@
 	}
 
 	/* Step 13: Create attachment on reference email, and set properties */
-	mapi_object_init(&obj_ref_attach);
 	retval = CreateAttach(&obj_ref_message, &obj_ref_attach);
 	mapitest_print_retval(mt, "CreateAttach");
 	if (retval != MAPI_E_SUCCESS) {
@@ -2073,7 +2053,7 @@
 	}
 
 	/* Step 2: Create test folder */
-        CreateFolder(&obj_top_folder, FOLDER_GENERIC, MT_DIRNAME_TOP, NULL,
+        retval = CreateFolder(&obj_top_folder, FOLDER_GENERIC, MT_DIRNAME_TOP, NULL,
 		     OPEN_IF_EXISTS, &obj_ref_folder);
 	mapitest_print_retval(mt, "CreateFolder");
 	if (retval != MAPI_E_SUCCESS) {

Modified: trunk/openchange/utils/mapitest/modules/module_oxomsg.c
===================================================================
--- trunk/openchange/utils/mapitest/modules/module_oxomsg.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/utils/mapitest/modules/module_oxomsg.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -240,19 +240,24 @@
 	id_msgs[0] = mapi_object_get_id(&obj_message);
 	retval = DeleteMessage(&obj_folder, id_msgs, 1);
 	mapitest_print_retval(mt, "DeleteMessage");
-	if ((retval != MAPI_E_SUCCESS) && (GetLastError() != ecNoDelSubmitMsg)) {
+	if ((retval != MAPI_E_SUCCESS) && (retval != ecNoDelSubmitMsg)) {
 		ret = false;
 	}
 	/* Step 6. Clean up anything else */
 	mapitest_common_message_delete_by_subject(mt, &obj_folder, MT_MAIL_SUBJECT);
-	GetDefaultFolder(&obj_store, &id_folder, olFolderInbox);
-	OpenFolder(&obj_store, id_folder, &obj_folder);
-	if (GetLastError() != MAPI_E_SUCCESS) {
+	retval = GetDefaultFolder(&obj_store, &id_folder, olFolderInbox);
+	if (retval != MAPI_E_SUCCESS) {
 		ret = false;
+		goto mapitest_oxomsg_AbortSubmit_bailout;
+	}
+	retval = OpenFolder(&obj_store, id_folder, &obj_folder);
+	if (retval != MAPI_E_SUCCESS) {
+		ret = false;
 	} else {
 		mapitest_common_message_delete_by_subject(mt, &obj_folder, MT_MAIL_SUBJECT);
 	}
 
+mapitest_oxomsg_AbortSubmit_bailout:
 	/* Release */
 	mapi_object_release(&obj_message);
 	mapi_object_release(&obj_folder);
@@ -466,14 +471,20 @@
 
 	/* Step 6. Clean up anything else */
 	mapitest_common_message_delete_by_subject(mt, &obj_folder, MT_MAIL_SUBJECT);
-	GetDefaultFolder(&obj_store, &id_folder, olFolderInbox);
-	OpenFolder(&obj_store, id_folder, &obj_folder);
-	if (GetLastError() != MAPI_E_SUCCESS) {
+	retval = GetDefaultFolder(&obj_store, &id_folder, olFolderInbox);
+	if (retval != MAPI_E_SUCCESS) {
 		ret = false;
+		goto mapitest_oxomsg_TransportSend_bailout;
+	}
+
+	retval = OpenFolder(&obj_store, id_folder, &obj_folder);
+	if (retval != MAPI_E_SUCCESS) {
+		ret = false;
 	} else {
 		mapitest_common_message_delete_by_subject(mt, &obj_folder, MT_MAIL_SUBJECT);
 	}
 
+mapitest_oxomsg_TransportSend_bailout:
 	/* Release */
 	mapi_object_release(&obj_message);
 	mapi_object_release(&obj_folder);

Modified: trunk/openchange/utils/openchangeclient.c
===================================================================
--- trunk/openchange/utils/openchangeclient.c	2009-09-12 12:09:36 UTC (rev 3045)
+++ trunk/openchange/utils/openchangeclient.c	2009-09-12 12:31:49 UTC (rev 3046)
@@ -115,7 +115,6 @@
 	char     		**folder  = NULL;
 	const char		*name;
 	const uint64_t		*fid;
-	const uint32_t		*child;
 	bool			found = false;
 	uint32_t		index;
 	uint32_t		i;
@@ -131,10 +130,9 @@
 		retval = GetHierarchyTable(&obj_folder, &obj_htable, 0, NULL);
 		MAPI_RETVAL_IF(retval, GetLastError(), folder);
 
-		SPropTagArray = set_SPropTagArray(mem_ctx, 0x3,
+		SPropTagArray = set_SPropTagArray(mem_ctx, 0x2,
 						  PR_DISPLAY_NAME,
-						  PR_FID,
-						  PR_FOLDER_CHILD_COUNT);
+						  PR_FID);
 		retval = SetColumns(&obj_htable, SPropTagArray);
 		MAPIFreeBuffer(SPropTagArray);
 		MAPI_RETVAL_IF(retval, retval, folder);
@@ -143,7 +141,6 @@
 			for (index = 0; (index < SRowSet.cRows) && (found == false); index++) {
 				fid = (const uint64_t *)find_SPropValue_data(&SRowSet.aRow[index], PR_FID);
 				name = (const char *)find_SPropValue_data(&SRowSet.aRow[index], PR_DISPLAY_NAME);
-				child = (const uint32_t *)find_SPropValue_data(&SRowSet.aRow[index], PR_FOLDER_CHILD_COUNT);
 
 				newname = utf8tolinux(mem_ctx, name);
 				if (newname && fid && !strcmp(newname, folder[i])) {
@@ -199,12 +196,12 @@
 	struct stat	sb;
 	int		fd;
 
-	/* stat the file */
-	if (stat(filename, &sb) != 0) return false;
 	if ((fd = open(filename, O_RDONLY)) == -1) {
 		printf("Error while opening %s\n", filename);
 		return false;
 	}
+	/* stat the file */
+	if (fstat(fd, &sb) != 0) return false;
 
 	switch (mapitag) {
 	case PR_HTML:
@@ -3363,6 +3360,9 @@
 
 	/* Uninitialize MAPI subsystem */
 end:
+
+	poptFreeContext(pc);
+
 	mapi_object_release(&obj_store);
 
 	MAPIUninitialize();




More information about the Pkg-samba-maint mailing list