Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2005:
[Freeciv-Dev] (PR#11170) Add -x extra information client command option.
Home

[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 09:03:39 -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.

Updated patch to match current svn trunk.



Index: utility/support.c
===================================================================
--- utility/support.c   (revision 11294)
+++ utility/support.c   (working copy)
@@ -68,6 +68,9 @@
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
+#ifdef HAVE_SYS_UTSNAME_H
+#include <sys/utsname.h>
+#endif
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>            /* usleep, fcntl, gethostname */
 #endif
@@ -587,3 +590,116 @@
 {
   return (char) tolower((int)((unsigned char)c));
 }
+
+/*****************************************************************
+  Returns an uname like string.
+*****************************************************************/
+void my_uname(char *buf, size_t len)
+{
+#ifdef HAVE_UNAME
+  {
+    struct utsname un;
+
+    uname(&un);
+    my_snprintf(buf, len,
+               "%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;
+
+    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+    GetVersionEx(&osvi);
+
+    switch (osvi.dwPlatformId) {
+    case VER_PLATFORM_WIN32s:
+      osname = "Win32s";
+      break;
+
+    case VER_PLATFORM_WIN32_WINDOWS:
+      osname = "Win32";
+
+      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;
+
+    case VER_PLATFORM_WIN32_NT:
+      osname = "WinNT";
+
+      if (osvi.dwMajorVersion == 5) {
+       switch (osvi.dwMinorVersion) {
+       case 0: osname = "Win2000";   break;
+       case 1: osname = "WinXP";           break;
+       default:                            break;
+       }
+      }
+      break;
+
+    default:
+      osname = osvi.szCSDVersion;
+      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_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;
+#endif
+      default:
+       sz_strlcpy(cpuname, "unknown");
+       break;
+    }
+    my_snprintf(buf, len,
+               "%s %ld.%ld [%s]",
+               osname, osvi.dwMajorVersion, osvi.dwMinorVersion,
+               cpuname);
+  }
+#else
+  my_snprintf(buf, len,
+              "unknown unknown [unknown]");
+#endif
+#endif /* HAVE_UNAME */
+}
+
Index: utility/support.h
===================================================================
--- utility/support.h   (revision 11294)
+++ utility/support.h   (working copy)
@@ -107,4 +107,6 @@
 char my_toupper(char c);
 char my_tolower(char c);
 
+void my_uname(char *buf, size_t len);
+
 #endif  /* FC__SUPPORT_H */
Index: common/version.c
===================================================================
--- common/version.c    (revision 11294)
+++ common/version.c    (working copy)
@@ -15,6 +15,7 @@
 #include <config.h>
 #endif
 
+#include "fciconv.h"
 #include "fcintl.h"
 #include "fc_types.h"
 #include "shared.h"
@@ -24,6 +25,31 @@
 
 
 /**********************************************************************
+  Display extra common information, for bug reporting purposes.
+***********************************************************************/
+const char *common_xtra_info(void)
+{
+  char machine_string[256];
+  static char msgbuf[512];
+
+  my_uname(machine_string, sizeof(machine_string));
+  
+  my_snprintf(msgbuf, sizeof(msgbuf),
+      "Freeciv %s%s\n"
+      "\n"
+      "Machine: %s\n"
+      "Encodings: Data=%s, Local=%s, Internal=%s\n",
+      word_version(),
+      VERSION_STRING,
+      machine_string,
+      get_data_encoding(),
+      get_local_encoding(),
+      get_internal_encoding());
+
+  return msgbuf;
+}
+
+/**********************************************************************
   ...
 ***********************************************************************/
 const char *freeciv_name_version(void)
Index: common/version.h
===================================================================
--- common/version.h    (revision 11294)
+++ common/version.h    (working copy)
@@ -58,6 +58,8 @@
                        VER_STRINGIFY(PATCH_VERSION) VERSION_LABEL
 #endif
 
+const char *common_xtra_info(void);
+
 /* version informational strings */
 const char *freeciv_name_version(void);
 const char *word_version(void);
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
--- client/gui-gtk-2.0/gui_main.c       (revision 11294)
+++ client/gui-gtk-2.0/gui_main.c       (working copy)
@@ -1089,6 +1089,22 @@
 }
 
 /**************************************************************************
+  Display extra client information, for bug reporting purposes.
+**************************************************************************/
+const char *ui_xtra_info(void)
+{
+  static char msgbuf[512];
+
+  my_snprintf(msgbuf, sizeof(msgbuf),
+      "GTK+: %u.%u.%u\n",
+      gtk_major_version,
+      gtk_minor_version,
+      gtk_micro_version);
+
+  return msgbuf;
+}
+
+/**************************************************************************
  called from main(), is what it's named.
 **************************************************************************/
 void ui_main(int argc, char **argv)
Index: client/include/gui_main_g.h
===================================================================
--- client/include/gui_main_g.h (revision 11294)
+++ client/include/gui_main_g.h (working copy)
@@ -21,6 +21,7 @@
                               int city_productions_font_size);
 
 void ui_init(void);
+const char *ui_xtra_info(void);
 void ui_main(int argc, char *argv[]);
 void update_conn_list_dialog(void);
 void sound_bell(void);
Index: client/civclient.c
===================================================================
--- client/civclient.c  (revision 11294)
+++ client/civclient.c  (working copy)
@@ -179,6 +179,8 @@
   init_nls();
   audio_init();
   init_character_encodings(gui_character_encoding, gui_use_transliteration);
+  ui_init();
+  charsets_init();
 
   /* default argument values are set in options.c */
   loglevel=LOG_NORMAL;
@@ -221,6 +223,7 @@
       fc_fprintf(stderr, _("  -t, --tiles FILE\t"
                           "Use data file FILE.tilespec for tiles\n"));
       fc_fprintf(stderr, _("  -v, --version\t\tPrint the version number\n"));
+      fc_fprintf(stderr, _("  -x, --xtra\t\tPrint extra information\n"));
       fc_fprintf(stderr, _("      --\t\t"
                           "Pass any following options to the UI.\n"
                           "\t\t\tTry \"%s -- --help\" for more.\n"), argv[0]);
@@ -228,6 +231,12 @@
     } else if (is_option("--version",argv[i])) {
       fc_fprintf(stderr, "%s %s\n", freeciv_name_version(), client_string);
       exit(EXIT_SUCCESS);
+    } else if (is_option("--xtra", argv[i])) {
+      fc_fprintf(stderr, "%s\nClient: %s\n%s",
+         common_xtra_info(),
+         client_string,
+         ui_xtra_info());
+      exit(EXIT_SUCCESS);
     } else if ((option = get_option_malloc("--log", argv, &i, argc))) {
       logfile = option; /* never free()d */
     } else  if ((option = get_option_malloc("--read", argv, &i, argc))) {
@@ -309,8 +318,6 @@
   game.all_connections = conn_list_new();
   game.est_connections = conn_list_new();
 
-  ui_init();
-  charsets_init();
   my_init_network();
   chatline_common_init();
   message_options_init();
Index: client/servers.c
===================================================================
--- client/servers.c    (revision 11296)
+++ client/servers.c    (working copy)
@@ -45,9 +45,6 @@
 #ifdef HAVE_SYS_UIO_H
 #include <sys/uio.h>
 #endif
-#ifdef HAVE_SYS_UTSNAME_H
-#include <sys/utsname.h>
-#endif
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -169,118 +166,6 @@
   return server_list;
 }
 
