Julien, team,

Please find attached a couple of patches for the mapiprofile utility.

The 0001 patch changes the status message for the --default option to make it read a little better.

The 0002 patch fixes the sanity check for an existing profile that has the same name, when creating a new profile. The "profile" argument to OpenProfile needs to be talloc'd, but we were just passing on the stack. This results in an error like:
        Bad talloc magic value - unknown value
        Aborted

I'm obviously a little rusty with OpenChange, so would like a review if you have time.

Brad
>From e3a00fc78e1be5059cc423a74ddc3d85e9f594df Mon Sep 17 00:00:00 2001
From: Brad Hards <[email protected]>
Date: Sun, 7 Apr 2013 11:23:17 +1000
Subject: [PATCH 1/2] Reword status message for setting default profile in
 mapiprofile

---
 utils/mapiprofile.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/utils/mapiprofile.c b/utils/mapiprofile.c
index 4773a3c..f24163c 100644
--- a/utils/mapiprofile.c
+++ b/utils/mapiprofile.c
@@ -307,7 +307,7 @@ static void mapiprofile_set_default(struct mapi_context *mapi_ctx, const char *p
 		exit (1);
 	}
 
-	printf("Profile %s is now set the default one\n", profname);
+	printf("Profile \"%s\" is now the default profile\n", profname);
 }
 
 static void mapiprofile_get_default(struct mapi_context *mapi_ctx, const char *profdb)
-- 
1.7.5.4

>From 8d819680e1b507f1b01fab0a71c14a069831697b Mon Sep 17 00:00:00 2001
From: Brad Hards <[email protected]>
Date: Sun, 7 Apr 2013 11:38:42 +1000
Subject: [PATCH 2/2] Fix check for an existing profile (with the same name)
 in profile creation

The API documentation for OpenProfile requires that the profile arg be talloc'd.
In this case, reality actually does match the docs.
---
 utils/mapiprofile.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/utils/mapiprofile.c b/utils/mapiprofile.c
index f24163c..8fce749 100644
--- a/utils/mapiprofile.c
+++ b/utils/mapiprofile.c
@@ -134,7 +134,7 @@ static bool mapiprofile_create(struct mapi_context *mapi_ctx,
 	enum MAPISTATUS		retval;
 	struct mapi_session	*session = NULL;
 	TALLOC_CTX		*mem_ctx;
-	struct mapi_profile	profile;
+	struct mapi_profile	*profile;
 	const char		*locale;
 	uint32_t		cpid = 0;
 	uint32_t		lcid = 0;
@@ -143,6 +143,7 @@ static bool mapiprofile_create(struct mapi_context *mapi_ctx,
 	char			*lcid_str;
 
 	mem_ctx = talloc_named(mapi_ctx->mem_ctx, 0, "mapiprofile_create");
+	profile = talloc(mem_ctx, struct mapi_profile);
 
 	/* catch CTRL-C */
 	g_profname = profname;
@@ -164,7 +165,7 @@ static bool mapiprofile_create(struct mapi_context *mapi_ctx,
 	}
 
 	/* Sanity check */
-	retval = OpenProfile(mapi_ctx, &profile, profname, NULL);
+	retval = OpenProfile(mapi_ctx, profile, profname, NULL);
 	if (retval == MAPI_E_SUCCESS) {
 		fprintf(stderr, "[ERROR] mapiprofile: profile \"%s\" already exists\n", profname);
 		talloc_free(mem_ctx);
-- 
1.7.5.4

_______________________________________________
devel mailing list
[email protected]
http://mailman.openchange.org/listinfo/devel

Reply via email to