source: trunk/tools/common/kDump.cpp@ 10367

Last change on this file since 10367 was 8003, checked in by bird, 24 years ago

New kFile* classes; now in sync with os2tools.

File size: 2.0 KB
Line 
1/* $Id: kDump.cpp,v 1.4 2002-02-24 02:47:24 bird Exp $
2 *
3 * Generic dumper...
4 *
5 * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
6 *
7 * Project Odin Software License can be found in LICENSE.TXT
8 *
9 */
10
11
12
13/*******************************************************************************
14* Defined Constants And Macros *
15*******************************************************************************/
16#define INCL_BASE
17
18/*******************************************************************************
19* Header Files *
20*******************************************************************************/
21#include <stdio.h>
22
23#include "kTypes.h"
24#include "kError.h"
25#include "kFile.h"
26#include "kFileFormatBase.h"
27#include "kFileInterfaces.h"
28#include "kFileDef.h"
29#include "kFileLX.h"
30#include "kFilePE.h"
31
32
33
34
35int main(int argc, char **argv)
36{
37 int argi;
38
39
40 for (argi = 1; argi < argc; argi++)
41 {
42 try
43 {
44 kFileFormatBase * pFile = NULL;
45 try {pFile = new kFilePE(new kFile(argv[argi]));}
46 catch (kError err)
47 {
48 try {pFile = new kFileLX(new kFile(argv[argi]));}
49 catch (kError err)
50 {
51 try {pFile = new kFileDef(new kFile(argv[argi]));}
52 catch (kError err)
53 {
54 kFile::StdErr.printf("Failed to recognize file %s.\n", argv[argi]);
55 return -2;
56 }
57 }
58 }
59
60 /*
61 * If successfully opened, then dump it.
62 */
63 if (pFile != NULL)
64 {
65 pFile->dump(&kFile::StdOut);
66 delete pFile;
67 }
68 }
69 catch (kError err)
70 {
71 fprintf(stderr, "Fatal: Failed to open file %s err=%d.\n", argv[argi], err.getErrno());
72 return -1;
73 }
74 }
75 return 0;
76}
Note: See TracBrowser for help on using the repository browser.