[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / dep / ACE_wrappers / ace / OS_NS_sys_utsname.cpp
blob0f64e716a7cbac417c3d369522fdd3ecd87f8d4a
1 // $Id: OS_NS_sys_utsname.cpp 80826 2008-03-04 14:51:23Z wotte $
3 #include "ace/OS_NS_sys_utsname.h"
5 ACE_RCSID(ace, OS_NS_sys_utsname, "$Id: OS_NS_sys_utsname.cpp 80826 2008-03-04 14:51:23Z wotte $")
7 #include "ace/OS_NS_string.h"
8 #include "ace/OS_NS_stdio.h"
9 #include "ace/OS_NS_unistd.h"
11 #if defined (ACE_VXWORKS) && defined (ACE_LACKS_UNAME)
12 // for sysBspRev(), sysModel()
13 # include /**/ <sysLib.h>
14 // for kernelVersion()
15 # include /**/ <kernelLib.h>
16 #endif /* ACE_VXWORKS && ACE_LACKS_UNAME */
18 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
20 int
21 ACE_OS::uname (ACE_utsname *name)
23 ACE_OS_TRACE ("ACE_OS::uname");
24 #if !defined (ACE_LACKS_UNAME)
25 ACE_OSCALL_RETURN (::uname (name), int, -1);
26 #elif defined (ACE_WIN32)
27 size_t maxnamelen = sizeof name->nodename;
28 ACE_OS::strcpy (name->sysname, "Win32");
30 ACE_TEXT_OSVERSIONINFO vinfo;
31 vinfo.dwOSVersionInfoSize = sizeof(ACE_TEXT_OSVERSIONINFO);
32 ACE_TEXT_GetVersionEx (&vinfo);
34 SYSTEM_INFO sinfo;
35 # if defined (ACE_HAS_PHARLAP)
36 // PharLap doesn't do GetSystemInfo. What's really wanted is the
37 // CPU architecture, so we can get that with EtsGetSystemInfo. Fill
38 // in what's wanted in the SYSTEM_INFO structure, and carry on. Note
39 // that the CPU type values in EK_KERNELINFO have the same values
40 // are the ones defined for SYSTEM_INFO.
41 EK_KERNELINFO ets_kern;
42 EK_SYSTEMINFO ets_sys;
43 EtsGetSystemInfo (&ets_kern, &ets_sys);
44 sinfo.wProcessorLevel = static_cast<WORD> (ets_kern.CpuType);
45 sinfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
46 sinfo.dwProcessorType = ets_kern.CpuType * 100 + 86;
47 # else
48 ::GetSystemInfo(&sinfo);
49 # endif /* ACE_HAS_PHARLAP */
51 const char* unknown = "???";
53 if (
54 vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT
55 # if defined (VER_PLATFORM_WIN32_CE)
56 || vinfo.dwPlatformId == VER_PLATFORM_WIN32_CE
57 # endif
60 // Get information from the two structures
61 const char *os;
62 if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
63 os = "Windows NT %d.%d";
64 else
65 os = "Windows CE %d.%d";
66 ACE_OS::sprintf (name->release,
67 os,
68 (int) vinfo.dwMajorVersion,
69 (int) vinfo.dwMinorVersion);
70 ACE_OS::sprintf (name->version,
71 "Build %d %s",
72 (int) vinfo.dwBuildNumber,
73 ACE_TEXT_ALWAYS_CHAR (vinfo.szCSDVersion));
75 // We have to make sure that the size of (processor + subtype)
76 // is not greater than the size of name->machine. So we give
77 // half the space to the processor and half the space to
78 // subtype. The -1 is necessary for because of the space
79 // between processor and subtype in the machine name.
80 const int bufsize = (sizeof (name->machine) / 2) - 1;
81 char processor[bufsize] = "Unknown";
82 char subtype[bufsize] = "Unknown";
84 # if defined (ghs)
85 WORD arch = sinfo.u.s.wProcessorArchitecture;
86 # else
87 WORD arch = sinfo.wProcessorArchitecture;
88 # endif
90 switch (arch)
92 case PROCESSOR_ARCHITECTURE_INTEL:
93 ACE_OS::strcpy (processor, "Intel");
94 if (sinfo.wProcessorLevel == 3)
95 ACE_OS::strcpy (subtype, "80386");
96 else if (sinfo.wProcessorLevel == 4)
97 ACE_OS::strcpy (subtype, "80486");
98 else if (sinfo.wProcessorLevel == 5)
99 ACE_OS::strcpy (subtype, "Pentium");
100 else if (sinfo.wProcessorLevel == 6)
101 ACE_OS::strcpy (subtype, "Pentium Pro");
102 else if (sinfo.wProcessorLevel == 7) // I'm guessing here
103 ACE_OS::strcpy (subtype, "Pentium II");
104 break;
105 case PROCESSOR_ARCHITECTURE_MIPS:
106 ACE_OS::strcpy (processor, "MIPS");
107 ACE_OS::strcpy (subtype, "R4000");
108 break;
109 case PROCESSOR_ARCHITECTURE_ALPHA:
110 ACE_OS::strcpy (processor, "Alpha");
111 ACE_OS::sprintf (subtype, "%d", sinfo.wProcessorLevel);
112 break;
113 case PROCESSOR_ARCHITECTURE_PPC:
114 ACE_OS::strcpy (processor, "PPC");
115 if (sinfo.wProcessorLevel == 1)
116 ACE_OS::strcpy (subtype, "601");
117 else if (sinfo.wProcessorLevel == 3)
118 ACE_OS::strcpy (subtype, "603");
119 else if (sinfo.wProcessorLevel == 4)
120 ACE_OS::strcpy (subtype, "604");
121 else if (sinfo.wProcessorLevel == 6)
122 ACE_OS::strcpy (subtype, "603+");
123 else if (sinfo.wProcessorLevel == 9)
124 ACE_OS::strcpy (subtype, "804+");
125 else if (sinfo.wProcessorLevel == 20)
126 ACE_OS::strcpy (subtype, "620");
127 break;
128 # if defined PROCESSOR_ARCHITECTURE_IA64
129 case PROCESSOR_ARCHITECTURE_IA64:
130 ACE_OS::strcpy (processor, "Itanium");
131 ACE_OS::sprintf (subtype, "%d",
132 sinfo.wProcessorLevel);
133 break;
134 # endif
135 # if defined PROCESSOR_ARCHITECTURE_AMD64
136 case PROCESSOR_ARCHITECTURE_AMD64:
137 ACE_OS::strcpy (processor, "x64");
138 ACE_OS::sprintf (subtype, "%d",
139 sinfo.wProcessorLevel);
140 break;
141 # endif
142 # if defined PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
143 case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
144 ACE_OS::strcpy (processor, "WOW64");
145 ACE_OS::sprintf (subtype, "%d",
146 sinfo.wProcessorLevel);
147 break;
148 # endif
149 # if defined PROCESSOR_ARCHITECTURE_ARM
150 case PROCESSOR_ARCHITECTURE_ARM:
151 ACE_OS::strcpy (processor, "ARM");
152 ACE_OS::sprintf (subtype, "%d",
153 sinfo.wProcessorLevel);
154 break;
155 # endif
156 case PROCESSOR_ARCHITECTURE_UNKNOWN:
157 default:
158 // @@ We could provide WinCE specific info here. But let's
159 // defer that to some later point.
160 ACE_OS::strcpy (processor, "Unknown");
161 break;
163 ACE_OS::sprintf (name->machine,
164 "%s %s",
165 processor, subtype);
167 else if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
169 if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 0)
171 ACE_OS::strcpy (name->release, "Windows 95");
172 if (vinfo.szCSDVersion[1] == ACE_TEXT('C'))
173 ACE_OS::strcat (name->release, " OSR2");
175 else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 10)
177 ACE_OS::strcpy (name->release, "Windows 98");
178 if (vinfo.szCSDVersion[1] == ACE_TEXT('A'))
179 ACE_OS::strcat (name->release, " SE");
181 else if (vinfo.dwMajorVersion == 4 && vinfo.dwMinorVersion == 90)
183 ACE_OS::strcpy (name->release, "Windows Me");
185 else
187 ACE_OS::strcpy (name->release, unknown);
190 ACE_OS::sprintf (name->version, "%d", LOWORD (vinfo.dwBuildNumber));
191 if (sinfo.dwProcessorType == PROCESSOR_INTEL_386)
192 ACE_OS::strcpy (name->machine, "Intel 80386");
193 else if (sinfo.dwProcessorType == PROCESSOR_INTEL_486)
194 ACE_OS::strcpy (name->machine, "Intel 80486");
195 else if (sinfo.dwProcessorType == PROCESSOR_INTEL_PENTIUM)
196 ACE_OS::strcpy (name->machine, "Intel Pentium");
197 else
198 ACE_OS::strcpy (name->machine, unknown);
200 else
202 // We don't know what this is!
204 ACE_OS::strcpy (name->release, unknown);
205 ACE_OS::strcpy (name->version, unknown);
206 ACE_OS::strcpy (name->machine, unknown);
209 # if defined (ACE_LACKS_HOSTNAME)
210 return 0;
211 # else /* ACE_LACKS_HOSTNAME */
212 return ACE_OS::hostname (name->nodename, maxnamelen);
213 # endif /* ACE_LACKS_HOSTNAME */
215 #elif defined (ACE_VXWORKS)
216 size_t maxnamelen = sizeof name->nodename;
217 ACE_OS::strcpy (name->sysname, "VxWorks");
218 ACE_OS::strcpy (name->release, kernelVersion());
219 ACE_OS::strcpy (name->version, sysBspRev ());
220 ACE_OS::strcpy (name->machine, sysModel ());
222 return ACE_OS::hostname (name->nodename, maxnamelen);
223 #elif defined (INTEGRITY)
224 if(!name) {
225 errno = EFAULT;
226 return -1;
228 strcpy(name->sysname,"INTEGRITY");
229 int status = gethostname(name->nodename,_SYS_NMLN);
230 strcpy(name->release,"4.0");
231 strcpy(name->version,"4.0.9");
232 strcpy(name->machine,"a standard name");
233 return status;
234 #endif /* ACE_WIN32 */
237 ACE_END_VERSIONED_NAMESPACE_DECL