2012-11-02 08:20:46 +04:00
|
|
|
|
|
|
|
#include <winpr/crt.h>
|
|
|
|
#include <winpr/tchar.h>
|
|
|
|
#include <winpr/cmdline.h>
|
|
|
|
|
|
|
|
const char* testArgv[] =
|
|
|
|
{
|
|
|
|
"mstsc.exe",
|
2012-11-05 01:09:43 +04:00
|
|
|
"+z",
|
2012-11-02 08:20:46 +04:00
|
|
|
"/w:1024",
|
|
|
|
"/h:768",
|
2012-11-05 01:09:43 +04:00
|
|
|
"/bpp:32",
|
2012-11-02 08:20:46 +04:00
|
|
|
"/admin",
|
|
|
|
"/multimon",
|
2012-11-05 01:09:43 +04:00
|
|
|
"+fonts",
|
|
|
|
"-wallpaper",
|
2012-11-02 08:20:46 +04:00
|
|
|
"/v:localhost:3389"
|
|
|
|
};
|
|
|
|
|
|
|
|
COMMAND_LINE_ARGUMENT_A args[] =
|
|
|
|
{
|
2012-11-07 03:49:02 +04:00
|
|
|
{ "v", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "destination server" },
|
|
|
|
{ "port", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "server port" },
|
|
|
|
{ "w", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "width" },
|
|
|
|
{ "h", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "height" },
|
|
|
|
{ "f", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "fullscreen" },
|
|
|
|
{ "bpp", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "session bpp (color depth)" },
|
|
|
|
{ "admin", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "console", "admin (or console) session" },
|
|
|
|
{ "multimon", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "multi-monitor" },
|
|
|
|
{ "a", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, "addin", "addin" },
|
|
|
|
{ "u", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "username" },
|
|
|
|
{ "p", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "password" },
|
|
|
|
{ "d", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "domain" },
|
|
|
|
{ "z", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "compression" },
|
|
|
|
{ "audio", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "audio output mode" },
|
|
|
|
{ "mic", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "audio input (microphone)" },
|
|
|
|
{ "fonts", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "smooth fonts (cleartype)" },
|
|
|
|
{ "aero", COMMAND_LINE_VALUE_BOOL, NULL, NULL, BoolValueFalse, -1, NULL, "desktop composition" },
|
|
|
|
{ "window-drag", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "full window drag" },
|
|
|
|
{ "menu-anims", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "menu animations" },
|
|
|
|
{ "themes", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "themes" },
|
|
|
|
{ "wallpaper", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "wallpaper" },
|
|
|
|
{ "codec", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "codec" },
|
|
|
|
{ "nego", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "protocol security negotiation" },
|
|
|
|
{ "sec", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "force specific protocol security" },
|
|
|
|
{ "sec-rdp", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "rdp protocol security" },
|
|
|
|
{ "sec-tls", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "tls protocol security" },
|
|
|
|
{ "sec-nla", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "nla protocol security" },
|
|
|
|
{ "sec-ext", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "nla extended protocol security" },
|
|
|
|
{ "cert-name", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "certificate name" },
|
|
|
|
{ "cert-ignore", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "ignore certificate" },
|
|
|
|
{ "version", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_VERSION, NULL, NULL, NULL, -1, NULL, "print version" },
|
|
|
|
{ "help", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, NULL, NULL, NULL, -1, "?", "print help" },
|
|
|
|
{ NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
|
2012-11-02 08:20:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define testArgc (sizeof(testArgv) / sizeof(testArgv[0]))
|
|
|
|
|
|
|
|
int TestCmdLine(int argc, char* argv[])
|
|
|
|
{
|
2012-11-02 22:16:37 +04:00
|
|
|
int status;
|
2012-11-02 08:58:32 +04:00
|
|
|
DWORD flags;
|
2013-03-15 23:41:10 +04:00
|
|
|
int width = 0;
|
|
|
|
int height = 0;
|
2012-11-02 08:58:32 +04:00
|
|
|
COMMAND_LINE_ARGUMENT_A* arg;
|
|
|
|
|
2012-11-05 01:09:43 +04:00
|
|
|
flags = COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_SIGIL_PLUS_MINUS;
|
2012-11-07 08:07:03 +04:00
|
|
|
status = CommandLineParseArgumentsA(testArgc, testArgv, args, flags, NULL, NULL, NULL);
|
2012-11-02 08:58:32 +04:00
|
|
|
|
2012-11-02 22:16:37 +04:00
|
|
|
if (status != 0)
|
|
|
|
{
|
|
|
|
printf("CommandLineParseArgumentsA failure: %d\n", status);
|
2012-11-02 08:20:46 +04:00
|
|
|
return -1;
|
2012-11-02 22:16:37 +04:00
|
|
|
}
|
2012-11-02 08:20:46 +04:00
|
|
|
|
2012-11-02 08:58:32 +04:00
|
|
|
arg = CommandLineFindArgumentA(args, "w");
|
|
|
|
|
|
|
|
if (strcmp("1024", arg->Value) != 0)
|
2012-11-02 22:16:37 +04:00
|
|
|
{
|
|
|
|
printf("CommandLineFindArgumentA: unexpected %s value %s\n", arg->Name, arg->Value);
|
2012-11-02 08:20:46 +04:00
|
|
|
return -1;
|
2012-11-02 22:16:37 +04:00
|
|
|
}
|
2012-11-02 08:20:46 +04:00
|
|
|
|
2012-11-02 08:58:32 +04:00
|
|
|
arg = CommandLineFindArgumentA(args, "h");
|
|
|
|
|
|
|
|
if (strcmp("768", arg->Value) != 0)
|
2012-11-02 22:16:37 +04:00
|
|
|
{
|
|
|
|
printf("CommandLineFindArgumentA: unexpected %s value %s\n", arg->Name, arg->Value);
|
2012-11-02 08:20:46 +04:00
|
|
|
return -1;
|
2012-11-02 22:16:37 +04:00
|
|
|
}
|
2012-11-02 08:20:46 +04:00
|
|
|
|
2012-11-02 08:58:32 +04:00
|
|
|
arg = CommandLineFindArgumentA(args, "f");
|
|
|
|
|
|
|
|
if (arg->Value)
|
2012-11-02 22:16:37 +04:00
|
|
|
{
|
|
|
|
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
|
2012-11-02 08:20:46 +04:00
|
|
|
return -1;
|
2012-11-02 22:16:37 +04:00
|
|
|
}
|
2012-11-02 08:20:46 +04:00
|
|
|
|
2012-11-02 08:58:32 +04:00
|
|
|
arg = CommandLineFindArgumentA(args, "admin");
|
|
|
|
|
|
|
|
if (!arg->Value)
|
2012-11-02 22:16:37 +04:00
|
|
|
{
|
|
|
|
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
|
2012-11-02 08:20:46 +04:00
|
|
|
return -1;
|
2012-11-02 22:16:37 +04:00
|
|
|
}
|
2012-11-02 08:20:46 +04:00
|
|
|
|
2012-11-02 08:58:32 +04:00
|
|
|
arg = CommandLineFindArgumentA(args, "multimon");
|
|
|
|
|
|
|
|
if (!arg->Value)
|
2012-11-02 22:16:37 +04:00
|
|
|
{
|
|
|
|
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
|
2012-11-02 08:20:46 +04:00
|
|
|
return -1;
|
2012-11-02 22:16:37 +04:00
|
|
|
}
|
2012-11-02 08:20:46 +04:00
|
|
|
|
2012-11-02 08:58:32 +04:00
|
|
|
arg = CommandLineFindArgumentA(args, "v");
|
|
|
|
|
|
|
|
if (strcmp("localhost:3389", arg->Value) != 0)
|
2012-11-02 22:16:37 +04:00
|
|
|
{
|
|
|
|
printf("CommandLineFindArgumentA: unexpected %s value %s\n", arg->Name, arg->Value);
|
2012-11-02 08:20:46 +04:00
|
|
|
return -1;
|
2012-11-02 22:16:37 +04:00
|
|
|
}
|
2012-11-02 08:20:46 +04:00
|
|
|
|
2012-11-05 01:09:43 +04:00
|
|
|
arg = CommandLineFindArgumentA(args, "fonts");
|
|
|
|
|
|
|
|
if (!arg->Value)
|
|
|
|
{
|
|
|
|
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
arg = CommandLineFindArgumentA(args, "wallpaper");
|
|
|
|
|
|
|
|
if (arg->Value)
|
|
|
|
{
|
|
|
|
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-11-07 03:49:02 +04:00
|
|
|
arg = CommandLineFindArgumentA(args, "help");
|
2012-11-02 08:58:32 +04:00
|
|
|
|
|
|
|
if (arg->Value)
|
2012-11-02 22:16:37 +04:00
|
|
|
{
|
|
|
|
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
|
2012-11-02 08:20:46 +04:00
|
|
|
return -1;
|
2012-11-02 22:16:37 +04:00
|
|
|
}
|
2012-11-02 08:20:46 +04:00
|
|
|
|
2012-11-05 01:09:43 +04:00
|
|
|
arg = args;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
printf("Argument: %s\n", arg->Name);
|
|
|
|
|
|
|
|
CommandLineSwitchStart(arg)
|
|
|
|
|
|
|
|
CommandLineSwitchCase(arg, "v")
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "w")
|
|
|
|
{
|
|
|
|
width = atoi(arg->Value);
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "h")
|
|
|
|
{
|
|
|
|
height = atoi(arg->Value);
|
|
|
|
}
|
|
|
|
CommandLineSwitchDefault(arg)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CommandLineSwitchEnd(arg)
|
|
|
|
}
|
|
|
|
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
|
|
|
|
|
|
|
if ((width != 1024) || (height != 768))
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
printf("Unexpected width and height: Actual: (%dx%d), Expected: (1024x768)\n", width, height);
|
2012-11-05 01:09:43 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-11-02 08:20:46 +04:00
|
|
|
return 0;
|
|
|
|
}
|