https://git.reactos.org/?p=reactos.git;a=commitdiff;h=611e6d7d0e1b080a31a1757bf1f59419584bc946
commit 611e6d7d0e1b080a31a1757bf1f59419584bc946 Author: Eric Kohl <eric.k...@reactos.org> AuthorDate: Mon May 20 22:35:11 2019 +0200 Commit: Eric Kohl <eric.k...@reactos.org> CommitDate: Mon May 20 22:36:10 2019 +0200 [NET] Start parsing the /times option of the USER command. Only '/times:' and '/times:all' are accepted yet. --- base/applications/network/net/cmdUser.c | 69 +++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/base/applications/network/net/cmdUser.c b/base/applications/network/net/cmdUser.c index 314a8b28e74..81506ea6cec 100644 --- a/base/applications/network/net/cmdUser.c +++ b/base/applications/network/net/cmdUser.c @@ -809,6 +809,53 @@ ParseDate( } +static +DWORD +ParseLogonHours( + PWSTR pszParams, + PBYTE *ppLogonHours, + PDWORD pdwUnitsPerWeek) +{ + PBYTE pLogonHours = NULL; + DWORD dwError = ERROR_SUCCESS; + + pLogonHours = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + UNITS_PER_WEEK / 8); + if (pLogonHours == NULL) + return ERROR_OUTOFMEMORY; + + if (*pszParams == UNICODE_NULL) + { + goto done; + } + + if (wcsicmp(pszParams, L"all") == 0) + { + FillMemory(pLogonHours, UNITS_PER_WEEK / 8, 0xFF); + goto done; + } + + /* FIXME */ + /* Mockup error because we do not parse the line yet */ + dwError = 3768; + +done: + if (dwError == ERROR_SUCCESS) + { + *ppLogonHours = pLogonHours; + *pdwUnitsPerWeek = UNITS_PER_WEEK; + } + else + { + if (pLogonHours != NULL) + HeapFree(GetProcessHeap(), 0, pLogonHours); + } + + return dwError; +} + + INT cmdUser( INT argc, @@ -831,6 +878,8 @@ cmdUser( LPWSTR endptr; DWORD value; BOOL bPasswordAllocated = FALSE; + PBYTE pLogonHours = NULL; + DWORD dwUnitsPerWeek; NET_API_STATUS Status; i = 2; @@ -884,7 +933,7 @@ cmdUser( ConPrintf(StdOut, L"Status: %lu\n", Status); return 0; } - else if (lpUserName != NULL && lpPassword == NULL) + else if (lpUserName != NULL && lpPassword == NULL && argc == 3) { Status = DisplayUser(lpUserName); ConPrintf(StdOut, L"Status: %lu\n", Status); @@ -1039,8 +1088,19 @@ cmdUser( } else if (_wcsnicmp(argv[j], L"/times:", 7) == 0) { - /* FIXME */ - ConPuts(StdErr, L"The /TIMES option is not supported yet.\n"); + Status = ParseLogonHours(&argv[j][7], + &pLogonHours, + &dwUnitsPerWeek); + if (Status == ERROR_SUCCESS) + { + pUserInfo->usri4_logon_hours = pLogonHours; + pUserInfo->usri4_units_per_week = dwUnitsPerWeek; + } + else + { + PrintMessageString(Status); + goto done; + } } else if (_wcsnicmp(argv[j], L"/usercomment:", 13) == 0) { @@ -1105,6 +1165,9 @@ cmdUser( } done: + if (pLogonHours != NULL) + HeapFree(GetProcessHeap(), 0, pLogonHours); + if (pWorkstations != NULL) HeapFree(GetProcessHeap(), 0, pWorkstations);