* Sync up to trunk head (r65426).
[reactos.git] / base / shell / 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)
18 * Unicode and redirection safe!
19 *
20 * 26-Feb-1999 (Eric Kohl)
21 * New version info and some output changes.
22 */
23
24 #include "precomp.h"
25 #include <reactos/buildno.h>
26 #include <reactos/version.h>
27
28 VOID ShortVersion (VOID)
29 {
30 OSVERSIONINFO VersionInfo;
31
32 ConOutResPrintf(STRING_CMD_SHELLINFO, _T(KERNEL_RELEASE_STR), _T(KERNEL_VERSION_BUILD_STR));
33 VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
34
35 memset(VersionInfo.szCSDVersion, 0, sizeof(VersionInfo.szCSDVersion));
36 if (GetVersionEx(&VersionInfo))
37 {
38 LPTSTR RosVersion;
39 SIZE_T RosVersionLen;
40
41 RosVersion = VersionInfo.szCSDVersion + _tcslen(VersionInfo.szCSDVersion) + 1;
42 RosVersionLen = sizeof(VersionInfo.szCSDVersion) / sizeof(VersionInfo.szCSDVersion[0]) -
43 (RosVersion - VersionInfo.szCSDVersion);
44 if (7 <= RosVersionLen && 0 == _tcsnicmp(RosVersion, _T("ReactOS"), 7))
45 {
46 ConOutResPrintf(STRING_VERSION_RUNVER, RosVersion);
47 }
48 }
49 ConOutChar(_T('\n'));
50 }
51
52
53 #ifdef INCLUDE_CMD_VER
54
55 /*
56 * display shell version info internal command.
57 */
58 INT cmd_ver (LPTSTR param)
59 {
60 INT i;
61
62 nErrorLevel = 0;
63
64 if (_tcsstr (param, _T("/?")) != NULL)
65 {
66 ConOutResPaging(TRUE,STRING_VERSION_HELP1);
67 return 0;
68 }
69
70 ShortVersion();
71
72 /* Basic copyright notice */
73 if (param[0] != _T('\0'))
74 {
75 ConOutPuts(_T("Copyright (C) 1994-1998 Tim Norman and others.\n"));
76 ConOutPuts(_T("Copyright (C) 1998-") _T(COPYRIGHT_YEAR) _T(" ReactOS Team\n"));
77
78 for (i = 0; param[i]; i++)
79 {
80 /* skip spaces */
81 if (param[i] == _T(' '))
82 continue;
83
84 if (param[i] == _T('/'))
85 {
86 /* is this a lone '/' ? */
87 if (param[i + 1] == 0)
88 {
89 error_invalid_switch (_T(' '));
90 return 1;
91 }
92 continue;
93 }
94
95 if (_totupper (param[i]) == _T('W'))
96 {
97 /* Warranty notice */
98 ConOutResPuts(STRING_VERSION_HELP3);
99 }
100 else if (_totupper (param[i]) == _T('R'))
101 {
102 /* Redistribution notice */
103 ConOutResPuts(STRING_VERSION_HELP4);
104 }
105 else if (_totupper (param[i]) == _T('C'))
106 {
107 /* Developer listing */
108 ConOutResPuts(STRING_VERSION_HELP6);
109 ConOutResPuts(STRING_FREEDOS_DEV);
110 ConOutResPuts(STRING_VERSION_HELP7);
111 ConOutResPuts(STRING_REACTOS_DEV);
112 }
113 else
114 {
115 error_invalid_switch ((TCHAR)_totupper (param[i]));
116 return 1;
117 }
118 }
119 ConOutResPuts(STRING_VERSION_HELP5);
120 }
121 return 0;
122 }
123
124 #endif