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>
13 PSERVER_INFO_102 ServerInfo
)
15 PSERVER_TRANSPORT_INFO_0 TransportInfo
= NULL
;
16 DWORD dwRead
, dwTotal
, i
;
17 INT nPaddedLength
= 38;
18 NET_API_STATUS Status
;
20 Status
= NetServerTransportEnum(NULL
, 0, (PBYTE
*)&TransportInfo
,
25 if (Status
!= NERR_Success
)
28 PrintPaddedMessageString(4481, nPaddedLength
);
29 ConPrintf(StdOut
, L
"\\\\%s\n", ServerInfo
->sv102_name
);
31 PrintPaddedMessageString(4482, nPaddedLength
);
32 ConPrintf(StdOut
, L
"%s\n\n", ServerInfo
->sv102_comment
);
34 PrintPaddedMessageString(4484, nPaddedLength
);
35 ConPrintf(StdOut
, L
"%lu.%lu\n",
36 ServerInfo
->sv102_version_major
,
37 ServerInfo
->sv102_version_minor
);
39 PrintPaddedMessageString(4489, nPaddedLength
);
40 ConPuts(StdOut
, L
"\n");
41 for (i
= 0; i
< dwRead
; i
++)
43 ConPrintf(StdOut
, L
" %s (%s)\n",
44 &TransportInfo
[i
].svti0_transportname
[8],
45 TransportInfo
[i
].svti0_networkaddress
);
47 ConPuts(StdOut
, L
"\n");
49 PrintPaddedMessageString(4492, nPaddedLength
);
50 ConResPuts(StdOut
, (ServerInfo
->sv102_hidden
== SV_HIDDEN
) ? IDS_GENERIC_YES
: IDS_GENERIC_NO
);
51 ConPuts(StdOut
, L
"\n");
53 PrintPaddedMessageString(4506, nPaddedLength
);
54 ConPrintf(StdOut
, L
"%lu\n", ServerInfo
->sv102_users
);
56 PrintPaddedMessageString(4511, nPaddedLength
);
57 ConPuts(StdOut
, L
"...\n\n");
59 PrintPaddedMessageString(4520, nPaddedLength
);
60 if (ServerInfo
->sv102_disc
== SV_NODISC
)
61 ConResPuts(StdOut
, IDS_GENERIC_UNLIMITED
);
63 ConPrintf(StdOut
, L
"%lu\n", ServerInfo
->sv102_disc
);
66 if (TransportInfo
!= NULL
)
67 NetApiBufferFree(TransportInfo
);
75 DisplayWorkstationConfig(VOID
)
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;
82 NET_API_STATUS Status
;
84 Status
= NetWkstaGetInfo(NULL
, 100, (PBYTE
*)&WorkstationInfo
);
85 if (Status
!= NERR_Success
)
88 Status
= NetWkstaUserGetInfo(NULL
, 1, (PBYTE
*)&UserInfo
);
89 if (Status
!= NERR_Success
)
92 Status
= NetWkstaTransportEnum(NULL
,
94 (PBYTE
*)&TransportInfo
,
99 if (Status
!= NERR_Success
)
102 PrintPaddedMessageString(4450, nPaddedLength
);
103 ConPrintf(StdOut
, L
"\\\\%s\n", WorkstationInfo
->wki100_computername
);
105 PrintPaddedMessageString(4468, nPaddedLength
);
106 ConPuts(StdOut
, L
"...\n");
108 PrintPaddedMessageString(4451, nPaddedLength
);
109 ConPrintf(StdOut
, L
"%s\n", UserInfo
->wkui1_username
);
111 ConPuts(StdOut
, L
"\n");
113 PrintPaddedMessageString(4453, nPaddedLength
);
114 ConPuts(StdOut
, L
"\n");
115 for (i
= 0; i
< dwRead
; i
++)
117 ConPrintf(StdOut
, L
" %s (%s)\n",
118 &TransportInfo
[i
].wkti0_transport_name
[8],
119 TransportInfo
[i
].wkti0_transport_address
);
121 ConPuts(StdOut
, L
"\n");
123 PrintPaddedMessageString(4452, nPaddedLength
);
124 ConPrintf(StdOut
, L
"%lu.%lu\n",
125 WorkstationInfo
->wki100_ver_major
,
126 WorkstationInfo
->wki100_ver_minor
);
128 ConPuts(StdOut
, L
"\n");
130 PrintPaddedMessageString(4455, nPaddedLength
);
131 ConPrintf(StdOut
, L
"%s\n", WorkstationInfo
->wki100_langroup
);
133 PrintPaddedMessageString(4469, nPaddedLength
);
134 ConPuts(StdOut
, L
"...\n");
136 PrintPaddedMessageString(4456, nPaddedLength
);
137 ConPrintf(StdOut
, L
"%s\n", UserInfo
->wkui1_logon_domain
);
139 ConPuts(StdOut
, L
"\n");
141 PrintPaddedMessageString(4458, nPaddedLength
);
142 ConPuts(StdOut
, L
"...\n");
144 PrintPaddedMessageString(4459, nPaddedLength
);
145 ConPuts(StdOut
, L
"...\n");
147 PrintPaddedMessageString(4460, nPaddedLength
);
148 ConPuts(StdOut
, L
"...\n");
151 if (TransportInfo
!= NULL
)
152 NetApiBufferFree(TransportInfo
);
154 if (UserInfo
!= NULL
)
155 NetApiBufferFree(UserInfo
);
157 if (WorkstationInfo
!= NULL
)
158 NetApiBufferFree(WorkstationInfo
);
170 BOOL bServer
= FALSE
;
171 BOOL bWorkstation
= FALSE
;
173 BOOL bModify
= FALSE
;
175 PSERVER_INFO_102 ServerInfo
= NULL
;
176 NET_API_STATUS Status
;
178 for (i
= 2; i
< argc
; i
++)
180 if (_wcsicmp(argv
[i
], L
"server") == 0)
182 if (bWorkstation
== FALSE
)
187 if (_wcsicmp(argv
[i
], L
"workstation") == 0)
189 if (bServer
== FALSE
)
194 if (_wcsicmp(argv
[i
], L
"help") == 0)
196 /* Print short syntax help */
199 ConResPuts(StdOut
, IDS_GENERIC_SYNTAX
);
200 PrintNetMessage(MSG_CONFIG_SERVER_SYNTAX
);
204 ConResPuts(StdOut
, IDS_GENERIC_SYNTAX
);
205 PrintNetMessage(MSG_CONFIG_SYNTAX
);
210 if (_wcsicmp(argv
[i
], L
"/help") == 0)
212 /* Print full help text*/
215 ConResPuts(StdOut
, IDS_GENERIC_SYNTAX
);
216 PrintNetMessage(MSG_CONFIG_SERVER_SYNTAX
);
217 PrintNetMessage(MSG_CONFIG_SERVER_HELP
);
221 ConResPuts(StdOut
, IDS_GENERIC_SYNTAX
);
222 PrintNetMessage(MSG_CONFIG_SYNTAX
);
223 PrintNetMessage(MSG_CONFIG_HELP
);
231 Status
= NetServerGetInfo(NULL
, 102, (PBYTE
*)&ServerInfo
);
232 if (Status
!= NERR_Success
)
235 for (i
= 2; i
< argc
; i
++)
237 if (argv
[i
][0] != L
'/')
240 if (_wcsnicmp(argv
[i
], L
"/autodisconnect:", 16) == 0)
243 lValue
= wcstol(p
, &endptr
, 10);
246 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/AUTODISCONNECT");
251 if (lValue
< -1 || lValue
> 65535)
253 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/AUTODISCONNECT");
258 ServerInfo
->sv102_disc
= lValue
;
261 else if (_wcsnicmp(argv
[i
], L
"/srvcomment:", 12) == 0)
263 ServerInfo
->sv102_comment
= &argv
[i
][12];
266 else if (_wcsnicmp(argv
[i
], L
"/hidden:", 8) == 0)
269 if (_wcsicmp(p
, L
"yes") != 0 && _wcsicmp(p
, L
"no") != 0)
271 ConResPrintf(StdErr
, IDS_ERROR_INVALID_OPTION_VALUE
, L
"/HIDDEN");
276 ServerInfo
->sv102_hidden
= (_wcsicmp(p
, L
"yes") == 0) ? TRUE
: FALSE
;
281 ConResPuts(StdOut
, IDS_GENERIC_SYNTAX
);
282 PrintNetMessage(MSG_CONFIG_SERVER_SYNTAX
);
290 Status
= NetServerSetInfo(NULL
, 102, (PBYTE
)&ServerInfo
, NULL
);
291 if (Status
!= NERR_Success
)
296 result
= DisplayServerConfig(ServerInfo
);
299 else if (bWorkstation
)
301 result
= DisplayWorkstationConfig();
305 PrintMessageString(4378);
306 ConPuts(StdOut
, L
"\n");
307 ConPuts(StdOut
, L
" Server\n");
308 ConPuts(StdOut
, L
" Workstation\n");
309 ConPuts(StdOut
, L
"\n");
313 if (ServerInfo
!= NULL
)
314 NetApiBufferFree(ServerInfo
);
317 PrintErrorMessage(ERROR_SUCCESS
);