ReactOS  0.4.12-dev-714-gfaac916
cmdConfig.c File Reference
#include "net.h"
Include dependency graph for cmdConfig.c:

Go to the source code of this file.

Functions

static INT DisplayServerConfig (PSERVER_INFO_102 ServerInfo)
 
static INT DisplayWorkstationConfig (VOID)
 
INT cmdConfig (INT argc, WCHAR **argv)
 

Function Documentation

◆ cmdConfig()

INT cmdConfig ( INT  argc,
WCHAR **  argv 
)

Definition at line 151 of file cmdConfig.c.

154 {
155  INT i, result = 0;
156  BOOL bServer = FALSE;
157  BOOL bWorkstation = FALSE;
158  PWSTR p, endptr;
159  BOOL bModify = FALSE;
160  LONG lValue;
161  PSERVER_INFO_102 ServerInfo = NULL;
163 
164  for (i = 2; i < argc; i++)
165  {
166  if (_wcsicmp(argv[i], L"server") == 0)
167  {
168  if (bWorkstation == FALSE)
169  bServer = TRUE;
170  continue;
171  }
172 
173  if (_wcsicmp(argv[i], L"workstation") == 0)
174  {
175  if (bServer == FALSE)
176  bWorkstation = TRUE;
177  continue;
178  }
179 
180  if (_wcsicmp(argv[i], L"help") == 0)
181  {
182  /* Print short syntax help */
183  if (bServer == TRUE)
184  {
186  PrintNetMessage(MSG_CONFIG_SERVER_SYNTAX);
187  }
188  else
189  {
191  PrintNetMessage(MSG_CONFIG_SYNTAX);
192  }
193  return 0;
194  }
195 
196  if (_wcsicmp(argv[i], L"/help") == 0)
197  {
198  /* Print full help text*/
199  if (bServer == TRUE)
200  {
202  PrintNetMessage(MSG_CONFIG_SERVER_SYNTAX);
203  PrintNetMessage(MSG_CONFIG_SERVER_HELP);
205  }
206  else
207  {
209  PrintNetMessage(MSG_CONFIG_SYNTAX);
210  PrintNetMessage(MSG_CONFIG_HELP);
211  }
212  return 0;
213  }
214  }
215 
216  if (bServer)
217  {
218  Status = NetServerGetInfo(NULL, 102, (PBYTE*)&ServerInfo);
219  if (Status != NERR_Success)
220  goto done;
221 
222  for (i = 2; i < argc; i++)
223  {
224  if (argv[i][0] != L'/')
225  continue;
226 
227  if (_wcsnicmp(argv[i], L"/autodisconnect:", 16) == 0)
228  {
229  p = &argv[i][16];
230  lValue = wcstol(p, &endptr, 10);
231  if (*endptr != 0)
232  {
234  result = 1;
235  goto done;
236  }
237 
238  if (lValue < -1 || lValue > 65535)
239  {
241  result = 1;
242  goto done;
243  }
244 
245  ServerInfo->sv102_disc = lValue;
246  bModify = TRUE;
247  }
248  else if (_wcsnicmp(argv[i], L"/srvcomment:", 12) == 0)
249  {
250  ServerInfo->sv102_comment = &argv[i][12];
251  bModify = TRUE;
252  }
253  else if (_wcsnicmp(argv[i], L"/hidden:", 8) == 0)
254  {
255  p = &argv[i][8];
256  if (_wcsicmp(p, L"yes") != 0 && _wcsicmp(p, L"no") != 0)
257  {
259  result = 1;
260  goto done;
261  }
262 
263  ServerInfo->sv102_hidden = (_wcsicmp(p, L"yes") == 0) ? TRUE : FALSE;
264  bModify = TRUE;
265  }
266  else
267  {
269  PrintNetMessage(MSG_CONFIG_SERVER_SYNTAX);
270  result = 1;
271  goto done;
272  }
273  }
274 
275  if (bModify)
276  {
277  Status = NetServerSetInfo(NULL, 102, (PBYTE)&ServerInfo, NULL);
278  if (Status != NERR_Success)
279  result = 1;
280  }
281  else
282  {
283  result = DisplayServerConfig(ServerInfo);
284  }
285  }
286  else if (bWorkstation)
287  {
289  }
290  else
291  {
293  }
294 
295 done:
296  if (ServerInfo != NULL)
297  NetApiBufferFree(ServerInfo);
298 
299  if (result == 0)
301 
302  return result;
303 }
static int argc
Definition: ServiceArgs.c:12
NET_API_STATUS WINAPI NetServerSetInfo(_In_ LPWSTR servername, _In_ DWORD level, _In_ LPBYTE buf, _Out_ LPDWORD parm_err)
Definition: srvsvc.c:399
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
uint16_t * PWSTR
Definition: typedefs.h:54
_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)
LPWSTR sv102_comment
Definition: lmserver.h:31
#define IDS_ERROR_INVALID_OPTION_VALUE
Definition: resource.h:122
VOID PrintNetMessage(DWORD dwMessage)
Definition: main.c:149
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
static INT DisplayServerConfig(PSERVER_INFO_102 ServerInfo)
Definition: cmdConfig.c:12
#define argv
Definition: mplay32.c:18
int32_t INT
Definition: typedefs.h:56
#define NERR_Success
Definition: lmerr.h:5
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
#define IDS_GENERIC_SYNTAX
Definition: resource.h:118
long LONG
Definition: pedump.c:60
BOOL sv102_hidden
Definition: lmserver.h:34
#define IDS_GENERIC_PAGE
Definition: resource.h:119
smooth NULL
Definition: ftsmooth.c:416
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
#define IDS_CONFIG_TEXT
Definition: resource.h:18
unsigned int BOOL
Definition: ntddk_ex.h:94
#define StdErr
Definition: stream.h:77
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
static const WCHAR L[]
Definition: oid.c:1250
NET_API_STATUS WINAPI NetServerGetInfo(LMSTR servername, DWORD level, LPBYTE *bufptr)
Definition: srvsvc.c:369
Status
Definition: gdiplustypes.h:24
static VOID PrintErrorMessage(DWORD dwError)
Definition: at.c:308
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
#define StdOut
Definition: stream.h:76
static INT DisplayWorkstationConfig(VOID)
Definition: cmdConfig.c:75
GLfloat GLfloat p
Definition: glext.h:8902
GLuint64EXT * result
Definition: glext.h:11304
BYTE * PBYTE
Definition: pedump.c:66
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

