ReactOS  0.4.12-dev-43-g63b00d8
net.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winnls.h>
#include <wincon.h>
#include <winsvc.h>
#include <winnetwk.h>
#include <lm.h>
#include <ndk/rtlfuncs.h>
#include <conutils.h>
#include "resource.h"
Include dependency graph for net.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 

Functions

VOID PrintPaddedResourceString (UINT uID, INT nPaddedLength)
 
VOID PrintPadding (WCHAR chr, INT nPaddedLength)
 
VOID PrintErrorMessage (DWORD dwError)
 
VOID ReadFromConsole (LPWSTR lpInput, DWORD dwLength, BOOL bEcho)
 
VOID help (VOID)
 
INT unimplemented (INT argc, WCHAR **argv)
 
INT cmdAccounts (INT argc, WCHAR **argv)
 
INT cmdConfig (INT argc, WCHAR **argv)
 
INT cmdContinue (INT argc, WCHAR **argv)
 
INT cmdGroup (INT argc, WCHAR **argv)
 
INT cmdHelp (INT argc, WCHAR **argv)
 
INT cmdHelpMsg (INT argc, WCHAR **argv)
 
INT cmdLocalGroup (INT argc, WCHAR **argv)
 
INT cmdPause (INT argc, WCHAR **argv)
 
INT cmdStart (INT argc, WCHAR **argv)
 
INT cmdStatistics (INT argc, WCHAR **argv)
 
INT cmdStop (INT argc, WCHAR **argv)
 
INT cmdUse (INT argc, WCHAR **argv)
 
INT cmdUser (INT argc, WCHAR **argv)
 

Macro Definition Documentation

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 15 of file net.h.

Function Documentation

◆ cmdAccounts()

INT cmdAccounts ( INT  argc,
WCHAR **  argv 
)

Definition at line 13 of file cmdAccounts.c.

16 {
17  PUSER_MODALS_INFO_0 Info0 = NULL;
18  PUSER_MODALS_INFO_1 Info1 = NULL;
19  PUSER_MODALS_INFO_3 Info3 = NULL;
20  NT_PRODUCT_TYPE ProductType;
21  LPWSTR p;
22  LPWSTR endptr;
23  DWORD ParamErr;
24  ULONG value;
25  INT i;
26  BOOL Modified = FALSE;
27 #if 0
28  BOOL Domain = FALSE;
29 #endif
30  INT nPaddedLength = 58;
32  INT result = 0;
33 
34  for (i = 2; i < argc; i++)
35  {
36  if (_wcsicmp(argv[i], L"help") == 0)
37  {
38  /* Print short syntax help */
41  return 0;
42  }
43 
44  if (_wcsicmp(argv[i], L"/help") == 0)
45  {
46  /* Print full help text*/
60  return 0;
61  }
62 
63  if (_wcsicmp(argv[i], L"/domain") == 0)
64  {
66 #if 0
67  Domain = TRUE;
68 #endif
69  }
70  }
71 
72  Status = NetUserModalsGet(NULL, 0, (LPBYTE*)&Info0);
73  if (Status != NERR_Success)
74  goto done;
75 
76  for (i = 2; i < argc; i++)
77  {
78  if (_wcsnicmp(argv[i], L"/forcelogoff:", 13) == 0)
79  {
80  p = &argv[i][13];
81  if (wcsicmp(p, L"no"))
82  {
84  Modified = TRUE;
85  }
86  else
87  {
88  value = wcstoul(p, &endptr, 10);
89  if (*endptr != 0)
90  {
92  result = 1;
93  goto done;
94  }
95 
96  Info0->usrmod0_force_logoff = value * 60;
97  Modified = TRUE;
98  }
99  }
100  else if (_wcsnicmp(argv[i], L"/minpwlen:", 10) == 0)
101  {
102  p = &argv[i][10];
103  value = wcstoul(p, &endptr, 10);
104  if (*endptr != 0)
105  {
107  result = 1;
108  goto done;
109  }
110 
111  Info0->usrmod0_min_passwd_len = value;
112  Modified = TRUE;
113  }
114  else if (_wcsnicmp(argv[i], L"/maxpwage:", 10) == 0)
115  {
116  p = &argv[i][10];
117 
118  if (wcsicmp(p, L"unlimited"))
119  {
121  Modified = TRUE;
122  }
123  else
124  {
125  value = wcstoul(p, &endptr, 10);
126  if (*endptr != 0)
127  {
129  result = 1;
130  goto done;
131  }
132 
133  Info0->usrmod0_max_passwd_age = value * 86400;
134  Modified = TRUE;
135  }
136  }
137  else if (_wcsnicmp(argv[i], L"/minpwage:", 10) == 0)
138  {
139  p = &argv[i][10];
140  value = wcstoul(p, &endptr, 10);
141  if (*endptr != 0)
142  {
144  result = 1;
145  goto done;
146  }
147 
148  Info0->usrmod0_min_passwd_age = value * 86400;
149  Modified = TRUE;
150  }
151  else if (_wcsnicmp(argv[i], L"/uniquepw:", 10) == 0)
152  {
153  p = &argv[i][10];
154  value = wcstoul(p, &endptr, 10);
155  if (*endptr != 0)
156  {
158  result = 1;
159  goto done;
160  }
161 
163  Modified = TRUE;
164  }
165  }
166 
167  if (Modified == TRUE)
168  {
169  Status = NetUserModalsSet(NULL, 0, (LPBYTE)Info0, &ParamErr);
170  if (Status != NERR_Success)
171  goto done;
172  }
173  else
174  {
175  Status = NetUserModalsGet(NULL, 1, (LPBYTE*)&Info1);
176  if (Status != NERR_Success)
177  goto done;
178 
179  Status = NetUserModalsGet(NULL, 3, (LPBYTE*)&Info3);
180  if (Status != NERR_Success)
181  goto done;
182 
183  RtlGetNtProductType(&ProductType);
184 
186  if (Info0->usrmod0_force_logoff == TIMEQ_FOREVER)
188  else
190  ConPuts(StdOut, L"\n");
191 
193  ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_min_passwd_age / 86400);
194 
196  ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_max_passwd_age / 86400);
197 
199  ConPrintf(StdOut, L"%lu\n", Info0->usrmod0_min_passwd_len);
200 
202  if (Info0->usrmod0_password_hist_len == 0)
204  else
206  ConPuts(StdOut, L"\n");
207 
209  if (Info3->usrmod3_lockout_threshold == 0)
211  else
213  ConPuts(StdOut, L"\n");
214 
216  ConPrintf(StdOut, L"%lu\n", Info3->usrmod3_lockout_duration / 60);
217 
220 
222  if (Info1->usrmod1_role == UAS_ROLE_PRIMARY)
223  {
224  if (ProductType == NtProductLanManNt)
225  {
227  }
228  else if (ProductType == NtProductServer)
229  {
231  }
232  else
233  {
235  }
236  }
237  else
238  {
240  }
241  ConPuts(StdOut, L"\n");
242  }
243 
244 done:
245  if (Info3 != NULL)
246  NetApiBufferFree(Info3);
247 
248  if (Info1 != NULL)
249  NetApiBufferFree(Info1);
250 
251  if (Info0 != NULL)
252  NetApiBufferFree(Info0);
253 
254  return result;
255 }
static int argc
Definition: ServiceArgs.c:12
#define IDS_ACCOUNTS_LOGOFF_SECONDS
Definition: resource.h:88
#define IDS_ACCOUNTS_PRIMARY_SERVER
Definition: resource.h:97
#define TRUE
Definition: types.h:120
#define IDS_ACCOUNTS_WORKSTATION
Definition: resource.h:100
#define IDS_ACCOUNTS_MIN_PW_LENGTH
Definition: resource.h:91
#define IDS_ACCOUNTS_MAX_PW_AGE
Definition: resource.h:90
#define IDS_ACCOUNTS_LOCKOUT_WINDOW
Definition: resource.h:95
DWORD usrmod3_lockout_threshold
Definition: lmaccess.h:450
_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)
#define IDS_ERROR_INVALID_OPTION_VALUE
Definition: resource.h:206
#define IDS_ACCOUNTS_STANDALONE_SERVER
Definition: resource.h:99
DWORD usrmod3_lockout_duration
Definition: lmaccess.h:448
#define IDS_ACCOUNTS_LOCKOUT_DURATION
Definition: resource.h:94
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
int32_t INT
Definition: typedefs.h:56
static char ** argv
Definition: ServiceArgs.c:11
#define NERR_Success
Definition: lmerr.h:5
DWORD usrmod0_min_passwd_len
Definition: lmaccess.h:433
#define IDS_ACCOUNTS_BACKUP_SERVER
Definition: resource.h:98
#define IDS_GENERIC_NEVER
Definition: resource.h:197
#define IDS_ACCOUNTS_HELP_10
Definition: resource.h:13
BOOLEAN NTAPI RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType)
Definition: version.c:96
#define IDS_ACCOUNTS_HELP_1
Definition: resource.h:4
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define IDS_GENERIC_SYNTAX
Definition: resource.h:202
unsigned char * LPBYTE
Definition: typedefs.h:52
DWORD usrmod0_max_passwd_age
Definition: lmaccess.h:434
NET_API_STATUS WINAPI NetUserModalsGet(LPCWSTR servername, DWORD level, LPBYTE *bufptr)
Definition: user.c:3261
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
#define IDS_GENERIC_PAGE
Definition: resource.h:203
#define IDS_ACCOUNTS_HELP_3
Definition: resource.h:6
smooth NULL
Definition: ftsmooth.c:416
#define IDS_ACCOUNTS_PW_HIST_LENGTH
Definition: resource.h:92
#define IDS_ACCOUNTS_HELP_2
Definition: resource.h:5
#define IDS_ACCOUNTS_FORCE_LOGOFF
Definition: resource.h:87
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
unsigned int BOOL
Definition: ntddk_ex.h:94
NET_API_STATUS WINAPI NetUserModalsSet(IN LPCWSTR servername, IN DWORD level, IN LPBYTE buf, OUT LPDWORD parm_err)
Definition: user.c:3545
#define UAS_ROLE_PRIMARY
Definition: lmaccess.h:53
#define IDS_ACCOUNTS_COMPUTER_ROLE
Definition: resource.h:96
#define IDS_ACCOUNTS_HELP_5
Definition: resource.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
#define StdErr
Definition: stream.h:77
DWORD usrmod0_password_hist_len
Definition: lmaccess.h:437
DWORD usrmod0_min_passwd_age
Definition: lmaccess.h:435
#define IDS_ACCOUNTS_HELP_4
Definition: resource.h:7
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
#define IDS_ERROR_OPTION_NOT_SUPPORTED
Definition: resource.h:205
static const WCHAR L[]
Definition: oid.c:1087
GLsizei const GLfloat * value
Definition: glext.h:6069
#define wcsicmp
Definition: string.h:1152
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:51
DWORD usrmod0_force_logoff
Definition: lmaccess.h:436
DWORD usrmod3_lockout_observation_window
Definition: lmaccess.h:449
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
#define IDS_ACCOUNTS_LOCKOUT_THRESHOLD
Definition: resource.h:93
#define IDS_ACCOUNTS_HELP_6
Definition: resource.h:9
#define TIMEQ_FOREVER
Definition: lmaccess.h:110
#define StdOut
Definition: stream.h:76
enum _NT_PRODUCT_TYPE NT_PRODUCT_TYPE
unsigned int ULONG
Definition: retypes.h:1
#define IDS_GENERIC_NONE
Definition: resource.h:198
#define IDS_ACCOUNTS_HELP_9
Definition: resource.h:12
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDS_ACCOUNTS_SYNTAX
Definition: resource.h:3
GLuint64EXT * result
Definition: glext.h:11304
#define IDS_ACCOUNTS_HELP_7
Definition: resource.h:10
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define ULONG_MAX
Definition: limits.h:44
#define IDS_ACCOUNTS_HELP_8
Definition: resource.h:11
#define IDS_ACCOUNTS_MIN_PW_AGE
Definition: resource.h:89

