2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS net command
4 * FILE: base/applications/network/net/main.c
7 * PROGRAMMERS: Magnus Olsen (greatlord@reactos.org)
12 #define MAX_BUFFER_SIZE 4096
14 typedef struct _COMMAND
17 INT (*func
)(INT
, WCHAR
**);
18 // VOID (*help)(INT, WCHAR**);
23 {L
"accounts", cmdAccounts
},
24 {L
"computer", unimplemented
},
25 {L
"config", unimplemented
},
26 {L
"continue", cmdContinue
},
27 {L
"file", unimplemented
},
28 {L
"group", unimplemented
},
30 {L
"helpmsg", cmdHelpMsg
},
31 {L
"localgroup", cmdLocalGroup
},
32 {L
"name", unimplemented
},
34 {L
"print", unimplemented
},
35 {L
"send", unimplemented
},
36 {L
"session", unimplemented
},
37 {L
"share", unimplemented
},
39 {L
"statistics", unimplemented
},
41 {L
"time", unimplemented
},
44 {L
"view", unimplemented
},
54 WCHAR szMsgBuffer
[MAX_BUFFER_SIZE
];
55 WCHAR szOutBuffer
[MAX_BUFFER_SIZE
];
58 va_start(arg_ptr
, resID
);
59 LoadStringW(GetModuleHandle(NULL
), resID
, szMsgBuffer
, MAX_BUFFER_SIZE
);
60 _vsnwprintf(szOutBuffer
, MAX_BUFFER_SIZE
, szMsgBuffer
, arg_ptr
);
63 WriteToConsole(szOutBuffer
);
68 PrintPaddedResourceString(
72 WCHAR szMsgBuffer
[MAX_BUFFER_SIZE
];
75 nLength
= LoadStringW(GetModuleHandle(NULL
), resID
, szMsgBuffer
, MAX_BUFFER_SIZE
);
76 if (nLength
< nPaddedLength
)
78 for (i
= nLength
; i
< nPaddedLength
; i
++)
79 szMsgBuffer
[i
] = L
' ';
80 szMsgBuffer
[nPaddedLength
] = UNICODE_NULL
;
83 WriteToConsole(szMsgBuffer
);
92 WCHAR szMsgBuffer
[MAX_BUFFER_SIZE
];
95 for (i
= 0; i
< nPaddedLength
; i
++)
97 szMsgBuffer
[nPaddedLength
] = UNICODE_NULL
;
99 WriteToConsole(szMsgBuffer
);
108 WCHAR szBuffer
[MAX_BUFFER_SIZE
];
111 va_start(arg_ptr
, lpFormat
);
112 _vsnwprintf(szBuffer
, MAX_BUFFER_SIZE
, lpFormat
, arg_ptr
);
115 WriteToConsole(szBuffer
);
123 CHAR szOemBuffer
[MAX_BUFFER_SIZE
* 2];
127 dwLength
= wcslen(lpString
);
129 hOutput
= GetStdHandle(STD_OUTPUT_HANDLE
);
130 if ((GetFileType(hOutput
) & ~FILE_TYPE_REMOTE
) == FILE_TYPE_CHAR
)
132 WriteConsoleW(hOutput
,
140 dwLength
= WideCharToMultiByte(CP_OEMCP
,
169 pBuf
= HeapAlloc(GetProcessHeap(), 0, dwLength
- 1);
170 ZeroMemory(lpInput
, dwLength
* sizeof(WCHAR
));
171 hFile
= GetStdHandle(STD_INPUT_HANDLE
);
172 GetConsoleMode(hFile
, &dwOldMode
);
174 SetConsoleMode(hFile
, ENABLE_LINE_INPUT
| (bEcho
? ENABLE_ECHO_INPUT
: 0));
176 ReadFile(hFile
, (PVOID
)pBuf
, dwLength
- 1, &dwRead
, NULL
);
178 MultiByteToWideChar(CP_OEMCP
, 0, pBuf
, dwRead
, lpInput
, dwLength
- 1);
179 HeapFree(GetProcessHeap(), 0, pBuf
);
181 for (p
= lpInput
; *p
; p
++)
190 SetConsoleMode(hFile
, dwOldMode
);
194 int wmain(int argc
, WCHAR
**argv
)
200 PrintResourceString(IDS_NET_SYNTAX
);
204 /* Scan the command table */
205 for (cmdptr
= cmds
; cmdptr
->name
; cmdptr
++)
207 if (_wcsicmp(argv
[1], cmdptr
->name
) == 0)
209 return cmdptr
->func(argc
, argv
);
213 PrintResourceString(IDS_NET_SYNTAX
);
218 INT
unimplemented(INT argc
, WCHAR
**argv
)
220 puts("This command is not implemented yet");