2006-08-25 17:50:26 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
2007-10-19 23:21:45 +00:00
|
|
|
* PROJECT: ReactOS net command
|
2015-09-09 13:13:35 +00:00
|
|
|
* FILE: base/applications/network/net/main.c
|
2007-10-19 23:21:45 +00:00
|
|
|
* PURPOSE:
|
2006-08-25 17:50:26 +00:00
|
|
|
*
|
2007-10-19 23:21:45 +00:00
|
|
|
* PROGRAMMERS: Magnus Olsen (greatlord@reactos.org)
|
2006-08-25 17:50:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "net.h"
|
|
|
|
|
2014-05-31 08:32:54 +00:00
|
|
|
#define MAX_BUFFER_SIZE 4096
|
|
|
|
|
2012-09-24 12:37:12 +00:00
|
|
|
typedef struct _COMMAND
|
2007-10-19 23:21:45 +00:00
|
|
|
{
|
2012-09-24 12:37:12 +00:00
|
|
|
WCHAR *name;
|
|
|
|
INT (*func)(INT, WCHAR**);
|
|
|
|
// VOID (*help)(INT, WCHAR**);
|
|
|
|
} COMMAND, *PCOMMAND;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2012-09-24 12:37:12 +00:00
|
|
|
COMMAND cmds[] =
|
|
|
|
{
|
2014-05-28 08:06:10 +00:00
|
|
|
{L"accounts", cmdAccounts},
|
2012-09-24 12:37:12 +00:00
|
|
|
{L"computer", unimplemented},
|
|
|
|
{L"config", unimplemented},
|
2013-04-30 02:57:30 +00:00
|
|
|
{L"continue", cmdContinue},
|
2012-09-24 12:37:12 +00:00
|
|
|
{L"file", unimplemented},
|
|
|
|
{L"group", unimplemented},
|
|
|
|
{L"help", cmdHelp},
|
2013-04-30 02:57:30 +00:00
|
|
|
{L"helpmsg", cmdHelpMsg},
|
2014-10-19 20:12:19 +00:00
|
|
|
{L"localgroup", cmdLocalGroup},
|
2012-09-24 12:37:12 +00:00
|
|
|
{L"name", unimplemented},
|
2013-04-30 02:57:30 +00:00
|
|
|
{L"pause", cmdPause},
|
2014-06-09 12:56:05 +00:00
|
|
|
{L"print", unimplemented},
|
2012-09-24 12:37:12 +00:00
|
|
|
{L"send", unimplemented},
|
|
|
|
{L"session", unimplemented},
|
|
|
|
{L"share", unimplemented},
|
|
|
|
{L"start", cmdStart},
|
|
|
|
{L"statistics", unimplemented},
|
|
|
|
{L"stop", cmdStop},
|
|
|
|
{L"time", unimplemented},
|
2016-08-02 10:10:25 +00:00
|
|
|
{L"use", cmdUse},
|
2014-10-23 18:36:11 +00:00
|
|
|
{L"user", cmdUser},
|
2012-09-24 12:37:12 +00:00
|
|
|
{L"view", unimplemented},
|
2013-04-30 02:57:30 +00:00
|
|
|
{NULL, NULL}
|
2012-09-24 12:37:12 +00:00
|
|
|
};
|
|
|
|
|
2014-05-31 08:32:54 +00:00
|
|
|
|
2014-10-25 21:27:05 +00:00
|
|
|
|
2014-11-08 21:44:32 +00:00
|
|
|
VOID
|
|
|
|
PrintPaddedResourceString(
|
2016-10-07 22:50:32 +00:00
|
|
|
UINT uID,
|
2014-11-09 13:39:20 +00:00
|
|
|
INT nPaddedLength)
|
2014-11-08 21:44:32 +00:00
|
|
|
{
|
2016-10-07 22:50:32 +00:00
|
|
|
INT nLength;
|
2014-11-08 21:44:32 +00:00
|
|
|
|
2016-10-07 22:50:32 +00:00
|
|
|
nLength = ConResPuts(StdOut, uID);
|
2014-11-08 21:44:32 +00:00
|
|
|
if (nLength < nPaddedLength)
|
2016-10-07 22:50:32 +00:00
|
|
|
PrintPadding(L' ', nPaddedLength - nLength);
|
2014-11-08 21:44:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-16 10:34:49 +00:00
|
|
|
VOID
|
|
|
|
PrintPadding(
|
|
|
|
WCHAR chr,
|
|
|
|
INT nPaddedLength)
|
|
|
|
{
|
|
|
|
INT i;
|
2016-10-07 22:50:32 +00:00
|
|
|
WCHAR szMsgBuffer[MAX_BUFFER_SIZE];
|
2014-11-16 10:34:49 +00:00
|
|
|
|
|
|
|
for (i = 0; i < nPaddedLength; i++)
|
|
|
|
szMsgBuffer[i] = chr;
|
|
|
|
szMsgBuffer[nPaddedLength] = UNICODE_NULL;
|
|
|
|
|
2016-10-07 22:50:32 +00:00
|
|
|
ConPuts(StdOut, szMsgBuffer);
|
2014-05-31 08:32:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-08 14:35:27 +00:00
|
|
|
VOID
|
|
|
|
ReadFromConsole(
|
|
|
|
LPWSTR lpInput,
|
|
|
|
DWORD dwLength,
|
|
|
|
BOOL bEcho)
|
|
|
|
{
|
|
|
|
DWORD dwOldMode;
|
|
|
|
DWORD dwRead = 0;
|
|
|
|
HANDLE hFile;
|
|
|
|
LPWSTR p;
|
|
|
|
PCHAR pBuf;
|
|
|
|
|
|
|
|
pBuf = HeapAlloc(GetProcessHeap(), 0, dwLength - 1);
|
|
|
|
ZeroMemory(lpInput, dwLength * sizeof(WCHAR));
|
|
|
|
hFile = GetStdHandle(STD_INPUT_HANDLE);
|
|
|
|
GetConsoleMode(hFile, &dwOldMode);
|
|
|
|
|
|
|
|
SetConsoleMode(hFile, ENABLE_LINE_INPUT | (bEcho ? ENABLE_ECHO_INPUT : 0));
|
|
|
|
|
|
|
|
ReadFile(hFile, (PVOID)pBuf, dwLength - 1, &dwRead, NULL);
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_OEMCP, 0, pBuf, dwRead, lpInput, dwLength - 1);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pBuf);
|
|
|
|
|
|
|
|
for (p = lpInput; *p; p++)
|
|
|
|
{
|
|
|
|
if (*p == L'\x0d')
|
|
|
|
{
|
|
|
|
*p = L'\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetConsoleMode(hFile, dwOldMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-24 12:37:12 +00:00
|
|
|
int wmain(int argc, WCHAR **argv)
|
|
|
|
{
|
|
|
|
PCOMMAND cmdptr;
|
2006-08-25 17:50:26 +00:00
|
|
|
|
2016-10-07 22:50:32 +00:00
|
|
|
/* Initialize the Console Standard Streams */
|
|
|
|
ConInitStdStreams();
|
|
|
|
|
2012-09-24 12:37:12 +00:00
|
|
|
if (argc < 2)
|
2006-08-25 17:50:26 +00:00
|
|
|
{
|
2016-10-07 22:50:32 +00:00
|
|
|
ConResPuts(StdOut, IDS_NET_SYNTAX);
|
2012-09-24 12:37:12 +00:00
|
|
|
return 1;
|
2006-08-25 17:50:26 +00:00
|
|
|
}
|
|
|
|
|
2012-09-24 12:37:12 +00:00
|
|
|
/* Scan the command table */
|
|
|
|
for (cmdptr = cmds; cmdptr->name; cmdptr++)
|
2006-08-25 17:50:26 +00:00
|
|
|
{
|
2012-09-24 12:37:12 +00:00
|
|
|
if (_wcsicmp(argv[1], cmdptr->name) == 0)
|
|
|
|
{
|
|
|
|
return cmdptr->func(argc, argv);
|
|
|
|
}
|
2006-08-25 17:50:26 +00:00
|
|
|
}
|
|
|
|
|
2016-10-07 22:50:32 +00:00
|
|
|
ConResPuts(StdOut, IDS_NET_SYNTAX);
|
2012-09-24 12:37:12 +00:00
|
|
|
|
|
|
|
return 1;
|
2006-08-25 17:50:26 +00:00
|
|
|
}
|
|
|
|
|
2012-09-24 12:37:12 +00:00
|
|
|
INT unimplemented(INT argc, WCHAR **argv)
|
2006-08-25 17:50:26 +00:00
|
|
|
{
|
2016-10-07 22:50:32 +00:00
|
|
|
ConPuts(StdOut, L"This command is not implemented yet\n");
|
2012-09-24 12:37:12 +00:00
|
|
|
return 1;
|
2006-08-25 17:50:26 +00:00
|
|
|
}
|