remove whitespace from end of lines
[reactos.git] / reactos / subsys / system / cmd / ver.c
1 /*
2 * VER.C - ver internal command.
3 *
4 *
5 * History:
6 *
7 * 06/30/98 (Rob Lake)
8 * rewrote ver command to accept switches, now ver alone prints
9 * copyright notice only.
10 *
11 * 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
12 * added config.h include
13 *
14 * 30-Jul-1998 (John P Price <linux-guru@gcfl.net>)
15 * added text about where to send bug reports and get updates.
16 *
17 * 20-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
18 * Unicode and redirection safe!
19 *
20 * 26-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
21 * New version info and some output changes.
22 */
23
24 #include "precomp.h"
25 #include "resource.h"
26
27
28 VOID ShortVersion (VOID)
29 {
30 OSVERSIONINFO VersionInfo;
31 unsigned RosVersionLen;
32 LPTSTR RosVersion;
33
34 ConOutPuts (_T("\n"
35 SHELLINFO));
36 VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
37 #ifdef _UNICODE
38 ConOutPrintf(_T("%S"), SHELLVER);
39 #else
40 ConOutPrintf(_T("%s"), SHELLVER);
41 #endif /* _UNICODE */
42 memset(VersionInfo.szCSDVersion, 0, sizeof(VersionInfo.szCSDVersion));
43 if (GetVersionEx(&VersionInfo))
44 {
45 RosVersion = VersionInfo.szCSDVersion + _tcslen(VersionInfo.szCSDVersion) + 1;
46 RosVersionLen = sizeof(VersionInfo.szCSDVersion) / sizeof(VersionInfo.szCSDVersion[0]) -
47 (RosVersion - VersionInfo.szCSDVersion);
48 if (7 <= RosVersionLen && 0 == _tcsnicmp(RosVersion, _T("ReactOS"), 7))
49 {
50 ConOutPrintf(_T(" running on %s"), RosVersion);
51 }
52 }
53 ConOutPuts (_T("\n"));
54 }
55
56
57 #ifdef INCLUDE_CMD_VER
58
59 /*
60 * display shell version info internal command.
61 *
62 *
63 */
64 INT cmd_ver (LPTSTR cmd, LPTSTR param)
65 {
66 INT i;
67
68 if (_tcsstr (param, _T("/?")) != NULL)
69 {
70 ConOutResPuts(STRING_VERSION_HELP1);
71 return 0;
72 }
73
74 ShortVersion();
75 ConOutPuts (_T("Copyright (C) 1994-1998 Tim Norman and others."));
76 ConOutPuts (_T("Copyright (C) 1998-2005 Eric Kohl and others."));
77
78 /* Basic copyright notice */
79 if (param[0] == _T('\0'))
80 {
81 ConOutPuts(_T("\n"SHELLINFO));
82 ConOutResPuts(STRING_VERSION_HELP2);
83 }
84 else
85 {
86 for (i = 0; param[i]; i++)
87 {
88 /* skip spaces */
89 if (param[i] == _T(' '))
90 continue;
91
92 if (param[i] == _T('/'))
93 {
94 /* is this a lone '/' ? */
95 if (param[i + 1] == 0)
96 {
97 error_invalid_switch (_T(' '));
98 return 1;
99 }
100 continue;
101 }
102
103 if (_totupper (param[i]) == _T('W'))
104 {
105 /* Warranty notice */
106 ConOutResPuts(STRING_VERSION_HELP3);
107 }
108 else if (_totupper (param[i]) == _T('R'))
109 {
110 /* Redistribution notice */
111 ConOutResPuts(STRING_VERSION_HELP4);
112 }
113 else if (_totupper (param[i]) == _T('C'))
114 {
115 /* Developer listing */
116 ConOutResPuts(STRING_VERSION_HELP6);
117 ConOutResPuts(STRING_FREEDOS_DEV);
118 ConOutResPuts(STRING_VERSION_HELP7);
119 ConOutResPuts(STRING_REACTOS_DEV);
120 }
121 else
122 {
123 error_invalid_switch ((TCHAR)_totupper (param[i]));
124 return 1;
125 }
126 }
127 }
128
129 ConOutResPuts(STRING_VERSION_HELP5);
130 return 0;
131 }
132
133 #endif