20 #ifndef WINPR_CMDLINE_H
21 #define WINPR_CMDLINE_H
23 #include <winpr/winpr.h>
24 #include <winpr/wtypes.h>
28 #define COMMAND_LINE_INPUT_FLAG_MASK 0x0000FFFF
29 #define COMMAND_LINE_OUTPUT_FLAG_MASK 0xFFFF0000
33 #define COMMAND_LINE_VALUE_FLAG 0x00000001
34 #define COMMAND_LINE_VALUE_REQUIRED 0x00000002
35 #define COMMAND_LINE_VALUE_OPTIONAL 0x00000004
36 #define COMMAND_LINE_VALUE_BOOL 0x00000008
38 #define COMMAND_LINE_ADVANCED 0x00000100
39 #define COMMAND_LINE_PRINT 0x00000200
40 #define COMMAND_LINE_PRINT_HELP 0x00000400
41 #define COMMAND_LINE_PRINT_VERSION 0x00000800
42 #define COMMAND_LINE_PRINT_BUILDCONFIG 0x00001000
46 #define COMMAND_LINE_ARGUMENT_PRESENT 0x80000000
47 #define COMMAND_LINE_VALUE_PRESENT 0x40000000
51 #define COMMAND_LINE_SIGIL_NONE 0x00000001
52 #define COMMAND_LINE_SIGIL_SLASH 0x00000002
53 #define COMMAND_LINE_SIGIL_DASH 0x00000004
54 #define COMMAND_LINE_SIGIL_DOUBLE_DASH 0x00000008
55 #define COMMAND_LINE_SIGIL_PLUS_MINUS 0x00000010
56 #define COMMAND_LINE_SIGIL_ENABLE_DISABLE 0x00000020
57 #define COMMAND_LINE_SIGIL_NOT_ESCAPED 0x00000040
59 #define COMMAND_LINE_SEPARATOR_COLON 0x00000100
60 #define COMMAND_LINE_SEPARATOR_EQUAL 0x00000200
61 #define COMMAND_LINE_SEPARATOR_SPACE 0x00000400
64 #define COMMAND_LINE_IGN_UNKNOWN_KEYWORD 0x00001000
65 #define COMMAND_LINE_SILENCE_PARSER 0x00002000
69 #define COMMAND_LINE_ERROR -1000
70 #define COMMAND_LINE_ERROR_NO_KEYWORD -1001
71 #define COMMAND_LINE_ERROR_UNEXPECTED_VALUE -1002
72 #define COMMAND_LINE_ERROR_MISSING_VALUE -1003
73 #define COMMAND_LINE_ERROR_MISSING_ARGUMENT -1004
74 #define COMMAND_LINE_ERROR_UNEXPECTED_SIGIL -1005
75 #define COMMAND_LINE_ERROR_MEMORY -1006
76 #define COMMAND_LINE_ERROR_LAST -1999
80 #define COMMAND_LINE_STATUS_PRINT -2001
81 #define COMMAND_LINE_STATUS_PRINT_HELP -2002
82 #define COMMAND_LINE_STATUS_PRINT_VERSION -2003
83 #define COMMAND_LINE_STATUS_PRINT_BUILDCONFIG -2004
84 #define COMMAND_LINE_STATUS_PRINT_LAST -2999
88 #define CommandLineSwitchStart(_arg) \
92 #define CommandLineSwitchCase(_arg, _name) else if (strcmp(_arg->Name, _name) == 0)
93 #define CommandLineSwitchDefault(_arg) else
94 #define CommandLineSwitchEnd(_arg)
96 #define BoolValueTrue ((LPSTR)1)
97 #define BoolValueFalse ((LPSTR)0)
124 #define COMMAND_LINE_ARGUMENT COMMAND_LINE_ARGUMENT_W
126 #define COMMAND_LINE_ARGUMENT COMMAND_LINE_ARGUMENT_A
129 typedef int (*COMMAND_LINE_PRE_FILTER_FN_A)(
void* context,
int index,
int argc, LPSTR* argv);
130 typedef int (*COMMAND_LINE_PRE_FILTER_FN_W)(
void* context,
int index,
int argc, LPWSTR* argv);
143 WINPR_API
int CommandLineParseArgumentsA(
int argc, LPSTR* argv,
145 void* context, COMMAND_LINE_PRE_FILTER_FN_A preFilter,
146 COMMAND_LINE_POST_FILTER_FN_A postFilter);
147 WINPR_API
int CommandLineParseArgumentsW(
int argc, LPWSTR* argv,
149 void* context, COMMAND_LINE_PRE_FILTER_FN_W preFilter,
150 COMMAND_LINE_POST_FILTER_FN_W postFilter);
166 WINPR_API
void CommandLineParserFree(
char** ptr);
168 WINPR_ATTR_MALLOC(CommandLineParserFree, 1)
169 WINPR_API
char** CommandLineParseCommaSeparatedValues(const
char* list,
size_t* count);
171 WINPR_ATTR_MALLOC(CommandLineParserFree, 1)
172 WINPR_API
char** CommandLineParseCommaSeparatedValuesEx(const
char* name, const
char* list,
175 WINPR_ATTR_MALLOC(free, 1)
176 WINPR_API
char* CommandLineToCommaSeparatedValues(
int argc,
char* argv[]);
178 WINPR_ATTR_MALLOC(free, 1)
179 WINPR_API
char* CommandLineToCommaSeparatedValuesEx(
int argc,
char* argv[],
180 const
char* filters[],
size_t number);
187 #define CommandLineClearArguments CommandLineClearArgumentsW
188 #define CommandLineParseArguments CommandLineParseArgumentsW
189 #define CommandLineFindArgument CommandLineFindArgumentW
191 #define CommandLineClearArguments CommandLineClearArgumentsA
192 #define CommandLineParseArguments CommandLineParseArgumentsA
193 #define CommandLineFindArgument CommandLineFindArgumentA