From 7120e97489acbf17d86d3f33e3b2e68974fd4b23 Mon Sep 17 00:00:00 2001 From: beveloper Date: Wed, 25 Dec 2002 23:20:24 +0000 Subject: [PATCH] a small tool to print files that consist of a flattened BMessage git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2304 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tools/Jamfile | 1 + src/tools/unflatten/Jamfile | 4 ++++ src/tools/unflatten/unflatten.cpp | 28 ++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 src/tools/unflatten/Jamfile create mode 100644 src/tools/unflatten/unflatten.cpp diff --git a/src/tools/Jamfile b/src/tools/Jamfile index 602383e43c..f8b6623f2b 100644 --- a/src/tools/Jamfile +++ b/src/tools/Jamfile @@ -2,4 +2,5 @@ SubDir OBOS_TOP src tools ; SubInclude OBOS_TOP src tools cppunit ; SubInclude OBOS_TOP src tools hey ; +SubInclude OBOS_TOP src tools unflatten ; diff --git a/src/tools/unflatten/Jamfile b/src/tools/unflatten/Jamfile new file mode 100644 index 0000000000..7fe0b78a9b --- /dev/null +++ b/src/tools/unflatten/Jamfile @@ -0,0 +1,4 @@ +SubDir OBOS_TOP src tools unflatten ; + +BinCommand unflatten : unflatten.cpp : be ; + diff --git a/src/tools/unflatten/unflatten.cpp b/src/tools/unflatten/unflatten.cpp new file mode 100644 index 0000000000..f1e8d248d6 --- /dev/null +++ b/src/tools/unflatten/unflatten.cpp @@ -0,0 +1,28 @@ +/* + * Copyright 2002, Marcus Overhagen. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#include +#include +#include + +int main(int argc, char *argv[]) +{ + BFile file; + BMessage msg; + if (argc != 2) { + fprintf(stderr, "You need to specify a filename on the command line.\n"); + return 1; + } + if (B_OK != file.SetTo(argv[1], O_RDONLY)) { + fprintf(stderr, "File \"%s\" not found.\n", argv[1]); + return 1; + } + if (B_OK != msg.Unflatten(&file)) { + fprintf(stderr, "Unflatten failed.\n"); + return 1; + } + msg.PrintToStream(); + return 0; +}