Mercurial > pidgin.yaz
comparison libgaim/protocols/jabber/win32/posix.uname.c @ 14192:60b1bc8dbf37
[gaim-migrate @ 16863]
Renamed 'core' to 'libgaim'
committer: Tailor Script <tailor@pidgin.im>
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Sat, 19 Aug 2006 01:50:10 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
14191:009db0b357b5 | 14192:60b1bc8dbf37 |
---|---|
1 /* | |
2 posix.uname.c - version 1.1 | |
3 Copyright (C) 1999, 2000 | |
4 Earnie Boyd and assigns | |
5 | |
6 Fills the utsname structure with the appropriate values. | |
7 | |
8 This program is free software; you can redistribute it and/or modify | |
9 it under the terms of the GNU Lesser General Public License as published | |
10 by the Free Software Foundation; either version 2.1, or (at your option) | |
11 any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICUALR PURPOSE. See the | |
16 GNU Lesser General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with this program; if not, write to the Free Software Foundation, | |
20 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
21 */ | |
22 | |
23 /* | |
24 Send bug reports to Earnie Boyd <earnie_boyd@yahoo.com> | |
25 */ | |
26 | |
27 #include "utsname.h" | |
28 #include <string.h> | |
29 #include <stdio.h> | |
30 | |
31 /* ANONYMOUS unions and structs are used from the windows header definitions. | |
32 These need to be defined for them to work correctly with gcc2.95.2-mingw. */ | |
33 /*#define _ANONYMOUS_STRUCT*/ | |
34 /*#define _ANONYMOUS_UNION*/ | |
35 #include <windows.h> | |
36 #include <_mingw.h> | |
37 | |
38 int | |
39 uname( struct utsname *uts ) | |
40 { | |
41 DWORD sLength; | |
42 OSVERSIONINFO OS_version; | |
43 SYSTEM_INFO System_Info; | |
44 | |
45 /* XXX Should these be in the global runtime */ | |
46 enum WinOS {Win95, Win98, WinNT, unknown}; | |
47 int MingwOS; | |
48 | |
49 memset( uts, 0, sizeof ( *uts ) ); | |
50 OS_version.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); | |
51 | |
52 GetVersionEx ( &OS_version ); | |
53 GetSystemInfo ( &System_Info ); | |
54 | |
55 strcpy( uts->sysname, "MINGW_" ); | |
56 switch( OS_version.dwPlatformId ) | |
57 { | |
58 case VER_PLATFORM_WIN32_NT: | |
59 strcat( uts->sysname, "WinNT" ); | |
60 MingwOS = WinNT; | |
61 break; | |
62 case VER_PLATFORM_WIN32_WINDOWS: | |
63 switch ( OS_version.dwMinorVersion ) | |
64 { | |
65 case 0: | |
66 strcat( uts->sysname, "Win95" ); | |
67 MingwOS = Win95; | |
68 break; | |
69 case 10: | |
70 strcat( uts->sysname, "Win98" ); | |
71 MingwOS = Win98; | |
72 break; | |
73 default: | |
74 strcat( uts->sysname, "Win??" ); | |
75 MingwOS = unknown; | |
76 break; | |
77 } | |
78 break; | |
79 default: | |
80 strcat( uts->sysname, "Win??" ); | |
81 MingwOS = unknown; | |
82 break; | |
83 } | |
84 | |
85 sprintf( uts->version, "%i", __MINGW32_MAJOR_VERSION ); | |
86 sprintf( uts->release, "%i", __MINGW32_MINOR_VERSION ); | |
87 | |
88 switch( System_Info.wProcessorArchitecture ) | |
89 { | |
90 case PROCESSOR_ARCHITECTURE_PPC: | |
91 strcpy( uts->machine, "ppc" ); | |
92 break; | |
93 case PROCESSOR_ARCHITECTURE_ALPHA: | |
94 strcpy( uts->machine, "alpha" ); | |
95 break; | |
96 case PROCESSOR_ARCHITECTURE_MIPS: | |
97 strcpy( uts->machine, "mips" ); | |
98 break; | |
99 case PROCESSOR_ARCHITECTURE_INTEL: | |
100 /* dwProcessorType is only valid in Win95 and Win98 | |
101 wProcessorLevel is only valid in WinNT */ | |
102 switch( MingwOS ) | |
103 { | |
104 case Win95: | |
105 case Win98: | |
106 switch( System_Info.dwProcessorType ) | |
107 { | |
108 case PROCESSOR_INTEL_386: | |
109 case PROCESSOR_INTEL_486: | |
110 case PROCESSOR_INTEL_PENTIUM: | |
111 sprintf( uts->machine, "i%ld", System_Info.dwProcessorType ); | |
112 break; | |
113 default: | |
114 strcpy( uts->machine, "i386" ); | |
115 break; | |
116 } | |
117 break; | |
118 case WinNT: | |
119 sprintf( uts->machine, "i%d86", System_Info.wProcessorLevel ); | |
120 break; | |
121 default: | |
122 strcpy( uts->machine, "unknown" ); | |
123 break; | |
124 } | |
125 break; | |
126 default: | |
127 strcpy( uts->machine, "unknown" ); | |
128 break; | |
129 } | |
130 | |
131 sLength = sizeof ( uts->nodename ) - 1; | |
132 GetComputerNameA( uts->nodename, &sLength ); | |
133 return 1; | |
134 } | |
135 |