◆ 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  {
187  }
188  else
189  {
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  {
209  }
210  else
211  {
216  }
217  return 0;
218  }
219  }
220 
221  if (bServer)
222  {
223  Status = NetServerGetInfo(NULL, 102, (PBYTE*)&ServerInfo);
224  if (Status != NERR_Success)
225  goto done;
226 
227  for (i = 2; i < argc; i++)
228  {
229  if (argv[i][0] != L'/')
230  continue;
231 
232  if (_wcsnicmp(argv[i], L"/autodisconnect:", 16) == 0)
233  {
234  p = &argv[i][16];
235  lValue = wcstol(p, &endptr, 10);
236  if (*endptr != 0)
237  {
239  result = 1;
240  goto done;
241  }
242 
243  if (lValue < -1 || lValue > 65535)
244  {
246  result = 1;
247  goto done;
248  }
249 
250  ServerInfo->sv102_disc = lValue;
251  bModify = TRUE;
252  }
253  else if (_wcsnicmp(argv[i], L"/srvcomment:", 12) == 0)
254  {
255  ServerInfo->sv102_comment = &argv[i][12];
256  bModify = TRUE;
257  }
258  else if (_wcsnicmp(argv[i], L"/hidden:", 8) == 0)
259  {
260  p = &argv[i][8];
261  if (_wcsicmp(p, L"yes") != 0 && _wcsicmp(p, L"no") != 0)
262  {
264  result = 1;
265  goto done;
266  }
267 
268  ServerInfo->sv102_hidden = (_wcsicmp(p, L"yes") == 0) ? TRUE : FALSE;
269  bModify = TRUE;
270  }
271  else
272  {
275  result = 1;
276  goto done;
277  }
278  }
279 
280  if (bModify)
281  {
282  Status = NetServerSetInfo(NULL, 102, (PBYTE)&ServerInfo, NULL);
283  if (Status != NERR_Success)
284  result = 1;
285  }
286  else
287  {
288  result = DisplayServerConfig(ServerInfo);
289  }
290  }
291  else if (bWorkstation)
292  {
293  result = DisplayWorkstationConfig();
294  }
295  else
296  {
298  }
299 
300 done:
301  if (ServerInfo != NULL)
302  NetApiBufferFree(ServerInfo);
303 
304  if (result == 0)
306 
307  return result;
308 }
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
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:206
#define IDS_CONFIG_SYNTAX
Definition: resource.h:17
_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 IDS_CONFIG_SERVER_HELP_5
Definition: resource.h:25
int32_t INT
Definition: typedefs.h:56
static char ** argv
Definition: ServiceArgs.c:11
#define NERR_Success
Definition: lmerr.h:5
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define IDS_GENERIC_SYNTAX
Definition: resource.h:202
long LONG
Definition: pedump.c:60
BOOL sv102_hidden
Definition: lmserver.h:34
#define IDS_GENERIC_PAGE
Definition: resource.h:203
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:102
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IDS_CONFIG_SERVER_HELP_4
Definition: resource.h:24
#define IDS_CONFIG_HELP_1
Definition: resource.h:18
#define IDS_CONFIG_SERVER_HELP_1
Definition: resource.h:21
#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:1087
#define IDS_ERROR_NO_ERROR
Definition: resource.h:208
NET_API_STATUS WINAPI NetServerGetInfo(LMSTR servername, DWORD level, LPBYTE *bufptr)
Definition: srvsvc.c:369
Status
Definition: gdiplustypes.h:24
#define IDS_CONFIG_SERVER_HELP_2
Definition: resource.h:22
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
#define IDS_CONFIG_SERVER_SYNTAX
Definition: resource.h:20
#define IDS_CONFIG_SERVER_HELP_3
Definition: resource.h:23
#define StdOut
Definition: stream.h:76
static INT DisplayWorkstationConfig(VOID)
Definition: cmdConfig.c:75
#define IDS_CONFIG_HELP_2
Definition: resource.h:19
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)

◆ cmdContinue()

INT cmdContinue ( INT  argc,
WCHAR **  argv 
)

Definition at line 12 of file cmdContinue.c.

