From 473a578ad8719f011f042f4791ec6a2d938de16b Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Wed, 29 Jul 2009 10:13:20 +0000 Subject: [PATCH] Add a simple utility to dump flattened BMessages. Added it to the image as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31897 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- build/jam/HaikuImage | 2 +- src/bin/Jamfile | 1 + src/bin/message.cpp | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/bin/message.cpp diff --git a/build/jam/HaikuImage b/build/jam/HaikuImage index ef27d45c8c..2400286d75 100644 --- a/build/jam/HaikuImage +++ b/build/jam/HaikuImage @@ -44,7 +44,7 @@ SYSTEM_BIN = "[" addattr alert arp base64 basename bash bc beep bootman bzip2 keymap kill less lessecho lesskey link linkcatkeys listarea listattr listimage listdev listport listres listsem listusb ln locate logger login logname ls lsindex - makebootable md5sum merge mimeset mkdos mkdir mkfifo mkfs mkindex + makebootable md5sum merge message mimeset mkdos mkdir mkfifo mkfs mkindex modifiers mount mount_nfs mountvolume mv nc netstat nl nohup od open diff --git a/src/bin/Jamfile b/src/bin/Jamfile index fdbd62908f..d6b93cbf0a 100644 --- a/src/bin/Jamfile +++ b/src/bin/Jamfile @@ -88,6 +88,7 @@ StdBinCommands listres.cpp mimeset.cpp mkindex.cpp + message.cpp modifiers.cpp open.cpp play.cpp diff --git a/src/bin/message.cpp b/src/bin/message.cpp new file mode 100644 index 0000000000..f96b322daa --- /dev/null +++ b/src/bin/message.cpp @@ -0,0 +1,36 @@ +/* + * Copyright 2009, Michael Lotz, mmlr@mlotz.ch. + * Distributed under the terms of the MIT License. + */ + +#include +#include + +#include +#include + + +int +main(int argc, char *argv[]) +{ + if (argc != 2) { + printf("usage: %s \n", argv[0]); + return 1; + } + + BFile input(argv[1], B_READ_ONLY); + if (!input.IsReadable()) { + printf("cannot open \"%s\" for reading\n", argv[1]); + return 2; + } + + BMessage message; + status_t result = message.Unflatten(&input); + if (result != B_OK) { + printf("failed to unflatten message: %s\n", strerror(result)); + return 3; + } + + message.PrintToStream(); + return 0; +}