1 /* 2 * Copyright 2009, Michael Lotz, mmlr@mlotz.ch. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #include <File.h> 7 #include <Message.h> 8 9 #include <stdio.h> 10 #include <string.h> 11 12 13 int 14 main(int argc, char *argv[]) 15 { 16 if (argc != 2) { 17 printf("usage: %s <flattened message file>\n", argv[0]); 18 return 1; 19 } 20 21 BFile input(argv[1], B_READ_ONLY); 22 if (!input.IsReadable()) { 23 printf("cannot open \"%s\" for reading\n", argv[1]); 24 return 2; 25 } 26 27 BMessage message; 28 status_t result = message.Unflatten(&input); 29 if (result != B_OK) { 30 printf("failed to unflatten message: %s\n", strerror(result)); 31 return 3; 32 } 33 34 message.PrintToStream(); 35 return 0; 36 } 37