13 {
14  SC_HANDLE hManager = NULL;
15  SC_HANDLE hService = NULL;
17  INT nError = 0;
18  INT i;
19 
20  if (argc != 3)
21  {
24  return 1;
25  }
26 
27  for (i = 2; i < argc; i++)
28  {
29  if (_wcsicmp(argv[i], L"/help") == 0)
30  {
36  return 1;
37  }
38  }
39 
41  if (hManager == NULL)
42  {
43  ConPrintf(StdErr, L"[OpenSCManager] Error: %ld\n", GetLastError());
44  nError = 1;
45  goto done;
46  }
47 
48  hService = OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE);
49  if (hService == NULL)
50  {
51  ConPrintf(StdErr, L"[OpenService] Error: %ld\n", GetLastError());
52  nError = 1;
53  goto done;
54  }
55 
56  if (!ControlService(hService, SERVICE_CONTROL_CONTINUE, &status))
57  {
58  ConPrintf(StdErr, L"[ControlService] Error: %ld\n", GetLastError());
59  nError = 1;
60  }
61 
62 done:
63  if (hService != NULL)
64  CloseServiceHandle(hService);
65 
66  if (hManager != NULL)
67  CloseServiceHandle(hManager);
68 
69  return nError;
70 }
static int argc
Definition: ServiceArgs.c:12
#define SC_MANAGER_ENUMERATE_SERVICE
Definition: winsvc.h:16
#define SERVICES_ACTIVE_DATABASE
Definition: winsvc.h:564
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
int32_t INT
Definition: typedefs.h:56
#define OpenService
Definition: winsvc.h:576
static char ** argv
Definition: ServiceArgs.c:11
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define IDS_GENERIC_SYNTAX
Definition: resource.h:202
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
#define IDS_GENERIC_PAGE
Definition: resource.h:203
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:576
smooth NULL
Definition: ftsmooth.c:416
#define IDS_CONTINUE_HELP_1
Definition: resource.h:27
#define OpenSCManager
Definition: winsvc.h:575
#define IDS_CONTINUE_HELP_2
Definition: resource.h:28
#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:1087
#define IDS_CONTINUE_SYNTAX
Definition: resource.h:26
#define SERVICE_CONTROL_CONTINUE
Definition: winsvc.h:38
BOOL WINAPI ControlService(SC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
Definition: scm.c:618
#define StdOut
Definition: stream.h:76
static SERVICE_STATUS status
Definition: service.c:31
#define SERVICE_PAUSE_CONTINUE
Definition: winsvc.h:59
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

◆ cmdGroup()

INT cmdGroup ( INT  argc,
WCHAR **  argv 
)

Definition at line 154 of file cmdGroup.c.

157 {
158  INT i, j;
159  INT result = 0;
160  ULONG dwUserCount = 0;
161  BOOL bAdd = FALSE;
162  BOOL bDelete = FALSE;
163 #if 0
164  BOOL bDomain = FALSE;
165 #endif
166  PWSTR pGroupName = NULL;
167  PWSTR pComment = NULL;
168  PWSTR *pUsers = NULL;
169  GROUP_INFO_0 Info0;
170  GROUP_INFO_1 Info1;
171  GROUP_INFO_1002 Info1002;
173 
174  if (argc == 2)
175  {
176  Status = EnumerateGroups();
177  ConPrintf(StdOut, L"Status: %lu\n", Status);
178  return 0;
179  }
180  else if (argc == 3)
181  {
182  Status = DisplayGroup(argv[2]);
183  ConPrintf(StdOut, L"Status: %lu\n", Status);
184  return 0;
185  }
186 
187  i = 2;
188  if (argv[i][0] != L'/')
189  {
190  pGroupName = argv[i];
191  i++;
192  }
193 
194  for (j = i; j < argc; j++)
195  {
196  if (argv[j][0] == L'/')
197  break;
198 
199  dwUserCount++;
200  }
201 
202  if (dwUserCount > 0)
203  {
204  pUsers = RtlAllocateHeap(RtlGetProcessHeap(),
206  dwUserCount * sizeof(PGROUP_USERS_INFO_0));
207  if (pUsers == NULL)
208  return 0;
209  }
210 
211  j = 0;
212  for (; i < argc; i++)
213  {
214  if (argv[i][0] == L'/')
215  break;
216 
217  pUsers[j] = argv[i];
218  j++;
219  }
220 
221  for (; i < argc; i++)
222  {
223  if (_wcsicmp(argv[i], L"/help") == 0)
224  {
235  return 0;
236  }
237  else if (_wcsicmp(argv[i], L"/add") == 0)
238  {
239  bAdd = TRUE;
240  }
241  else if (_wcsicmp(argv[i], L"/delete") == 0)
242  {
243  bDelete = TRUE;
244  }
245  else if (_wcsnicmp(argv[i], L"/comment:", 9) == 0)
246  {
247  pComment = &argv[i][9];
248  }
249  else if (_wcsicmp(argv[i], L"/domain") == 0)
250  {
252 #if 0
253  bDomain = TRUE;
254 #endif
255  }
256  else
257  {
258  result = 1;
259  goto done;
260  }
261  }
262 
263  if (pGroupName == NULL)
264  {
265  result = 1;
266  goto done;
267  }
268 
269  if (bAdd && bDelete)
270  {
271  result = 1;
272  goto done;
273  }
274 
275  if (pUsers == NULL)
276  {
277  if (!bAdd && !bDelete && pComment != NULL)
278  {
279  /* Set group comment */
280  Info1002.grpi1002_comment = pComment;
281  Status = NetGroupSetInfo(NULL,
282  pGroupName,
283  1002,
284  (LPBYTE)&Info1002,
285  NULL);
286  ConPrintf(StdOut, L"Status: %lu\n", Status);
287  }
288  else if (bAdd && !bDelete)
289  {
290  /* Add the group */
291  if (pComment == NULL)
292  {
293  Info0.grpi0_name = pGroupName;
294  }
295  else
296  {
297  Info1.grpi1_name = pGroupName;
298  Info1.grpi1_comment = pComment;
299  }
300 
301  Status = NetGroupAdd(NULL,
302  (pComment == NULL) ? 0 : 1,
303  (pComment == NULL) ? (LPBYTE)&Info0 : (LPBYTE)&Info1,
304  NULL);
305  ConPrintf(StdOut, L"Status: %lu\n", Status);
306  }
307  else if (!bAdd && bDelete && pComment == NULL)
308  {
309  /* Delete the group */
310  Status = NetGroupDel(NULL,
311  pGroupName);
312  ConPrintf(StdOut, L"Status: %lu\n", Status);
313  }
314  else
315  {
316  result = 1;
317  }
318  }
319  else
320  {
321  if (bAdd && !bDelete && pComment == NULL)
322  {
323  /* Add group user */
324  for (i = 0; i < dwUserCount; i++)
325  {
326  Status = NetGroupAddUser(NULL,
327  pGroupName,
328  pUsers[i]);
329  if (Status != NERR_Success)
330  break;
331  }
332  ConPrintf(StdOut, L"Status: %lu\n", Status);
333  }
334  else if (!bAdd && bDelete && pComment == NULL)
335  {
336  /* Delete group members */
337  for (i = 0; i < dwUserCount; i++)
338  {
339  Status = NetGroupDelUser(NULL,
340  pGroupName,
341  pUsers[i]);
342  if (Status != NERR_Success)
343  break;
344  }
345  ConPrintf(StdOut, L"Status: %lu\n", Status);
346  }
347  else
348  {
349  result = 1;
350  }
351  }
352 
353 done:
354  if (pUsers != NULL)
355  RtlFreeHeap(RtlGetProcessHeap(), 0, pUsers);
356 
357  if (result != 0)
358  {
361  }
362 
363  return result;
364 }
#define IDS_GROUP_HELP_7
Definition: resource.h:38
static int argc
Definition: ServiceArgs.c:12
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:54
LPWSTR grpi0_name
Definition: lmaccess.h:474
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
LPWSTR grpi1002_comment
Definition: lmaccess.h:493
_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)
NET_API_STATUS WINAPI NetGroupSetInfo(_In_opt_ LPCWSTR servername, _In_ LPCWSTR groupname, _In_ DWORD level, _In_ LPBYTE buf, _Out_opt_ LPDWORD parm_err)
Definition: group_new.c:1379
int32_t INT
Definition: typedefs.h:56
static char ** argv
Definition: ServiceArgs.c:11
#define NERR_Success
Definition: lmerr.h:5
static NET_API_STATUS EnumerateGroups(VOID)
Definition: cmdGroup.c:23
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define IDS_GENERIC_SYNTAX
Definition: resource.h:202
unsigned char * LPBYTE
Definition: typedefs.h:52
static NET_API_STATUS DisplayGroup(LPWSTR lpGroupName)
Definition: cmdGroup.c:75
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
#define IDS_GENERIC_PAGE
Definition: resource.h:203
smooth NULL
Definition: ftsmooth.c:416
NET_API_STATUS WINAPI NetGroupAddUser(_In_opt_ LPCWSTR servername, _In_ LPCWSTR groupname, _In_ LPCWSTR username)
Definition: group_new.c:463
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IDS_GROUP_SYNTAX
Definition: resource.h:31
#define IDS_GROUP_HELP_2
Definition: resource.h:33
#define StdErr
Definition: stream.h:77
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
#define IDS_ERROR_OPTION_NOT_SUPPORTED
Definition: resource.h:205
static const WCHAR L[]
Definition: oid.c:1087
#define IDS_GROUP_HELP_5
Definition: resource.h:36
LPWSTR grpi1_comment
Definition: lmaccess.h:478
LPWSTR grpi1_name
Definition: lmaccess.h:477
Status
Definition: gdiplustypes.h:24
#define IDS_GROUP_HELP_1
Definition: resource.h:32
NET_API_STATUS WINAPI NetGroupAdd(_In_opt_ LPCWSTR servername, _In_ DWORD level, _In_ LPBYTE buf, _Out_opt_ LPDWORD parm_err)
Definition: group_new.c:286
#define IDS_GROUP_HELP_4
Definition: resource.h:35
NET_API_STATUS WINAPI NetGroupDelUser(_In_opt_ LPCWSTR servername, _In_ LPCWSTR groupname, _In_ LPCWSTR username)
Definition: group_new.c:662
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define StdOut
Definition: stream.h:76
unsigned int ULONG
Definition: retypes.h:1
GLuint64EXT * result
Definition: glext.h:11304
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
NET_API_STATUS WINAPI NetGroupDel(_In_opt_ LPCWSTR servername, _In_ IN LPCWSTR groupname)
Definition: group_new.c:579
#define IDS_GROUP_HELP_3
Definition: resource.h:34
#define IDS_GROUP_HELP_6
Definition: resource.h:37

◆ cmdHelp()

INT cmdHelp ( INT  argc,
WCHAR **  argv 
)

Definition at line 12 of file help.c.

