| 1 | // | 
|---|
| 2 | // Copyright (c) Microsoft. All rights reserved. | 
|---|
| 3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. | 
|---|
| 4 | // | 
|---|
| 5 |  | 
|---|
| 6 | #include "standardpch.h" | 
|---|
| 7 | #include "mcs.h" | 
|---|
| 8 | #include "commandline.h" | 
|---|
| 9 | #include "verbasmdump.h" | 
|---|
| 10 | #include "verbinteg.h" | 
|---|
| 11 | #include "verbdump.h" | 
|---|
| 12 | #include "verbfracture.h" | 
|---|
| 13 | #include "verbdumpmap.h" | 
|---|
| 14 | #include "verbdumptoc.h" | 
|---|
| 15 | #include "verbildump.h" | 
|---|
| 16 | #include "verbtoc.h" | 
|---|
| 17 | #include "verbremovedup.h" | 
|---|
| 18 | #include "verbstat.h" | 
|---|
| 19 | #include "verbconcat.h" | 
|---|
| 20 | #include "verbmerge.h" | 
|---|
| 21 | #include "verbstrip.h" | 
|---|
| 22 | #include "logging.h" | 
|---|
| 23 |  | 
|---|
| 24 | int __cdecl main(int argc, char* argv[]) | 
|---|
| 25 | { | 
|---|
| 26 | #ifdef FEATURE_PAL | 
|---|
| 27 | if (0 != PAL_Initialize(argc, argv)) | 
|---|
| 28 | { | 
|---|
| 29 | fprintf(stderr, "Error: Fail to PAL_Initialize\n"); | 
|---|
| 30 | exit(1); | 
|---|
| 31 | } | 
|---|
| 32 | #endif // FEATURE_PAL | 
|---|
| 33 |  | 
|---|
| 34 | Logger::Initialize(); | 
|---|
| 35 |  | 
|---|
| 36 | CommandLine::Options o; | 
|---|
| 37 | if (!CommandLine::Parse(argc, argv, &o)) | 
|---|
| 38 | { | 
|---|
| 39 | return -1; | 
|---|
| 40 | } | 
|---|
| 41 |  | 
|---|
| 42 | // execute the chosen command. | 
|---|
| 43 | int exitCode = 0; | 
|---|
| 44 | if (o.actionASMDump) | 
|---|
| 45 | { | 
|---|
| 46 | exitCode = verbASMDump::DoWork(o.nameOfFile1, o.nameOfFile2, o.indexCount, o.indexes); | 
|---|
| 47 | } | 
|---|
| 48 | if (o.actionConcat) | 
|---|
| 49 | { | 
|---|
| 50 | exitCode = verbConcat::DoWork(o.nameOfFile1, o.nameOfFile2); | 
|---|
| 51 | } | 
|---|
| 52 | if (o.actionMerge) | 
|---|
| 53 | { | 
|---|
| 54 | exitCode = verbMerge::DoWork(o.nameOfFile1, o.nameOfFile2, o.recursive); | 
|---|
| 55 | } | 
|---|
| 56 | if (o.actionCopy) | 
|---|
| 57 | { | 
|---|
| 58 | exitCode = verbStrip::DoWork(o.nameOfFile1, o.nameOfFile2, o.indexCount, o.indexes, false, o.stripCR); | 
|---|
| 59 | } | 
|---|
| 60 | if (o.actionDump) | 
|---|
| 61 | { | 
|---|
| 62 | exitCode = verbDump::DoWork(o.nameOfFile1, o.indexCount, o.indexes); | 
|---|
| 63 | } | 
|---|
| 64 | if (o.actionFracture) | 
|---|
| 65 | { | 
|---|
| 66 | exitCode = verbFracture::DoWork(o.nameOfFile1, o.nameOfFile2, o.indexCount, o.indexes, o.stripCR); | 
|---|
| 67 | } | 
|---|
| 68 | if (o.actionDumpMap) | 
|---|
| 69 | { | 
|---|
| 70 | exitCode = verbDumpMap::DoWork(o.nameOfFile1); | 
|---|
| 71 | } | 
|---|
| 72 | if (o.actionDumpToc) | 
|---|
| 73 | { | 
|---|
| 74 | exitCode = verbDumpToc::DoWork(o.nameOfFile1); | 
|---|
| 75 | } | 
|---|
| 76 | if (o.actionILDump) | 
|---|
| 77 | { | 
|---|
| 78 | exitCode = verbILDump::DoWork(o.nameOfFile1, o.indexCount, o.indexes); | 
|---|
| 79 | } | 
|---|
| 80 | if (o.actionInteg) | 
|---|
| 81 | { | 
|---|
| 82 | exitCode = verbInteg::DoWork(o.nameOfFile1); | 
|---|
| 83 | } | 
|---|
| 84 | if (o.actionRemoveDup) | 
|---|
| 85 | { | 
|---|
| 86 | exitCode = verbRemoveDup::DoWork(o.nameOfFile1, o.nameOfFile2, o.stripCR, o.legacyCompare); | 
|---|
| 87 | } | 
|---|
| 88 | if (o.actionStat) | 
|---|
| 89 | { | 
|---|
| 90 | exitCode = verbStat::DoWork(o.nameOfFile1, o.nameOfFile2, o.indexCount, o.indexes); | 
|---|
| 91 | } | 
|---|
| 92 | if (o.actionStrip) | 
|---|
| 93 | { | 
|---|
| 94 | exitCode = verbStrip::DoWork(o.nameOfFile1, o.nameOfFile2, o.indexCount, o.indexes, true, o.stripCR); | 
|---|
| 95 | } | 
|---|
| 96 | if (o.actionTOC) | 
|---|
| 97 | { | 
|---|
| 98 | exitCode = verbTOC::DoWork(o.nameOfFile1); | 
|---|
| 99 | } | 
|---|
| 100 |  | 
|---|
| 101 | Logger::Shutdown(); | 
|---|
| 102 | return exitCode; | 
|---|
| 103 | } | 
|---|
| 104 |  | 
|---|