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

Last change on this file since 4360 was 4360, checked in by bird, 25 years ago

Initial coding for limited kFilePE dump support.

File size: 2.0 KB
Line 
1/* $Id: kDump.cpp,v 1.1 2000-10-02 04:07:44 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 <os2.h>
22
23#include <stdio.h>
24
25#include "kFile.h"
26#include "kFileFormatBase.h"
27#include "kFileDef.h"
28#include "kFileLX.h"
29#include "kFilePE.h"
30
31
32
33
34int main(int argc, char **argv)
35{
36 int argi;
37
38
39 for (argi = 1; argi < argc; argi++)
40 {
41 FILE *phFile = fopen(argv[argi], "rb");
42 if (phFile)
43 {
44 kFileFormatBase *pFile = NULL;
45 try {pFile = new kFilePE(phFile);}
46 catch (int err)
47 {
48 //try {pFile = new kFileLX(phFile);}
49 //catch (int err)
50 {
51 try {pFile = new kFileDef(phFile);}
52 catch (int 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 fclose(phFile);
69 }
70 else
71 {
72 fprintf(stderr, "Fatal: Failed to open file %s.\n", argv[argi]);
73 return -1;
74 }
75 }
76 return 0;
77}
Note: See TracBrowser for help on using the repository browser.