ReactOS 0.4.15-dev-7942-gd23573b
cmdConfig.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS net command
4 * FILE: base/applications/network/net/cmdConfig.c
5 * PROGRAMMERS: Eric Kohl <eric.kohl@reactos.org>
6 */
7
8#include "net.h"
9
10static
11INT
13 PSERVER_INFO_102 ServerInfo)
14{
15 PSERVER_TRANSPORT_INFO_0 TransportInfo = NULL;
16 DWORD dwRead, dwTotal, i;
17 INT nPaddedLength = 38;
19
20 Status = NetServerTransportEnum(NULL, 0, (PBYTE*)&TransportInfo,
22 &dwRead,
23 &dwTotal,
24 NULL);
25 if (Status != NERR_Success)
26 goto done;
27
28 PrintPaddedMessageString(4481, nPaddedLength);
29 ConPrintf(StdOut, L"\\\\%s\n", ServerInfo->sv102_name);
30
31 PrintPaddedMessageString(4482, nPaddedLength);
32 ConPrintf(StdOut, L"%s\n\n", ServerInfo->sv102_comment);
33
34 PrintPaddedMessageString(4484, nPaddedLength);
35 ConPrintf(StdOut, L"%lu.%lu\n",
36 ServerInfo->sv102_version_major,
37 ServerInfo->sv102_version_minor);
38
39 PrintPaddedMessageString(4489, nPaddedLength);
40 ConPuts(StdOut, L"\n");
41 for (i = 0; i < dwRead; i++)
42 {
43 ConPrintf(StdOut, L" %s (%s)\n",
44 &TransportInfo[i].svti0_transportname[8],
45 TransportInfo[i].svti0_networkaddress);
46 }
47 ConPuts(StdOut, L"\n");
48
49 PrintPaddedMessageString(4492, nPaddedLength);
50 PrintMessageString((ServerInfo->sv102_hidden == SV_HIDDEN) ? 4300 : 4301);
51 ConPuts(StdOut, L"\n");
52
53 PrintPaddedMessageString(4506, nPaddedLength);
54 ConPrintf(StdOut, L"%lu\n", ServerInfo->sv102_users);
55
56 PrintPaddedMessageString(4511, nPaddedLength);
57 ConPuts(StdOut, L"...\n\n");
58
59 PrintPaddedMessageString(4520, nPaddedLength);
60 if (ServerInfo->sv102_disc == SV_NODISC)
62 else
63 ConPrintf(StdOut, L"%lu\n", ServerInfo->sv102_disc);
64
65done:
66 if (TransportInfo != NULL)
67 NetApiBufferFree(TransportInfo);
68
69 return 0;
70}
71
72
73static
74INT
76{
77 PWKSTA_INFO_100 WorkstationInfo = NULL;
78 PWKSTA_USER_INFO_1 UserInfo = NULL;
79 PWKSTA_TRANSPORT_INFO_0 TransportInfo = NULL;
80 DWORD dwRead = 0, dwTotal = 0, i;
81 INT nPaddedLength = 38;
83
84 Status = NetWkstaGetInfo(NULL, 100, (PBYTE*)&WorkstationInfo);
85 if (Status != NERR_Success)
86 goto done;
87
88 Status = NetWkstaUserGetInfo(NULL, 1, (PBYTE*)&UserInfo);
89 if (Status != NERR_Success)
90 goto done;
91
93 0,
94 (PBYTE*)&TransportInfo,
96 &dwRead,
97 &dwTotal,
98 NULL);
99 if (Status != NERR_Success)
100 goto done;
101
102 PrintPaddedMessageString(4450, nPaddedLength);
103 ConPrintf(StdOut, L"\\\\%s\n", WorkstationInfo->wki100_computername);
104
105 PrintPaddedMessageString(4468, nPaddedLength);
106 ConPuts(StdOut, L"...\n");
107
108 PrintPaddedMessageString(4451, nPaddedLength);
109 ConPrintf(StdOut, L"%s\n", UserInfo->wkui1_username);
110
111 ConPuts(StdOut, L"\n");
112
113 PrintPaddedMessageString(4453, nPaddedLength);
114 ConPuts(StdOut, L"\n");
115 for (i = 0; i < dwRead; i++)
116 {
117 ConPrintf(StdOut, L" %s (%s)\n",
118 &TransportInfo[i].wkti0_transport_name[8],
119 TransportInfo[i].wkti0_transport_address);
120 }
121 ConPuts(StdOut, L"\n");
122
123 PrintPaddedMessageString(4452, nPaddedLength);
124 ConPrintf(StdOut, L"%lu.%lu\n",
125 WorkstationInfo->wki100_ver_major,
126 WorkstationInfo->wki100_ver_minor);
127
128 ConPuts(StdOut, L"\n");
129
130 PrintPaddedMessageString(4455, nPaddedLength);
131 ConPrintf(StdOut, L"%s\n", WorkstationInfo->wki100_langroup);
132
133 PrintPaddedMessageString(4469, nPaddedLength);
134 ConPuts(StdOut, L"...\n");
135
136 PrintPaddedMessageString(4456, nPaddedLength);
137 ConPrintf(StdOut, L"%s\n", UserInfo->wkui1_logon_domain);
138
139 ConPuts(StdOut, L"\n");
140
141 PrintPaddedMessageString(4458, nPaddedLength);
142 ConPuts(StdOut, L"...\n");
143
144 PrintPaddedMessageString(4459, nPaddedLength);
145 ConPuts(StdOut, L"...\n");
146
147 PrintPaddedMessageString(4460, nPaddedLength);
148 ConPuts(StdOut, L"...\n");
149
150done:
151 if (TransportInfo != NULL)
152 NetApiBufferFree(TransportInfo);
153
154 if (UserInfo != NULL)
155 NetApiBufferFree(UserInfo);
156
157 if (WorkstationInfo != NULL)
158 NetApiBufferFree(WorkstationInfo);
159
160 return 0;
161}
162
163
164INT
166 INT argc,
167 WCHAR **argv)
168{
169 INT i, result = 0;
170 BOOL bServer = FALSE;
171 BOOL bWorkstation = FALSE;
172 PWSTR p, endptr;
173 BOOL bModify = FALSE;
174 LONG lValue;
175 PSERVER_INFO_102 ServerInfo = NULL;
177
178 for (i = 2; i < argc; i++)
179 {
180 if (_wcsicmp(argv[i], L"server") == 0)
181 {
182 if (bWorkstation == FALSE)
183 bServer = TRUE;
184 continue;
185 }
186
187 if (_wcsicmp(argv[i], L"workstation") == 0)
188 {
189 if (bServer == FALSE)
190 bWorkstation = TRUE;
191 continue;
192 }
193
194 if (_wcsicmp(argv[i], L"help") == 0)
195 {
196 /* Print short syntax help */
197 if (bServer == TRUE)
198 {
199 PrintMessageString(4381);
200 ConPuts(StdOut, L"\n");
201 PrintNetMessage(MSG_CONFIG_SERVER_SYNTAX);
202 }
203 else
204 {
205 PrintMessageString(4381);
206 ConPuts(StdOut, L"\n");
207 PrintNetMessage(MSG_CONFIG_SYNTAX);
208 }
209 return 0;
210 }
211
212 if (_wcsicmp(argv[i], L"/help") == 0)
213 {
214 /* Print full help text*/
215 if (bServer == TRUE)
216 {
217 PrintMessageString(4381);
218 ConPuts(StdOut, L"\n");
219 PrintNetMessage(MSG_CONFIG_SERVER_SYNTAX);
220 PrintNetMessage(MSG_CONFIG_SERVER_HELP);
221 }
222 else
223 {
224 PrintMessageString(4381);
225 ConPuts(StdOut, L"\n");
226 PrintNetMessage(MSG_CONFIG_SYNTAX);
227 PrintNetMessage(MSG_CONFIG_HELP);
228 }
229 return 0;
230 }
231 }
232
233 if (bServer)
234 {
235 Status = NetServerGetInfo(NULL, 102, (PBYTE*)&ServerInfo);
236 if (Status != NERR_Success)
237 goto done;
238
239 for (i = 2; i < argc; i++)
240 {
241 if (argv[i][0] != L'/')
242 continue;
243
244 if (_wcsnicmp(argv[i], L"/autodisconnect:", 16) == 0)
245 {
246 p = &argv[i][16];
247 lValue = wcstol(p, &endptr, 10);
248 if (*endptr != 0)
249 {
250 PrintMessageStringV(3952, L"/AUTODISCONNECT");
251 result = 1;
252 goto done;
253 }
254
255 if (lValue < -1 || lValue > 65535)
256 {
257 PrintMessageStringV(3952, L"/AUTODISCONNECT");
258 result = 1;
259 goto done;
260 }
261
262 ServerInfo->sv102_disc = lValue;
263 bModify = TRUE;
264 }
265 else if (_wcsnicmp(argv[i], L"/srvcomment:", 12) == 0)
266 {
267 ServerInfo->sv102_comment = &argv[i][12];
268 bModify = TRUE;
269 }
270 else if (_wcsnicmp(argv[i], L"/hidden:", 8) == 0)
271 {
272 p = &argv[i][8];
273 if (_wcsicmp(p, L"yes") != 0 && _wcsicmp(p, L"no") != 0)
274 {
275 PrintMessageStringV(3952, L"/HIDDEN");
276 result = 1;
277 goto done;
278 }
279
280 ServerInfo->sv102_hidden = (_wcsicmp(p, L"yes") == 0) ? TRUE : FALSE;
281 bModify = TRUE;
282 }
283 else
284 {
285 PrintMessageString(4381);
286 ConPuts(StdOut, L"\n");
287 PrintNetMessage(MSG_CONFIG_SERVER_SYNTAX);
288 result = 1;
289 goto done;
290 }
291 }
292
293 if (bModify)
294 {
295 Status = NetServerSetInfo(NULL, 102, (PBYTE)&ServerInfo, NULL);
296 if (Status != NERR_Success)
297 result = 1;
298 }
299 else
300 {
301 result = DisplayServerConfig(ServerInfo);
302 }
303 }
304 else if (bWorkstation)
305 {
307 }
308 else
309 {
310 PrintMessageString(4378);
311 ConPuts(StdOut, L"\n");
312 ConPuts(StdOut, L" Server\n");
313 ConPuts(StdOut, L" Workstation\n");
314 ConPuts(StdOut, L"\n");
315 }
316
317done:
318 if (ServerInfo != NULL)
319 NetApiBufferFree(ServerInfo);
320
321 if (result == 0)
323
324 return result;
325}
static int argc
Definition: ServiceArgs.c:12
static VOID PrintErrorMessage(DWORD dwError)
Definition: at.c:308
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition: fc.c:20
#define StdOut
Definition: fc.c:14
VOID PrintNetMessage(DWORD dwMessage)
Definition: main.c:239
VOID PrintPaddedMessageString(DWORD dwMessage, INT nPaddedLength)
Definition: main.c:143
VOID PrintMessageStringV(DWORD dwMessage,...)
Definition: main.c:93
VOID PrintMessageString(DWORD dwMessage)
Definition: main.c:120
INT cmdConfig(INT argc, WCHAR **argv)
Definition: cmdConfig.c:165
static INT DisplayServerConfig(PSERVER_INFO_102 ServerInfo)
Definition: cmdConfig.c:12
static INT DisplayWorkstationConfig(VOID)
Definition: cmdConfig.c:75
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
NET_API_STATUS WINAPI NetServerSetInfo(_In_ LPWSTR servername, _In_ DWORD level, _In_ LPBYTE buf, _Out_ LPDWORD parm_err)
Definition: srvsvc.c:399
NET_API_STATUS WINAPI NetServerGetInfo(LMSTR servername, DWORD level, LPBYTE *bufptr)
Definition: srvsvc.c:369
NET_API_STATUS WINAPI NetServerTransportEnum(_In_ LPWSTR servername, _In_ DWORD level, _Out_ LPBYTE *bufptr, _In_ DWORD prefmaxlen, _Out_ LPDWORD entriesread, _Out_ LPDWORD totalentries, _Inout_ LPDWORD resume_handle)
Definition: srvsvc.c:543
NET_API_STATUS WINAPI NetWkstaUserGetInfo(LMSTR reserved, DWORD level, PBYTE *bufptr)
Definition: wksta.c:279
NET_API_STATUS WINAPI NetWkstaTransportEnum(LMSTR ServerName, DWORD level, PBYTE *pbuf, DWORD prefmaxlen, LPDWORD read_entries, PDWORD total_entries, PDWORD hresume)
Definition: wksta.c:221
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
GLfloat GLfloat p
Definition: glext.h:8902
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define MAX_PREFERRED_LENGTH
Definition: lmcons.h:48
#define NERR_Success
Definition: lmerr.h:5
#define SV_NODISC
Definition: lmserver.h:455
#define SV_HIDDEN
Definition: lmserver.h:458
#define argv
Definition: mplay32.c:18
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
#define L(x)
Definition: ntvdm.h:50
BYTE * PBYTE
Definition: pedump.c:66
long LONG
Definition: pedump.c:60
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
Deprecated header file that includes net_sockets.h.
LPWSTR sv102_name
Definition: lmserver.h:27
LPWSTR sv102_comment
Definition: lmserver.h:31
DWORD sv102_version_major
Definition: lmserver.h:28
DWORD sv102_version_minor
Definition: lmserver.h:29
DWORD sv102_users
Definition: lmserver.h:32
BOOL sv102_hidden
Definition: lmserver.h:34
DWORD wki100_ver_major
Definition: lmwksta.h:68
LPWSTR wki100_langroup
Definition: lmwksta.h:67
DWORD wki100_ver_minor
Definition: lmwksta.h:69
LPWSTR wki100_computername
Definition: lmwksta.h:66
LPWSTR wkui1_username
Definition: lmwksta.h:204
LPWSTR wkui1_logon_domain
Definition: lmwksta.h:205
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
NET_API_STATUS WINAPI NetWkstaGetInfo(_In_ LPWSTR servername, _In_ DWORD level, _Out_ LPBYTE *bufptr)
Definition: wksta_new.c:868
__wchar_t WCHAR
Definition: xmlstorage.h:180