2 * Copyright 2009, Michael Lotz, mmlr@mlotz.ch.
3 * Distributed under the terms of the MIT License.
15 main(int argc
, char *argv
[])
17 if (argc
< 2 || argc
> 3) {
18 printf("usage: %s <flattened message file> [index]\n", argv
[0]);
22 BFile
input(argv
[1], B_READ_ONLY
);
23 if (!input
.IsReadable()) {
24 printf("cannot open \"%s\" for reading\n", argv
[1]);
30 if ((result
= input
.GetSize(&fileSize
)) != B_OK
) {
31 printf("cannot determine size of file \"%s\"\n", argv
[1]);
35 int index
= argc
> 2 ? atoi(argv
[2]) : 0;
37 for (int i
= 1; input
.Position() < fileSize
; ++i
) {
39 result
= message
.Unflatten(&input
);
41 printf("failed to unflatten message: %s\n", strerror(result
));
44 if (index
== 0 || i
== index
)
45 message
.PrintToStream();