◆ DisplayServerConfig()

static INT DisplayServerConfig ( PSERVER_INFO_102  ServerInfo)
static

Definition at line 12 of file cmdConfig.c.

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 
29  ConPrintf(StdOut, L"\\\\%s\n", ServerInfo->sv102_name);
30 
32  ConPrintf(StdOut, L"%s\n\n", ServerInfo->sv102_comment);
33 
35  ConPrintf(StdOut, L"%lu.%lu\n",
36  ServerInfo->sv102_version_major,
37  ServerInfo->sv102_version_minor);
38 
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 
51  ConPuts(StdOut, L"\n");
52 
54  ConPrintf(StdOut, L"%lu\n", ServerInfo->sv102_users);
55 
57  ConPuts(StdOut, L"...\n\n");
58 
60  if (ServerInfo->sv102_disc == SV_NODISC)
62  else
63  ConPrintf(StdOut, L"%lu\n", ServerInfo->sv102_disc);
64 
65 done:
66  if (TransportInfo != NULL)
67  NetApiBufferFree(TransportInfo);
68 
69  return 0;
70 }
#define IDS_GENERIC_NO
Definition: resource.h:112
DWORD sv102_version_major
Definition: lmserver.h:28
#define MAX_PREFERRED_LENGTH
Definition: lmcons.h:48
LPWSTR sv102_name
Definition: lmserver.h:27
#define SV_HIDDEN
Definition: lmserver.h:458
#define IDS_CONFIG_SERVER_ACTIVE
Definition: resource.h:22
#define IDS_CONFIG_SERVER_FILES
Definition: resource.h:25
LPWSTR sv102_comment
Definition: lmserver.h:31
#define IDS_CONFIG_SERVER_USERS
Definition: resource.h:24
int32_t INT
Definition: typedefs.h:56
#define NERR_Success
Definition: lmerr.h:5
#define IDS_CONFIG_SERVER_IDLE
Definition: resource.h:26
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
DWORD sv102_users
Definition: lmserver.h:32
BOOL sv102_hidden
Definition: lmserver.h:34
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
#define IDS_CONFIG_SERVER_COMMENT
Definition: resource.h:20
smooth NULL
Definition: ftsmooth.c:416
#define SV_NODISC
Definition: lmserver.h:455
#define IDS_CONFIG_SERVER_HIDDEN
Definition: resource.h:23
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
#define IDS_CONFIG_SERVER_VERSION
Definition: resource.h:21
unsigned long DWORD
Definition: ntddk_ex.h:95
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
VOID PrintPaddedResourceString(UINT uID, INT nPaddedLength)
Definition: main.c:52
#define IDS_CONFIG_SERVER_NAME
Definition: resource.h:19
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
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
#define StdOut
Definition: stream.h:76
DWORD sv102_version_minor
Definition: lmserver.h:29
#define IDS_GENERIC_UNLIMITED
Definition: resource.h:117
BYTE * PBYTE
Definition: pedump.c:66
#define IDS_GENERIC_YES
Definition: resource.h:111

