[Freeciv-Dev] (PR#11170) Add -x extra information client command option.
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#11170) Add -x extra information client command option. |
From: |
"Vasco Alexandre da Silva Costa" <vasco.costa@xxxxxxxxx> |
Date: |
Sat, 3 Dec 2005 08:33:22 -0800 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11170 >
> [vasc - Wed Nov 24 00:40:26 2004]:
>
> Here is a patch to implement this useful debug information functionality.
>
> I didn't take care of clients other than gui-gtk-2.0. Someone ( read:
> not me :) ) should fix this before commiting.
I split the my_uname function merge into a separate patch. Patch
attached, to commit ASAP.
-Vasco Alexandre da Silva Costa
Index: client/servers.c
===================================================================
--- client/servers.c (revision 11294)
+++ client/servers.c (working copy)
@@ -169,99 +169,121 @@
return server_list;
}
-#ifdef WIN32_NATIVE
/*****************************************************************
- Returns an uname like string for windows
+ Returns an uname like string.
*****************************************************************/
-static char *win_uname()
+static const char *my_uname(void)
{
- static char uname_buf[256];
- char cpuname[16];
- char *osname;
- SYSTEM_INFO sysinfo;
- OSVERSIONINFO osvi;
+ static char machine_string[128];
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&osvi);
+#ifdef HAVE_UNAME
+ {
+ struct utsname un;
- switch (osvi.dwPlatformId) {
- case VER_PLATFORM_WIN32s:
- osname = "Win32s";
- break;
+ uname(&un);
+ my_snprintf(machine_string, sizeof(machine_string),
+ "%s %s [%s]",
+ un.sysname,
+ un.release,
+ un.machine);
+ }
+#else /* ! HAVE_UNAME */
+ /* Fill in here if you are making a binary without sys/utsname.h and know
+ the OS name, release number, and machine architechture */
+#ifdef WIN32_NATIVE
+ {
+ char cpuname[16];
+ char *osname;
+ SYSTEM_INFO sysinfo;
+ OSVERSIONINFO osvi;
- case VER_PLATFORM_WIN32_WINDOWS:
- osname = "Win32";
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&osvi);
- if (osvi.dwMajorVersion == 4) {
- switch (osvi.dwMinorVersion) {
- case 0: osname = "Win95"; break;
- case 10: osname = "Win98"; break;
- case 90: osname = "WinME"; break;
- default: break;
- }
- }
- break;
+ switch (osvi.dwPlatformId) {
+ case VER_PLATFORM_WIN32s:
+ osname = "Win32s";
+ break;
- case VER_PLATFORM_WIN32_NT:
- osname = "WinNT";
+ case VER_PLATFORM_WIN32_WINDOWS:
+ osname = "Win32";
- if (osvi.dwMajorVersion == 5) {
- switch (osvi.dwMinorVersion) {
- case 0: osname = "Win2000"; break;
- case 1: osname = "WinXP"; break;
- default: break;
+ if (osvi.dwMajorVersion == 4) {
+ switch (osvi.dwMinorVersion) {
+ case 0: osname = "Win95"; break;
+ case 10: osname = "Win98"; break;
+ case 90: osname = "WinME"; break;
+ default: break;
+ }
}
- }
- break;
+ break;
- default:
- osname = osvi.szCSDVersion;
- break;
- }
+ case VER_PLATFORM_WIN32_NT:
+ osname = "WinNT";
- GetSystemInfo(&sysinfo);
- switch (sysinfo.wProcessorArchitecture) {
- case PROCESSOR_ARCHITECTURE_INTEL:
- {
- unsigned int ptype;
- if (sysinfo.wProcessorLevel < 3) /* Shouldn't happen. */
- ptype = 3;
- else if (sysinfo.wProcessorLevel > 9) /* P4 */
- ptype = 6;
- else
- ptype = sysinfo.wProcessorLevel;
-
- my_snprintf(cpuname, sizeof(cpuname), "i%d86", ptype);
+ if (osvi.dwMajorVersion == 5) {
+ switch (osvi.dwMinorVersion) {
+ case 0: osname = "Win2000"; break;
+ case 1: osname = "WinXP"; break;
+ default: break;
+ }
}
break;
- case PROCESSOR_ARCHITECTURE_MIPS:
- sz_strlcpy(cpuname, "mips");
+ default:
+ osname = osvi.szCSDVersion;
break;
+ }
- case PROCESSOR_ARCHITECTURE_ALPHA:
- sz_strlcpy(cpuname, "alpha");
- break;
+ GetSystemInfo(&sysinfo);
+ switch (sysinfo.wProcessorArchitecture) {
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ {
+ unsigned int ptype;
+ if (sysinfo.wProcessorLevel < 3) /* Shouldn't happen. */
+ ptype = 3;
+ else if (sysinfo.wProcessorLevel > 9) /* P4 */
+ ptype = 6;
+ else
+ ptype = sysinfo.wProcessorLevel;
+
+ my_snprintf(cpuname, sizeof(cpuname), "i%d86", ptype);
+ }
+ break;
- case PROCESSOR_ARCHITECTURE_PPC:
- sz_strlcpy(cpuname, "ppc");
- break;
+ case PROCESSOR_ARCHITECTURE_MIPS:
+ sz_strlcpy(cpuname, "mips");
+ break;
+
+ case PROCESSOR_ARCHITECTURE_ALPHA:
+ sz_strlcpy(cpuname, "alpha");
+ break;
+
+ case PROCESSOR_ARCHITECTURE_PPC:
+ sz_strlcpy(cpuname, "ppc");
+ break;
#if 0
- case PROCESSOR_ARCHITECTURE_IA64:
- sz_strlcpy(cpuname, "ia64");
- break;
+ case PROCESSOR_ARCHITECTURE_IA64:
+ sz_strlcpy(cpuname, "ia64");
+ break;
#endif
- default:
- sz_strlcpy(cpuname, "unknown");
- break;
+ default:
+ sz_strlcpy(cpuname, "unknown");
+ break;
+ }
+ my_snprintf(machine_string, sizeof(machine_string),
+ "%s %ld.%ld [%s]", osname, osvi.dwMajorVersion,
osvi.dwMinorVersion,
+ cpuname);
}
- my_snprintf(uname_buf, sizeof(uname_buf),
- "%s %ld.%ld [%s]", osname, osvi.dwMajorVersion,
osvi.dwMinorVersion,
- cpuname);
- return uname_buf;
-}
+#else
+ my_snprintf(machine_string, sizeof(machine_string),
+ "unknown unknown [unknown]");
#endif
+#endif /* HAVE_UNAME */
+ return machine_string;
+}
+
/****************************************************************************
Send the request string to the metaserver.
****************************************************************************/
@@ -269,28 +291,9 @@
{
const char *capstr;
char str[MAX_LEN_PACKET];
-#ifdef HAVE_UNAME
- struct utsname un;
-#endif
char machine_string[128];
-#ifdef HAVE_UNAME
- uname(&un);
- my_snprintf(machine_string,sizeof(machine_string),
- "%s %s [%s]",
- un.sysname,
- un.release,
- un.machine);
-#else /* ! HAVE_UNAME */
- /* Fill in here if you are making a binary without sys/utsname.h and know
- the OS name, release number, and machine architechture */
-#ifdef WIN32_NATIVE
- sz_strlcpy(machine_string,win_uname());
-#else
- my_snprintf(machine_string,sizeof(machine_string),
- "unknown unknown [unknown]");
-#endif
-#endif /* HAVE_UNAME */
+ sz_strlcpy(machine_string, my_uname());
capstr = my_url_encode(our_capability);
- [Freeciv-Dev] (PR#11170) Add -x extra information client command option.,
Vasco Alexandre da Silva Costa <=
|
|