13 {
15 
16 /*
17  if (argc != 3)
18  {
19  ConResPuts(StdOut, IDS_HELP_SYNTAX);
20  return 0;
21  }
22 */
23  if (_wcsicmp(argv[2], L"ACCOUNTS") == 0)
24  {
37  return 0;
38  }
39 
40  if (_wcsicmp(argv[2], L"COMPUTER") == 0)
41  {
45  return 0;
46  }
47 
48  if (_wcsicmp(argv[2], L"CONFIG") == 0)
49  {
50  if ((argc > 3) && (_wcsicmp(argv[3], L"SERVER") == 0))
51  {
59  return 0;
60  }
61  else
62  {
67  return 0;
68  }
69  }
70 
71  if (_wcsicmp(argv[2], L"CONTINUE") == 0)
72  {
76  return 0;
77  }
78 
79  if (_wcsicmp(argv[2], L"FILE") == 0)
80  {
83  return 0;
84  }
85 
86  if (_wcsicmp(argv[2], L"GROUP") == 0)
87  {
97  return 0;
98  }
99 
100  if (_wcsicmp(argv[2], L"HELPMSG") == 0)
101  {
105  return 0;
106  }
107 
108  if (_wcsicmp(argv[2], L"LOCALGROUP") == 0)
109  {
119  return 0;
120  }
121 
122  if (_wcsicmp(argv[2], L"NAME") == 0)
123  {
126  return 0;
127  }
128 
129  if (_wcsicmp(argv[2], L"PAUSE") == 0)
130  {
134  return 0;
135  }
136 
137  if (_wcsicmp(argv[2], L"PRINT") == 0)
138  {
141  return 0;
142  }
143 
144  if (_wcsicmp(argv[2], L"SEND") == 0)
145  {
148  return 0;
149  }
150 
151  if (_wcsicmp(argv[2], L"SESSION") == 0)
152  {
155  return 0;
156  }
157 
158  if (_wcsicmp(argv[2], L"SHARE") == 0)
159  {
162  return 0;
163  }
164 
165  if (_wcsicmp(argv[2], L"START") == 0)
166  {
171  return 0;
172  }
173 
174  if (_wcsicmp(argv[2], L"STATISTICS") == 0)
175  {
179  return 0;
180  }
181 
182  if (_wcsicmp(argv[2], L"STOP") == 0)
183  {
188  return 0;
189  }
190 
191  if (_wcsicmp(argv[2], L"TIME") == 0)
192  {
195  return 0;
196  }
197 
198  if (_wcsicmp(argv[2], L"USE") == 0)
199  {
202  return 0;
203  }
204 
205  if (_wcsicmp(argv[2], L"USER") == 0)
206  {
209  return 0;
210  }
211 
212  if (_wcsicmp(argv[2], L"VIEW") == 0)
213  {
216  return 0;
217  }
218 
219 #if 0
220  if (_wcsicmp(argv[2], L"SERVICES") == 0)
221  {
222  return 0;
223  }
224 
225  if (_wcsicmp(argv[2], L"SYNTAX") == 0)
226  {
227  return 0;
228  }
229 #endif
230 
234 
235  return 0;
236 }
#define IDS_STOP_SYNTAX
Definition: resource.h:73
#define IDS_GROUP_HELP_7
Definition: resource.h:38
#define IDS_LOCALGROUP_SYNTAX
Definition: resource.h:45
static int argc
Definition: ServiceArgs.c:12
#define IDS_PRINT_SYNTAX
Definition: resource.h:58
#define IDS_USER_HELP
Definition: resource.h:82
#define IDS_HELPMSG_HELP_2
Definition: resource.h:44
#define IDS_USE_SYNTAX
Definition: resource.h:79
#define IDS_HELP_HELP_1
Definition: resource.h:40
#define IDS_VIEW_HELP
Definition: resource.h:84
#define IDS_COMPUTER_SYNTAX
Definition: resource.h:14
#define IDS_VIEW_SYNTAX
Definition: resource.h:83
#define IDS_FILE_HELP
Definition: resource.h:30
#define IDS_CONFIG_SYNTAX
Definition: resource.h:17
#define IDS_CONFIG_SERVER_HELP_5
Definition: resource.h:25
#define IDS_STOP_HELP_1
Definition: resource.h:74
static char ** argv
Definition: ServiceArgs.c:11
#define IDS_LOCALGROUP_HELP_4
Definition: resource.h:49
#define IDS_PAUSE_HELP_1
Definition: resource.h:56
#define IDS_ACCOUNTS_HELP_10
Definition: resource.h:13
#define IDS_ACCOUNTS_HELP_1
Definition: resource.h:4
#define IDS_GENERIC_SYNTAX
Definition: resource.h:202
#define IDS_GENERIC_PAGE
Definition: resource.h:203
#define IDS_ACCOUNTS_HELP_3
Definition: resource.h:6
#define IDS_HELPMSG_SYNTAX
Definition: resource.h:42
#define IDS_START_HELP_1
Definition: resource.h:67
#define IDS_CONTINUE_HELP_1
Definition: resource.h:27
#define IDS_NAME_SYNTAX
Definition: resource.h:53
#define IDS_ACCOUNTS_HELP_2
Definition: resource.h:5
#define IDS_STATISTICS_HELP_2
Definition: resource.h:72
#define IDS_NAME_HELP
Definition: resource.h:54
#define IDS_SESSION_SYNTAX
Definition: resource.h:62
#define IDS_START_HELP_2
Definition: resource.h:68
#define IDS_GROUP_SYNTAX
Definition: resource.h:31
#define IDS_SHARE_SYNTAX
Definition: resource.h:64
#define IDS_CONFIG_SERVER_HELP_4
Definition: resource.h:24
#define IDS_GROUP_HELP_2
Definition: resource.h:33
#define IDS_CONTINUE_HELP_2
Definition: resource.h:28
#define IDS_CONFIG_HELP_1
Definition: resource.h:18
#define IDS_ACCOUNTS_HELP_5
Definition: resource.h:8
#define IDS_CONFIG_SERVER_HELP_1
Definition: resource.h:21
#define IDS_ACCOUNTS_HELP_4
Definition: resource.h:7
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
static const WCHAR L[]
Definition: oid.c:1087
#define IDS_GROUP_HELP_5
Definition: resource.h:36
#define IDS_COMPUTER_HELP_1
Definition: resource.h:15
#define IDS_HELP_SYNTAX
Definition: resource.h:39
#define IDS_PAUSE_SYNTAX
Definition: resource.h:55
#define IDS_CONFIG_SERVER_HELP_2
Definition: resource.h:22
#define IDS_LOCALGROUP_HELP_6
Definition: resource.h:51
#define IDS_GROUP_HELP_1
Definition: resource.h:32
#define IDS_CONTINUE_SYNTAX
Definition: resource.h:26
#define IDS_STATISTICS_SYNTAX
Definition: resource.h:70
#define IDS_USE_HELP
Definition: resource.h:80
#define IDS_STOP_HELP_3
Definition: resource.h:76
#define IDS_LOCALGROUP_HELP_3
Definition: resource.h:48
#define IDS_HELPMSG_HELP_1
Definition: resource.h:43
#define IDS_USER_SYNTAX
Definition: resource.h:81
#define IDS_SESSION_HELP
Definition: resource.h:63
#define IDS_LOCALGROUP_HELP_2
Definition: resource.h:47
#define IDS_GROUP_HELP_4
Definition: resource.h:35
#define IDS_LOCALGROUP_HELP_7
Definition: resource.h:52
#define IDS_CONFIG_SERVER_SYNTAX
Definition: resource.h:20
#define IDS_CONFIG_SERVER_HELP_3
Definition: resource.h:23
#define IDS_FILE_SYNTAX
Definition: resource.h:29
#define IDS_ACCOUNTS_HELP_6
Definition: resource.h:9
#define IDS_SEND_SYNTAX
Definition: resource.h:60
#define IDS_LOCALGROUP_HELP_1
Definition: resource.h:46
#define IDS_COMPUTER_HELP_2
Definition: resource.h:16
#define StdOut
Definition: stream.h:76
#define IDS_SHARE_HELP
Definition: resource.h:65
#define IDS_HELP_HELP_2
Definition: resource.h:41
#define IDS_ACCOUNTS_HELP_9
Definition: resource.h:12
#define IDS_CONFIG_HELP_2
Definition: resource.h:19
#define IDS_LOCALGROUP_HELP_5
Definition: resource.h:50
#define IDS_TIME_HELP
Definition: resource.h:78
#define IDS_ACCOUNTS_SYNTAX
Definition: resource.h:3
#define IDS_PRINT_HELP
Definition: resource.h:59
#define IDS_SEND_HELP
Definition: resource.h:61
#define IDS_STOP_HELP_2
Definition: resource.h:75
#define IDS_ACCOUNTS_HELP_7
Definition: resource.h:10
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define IDS_PAUSE_HELP_2
Definition: resource.h:57
#define IDS_STATISTICS_HELP_1
Definition: resource.h:71
#define IDS_START_SYNTAX
Definition: resource.h:66
#define IDS_ACCOUNTS_HELP_8
Definition: resource.h:11
#define IDS_TIME_SYNTAX
Definition: resource.h:77
#define IDS_START_HELP_3
Definition: resource.h:69
#define IDS_GROUP_HELP_3
Definition: resource.h:34
#define IDS_GROUP_HELP_6
Definition: resource.h:37

◆ cmdHelpMsg()

INT cmdHelpMsg ( INT  argc,
WCHAR **  argv 
)

Definition at line 14 of file cmdHelpMsg.c.

15 {
16  WCHAR szBuffer[MAX_PATH];
17  HMODULE hMsgDll = NULL;
18  INT i;
19  LONG errNum;
20  PWSTR endptr;
21  PWSTR pBuffer;
22  PWSTR pInserts[10] = {L"***", L"***", L"***", L"***",
23  L"***", L"***", L"***", L"***",
24  L"***", NULL};
25 
26  if (argc < 3)
27  {
30  return 1;
31  }
32 
33  for (i = 2; i < argc; i++)
34  {
35  if (_wcsicmp(argv[i], L"/help") == 0)
36  {
41  return 1;
42  }
43  }
44 
45  errNum = wcstol(argv[2], &endptr, 10);
46  if (*endptr != 0)
47  {
50  return 1;
51  }
52 
53  if (errNum >= MIN_LANMAN_MESSAGE_ID && errNum <= MAX_LANMAN_MESSAGE_ID)
54  {
55  /* Load netmsg.dll */
56  GetSystemDirectoryW(szBuffer, ARRAYSIZE(szBuffer));
57  wcscat(szBuffer, L"\\netmsg.dll");
58 
59  hMsgDll = LoadLibrary(szBuffer);
60  if (hMsgDll == NULL)
61  {
62  ConPrintf(StdOut, L"Failed to load netmsg.dll\n");
63  return 0;
64  }
65 
68  hMsgDll,
69  errNum,
71  (LPWSTR)&pBuffer,
72  0,
73  (va_list *)pInserts);
74  if (pBuffer)
75  {
76  ConPrintf(StdOut, L"\n%s\n", pBuffer);
77  LocalFree(pBuffer);
78  }
79  else
80  {
81  PrintErrorMessage(3871);
82  }
83 
84  FreeLibrary(hMsgDll);
85  }
86  else
87  {
88  /* Retrieve the message string without appending extra newlines */
91  NULL,
92  errNum,
94  (LPWSTR)&pBuffer,
95  0,
96  (va_list *)pInserts);
97  if (pBuffer)
98  {
99  ConPrintf(StdOut, L"\n%s\n", pBuffer);
100  LocalFree(pBuffer);
101  }
102  else
103  {
104  PrintErrorMessage(3871);
105  }
106  }
107 
108  return 0;
109 }
static int argc
Definition: ServiceArgs.c:12
#define IDS_HELPMSG_HELP_2
Definition: resource.h:44
#define LoadLibrary
Definition: winbase.h:3676
__wchar_t WCHAR
Definition: xmlstorage.h:180
uint16_t * PWSTR
Definition: typedefs.h:54
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:405
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
int32_t INT
Definition: typedefs.h:56
static char ** argv
Definition: ServiceArgs.c:11
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define IDS_GENERIC_SYNTAX
Definition: resource.h:202
long LONG
Definition: pedump.c:60
#define MIN_LANMAN_MESSAGE_ID
Definition: lmcons.h:10
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
smooth NULL
Definition: ftsmooth.c:416
PVOID pBuffer
char * va_list
Definition: acmsvcex.h:78
#define IDS_HELPMSG_SYNTAX
Definition: resource.h:42
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:403
#define FreeLibrary(x)
Definition: compat.h:405
#define MAX_LANMAN_MESSAGE_ID
Definition: lmcons.h:11
#define MAX_PATH
Definition: compat.h:26
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
static const WCHAR L[]
Definition: oid.c:1087
static VOID PrintErrorMessage(DWORD dwError)
Definition: at.c:308
#define IDS_HELPMSG_HELP_1
Definition: resource.h:43
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2312
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define StdOut
Definition: stream.h:76
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50

◆ cmdLocalGroup()

INT cmdLocalGroup ( INT  argc,
WCHAR **  argv 
)

Definition at line 172 of file cmdLocalGroup.c.

