blob: ed4a85659e4cbe0d597346e733ab58f897580bb4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
#ifndef __CONSOLEARGS_H__
#define __CONSOLEARGS_H__
#include "list.h"
#include "tree.h"
#include <strsafe.h>
#include "palclr.h"
typedef tree<LPCWSTR> b_tree;
typedef list<WCHAR*> WStrList;
const LPCWSTR kOutOfMemory = W("Out of memory");
class ConsoleArgs
{
public:
// Place the fully-qualified filename in the given output buffer
bool GetFullFileName(LPCWSTR szSource, __out_ecount(cbFilenameBuffer) LPWSTR filenameBuffer, DWORD cbFilenameBuffer, bool fOutputFilename);
ConsoleArgs() :
m_rgArgs(NULL),
m_listArgs(NULL),
m_errorOccured(false),
m_lastErrorMessage(nullptr)
{
};
~ConsoleArgs()
{
CleanUpArgs();
};
// returns false if there are errors
bool ExpandResponseFiles(__in int argc, __deref_in_ecount(argc) const LPCWSTR * argv, int * pargc2, __deref_out_ecount(*pargc2) LPWSTR ** pppargv2);
// Frees all memory used by the arg list and the argv/argc array
void CleanUpArgs();
LPCWSTR ErrorMessage()
{
if (m_errorOccured)
{
return m_lastErrorMessage;
}
else
{
return nullptr;
}
}
private:
void SetErrorMessage(__in LPCWSTR pwzMessage);
b_tree * MakeLeaf( LPCWSTR szText);
void CleanupTree( b_tree * root);
HRESULT TreeAdd( b_tree ** root, LPCWSTR szAdd);
void TextToArgs( LPCWSTR szText, WStrList ** listReplace);
bool ReadTextFile(LPCWSTR pwzFilename, __deref_out LPWSTR *ppwzTextBuffer);
void ProcessResponseArgs();
LPWSTR * m_rgArgs;
WStrList * m_listArgs;
bool m_errorOccured;
LPCWSTR m_lastErrorMessage;
};
#endif // __CONSOLEARGS_H__
|