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)
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>
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*/
43 jabber_win32_uname( struct utsname
*uts
)
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
};
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
) );
66 case VER_PLATFORM_WIN32_WINDOWS
:
67 switch ( OS_version
.dwMinorVersion
)
70 g_strlcat( uts
->sysname
, "Win95", sizeof(uts
->sysname
) );
74 g_strlcat( uts
->sysname
, "Win98", sizeof(uts
->sysname
) );
78 g_strlcat( uts
->sysname
, "Win??", sizeof(uts
->sysname
) );
84 g_strlcat( uts
->sysname
, "Win??", sizeof(uts
->sysname
) );
90 sprintf( uts
->version
, "%i", __MINGW32_MAJOR_VERSION
);
91 sprintf( uts
->release
, "%i", __MINGW32_MINOR_VERSION
);
94 switch( System_Info
.wProcessorArchitecture
)
96 case PROCESSOR_ARCHITECTURE_PPC
:
97 g_strlcpy( uts
->machine
, "ppc" , sizeof( uts
->machine
) );
99 case PROCESSOR_ARCHITECTURE_ALPHA
:
100 g_strlcpy( uts
->machine
, "alpha" , sizeof( uts
->machine
) );
102 case PROCESSOR_ARCHITECTURE_MIPS
:
103 g_strlcpy( uts
->machine
, "mips" , sizeof( uts
->machine
) );
105 case PROCESSOR_ARCHITECTURE_INTEL
:
106 /* dwProcessorType is only valid in Win95 and Win98
107 wProcessorLevel is only valid in WinNT */
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
);
120 g_strlcpy( uts
->machine
, "i386" , sizeof( uts
->machine
) );
125 sprintf( uts
->machine
, "i%d86", System_Info
.wProcessorLevel
);
128 g_strlcpy( uts
->machine
, "unknown" , sizeof( uts
->machine
) );
133 g_strlcpy( uts
->machine
, "unknown" , sizeof( uts
->machine
) );
137 sLength
= sizeof ( uts
->nodename
) - 1;
138 GetComputerNameA( uts
->nodename
, &sLength
);