175 {
176  INT i, j;
177  INT result = 0;
178  ULONG dwMemberCount = 0;
179  BOOL bAdd = FALSE;
180  BOOL bDelete = FALSE;
181 #if 0
182  BOOL bDomain = FALSE;
183 #endif
184  LPWSTR lpGroupName = NULL;
185  LPWSTR lpComment = NULL;
186  LPLOCALGROUP_MEMBERS_INFO_3 lpMembers = NULL;
187  LOCALGROUP_INFO_0 Info0;
188  LOCALGROUP_INFO_1 Info1;
189  LOCALGROUP_INFO_1002 Info1002;
191 
192  if (argc == 2)
193  {
194  Status = EnumerateLocalGroups();
195  ConPrintf(StdOut, L"Status: %lu\n", Status);
196  return 0;
197  }
198  else if (argc == 3)
199  {
200  Status = DisplayLocalGroup(argv[2]);
201  ConPrintf(StdOut, L"Status: %lu\n", Status);
202  return 0;
203  }
204 
205  i = 2;
206  if (argv[i][0] != L'/')
207  {
208  lpGroupName = argv[i];
209  i++;
210  }
211 
212  for (j = i; j < argc; j++)
213  {
214  if (argv[j][0] == L'/')
215  break;
216 
217  dwMemberCount++;
218  }
219 
220  ConPrintf(StdOut, L"Member count: %lu\n", dwMemberCount);
221 
222  if (dwMemberCount > 0)
223  {
224  lpMembers = RtlAllocateHeap(RtlGetProcessHeap(),
226  dwMemberCount * sizeof(LPLOCALGROUP_MEMBERS_INFO_3));
227  if (lpMembers == NULL)
228  return 0;
229  }
230 
231  j = 0;
232  for (; i < argc; i++)
233  {
234  if (argv[i][0] == L'/')
235  break;
236 
237  lpMembers[j].lgrmi3_domainandname = argv[i];
238  j++;
239  }
240 
241  for (; i < argc; i++)
242  {
243  if (_wcsicmp(argv[i], L"/help") == 0)
244  {
255  return 0;
256  }
257  else if (_wcsicmp(argv[i], L"/add") == 0)
258  {
259  bAdd = TRUE;
260  }
261  else if (_wcsicmp(argv[i], L"/delete") == 0)
262  {
263  bDelete = TRUE;
264  }
265  else if (_wcsnicmp(argv[i], L"/comment:", 9) == 0)
266  {
267  lpComment = &argv[i][9];
268  }
269  else if (_wcsicmp(argv[i], L"/domain") == 0)
270  {
272 #if 0
273  bDomain = TRUE;
274 #endif
275  }
276  else
277  {
278  result = 1;
279  goto done;
280  }
281  }
282 
283  if (lpGroupName == NULL)
284  {
285  result = 1;
286  goto done;
287  }
288 
289  if (bAdd && bDelete)
290  {
291  result = 1;
292  goto done;
293  }
294 
295 #if 0
296  ConPrintf(StdOut, L"Group:\n %s\n", lpGroupName);
297 
298  if (lpMembers != NULL)
299  {
300  ConPuts(StdOut, L"\nMembers:\n");
301  for (i = 0; i < dwMemberCount; i++)
302  ConPrintf(StdOut, L" %s\n", lpMembers[i].lgrmi3_domainandname);
303  }
304 
305  if (lpComment != NULL)
306  {
307  ConPrintf(StdOut, L"\nComment:\n %s\n", lpComment);
308  }
309 #endif
310 
311  if (lpMembers == NULL)
312  {
313  if (!bAdd && !bDelete && lpComment != NULL)
314  {
315  /* Set group comment */
316  Info1002.lgrpi1002_comment = lpComment;
317  Status = NetLocalGroupSetInfo(NULL,
318  lpGroupName,
319  1002,
320  (LPBYTE)&Info1002,
321  NULL);
322  ConPrintf(StdOut, L"Status: %lu\n", Status);
323  }
324  else if (bAdd && !bDelete)
325  {
326  /* Add the group */
327  if (lpComment == NULL)
328  {
329  Info0.lgrpi0_name = lpGroupName;
330  }
331  else
332  {
333  Info1.lgrpi1_name = lpGroupName;
334  Info1.lgrpi1_comment = lpComment;
335  }
336 
337  Status = NetLocalGroupAdd(NULL,
338  (lpComment == NULL) ? 0 : 1,
339  (lpComment == NULL) ? (LPBYTE)&Info0 : (LPBYTE)&Info1,
340  NULL);
341  ConPrintf(StdOut, L"Status: %lu\n", Status);
342  }
343  else if (!bAdd && bDelete && lpComment == NULL)
344  {
345  /* Delete the group */
346  Status = NetLocalGroupDel(NULL,
347  lpGroupName);
348  ConPrintf(StdOut, L"Status: %lu\n", Status);
349  }
350  else
351  {
352  result = 1;
353  }
354  }
355  else
356  {
357  if (bAdd && !bDelete && lpComment == NULL)
358  {
359  /* Add group members */
360  Status = NetLocalGroupAddMembers(NULL,
361  lpGroupName,
362  3,
363  (LPBYTE)lpMembers,
364  dwMemberCount);
365  ConPrintf(StdOut, L"Status: %lu\n", Status);
366  }
367  else if (!bAdd && bDelete && lpComment == NULL)
368  {
369  /* Delete group members */
370  Status = NetLocalGroupDelMembers(NULL,
371  lpGroupName,
372  3,
373  (LPBYTE)lpMembers,
374  dwMemberCount);
375  ConPrintf(StdOut, L"Status: %lu\n", Status);
376  }
377  else
378  {
379  result = 1;
380  }
381  }
382 
383 done:
384  if (lpMembers != NULL)
385  RtlFreeHeap(RtlGetProcessHeap(), 0, lpMembers);
386 
387  if (result != 0)
388  {
391  }
392 
393  return result;
394 }
NET_API_STATUS WINAPI NetLocalGroupDelMembers(LPCWSTR servername, LPCWSTR groupname, DWORD level, LPBYTE buf, DWORD totalentries)
Definition: local_group.c:814
#define IDS_LOCALGROUP_SYNTAX
Definition: resource.h:45
static int argc
Definition: ServiceArgs.c:12
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
#define TRUE
Definition: types.h:120
NET_API_STATUS WINAPI NetLocalGroupAddMembers(LPCWSTR servername, LPCWSTR groupname, DWORD level, LPBYTE buf, DWORD totalentries)
Definition: local_group.c:517
NET_API_STATUS WINAPI NetLocalGroupAdd(LPCWSTR servername, DWORD level, LPBYTE buf, LPDWORD parm_err)
Definition: local_group.c:334
static NET_API_STATUS EnumerateLocalGroups(VOID)
Definition: cmdLocalGroup.c:25
static NET_API_STATUS DisplayLocalGroup(LPWSTR lpGroupName)
Definition: cmdLocalGroup.c:78
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
_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 lgrpi1_comment
Definition: lmaccess.h:510
int32_t INT
Definition: typedefs.h:56
static char ** argv
Definition: ServiceArgs.c:11
#define IDS_LOCALGROUP_HELP_4
Definition: resource.h:49
NET_API_STATUS WINAPI NetLocalGroupSetInfo(LPCWSTR servername, LPCWSTR groupname, DWORD level, LPBYTE buf, LPDWORD parm_err)
Definition: local_group.c:1729
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define IDS_GENERIC_SYNTAX
Definition: resource.h:202
unsigned char * LPBYTE
Definition: typedefs.h:52
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
#define IDS_GENERIC_PAGE
Definition: resource.h:203
smooth NULL
Definition: ftsmooth.c:416
LPWSTR lgrpi1002_comment
Definition: lmaccess.h:513
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
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
LPWSTR lgrpi0_name
Definition: lmaccess.h:506
#define IDS_ERROR_OPTION_NOT_SUPPORTED
Definition: resource.h:205
static const WCHAR L[]
Definition: oid.c:1087
LPWSTR lgrpi1_name
Definition: lmaccess.h:509
Status
Definition: gdiplustypes.h:24
#define IDS_LOCALGROUP_HELP_6
Definition: resource.h:51
#define IDS_LOCALGROUP_HELP_3
Definition: resource.h:48
#define IDS_LOCALGROUP_HELP_2
Definition: resource.h:47
#define IDS_LOCALGROUP_HELP_7
Definition: resource.h:52
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
#define IDS_LOCALGROUP_HELP_1
Definition: resource.h:46
#define StdOut
Definition: stream.h:76
NET_API_STATUS WINAPI NetLocalGroupDel(LPCWSTR servername, LPCWSTR groupname)
Definition: local_group.c:674
unsigned int ULONG
Definition: retypes.h:1
#define IDS_LOCALGROUP_HELP_5
Definition: resource.h:50
WCHAR * LPWSTR
Definition: xmlstorage.h:184
GLuint64EXT * result
Definition: glext.h:11304
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

◆ cmdPause()

INT cmdPause ( INT  argc,
WCHAR **  argv 
)

Definition at line 12 of file cmdPause.c.

13 {
14  SC_HANDLE hManager = NULL;
15  SC_HANDLE hService = NULL;
17  INT nError = 0;
18  INT i;
19 
20  if (argc != 3)
21  {
24  return 1;
25  }
26 
27  for (i = 2; i < argc; i++)
28  {
29  if (_wcsicmp(argv[i], L"/help") == 0)
30  {
35  return 1;
36  }
37  }
38 
40  if (hManager == NULL)
41  {
42  ConPrintf(StdErr, L"[OpenSCManager] Error: %ld\n", GetLastError());
43  nError = 1;
44  goto done;
45  }
46 
47  hService = OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE);
48  if (hService == NULL)
49  {
50  ConPrintf(StdErr, L"[OpenService] Error: %ld\n", GetLastError());
51  nError = 1;
52  goto done;
53  }
54 
55  if (!ControlService(hService, SERVICE_CONTROL_PAUSE, &status))
56  {
57  ConPrintf(StdErr, L"[ControlService] Error: %ld\n", GetLastError());
58  }
59 
60 done:
61  if (hService != NULL)
62  CloseServiceHandle(hService);
63 
64  if (hManager != NULL)
65  CloseServiceHandle(hManager);
66 
67  return nError;
68 }
static int argc
Definition: ServiceArgs.c:12
#define SC_MANAGER_ENUMERATE_SERVICE
Definition: winsvc.h:16
#define SERVICES_ACTIVE_DATABASE
Definition: winsvc.h:564
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
int32_t INT
Definition: typedefs.h:56
#define OpenService
Definition: winsvc.h:576
static char ** argv
Definition: ServiceArgs.c:11
#define IDS_PAUSE_HELP_1
Definition: resource.h:56
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define IDS_GENERIC_SYNTAX
Definition: resource.h:202
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:576
smooth NULL
Definition: ftsmooth.c:416
#define OpenSCManager
Definition: winsvc.h:575
#define StdErr
Definition: stream.h:77
#define SERVICE_CONTROL_PAUSE
Definition: winsvc.h:37
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
static const WCHAR L[]
Definition: oid.c:1087
#define IDS_PAUSE_SYNTAX
Definition: resource.h:55
BOOL WINAPI ControlService(SC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
Definition: scm.c:618
#define StdOut
Definition: stream.h:76
static SERVICE_STATUS status
Definition: service.c:31
#define SERVICE_PAUSE_CONTINUE
Definition: winsvc.h:59
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define IDS_PAUSE_HELP_2
Definition: resource.h:57

◆ cmdStart()

INT cmdStart ( INT  argc,
WCHAR **  argv 
)

Definition at line 163 of file cmdStart.c.

Referenced by CommandShell().

164 {
165  INT i;
166 
167  if (argc == 2)
168  {
169  return EnumerateRunningServices();
170  }
171 
172  for (i = 2; i < argc; i++)
173  {
174  if (_wcsicmp(argv[i], L"/help") == 0)
175  {
181  return 1;
182  }
183  }
184 
185  return StartOneService(argc, argv);
186 }
static int argc
Definition: ServiceArgs.c:12
static INT StartOneService(INT argc, WCHAR **argv)
Definition: cmdStart.c:91
int32_t INT
Definition: typedefs.h:56
static char ** argv
Definition: ServiceArgs.c:11
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define IDS_GENERIC_SYNTAX
Definition: resource.h:202
#define IDS_START_HELP_1
Definition: resource.h:67
#define IDS_START_HELP_2
Definition: resource.h:68
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
static const WCHAR L[]
Definition: oid.c:1087
static INT EnumerateRunningServices(VOID)
Definition: cmdStart.c:15
#define StdOut
Definition: stream.h:76
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define IDS_START_SYNTAX
Definition: resource.h:66
#define IDS_START_HELP_3
Definition: resource.h:69

◆ cmdStatistics()

INT cmdStatistics ( INT  argc,
WCHAR **  argv 
)

Definition at line 240 of file cmdStatistics.c.

243 {
244  INT i, result = 0;
245  BOOL bServer = FALSE;
246  BOOL bWorkstation = FALSE;
247 
248  for (i = 2; i < argc; i++)
249  {
250  if (_wcsicmp(argv[i], L"server") == 0)
251  {
252  if (bWorkstation == FALSE)
253  bServer = TRUE;
254  continue;
255  }
256 
257  if (_wcsicmp(argv[i], L"workstation") == 0)
258  {
259  if (bServer == FALSE)
260  bWorkstation = TRUE;
261  continue;
262  }
263 
264  if (_wcsicmp(argv[i], L"help") == 0)
265  {
266  /* Print short syntax help */
269  return 0;
270  }
271 
272  if (_wcsicmp(argv[i], L"/help") == 0)
273  {
274  /* Print full help text*/
279  return 0;
280  }
281  }
282 
283  if (bServer)
284  {
285  result = DisplayServerStatistics();
286  }
287  else if (bWorkstation)
288  {
289  result = DisplayWorkstationStatistics();
290  }
291  else
292  {
294  }
295 
296  if (result == 0)
298 
299  return result;
300 }
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
#define IDS_STATISTICS_TEXT
Definition: resource.h:129
static INT DisplayWorkstationStatistics(VOID)
int32_t INT
Definition: typedefs.h:56
static char ** argv
Definition: ServiceArgs.c:11
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define IDS_GENERIC_SYNTAX
Definition: resource.h:202
#define IDS_STATISTICS_HELP_2
Definition: resource.h:72
unsigned int BOOL
Definition: ntddk_ex.h:94
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
static const WCHAR L[]
Definition: oid.c:1087
#define IDS_ERROR_NO_ERROR
Definition: resource.h:208
#define IDS_STATISTICS_SYNTAX
Definition: resource.h:70
static INT DisplayServerStatistics(VOID)
Definition: cmdStatistics.c:14
#define StdOut
Definition: stream.h:76
GLuint64EXT * result
Definition: glext.h:11304
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define IDS_STATISTICS_HELP_1
Definition: resource.h:71

◆ cmdStop()

INT cmdStop ( INT  argc,
WCHAR **  argv 
)

Definition at line 12 of file cmdStop.c.

Referenced by CommandShell().

13 {
14  SC_HANDLE hManager = NULL;
15  SC_HANDLE hService = NULL;
17  DWORD dwError = ERROR_SUCCESS;
18  INT nError = 0;
19  INT i;
20 
21  if (argc != 3)
22  {
25  return 1;
26  }
27 
28  for (i = 2; i < argc; i++)
29  {
30  if (_wcsicmp(argv[i], L"/help") == 0)
31  {
37  return 1;
38  }
39  }
40 
41  hManager = OpenSCManagerW(NULL,
44  if (hManager == NULL)
45  {
46  dwError = GetLastError();
47  nError = 1;
48  goto done;
49  }
50 
51  hService = OpenServiceW(hManager,
52  argv[2],
53  SERVICE_STOP);
54  if (hService == NULL)
55  {
56  dwError = GetLastError();
57  nError = 1;
58  goto done;
59  }
60 
61  if (!ControlService(hService, SERVICE_CONTROL_STOP, &ServiceStatus))
62  {
63  dwError = GetLastError();
64  nError = 1;
65  goto done;
66  }
67 
68 done:
69  if (hService != NULL)
70  CloseServiceHandle(hService);
71 
72  if (hManager != NULL)
73  CloseServiceHandle(hManager);
74 
75  if (dwError != ERROR_SUCCESS)
76  {
77  /* FIXME: Print proper error message */
78  ConPrintf(StdErr, L"Error: %lu\n", dwError);
79  }
80 
81  return nError;
82 }
#define IDS_STOP_SYNTAX
Definition: resource.h:73
static int argc
Definition: ServiceArgs.c:12
#define SC_MANAGER_ENUMERATE_SERVICE
Definition: winsvc.h:16
#define ERROR_SUCCESS
Definition: deptool.c:10
#define SERVICES_ACTIVE_DATABASE
Definition: winsvc.h:564
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
int32_t INT
Definition: typedefs.h:56
#define IDS_STOP_HELP_1
Definition: resource.h:74
static char ** argv
Definition: ServiceArgs.c:11
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define IDS_GENERIC_SYNTAX
Definition: resource.h:202
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2102
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:576
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#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:1087
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2010
#define IDS_STOP_HELP_3
Definition: resource.h:76
#define SERVICE_STOP
Definition: winsvc.h:58
BOOL WINAPI ControlService(SC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
Definition: scm.c:618
SERVICE_STATUS ServiceStatus
Definition: dhcpcsvc.c:18
#define StdOut
Definition: stream.h:76
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
#define IDS_STOP_HELP_2
Definition: resource.h:75
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

◆ cmdUse()

INT cmdUse ( INT  argc,
WCHAR **  argv 
)

Definition at line 102 of file cmdUse.c.

105 {
107 
108  if (argc == 2)
109  {
110  Status = EnumerateConnections(NULL);
111  if (Status == NO_ERROR)
113  else
114  PrintError(Status);
115 
116  return 0;
117  }
118  else if (argc == 3)
119  {
120  if (!ValidateDeviceName(argv[2]))
121  {
123  return 1;
124  }
125 
126  Status = EnumerateConnections(argv[2]);
127  if (Status == NO_ERROR)
129  else
130  PrintError(Status);
131 
132  return 0;
133  }
134 
135  Delete = 0;
136  if (wcsicmp(argv[2], L"/DELETE") == 0)
137  {
138  Delete = 3;
139  }
140  else
141  {
142  if ((argv[2][0] != '*' && argv[2][1] != 0) &&
144  {
146  return 1;
147  }
148  }
149 
150  if (wcsicmp(argv[3], L"/DELETE") == 0)
151  {
152  Delete = 2;
153  }
154 
155  if (Delete != 0)
156  {
157  if (!ValidateDeviceName(argv[Delete]) || argv[Delete][0] == L'*')
158  {
160  return 1;
161  }
162 
164  if (Status != NO_ERROR)
165  PrintError(Status);
166 
167  return Status;
168  }
169  else
170  {
171  BOOL Persist = FALSE;
172  NETRESOURCE lpNet;
173  WCHAR Access[256];
174  DWORD OutFlags = 0, Size = ARRAYSIZE(Access);
175 
176  Len = wcslen(argv[3]);
177  if (Len < 4)
178  {
180  return 1;
181  }
182 
183  if (argv[3][0] != L'\\' || argv[3][1] != L'\\')
184  {
186  return 1;
187  }
188 
189  if (argc > 4)
190  {
191  LPWSTR Cpy;
192  Len = wcslen(argv[4]);
193  if (Len > 12)
194  {
195  Cpy = HeapAlloc(GetProcessHeap(), 0, (Len + 1) * sizeof(WCHAR));
196  if (Cpy)
197  {
198  INT i;
199  for (i = 0; i < Len; ++i)
200  Cpy[i] = towupper(argv[4][i]);
201 
202  if (wcsstr(Cpy, L"/PERSISTENT:") == Cpy)
203  {
204  LPWSTR Arg = Cpy + 12;
205  if (Len == 14 && Arg[0] == 'N' && Arg[1] == 'O')
206  {
207  Persist = FALSE;
208  }
209  else if (Len == 15 && Arg[0] == 'Y' && Arg[1] == 'E' && Arg[2] == 'S')
210  {
211  Persist = TRUE;
212  }
213  else
214  {
215  HeapFree(GetProcessHeap(), 0, Cpy);
217  return 1;
218  }
219  }
220  HeapFree(GetProcessHeap(), 0, Cpy);
221  }
222  }
223 
224  }
225 
226  lpNet.dwType = RESOURCETYPE_DISK;
227  lpNet.lpLocalName = (argv[2][0] != L'*') ? argv[2] : NULL;
228  lpNet.lpRemoteName = argv[3];
229  lpNet.lpProvider = NULL;
230 
231  Status = WNetUseConnection(NULL, &lpNet, NULL, NULL, CONNECT_REDIRECT | (Persist ? CONNECT_UPDATE_PROFILE : 0), Access, &Size, &OutFlags);
232  if (argv[2][0] == L'*' && Status == NO_ERROR && OutFlags == CONNECT_LOCALDRIVE)
234  else if (Status != NO_ERROR)
235  PrintError(Status);
236 
237  return Status;
238  }
239 }
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
DWORD dwType
Definition: winnetwk.h:168
#define CONNECT_UPDATE_PROFILE
Definition: winnetwk.h:87
__wchar_t WCHAR
Definition: xmlstorage.h:180
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define WNetCancelConnection2
Definition: winnetwk.h:607
#define IDS_ERROR_INVALID_OPTION_VALUE
Definition: resource.h:206
LPSTR lpLocalName
Definition: winnetwk.h:171
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define WNetUseConnection
Definition: winnetwk.h:609
#define NO_ERROR
Definition: dderror.h:5
int32_t INT
Definition: typedefs.h:56
static char ** argv
Definition: ServiceArgs.c:11
GLenum GLclampf GLint i
Definition: glfuncs.h:14
static IPersist Persist
Definition: atl.c:503
smooth NULL
Definition: ftsmooth.c:416
LPSTR lpProvider
Definition: winnetwk.h:174
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
static DWORD EnumerateConnections(LPCWSTR Local)
Definition: cmdUse.c:14
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define CONNECT_REDIRECT
Definition: winnetwk.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
static VOID PrintError(DWORD Status)
Definition: cmdUse.c:68
#define Len
Definition: deflate.h:82
#define StdErr
Definition: stream.h:77
static const WCHAR L[]
Definition: oid.c:1087
#define IDS_USE_NOW_CONNECTED
Definition: resource.h:193
#define IDS_ERROR_NO_ERROR
Definition: resource.h:208
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define wcsicmp
Definition: string.h:1152
#define RESOURCETYPE_DISK
Definition: winnetwk.h:64
Status
Definition: gdiplustypes.h:24
static BOOL ValidateDeviceName(PWSTR DevName)
Definition: cmdUse.c:83
LPSTR lpRemoteName
Definition: winnetwk.h:172
#define CONNECT_LOCALDRIVE
Definition: winnetwk.h:95
#define StdOut
Definition: stream.h:76
#define towupper(c)
Definition: wctype.h:99
WCHAR * LPWSTR
Definition: xmlstorage.h:184
BOOL Delete(LPCTSTR ServiceName)
Definition: delete.c:12
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ cmdUser()

INT cmdUser ( INT  argc,
WCHAR **  argv 
)

Definition at line 616 of file cmdUser.c.

619 {
620  INT i, j;
621  INT result = 0;
622  BOOL bAdd = FALSE;
623  BOOL bDelete = FALSE;
624 #if 0
625  BOOL bDomain = FALSE;
626 #endif
627  BOOL bRandomPassword = FALSE;
628  LPWSTR lpUserName = NULL;
629  LPWSTR lpPassword = NULL;
630  PUSER_INFO_4 pUserInfo = NULL;
631  USER_INFO_4 UserInfo;
632  LPWSTR pWorkstations = NULL;
633  LPWSTR p;
634  LPWSTR endptr;
635  DWORD value;
636  BOOL bPasswordAllocated = FALSE;
638 
639  if (argc == 2)
640  {
641  Status = EnumerateUsers();
642  ConPrintf(StdOut, L"Status: %lu\n", Status);
643  return 0;
644  }
645  else if (argc == 3)
646  {
647  Status = DisplayUser(argv[2]);
648  ConPrintf(StdOut, L"Status: %lu\n", Status);
649  return 0;
650  }
651 
652  i = 2;
653  if (argv[i][0] != L'/')
654  {
655  lpUserName = argv[i];
656 // ConPrintf(StdOut, L"User: %s\n", lpUserName);
657  i++;
658  }
659 
660  if (argv[i][0] != L'/')
661  {
662  lpPassword = argv[i];
663 // ConPrintf(StdOut, L"Password: %s\n", lpPassword);
664  i++;
665  }
666 
667  for (j = i; j < argc; j++)
668  {
669  if (_wcsicmp(argv[j], L"/help") == 0)
670  {
672  return 0;
673  }
674  else if (_wcsicmp(argv[j], L"/add") == 0)
675  {
676  bAdd = TRUE;
677  }
678  else if (_wcsicmp(argv[j], L"/delete") == 0)
679  {
680  bDelete = TRUE;
681  }
682  else if (_wcsicmp(argv[j], L"/domain") == 0)
683  {
685 #if 0
686  bDomain = TRUE;
687 #endif
688  }
689  else if (_wcsicmp(argv[j], L"/random") == 0)
690  {
691  bRandomPassword = TRUE;
692  GenerateRandomPassword(&lpPassword,
693  &bPasswordAllocated);
694  }
695  }
696 
697  if (bAdd && bDelete)
698  {
699  result = 1;
700  goto done;
701  }
702 
703  /* Interactive password input */
704  if (lpPassword != NULL && wcscmp(lpPassword, L"*") == 0)
705  {
706  ReadPassword(&lpPassword,
707  &bPasswordAllocated);
708  }
709 
710  if (!bAdd && !bDelete)
711  {
712  /* Modify the user */
713  Status = NetUserGetInfo(NULL,
714  lpUserName,
715  4,
716  (LPBYTE*)&pUserInfo);
717  if (Status != NERR_Success)
718  {
719  ConPrintf(StdOut, L"Status: %lu\n", Status);
720  result = 1;
721  goto done;
722  }
723  }
724  else if (bAdd && !bDelete)
725  {
726  /* Add the user */
727  ZeroMemory(&UserInfo, sizeof(USER_INFO_4));
728 
729  UserInfo.usri4_name = lpUserName;
730  UserInfo.usri4_password = lpPassword;
734 
735  pUserInfo = &UserInfo;
736  }
737 
738  for (j = i; j < argc; j++)
739  {
740  if (_wcsnicmp(argv[j], L"/active:", 8) == 0)
741  {
742  p = &argv[i][8];
743  if (_wcsicmp(p, L"yes") == 0)
744  {
745  pUserInfo->usri4_flags &= ~UF_ACCOUNTDISABLE;
746  }
747  else if (_wcsicmp(p, L"no") == 0)
748  {
749  pUserInfo->usri4_flags |= UF_ACCOUNTDISABLE;
750  }
751  else
752  {
754  result = 1;
755  goto done;
756  }
757  }
758  else if (_wcsnicmp(argv[j], L"/comment:", 9) == 0)
759  {
760  pUserInfo->usri4_comment = &argv[j][9];
761  }
762  else if (_wcsnicmp(argv[j], L"/countrycode:", 13) == 0)
763  {
764  p = &argv[i][13];
765  value = wcstoul(p, &endptr, 10);
766  if (*endptr != 0)
767  {
769  result = 1;
770  goto done;
771  }
772 
773  /* FIXME: verify the country code */
774 
775  pUserInfo->usri4_country_code = value;
776  }
777  else if (_wcsnicmp(argv[j], L"/expires:", 9) == 0)
778  {
779  p = &argv[i][9];
780  if (_wcsicmp(p, L"never") == 0)
781  {
782  pUserInfo->usri4_acct_expires = TIMEQ_FOREVER;
783  }
784  else if (!ParseDate(p, &pUserInfo->usri4_acct_expires))
785  {
787  result = 1;
788  goto done;
789 
790  /* FIXME: Parse the date */
791 // ConResPrintf(StdErr, IDS_ERROR_OPTION_NOT_SUPPORTED, L"/EXPIRES");
792  }
793  }
794  else if (_wcsnicmp(argv[j], L"/fullname:", 10) == 0)
795  {
796  pUserInfo->usri4_full_name = &argv[j][10];
797  }
798  else if (_wcsnicmp(argv[j], L"/homedir:", 9) == 0)
799  {
800  pUserInfo->usri4_home_dir = &argv[j][9];
801  }
802  else if (_wcsnicmp(argv[j], L"/passwordchg:", 13) == 0)
803  {
804  p = &argv[i][13];
805  if (_wcsicmp(p, L"yes") == 0)
806  {
807  pUserInfo->usri4_flags &= ~UF_PASSWD_CANT_CHANGE;
808  }
809  else if (_wcsicmp(p, L"no") == 0)
810  {
811  pUserInfo->usri4_flags |= UF_PASSWD_CANT_CHANGE;
812  }
813  else
814  {
816  result = 1;
817  goto done;
818  }
819  }
820  else if (_wcsnicmp(argv[j], L"/passwordreq:", 13) == 0)
821  {
822  p = &argv[i][13];
823  if (_wcsicmp(p, L"yes") == 0)
824  {
825  pUserInfo->usri4_flags &= ~UF_PASSWD_NOTREQD;
826  }
827  else if (_wcsicmp(p, L"no") == 0)
828  {
829  pUserInfo->usri4_flags |= UF_PASSWD_NOTREQD;
830  }
831  else
832  {
834  result = 1;
835  goto done;
836  }
837  }
838  else if (_wcsnicmp(argv[j], L"/profilepath:", 13) == 0)
839  {
840  pUserInfo->usri4_profile = &argv[j][13];
841  }
842  else if (_wcsnicmp(argv[j], L"/scriptpath:", 12) == 0)
843  {
844  pUserInfo->usri4_script_path = &argv[j][12];
845  }
846  else if (_wcsnicmp(argv[j], L"/times:", 7) == 0)
847  {
848  /* FIXME */
850  }
851  else if (_wcsnicmp(argv[j], L"/usercomment:", 13) == 0)
852  {
853  pUserInfo->usri4_usr_comment = &argv[j][13];
854  }
855  else if (_wcsnicmp(argv[j], L"/workstations:", 14) == 0)
856  {
857  p = &argv[i][14];
858  if (wcscmp(p, L"*") == 0 || wcscmp(p, L"") == 0)
859  {
860  pUserInfo->usri4_workstations = NULL;
861  }
862  else
863  {
864  Status = BuildWorkstationsList(&pWorkstations, p);
865  if (Status == NERR_Success)
866  {
867  pUserInfo->usri4_workstations = pWorkstations;
868  }
869  else
870  {
871  ConPrintf(StdOut, L"Status %lu\n\n", Status);
872  result = 1;
873  goto done;
874  }
875  }
876  }
877  }
878 
879  if (!bAdd && !bDelete)
880  {
881  /* Modify the user */
882  Status = NetUserSetInfo(NULL,
883  lpUserName,
884  4,
885  (LPBYTE)pUserInfo,
886  NULL);
887  ConPrintf(StdOut, L"Status: %lu\n", Status);
888  }
889  else if (bAdd && !bDelete)
890  {
891  /* Add the user */
892  Status = NetUserAdd(NULL,
893  4,
894  (LPBYTE)pUserInfo,
895  NULL);
896  ConPrintf(StdOut, L"Status: %lu\n", Status);
897  }
898  else if (!bAdd && bDelete)
899  {
900  /* Delete the user */
901  Status = NetUserDel(NULL,
902  lpUserName);
903  ConPrintf(StdOut, L"Status: %lu\n", Status);
904  }
905 
906  if (Status == NERR_Success &&
907  lpPassword != NULL &&
908  bRandomPassword == TRUE)
909  {
910  ConPrintf(StdOut, L"The password for %s is: %s\n", lpUserName, lpPassword);
911  }
912 
913 done:
914  if (pWorkstations != NULL)
915  HeapFree(GetProcessHeap(), 0, pWorkstations);
916 
917  if ((bPasswordAllocated == TRUE) && (lpPassword != NULL))
918  HeapFree(GetProcessHeap(), 0, lpPassword);
919 
920  if (!bAdd && !bDelete && pUserInfo != NULL)
921  NetApiBufferFree(pUserInfo);
922 
923  if (result != 0)
924  {
927  }
928 
929  return result;
930 }
static NET_API_STATUS DisplayUser(LPWSTR lpUserName)
Definition: cmdUser.c:135
static int argc
Definition: ServiceArgs.c:12
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
#define TRUE
Definition: types.h:120
#define IDS_USER_HELP
Definition: resource.h:82
_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)
#define IDS_ERROR_INVALID_OPTION_VALUE
Definition: resource.h:206
LPWSTR usri4_home_dir
Definition: lmaccess.h:274
#define ZeroMemory
Definition: winbase.h:1635
DWORD usri4_flags
Definition: lmaccess.h:276
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
int32_t INT
Definition: typedefs.h:56
static char ** argv
Definition: ServiceArgs.c:11
#define NERR_Success
Definition: lmerr.h:5
DWORD usri4_country_code
Definition: lmaccess.h:292
#define UF_PASSWD_CANT_CHANGE
Definition: lmaccess.h:28
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define IDS_GENERIC_SYNTAX
Definition: resource.h:202
static NET_API_STATUS EnumerateUsers(VOID)
Definition: cmdUser.c:26
unsigned char * LPBYTE
Definition: typedefs.h:52
LPWSTR usri4_workstations
Definition: lmaccess.h:282
LPWSTR usri4_full_name
Definition: lmaccess.h:279
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
NET_API_STATUS WINAPI NetUserAdd(LPCWSTR servername, DWORD level, LPBYTE bufptr, LPDWORD parm_err)
Definition: user.c:2046
DWORD usri4_primary_group_id
Definition: lmaccess.h:295
LPWSTR usri4_password
Definition: lmaccess.h:271
smooth NULL
Definition: ftsmooth.c:416
#define UF_PASSWD_NOTREQD
Definition: lmaccess.h:27
NET_API_STATUS WINAPI NetUserGetInfo(LPCWSTR servername, LPCWSTR username, DWORD level, LPBYTE *bufptr)
Definition: user.c:2803
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
DWORD usri4_acct_expires
Definition: lmaccess.h:285
static VOID ReadPassword(LPWSTR *lpPassword, LPBOOL lpAllocated)
Definition: cmdUser.c:316
LPWSTR usri4_profile
Definition: lmaccess.h:296
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL ParseDate(PWSTR s, PULONG pSeconds)
Definition: cmdUser.c:527
#define StdErr
Definition: stream.h:77
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
NET_API_STATUS WINAPI NetUserDel(LPCWSTR servername, LPCWSTR username)
Definition: user.c:2312
#define IDS_ERROR_OPTION_NOT_SUPPORTED
Definition: resource.h:205
static const WCHAR L[]
Definition: oid.c:1087
LPWSTR usri4_comment
Definition: lmaccess.h:275
GLsizei const GLfloat * value
Definition: glext.h:6069
static NET_API_STATUS BuildWorkstationsList(_Out_ PWSTR *pWorkstationsList, _In_ PWSTR pRaw)
Definition: cmdUser.c:392
Status
Definition: gdiplustypes.h:24
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
NET_API_STATUS WINAPI NetUserSetInfo(LPCWSTR servername, LPCWSTR username, DWORD level, LPBYTE buf, LPDWORD parm_err)
Definition: user.c:3577
static VOID GenerateRandomPassword(LPWSTR *lpPassword, LPBOOL lpAllocated)
Definition: cmdUser.c:363
LPWSTR usri4_usr_comment
Definition: lmaccess.h:280
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
#define IDS_USER_SYNTAX
Definition: resource.h:81
#define UF_ACCOUNTDISABLE
Definition: lmaccess.h:24
#define DOMAIN_GROUP_RID_USERS
Definition: setypes.h:612
#define UF_NORMAL_ACCOUNT
Definition: lmaccess.h:30
#define TIMEQ_FOREVER
Definition: lmaccess.h:110
#define StdOut
Definition: stream.h:76
LPWSTR usri4_name
Definition: lmaccess.h:270
LPWSTR usri4_script_path
Definition: lmaccess.h:277
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
GLuint64EXT * result
Definition: glext.h:11304
#define HeapFree(x, y, z)
Definition: compat.h:394
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define UF_SCRIPT
Definition: lmaccess.h:23

◆ help()

VOID help ( VOID  )

Definition at line 27 of file cat.c.

Referenced by main().

28 {
30  "\n"
31  "ReactOS File Concatenation Tool\n"
32  "\n"
33  "Usage: cat [options] [file [...]]\n"
34  "options - Currently ignored\n");
35 }
FILE * stdout
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)

◆ PrintErrorMessage()

VOID PrintErrorMessage ( DWORD  dwError)

Definition at line 123 of file common.c.

Referenced by OpenVolume().

124 {
125  TCHAR * String;
126 
127  /* Try to get textual error */
129  NULL, Error, 0, (TCHAR *)&String, 0, NULL) != 0)
130  {
131  /* And print it */
132  _ftprintf(stderr, _T("Error: %s\n"), String);
133  LocalFree(String);
134  }
135  else
136  {
137  /* Otherwise, just print the error number */
138  _ftprintf(stderr, _T("Error: %d\n"), Error);
139  }
140 
141  return Error;
142 }
static WCHAR String[]
Definition: stringtable.c:55
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
smooth NULL
Definition: ftsmooth.c:416
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
#define _ftprintf
Definition: tchar.h:518
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
BOOL Error
Definition: chkdsk.c:66
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
FILE * stderr

◆ PrintPaddedResourceString()

VOID PrintPaddedResourceString ( UINT  uID,
INT  nPaddedLength 
)

Definition at line 51 of file main.c.

Referenced by cmdAccounts(), DisplayGroup(), DisplayLocalGroup(), DisplayServerConfig(), DisplayServerStatistics(), DisplayUser(), DisplayWorkstationConfig(), and DisplayWorkstationStatistics().

54 {
55  INT nLength;
56 
57  nLength = ConResPuts(StdOut, uID);
58  if (nLength < nPaddedLength)
59  PrintPadding(L' ', nPaddedLength - nLength);
60 }
_In_ DWORD nLength
Definition: wincon.h:461
int32_t INT
Definition: typedefs.h:56
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
static const WCHAR L[]
Definition: oid.c:1087
VOID PrintPadding(WCHAR chr, INT nPaddedLength)
Definition: main.c:64
#define StdOut
Definition: stream.h:76

◆ PrintPadding()

VOID PrintPadding ( WCHAR  chr,
INT  nPaddedLength 
)

Definition at line 64 of file main.c.

Referenced by DisplayGroup(), DisplayLocalGroup(), DisplayUser(), EnumerateGroups(), EnumerateLocalGroups(), EnumerateUsers(), and PrintPaddedResourceString().

67 {
68  INT i;
69  WCHAR szMsgBuffer[MAX_BUFFER_SIZE];
70 
71  for (i = 0; i < nPaddedLength; i++)
72  szMsgBuffer[i] = chr;
73  szMsgBuffer[nPaddedLength] = UNICODE_NULL;
74 
75  ConPuts(StdOut, szMsgBuffer);
76 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
int32_t INT
Definition: typedefs.h:56
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define UNICODE_NULL
#define MAX_BUFFER_SIZE
Definition: main.c:12
int chr(char *serport)
Definition: gdblib.c:152
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
#define StdOut
Definition: stream.h:76

◆ ReadFromConsole()

VOID ReadFromConsole ( LPWSTR  lpInput,
DWORD  dwLength,
BOOL  bEcho 
)

Definition at line 163 of file main.c.

Referenced by ReadPassword().

167 {
168  DWORD dwOldMode;
169  DWORD dwRead = 0;
170  HANDLE hFile;
171  LPWSTR p;
172  PCHAR pBuf;
173 
174  pBuf = HeapAlloc(GetProcessHeap(), 0, dwLength - 1);
175  ZeroMemory(lpInput, dwLength * sizeof(WCHAR));
177  GetConsoleMode(hFile, &dwOldMode);
178 
180 
181  ReadFile(hFile, (PVOID)pBuf, dwLength - 1, &dwRead, NULL);
182 
183  MultiByteToWideChar(CP_OEMCP, 0, pBuf, dwRead, lpInput, dwLength - 1);
184  HeapFree(GetProcessHeap(), 0, pBuf);
185 
186  for (p = lpInput; *p; p++)
187  {
188  if (*p == L'\x0d')
189  {
190  *p = L'\0';
191  break;
192  }
193  }
194 
195  SetConsoleMode(hFile, dwOldMode);
196 }
signed char * PCHAR
Definition: retypes.h:7
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1571
BOOL bEcho
Definition: batch.c:68
#define ZeroMemory
Definition: winbase.h:1635
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
#define ENABLE_ECHO_INPUT
Definition: wincon.h:77
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1608
smooth NULL
Definition: ftsmooth.c:416
#define STD_INPUT_HANDLE
Definition: winbase.h:264
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static DWORD DWORD * dwLength
Definition: fusion.c:83
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ENABLE_LINE_INPUT
Definition: wincon.h:76
static const WCHAR L[]
Definition: oid.c:1087
_In_ HANDLE hFile
Definition: mswsock.h:90
#define MultiByteToWideChar
Definition: compat.h:100
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define CP_OEMCP
Definition: winnls.h:219
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ unimplemented()

INT unimplemented ( INT  argc,
WCHAR **  argv 
)

Definition at line 226 of file main.c.

227 {
228  ConPuts(StdOut, L"This command is not implemented yet\n");
229  return 1;
230 }
static const WCHAR L[]
Definition: oid.c:1087
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
#define StdOut
Definition: stream.h:76