| 54 | |
| 55 | |
| 56 | BOOL parseCommandLine(const TCHAR* cmdLine, Options& options) |
| 57 | { |
| 58 | /* Command line options are |
| 59 | * -a <actionsFile.xml> |
| 60 | * -w <windowName> |
| 61 | * -e <exeToRun> |
| 62 | * |
| 63 | * w and e are mandatory |
| 64 | */ |
| 65 | |
| 66 | if (!cmdLine) |
| 67 | return TRUE; |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | tstring* arg; |
| 73 | arg = new tstring; |
| 74 | |
| 75 | list<tstring*> argList; |
| 76 | |
| 77 | enum PARSEMODE |
| 78 | { |
| 79 | PARSEMODE_START, |
| 80 | PARSEMODE_STANDARD, |
| 81 | PARSEMODE_QUOTED |
| 82 | } parseMode; |
| 83 | |
| 84 | parseMode = PARSEMODE_START; |
| 85 | |
| 86 | while(*cmdLine) |
| 87 | { |
| 88 | |
| 89 | switch(parseMode) |
| 90 | { |
| 91 | case PARSEMODE_START: |
| 92 | if (*cmdLine == _T('\"')) |
| 93 | { |
| 94 | parseMode = PARSEMODE_QUOTED; |
| 95 | } |
| 96 | else if (*cmdLine != _T(' ')) |
| 97 | { |
| 98 | arg->push_back(*cmdLine); |
| 99 | parseMode = PARSEMODE_STANDARD; |
| 100 | } |
| 101 | |
| 102 | break; |
| 103 | |
| 104 | |
| 105 | case PARSEMODE_STANDARD: |
| 106 | if (*cmdLine == _T(' ')) |
| 107 | { |
| 108 | parseMode = PARSEMODE_START; |
| 109 | argList.push_back(arg); |
| 110 | arg = new tstring; |
| 111 | } |
| 112 | else |
| 113 | { |
no test coverage detected