Referenced by cmdConfig().

◆ DisplayWorkstationConfig()

static INT DisplayWorkstationConfig ( VOID  )
static

Definition at line 75 of file cmdConfig.c.

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 
103  ConPrintf(StdOut, L"\\\\%s\n", WorkstationInfo->wki100_computername);
104 
106  ConPuts(StdOut, L"...\n");
107 
109  ConPrintf(StdOut, L"%s\n", UserInfo->wkui1_username);
110 
111  ConPuts(StdOut, L"\n");
112 
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 
124  ConPrintf(StdOut, L"%lu.%lu\n",
125  WorkstationInfo->wki100_ver_major,
126  WorkstationInfo->wki100_ver_minor);
127 
128  ConPuts(StdOut, L"\n");
129 
131  ConPrintf(StdOut, L"%s\n", WorkstationInfo->wki100_langroup);
132 
134  ConPrintf(StdOut, L"%s\n", UserInfo->wkui1_logon_domain);
135 
136 done:
137  if (TransportInfo != NULL)
138  NetApiBufferFree(TransportInfo);
139 
140  if (UserInfo != NULL)
141  NetApiBufferFree(UserInfo);
142 
143  if (WorkstationInfo != NULL)
144  NetApiBufferFree(WorkstationInfo);
145 
146  return 0;
147 }
#define MAX_PREFERRED_LENGTH
Definition: lmcons.h:48
#define IDS_CONFIG_WORKSTATION_NAME
Definition: resource.h:27
#define IDS_CONFIG_WORKSTATION_USERNAME
Definition: resource.h:29
LPWSTR wkui1_username
Definition: lmwksta.h:204
int32_t INT
Definition: typedefs.h:56
#define NERR_Success
Definition: lmerr.h:5
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
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
smooth NULL
Definition: ftsmooth.c:416
#define IDS_CONFIG_WORKSTATION_VERSION
Definition: resource.h:31
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
NET_API_STATUS WINAPI NetWkstaUserGetInfo(LMSTR reserved, DWORD level, PBYTE *bufptr)
Definition: wksta.c:279
#define IDS_CONFIG_WORKSTATION_DOMAIN
Definition: resource.h:32
unsigned long DWORD
Definition: ntddk_ex.h:95
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
static const WCHAR L[]
Definition: oid.c:1250
NET_API_STATUS WINAPI NetWkstaGetInfo(LMSTR servername, DWORD level, LPBYTE *bufptr)
Definition: wksta.c:472
#define IDS_CONFIG_WORKSTATION_ACTIVE
Definition: resource.h:30
#define IDS_CONFIG_WORKSTATION_LOGON
Definition: resource.h:33
LPWSTR wki100_langroup
Definition: lmwksta.h:67
Status
Definition: gdiplustypes.h:24
DWORD wki100_ver_minor
Definition: lmwksta.h:69
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
VOID PrintPaddedResourceString(UINT uID, INT nPaddedLength)
Definition: main.c:52
#define IDS_CONFIG_WORKSTATION_FULLNAME
Definition: resource.h:28
DWORD wki100_ver_major
Definition: lmwksta.h:68
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
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
#define StdOut
Definition: stream.h:76
LPWSTR wki100_computername
Definition: lmwksta.h:66
BYTE * PBYTE
Definition: pedump.c:66
LPWSTR wkui1_logon_domain
Definition: lmwksta.h:205

Referenced by cmdConfig().