Migrate certificates, icons, logs to XDG dirs
[pidgin-git.git] / libpurple / protocols / jabber / win32 / posix.uname.c
blobf898dc5ced3b624400be6db967b68304e701b29e
1 /*
2 posix.uname.c - version 1.1
3 Copyright (C) 1999, 2000
4 Earnie Boyd and assigns
6 Fills the utsname structure with the appropriate values.
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA.
24 Send bug reports to Earnie Boyd <earnie_boyd@yahoo.com>
27 #include "utsname.h"
28 #include <string.h>
29 #include <stdio.h>
31 #include <glib.h>
33 /* ANONYMOUS unions and structs are used from the windows header definitions.
34 These need to be defined for them to work correctly with gcc2.95.2-mingw. */
35 /*#define _ANONYMOUS_STRUCT*/
36 /*#define _ANONYMOUS_UNION*/
37 #include <windows.h>
38 #ifdef __MINGW32__
39 #include <_mingw.h>
40 #endif
42 int
43 jabber_win32_uname( struct utsname *uts )
45 DWORD sLength;
46 OSVERSIONINFO OS_version;
47 SYSTEM_INFO System_Info;
49 /* XXX Should these be in the global runtime */
50 enum WinOS {Win95, Win98, WinNT, unknown};
51 int MingwOS;
53 memset( uts, 0, sizeof ( *uts ) );
54 OS_version.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
56 GetVersionEx ( &OS_version );
57 GetSystemInfo ( &System_Info );
59 g_strlcpy( uts->sysname, "WIN32_" , sizeof(uts->sysname));
60 switch( OS_version.dwPlatformId )
62 case VER_PLATFORM_WIN32_NT:
63 g_strlcat( uts->sysname, "WinNT", sizeof(uts->sysname) );
64 MingwOS = WinNT;
65 break;
66 case VER_PLATFORM_WIN32_WINDOWS:
67 switch ( OS_version.dwMinorVersion )
69 case 0:
70 g_strlcat( uts->sysname, "Win95", sizeof(uts->sysname) );
71 MingwOS = Win95;
72 break;
73 case 10:
74 g_strlcat( uts->sysname, "Win98", sizeof(uts->sysname) );
75 MingwOS = Win98;
76 break;
77 default:
78 g_strlcat( uts->sysname, "Win??", sizeof(uts->sysname) );
79 MingwOS = unknown;
80 break;
82 break;
83 default:
84 g_strlcat( uts->sysname, "Win??", sizeof(uts->sysname) );
85 MingwOS = unknown;
86 break;
89 #ifdef __MINGW32__
90 sprintf( uts->version, "%i", __MINGW32_MAJOR_VERSION );
91 sprintf( uts->release, "%i", __MINGW32_MINOR_VERSION );
92 #endif
94 switch( System_Info.wProcessorArchitecture )
96 case PROCESSOR_ARCHITECTURE_PPC:
97 g_strlcpy( uts->machine, "ppc" , sizeof( uts->machine ) );
98 break;
99 case PROCESSOR_ARCHITECTURE_ALPHA:
100 g_strlcpy( uts->machine, "alpha" , sizeof( uts->machine ) );
101 break;
102 case PROCESSOR_ARCHITECTURE_MIPS:
103 g_strlcpy( uts->machine, "mips" , sizeof( uts->machine ) );
104 break;
105 case PROCESSOR_ARCHITECTURE_INTEL:
106 /* dwProcessorType is only valid in Win95 and Win98
107 wProcessorLevel is only valid in WinNT */
108 switch( MingwOS )
110 case Win95:
111 case Win98:
112 switch( System_Info.dwProcessorType )
114 case PROCESSOR_INTEL_386:
115 case PROCESSOR_INTEL_486:
116 case PROCESSOR_INTEL_PENTIUM:
117 sprintf( uts->machine, "i%ld", System_Info.dwProcessorType );
118 break;
119 default:
120 g_strlcpy( uts->machine, "i386" , sizeof( uts->machine ) );
121 break;
123 break;
124 case WinNT:
125 sprintf( uts->machine, "i%d86", System_Info.wProcessorLevel );
126 break;
127 default:
128 g_strlcpy( uts->machine, "unknown" , sizeof( uts->machine ) );
129 break;
131 break;
132 default:
133 g_strlcpy( uts->machine, "unknown" , sizeof( uts->machine ) );
134 break;
137 sLength = sizeof ( uts->nodename ) - 1;
138 GetComputerNameA( uts->nodename, &sLength );
139 return 1;