-/*****************************************************************
-  Returns an uname like string.
-*****************************************************************/
-static void my_uname(char *buf, size_t len)
-{
-#ifdef HAVE_UNAME
-  {
-    struct utsname un;
-
-    uname(&un);
-    my_snprintf(buf, len,
-               "%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;
-
-    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-    GetVersionEx(&osvi);
-
-    switch (osvi.dwPlatformId) {
-    case VER_PLATFORM_WIN32s:
-      osname = "Win32s";
-      break;
-
-    case VER_PLATFORM_WIN32_WINDOWS:
-      osname = "Win32";
-
-      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;
-
-    case VER_PLATFORM_WIN32_NT:
-      osname = "WinNT";
-
-      if (osvi.dwMajorVersion == 5) {
-       switch (osvi.dwMinorVersion) {
-       case 0: osname = "Win2000";   break;
-       case 1: osname = "WinXP";           break;
-       default:                            break;
-       }
-      }
-      break;
-
-    default:
-      osname = osvi.szCSDVersion;
-      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_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;
-#endif
-      default:
-       sz_strlcpy(cpuname, "unknown");
-       break;
-    }
-    my_snprintf(buf, len,
-               "%s %ld.%ld [%s]",
-               osname, osvi.dwMajorVersion, osvi.dwMinorVersion,
-               cpuname);
-  }
-#else
-  my_snprintf(buf, len,
-              "unknown unknown [unknown]");
-#endif
-#endif /* HAVE_UNAME */
-}
-
 /****************************************************************************
   Send the request string to the metaserver.
 ****************************************************************************/

[Prev in Thread] Current Thread [Next in Thread]