* adjusted 'message' to be able to deal with more than a single message
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40254 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
439859b9a7
commit
81b0e79a7b
|
@ -7,14 +7,15 @@
|
|||
#include <Message.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2) {
|
||||
printf("usage: %s <flattened message file>\n", argv[0]);
|
||||
if (argc < 2 || argc > 3) {
|
||||
printf("usage: %s <flattened message file> [index]\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -24,13 +25,25 @@ main(int argc, char *argv[])
|
|||
return 2;
|
||||
}
|
||||
|
||||
BMessage message;
|
||||
status_t result = message.Unflatten(&input);
|
||||
if (result != B_OK) {
|
||||
printf("failed to unflatten message: %s\n", strerror(result));
|
||||
off_t fileSize;
|
||||
status_t result;
|
||||
if ((result = input.GetSize(&fileSize)) != B_OK) {
|
||||
printf("cannot determine size of file \"%s\"\n", argv[1]);
|
||||
return 3;
|
||||
}
|
||||
|
||||
message.PrintToStream();
|
||||
int index = argc > 2 ? atoi(argv[2]) : 0;
|
||||
|
||||
for (int i = 1; input.Position() < fileSize; ++i) {
|
||||
BMessage message;
|
||||
result = message.Unflatten(&input);
|
||||
if (result != B_OK) {
|
||||
printf("failed to unflatten message: %s\n", strerror(result));
|
||||
return 4;
|
||||
}
|
||||
if (index == 0 || i == index)
|
||||
message.PrintToStream();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue