Commit 8238c1d4 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

tasklist: Support '/nh' option.

parent 62af0b5f
......@@ -163,17 +163,21 @@ static BOOL tasklist_get_process_info(const PROCESSENTRY32W *process_entry, stru
return TRUE;
}
static void tasklist_print(void)
static void tasklist_print(const struct tasklist_options *options)
{
struct tasklist_process_info header, info;
PROCESSENTRY32W *process_list;
DWORD process_count, i;
wprintf(L"\n");
tasklist_get_header(&header);
wprintf(L"%-25.25s %8.8s %-16.16s %11.11s %12.12s\n"
L"========================= ======== ================ =========== ============\n",
header.image_name, header.pid, header.session_name, header.session_number, header.memory_usage);
if (!options->no_header)
{
tasklist_get_header(&header);
wprintf(L"%-25.25s %8.8s %-16.16s %11.11s %12.12s\n"
L"========================= ======== ================ =========== ============\n",
header.image_name, header.pid, header.session_name, header.session_number, header.memory_usage);
}
process_list = enumerate_processes(&process_count);
for (i = 0; i < process_count; ++i)
......@@ -189,6 +193,7 @@ static void tasklist_print(void)
int __cdecl wmain(int argc, WCHAR *argv[])
{
struct tasklist_options options = {0};
int i;
for (i = 0; i < argc; i++)
......@@ -202,12 +207,16 @@ int __cdecl wmain(int argc, WCHAR *argv[])
tasklist_message(STRING_USAGE);
return 0;
}
else if (!wcsicmp(argv[i], L"/nh"))
{
options.no_header = TRUE;
}
else
{
WINE_WARN("Ignoring option %s\n", wine_dbgstr_w(argv[i]));
}
}
tasklist_print();
tasklist_print(&options);
return 0;
}
......@@ -36,3 +36,8 @@ struct tasklist_process_info
WCHAR session_number[32];
WCHAR memory_usage[32];
};
struct tasklist_options
{
BOOL no_header;
};
......@@ -108,6 +108,20 @@ static void test_basic(void)
ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size);
}
static void test_no_header(void)
{
char *pos;
/* /nh */
run_tasklist("/nh", 0);
ok(stdout_size > 0, "Unexpected stdout buffer size %ld.\n", stdout_size);
ok(stderr_size == 0, "Unexpected stderr buffer size %ld.\n", stderr_size);
pos = strstr(stdout_buffer, "Image Name");
ok(!pos, "Got header.\n");
pos = strstr(stdout_buffer, "=");
ok(!pos, "Got header.\n");
}
START_TEST(tasklist)
{
if (PRIMARYLANGID(GetUserDefaultUILanguage()) != LANG_ENGLISH)
......@@ -117,4 +131,5 @@ START_TEST(tasklist)
}
test_basic();
test_no_header();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment