ReactOS  0.4.14-dev-50-g13bb5e2
logoff.c File Reference
#include <stdio.h>
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <conutils.h>
#include "resource.h"
Include dependency graph for logoff.c:

Go to the source code of this file.

Functions

VOID DisplayError (DWORD dwError)
 
BOOL ParseCommandLine (int argc, WCHAR *argv[])
 
int wmain (int argc, WCHAR *argv[])
 

Variables

LPWSTR szRemoteServerName = NULL
 
BOOL bVerbose
 

Function Documentation

◆ DisplayError()

VOID DisplayError ( DWORD  dwError)

Definition at line 33 of file logoff.c.

34 {
36  NULL, dwError, LANG_USER_DEFAULT);
37  ConPrintf(StdErr, L"Error code: %lu\n", dwError);
38 }
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
smooth NULL
Definition: ftsmooth.c:416
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
INT ConMsgPuts(IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId)
Definition: outstream.c:837
#define StdErr
Definition: stream.h:77
static const WCHAR L[]
Definition: oid.c:1250
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50

Referenced by EnablePrivilege(), GetListOfTestExes(), GetNumberOfExesInFolder(), and wmain().

◆ ParseCommandLine()

BOOL ParseCommandLine ( int  argc,
WCHAR argv[] 
)

Definition at line 45 of file logoff.c.

46 {
47  int i;
48 
49  // FIXME: Add handling of command-line arguments to select
50  // the session number and name, and also name of remote machine.
51  // Example: logoff.exe 4 /SERVER:Master
52  // should logoff session number 4 on remote machine called Master.
53 
54  for (i = 1; i < argc; i++)
55  {
56  switch (argv[i][0])
57  {
58  case L'-':
59  case L'/':
60  // -v (verbose)
61  if (argv[i][1] == L'v')
62  {
63  bVerbose = TRUE;
64  break;
65  }
66  // -? (usage)
67  else if (argv[i][1] == L'?')
68  {
69  /* Will display the Usage */
70  return FALSE;
71  }
72  /* Fall through */
73  default:
74  /* Invalid parameter detected */
76  return FALSE;
77  }
78  }
79 
80  return TRUE;
81 }
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
#define argv
Definition: mplay32.c:18
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
BOOL bVerbose
Definition: logoff.c:26
#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
#define IDS_ILLEGAL_PARAM
Definition: resource.h:6

Referenced by wmain().

◆ wmain()

int wmain ( int  argc,
WCHAR argv[] 
)

Definition at line 88 of file logoff.c.

89 {
90  /* Initialize the Console Standard Streams */
92 
93  /* Parse command line */
94  if (!ParseCommandLine(argc, argv))
95  {
97  return 1;
98  }
99 
100  /* Should we log off session on remote server? */
101  if (szRemoteServerName)
102  {
103  if (bVerbose)
105 
106  // FIXME: Add Remote Procedure Call to logoff user on a remote machine
107  ConPuts(StdErr, L"Remote Procedure Call in logoff.exe has not been implemented");
108  }
109  /* Perform logoff of current session on local machine instead */
110  else
111  {
112  if (bVerbose)
113  {
114  /* Get resource string and print it */
116  }
117 
118  /* Actual logoff */
119  if (!ExitWindowsEx(EWX_LOGOFF, 0))
120  {
122  return 1;
123  }
124  }
125 
126  return 0;
127 }
static int argc
Definition: ServiceArgs.c:12
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define IDS_USAGE
Definition: resource.h:3
#define argv
Definition: mplay32.c:18
#define EWX_LOGOFF
Definition: winuser.h:631
#define ConInitStdStreams()
Definition: stream.h:122
LPWSTR szRemoteServerName
Definition: logoff.c:25
BOOL ParseCommandLine(int argc, WCHAR *argv[])
Definition: logoff.c:45
BOOL bVerbose
Definition: logoff.c:26
#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
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
VOID DisplayError(DWORD dwError)
Definition: logoff.c:33
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
#define StdOut
Definition: stream.h:76
#define IDS_LOGOFF_LOCAL
Definition: resource.h:5
#define IDS_LOGOFF_REMOTE
Definition: resource.h:4

Variable Documentation

◆ bVerbose

BOOL bVerbose

Definition at line 26 of file logoff.c.

Referenced by ParseCommandLine(), and wmain().

◆ szRemoteServerName

LPWSTR szRemoteServerName = NULL

Definition at line 25 of file logoff.c.

Referenced by register_appid(), and wmain().