X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=base%2Fapplications%2Fnetwork%2Fnet%2Fmain.c;h=298b875caf96245d770a8eff43c6ceacaf417da2;hp=f8adf735559cdd4ba0887ff41f8e3be12235779d;hb=23a90aab5a5b4eb323a9ca0b0a267dc156528422;hpb=7f2624f282608e1458b7611109edef148a918c8a diff --git a/base/applications/network/net/main.c b/base/applications/network/net/main.c index f8adf735559..298b875caf9 100644 --- a/base/applications/network/net/main.c +++ b/base/applications/network/net/main.c @@ -1,8 +1,7 @@ - /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS net command - * FILE: + * FILE: base/applications/network/net/main.c * PURPOSE: * * PROGRAMMERS: Magnus Olsen (greatlord@reactos.org) @@ -10,129 +9,139 @@ #include "net.h" +#define MAX_BUFFER_SIZE 4096 - -int main(int argc, char **argv) +typedef struct _COMMAND { - if (argc<2) - { - help(); - return 1; - } - - if (_stricmp(argv[1],"ACCOUNTS")==0) - { - return unimplemented(); - } - if (_stricmp(argv[1],"COMPUTER")==0) - { - return unimplemented(); - } - if (_stricmp(argv[1],"CONFIG")==0) - { - return unimplemented(); - } - if (_stricmp(argv[1],"CONTINUE")==0) - { - return unimplemented(); - } - - if (_stricmp(argv[1],"FILE")==0) - { - return unimplemented(); - } - if (_stricmp(argv[1],"GROUP")==0) - { - return unimplemented(); - } - if (_stricmp(argv[1],"HELP")==0) - { - return cmdHelp(argc,&argv[1]); - } - if (_stricmp(argv[1],"HELPMSG")==0) - { - return unimplemented(); - } - if (_stricmp(argv[1],"LOCALGROUP")==0) - { - return unimplemented(); - } - if (_stricmp(argv[1],"NAME")==0) - { - return unimplemented(); - } - if (_stricmp(argv[1],"PRINT")==0) - { - return unimplemented(); - } - if (_stricmp(argv[1],"SEND")==0) - { - return unimplemented(); - } - if (_stricmp(argv[1],"SESSION")==0) - { - return unimplemented(); - } - if (_stricmp(argv[1],"SHARE")==0) - { - return unimplemented(); - } + WCHAR *name; + INT (*func)(INT, WCHAR**); +// VOID (*help)(INT, WCHAR**); +} COMMAND, *PCOMMAND; - if (_stricmp(argv[1],"START")==0) - { - return cmdStart(argc, &argv[1]); - } - if (_stricmp(argv[1],"STATISTICS")==0) - { - return unimplemented(); - } - if (_stricmp(argv[1],"STOP")==0) - { - return cmdStop(argc, &argv[1]); - } - if (_stricmp(argv[1],"TIME")==0) - { - return unimplemented(); - } - if (_stricmp(argv[1],"USE")==0) - { - return unimplemented(); - } - if (_stricmp(argv[1],"USER")==0) - { - return unimplemented(); - } - if (_stricmp(argv[1],"VIEW")==0) - { - return unimplemented(); - } +COMMAND cmds[] = +{ + {L"accounts", cmdAccounts}, + {L"computer", unimplemented}, + {L"config", cmdConfig}, + {L"continue", cmdContinue}, + {L"file", unimplemented}, + {L"group", cmdGroup}, + {L"help", cmdHelp}, + {L"helpmsg", cmdHelpMsg}, + {L"localgroup", cmdLocalGroup}, + {L"name", unimplemented}, + {L"pause", cmdPause}, + {L"print", unimplemented}, + {L"send", unimplemented}, + {L"session", unimplemented}, + {L"share", unimplemented}, + {L"start", cmdStart}, + {L"statistics", cmdStatistics}, + {L"stop", cmdStop}, + {L"time", unimplemented}, + {L"use", cmdUse}, + {L"user", cmdUser}, + {L"view", unimplemented}, + {NULL, NULL} +}; + + + +VOID +PrintPaddedResourceString( + UINT uID, + INT nPaddedLength) +{ + INT nLength; - help(); - return 1; + nLength = ConResPuts(StdOut, uID); + if (nLength < nPaddedLength) + PrintPadding(L' ', nPaddedLength - nLength); } -int unimplemented() +VOID +PrintPadding( + WCHAR chr, + INT nPaddedLength) { - puts("This command is not implemented yet"); - return 1; -} - + INT i; + WCHAR szMsgBuffer[MAX_BUFFER_SIZE]; + for (i = 0; i < nPaddedLength; i++) + szMsgBuffer[i] = chr; + szMsgBuffer[nPaddedLength] = UNICODE_NULL; + ConPuts(StdOut, szMsgBuffer); +} +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); +} +int wmain(int argc, WCHAR **argv) +{ + PCOMMAND cmdptr; + /* Initialize the Console Standard Streams */ + ConInitStdStreams(); + if (argc < 2) + { + ConResPuts(StdOut, IDS_NET_SYNTAX); + return 1; + } + /* Scan the command table */ + for (cmdptr = cmds; cmdptr->name; cmdptr++) + { + if (_wcsicmp(argv[1], cmdptr->name) == 0) + { + return cmdptr->func(argc, argv); + } + } + ConResPuts(StdOut, IDS_NET_SYNTAX); + return 1; +} +INT unimplemented(INT argc, WCHAR **argv) +{ + ConPuts(StdOut, L"This command is not implemented yet\n"); + return 1; +}