|
Last change
on this file since 5702 was 5531, checked in by bird, 25 years ago |
|
Second iteration of the kFile* classes and interfaces.
|
|
File size:
2.0 KB
|
| Line | |
|---|
| 1 | /* $Id: kDump.cpp,v 1.3 2001-04-17 00:26:10 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 "kInterfaces.h"
|
|---|
| 28 | #include "kFileDef.h"
|
|---|
| 29 | #include "kFileLX.h"
|
|---|
| 30 | #include "kFilePE.h"
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 | int main(int argc, char **argv)
|
|---|
| 36 | {
|
|---|
| 37 | int argi;
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 | for (argi = 1; argi < argc; argi++)
|
|---|
| 41 | {
|
|---|
| 42 | try
|
|---|
| 43 | {
|
|---|
| 44 | kFile file(argv[argi]);
|
|---|
| 45 | kFileFormatBase * pFile = NULL;
|
|---|
| 46 | try {pFile = new kFilePE(&file);}
|
|---|
| 47 | catch (int err)
|
|---|
| 48 | {
|
|---|
| 49 | try {pFile = new kFileLX(&file);}
|
|---|
| 50 | catch (int err)
|
|---|
| 51 | {
|
|---|
| 52 | try {pFile = new kFileDef(&file);}
|
|---|
| 53 | catch (int err)
|
|---|
| 54 | {
|
|---|
| 55 | kFile::StdErr.printf("Failed to recognize file %s.\n", argv[argi]);
|
|---|
| 56 | return -2;
|
|---|
| 57 | }
|
|---|
| 58 | }
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | /*
|
|---|
| 62 | * If successfully opened, then dump it.
|
|---|
| 63 | */
|
|---|
| 64 | if (pFile != NULL)
|
|---|
| 65 | {
|
|---|
| 66 | pFile->dump(&kFile::StdOut);
|
|---|
| 67 | delete pFile;
|
|---|
| 68 | }
|
|---|
| 69 | }
|
|---|
| 70 | catch (int err)
|
|---|
| 71 | {
|
|---|
| 72 | fprintf(stderr, "Fatal: Failed to open file %s err=%d.\n", argv[argi], err);
|
|---|
| 73 | return -1;
|
|---|
| 74 | }
|
|---|
| 75 | }
|
|---|
| 76 | return 0;
|
|---|
| 77 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.