Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2004:
[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" <vasc@xxxxxxxxxxxxxx>
Date: Tue, 23 Nov 2004 16:40:27 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=11170 >

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.

? client/.civclient.c.swo
Index: client/civclient.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v
retrieving revision 1.205
diff -u -r1.205 civclient.c
--- client/civclient.c  22 Nov 2004 19:24:18 -0000      1.205
+++ client/civclient.c  24 Nov 2004 00:38:14 -0000
@@ -175,6 +175,8 @@
 
   init_nls();
   audio_init();
+  ui_init();
+  charsets_init();
 
   /* default argument values are set in options.c */
   loglevel=LOG_NORMAL;
@@ -216,6 +218,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]);
@@ -223,6 +226,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("--log",argv,&i,argc))) {
       logfile = mystrdup(option); /* never free()d */
    } else  if ((option = get_option("--read", argv, &i, argc)))
@@ -248,9 +257,9 @@
       if (loglevel==-1) {
         exit(EXIT_FAILURE);
       }
-   } else if ((option = get_option("--tiles", argv, &i, argc)))
+   } else if ((option = get_option("--tiles", argv, &i, argc))) {
       sz_strlcpy(tileset_name, option);
-   else if (is_option("--", argv[i])) {
+   } else if (is_option("--", argv[i])) {
      ui_separator = TRUE;
    } else { 
       fc_fprintf(stderr, _("Unrecognized option: \"%s\"\n"), argv[i]);
@@ -278,8 +287,6 @@
   conn_list_init(&game.est_connections);
   conn_list_init(&game.game_connections);
 
-  ui_init();
-  charsets_init();
   my_init_network();
   chatline_common_init();
   init_messages_where();
Index: client/clinet.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/clinet.c,v
retrieving revision 1.107
diff -u -r1.107 clinet.c
--- client/clinet.c     14 Nov 2004 23:09:59 -0000      1.107
+++ client/clinet.c     24 Nov 2004 00:38:14 -0000
@@ -48,9 +48,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
@@ -402,99 +399,6 @@
   unqueue_mapview_updates();
 }
 
-#ifdef WIN32_NATIVE
-/*****************************************************************
-   Returns an uname like string for windows
-*****************************************************************/
-static char *win_uname()
-{
-  static char uname_buf[256];
-  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(uname_buf, sizeof(uname_buf),
-             "%s %ld.%ld [%s]", osname, osvi.dwMajorVersion, 
osvi.dwMinorVersion,
-             cpuname);
-  return uname_buf;
-}
-#endif
-
 /**************************************************************************
  The server sends a stream in a registry 'ini' type format.
  Read it using secfile functions and fill the server_list structs.
@@ -588,9 +492,6 @@
   const char *capstr;
   char str[MAX_LEN_PACKET];
   char machine_string[128];
-#ifdef HAVE_UNAME
-  struct utsname un;
-#endif 
 
   urlpath = my_lookup_httpd(metaname, &metaport, METALIST_ADDR);//metaserver);
   if (!urlpath) {
@@ -615,23 +516,7 @@
     return NULL;
   }
 
-#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);
 
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.c,v
retrieving revision 1.93
diff -u -r1.93 gui_main.c
--- client/gui-gtk-2.0/gui_main.c       23 Nov 2004 15:44:10 -0000      1.93
+++ client/gui-gtk-2.0/gui_main.c       24 Nov 2004 00:38:15 -0000
@@ -1024,6 +1024,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
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/gui_main_g.h,v
retrieving revision 1.10
diff -u -r1.10 gui_main_g.h
--- client/include/gui_main_g.h 3 Sep 2004 04:22:36 -0000       1.10
+++ client/include/gui_main_g.h 24 Nov 2004 00:38:15 -0000
@@ -18,6 +18,7 @@
 #include "fc_types.h"
 
 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: common/version.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/version.c,v
retrieving revision 1.7
diff -u -r1.7 version.c
--- common/version.c    2 May 2004 11:42:23 -0000       1.7
+++ common/version.c    24 Nov 2004 00:38:15 -0000
@@ -15,6 +15,7 @@
 #include <config.h>
 #endif
 
+#include "fciconv.h"
 #include "fcintl.h"
 #include "shared.h"
 #include "support.h"
@@ -23,6 +24,28 @@
 
 
 /**********************************************************************
+  Display extra common information, for bug reporting purposes.
+***********************************************************************/
+const char *common_xtra_info(void)
+{
+  static char msgbuf[512];
+
+  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,
+      my_uname(),
+      get_data_encoding(),
+      get_local_encoding(),
+      get_internal_encoding());
+
+  return msgbuf;
+}
+
+/**********************************************************************
   ...
 ***********************************************************************/
 const char *freeciv_name_version(void)
Index: common/version.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/version.h,v
retrieving revision 1.54
diff -u -r1.54 version.h
--- common/version.h    9 Oct 2004 15:09:28 -0000       1.54
+++ common/version.h    24 Nov 2004 00:38:15 -0000
@@ -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: utility/support.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/utility/support.c,v
retrieving revision 1.29
diff -u -r1.29 support.c
--- utility/support.c   19 Nov 2004 01:13:01 -0000      1.29
+++ utility/support.c   24 Nov 2004 00:38:18 -0000
@@ -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
@@ -582,3 +585,121 @@
 {
   return (char) tolower((int)((unsigned char)c));
 }
+
+/*****************************************************************
+   Returns an uname like string.
+*****************************************************************/
+const char *my_uname(void)
+{
+  static char machine_string[256];
+
+#ifdef HAVE_UNAME
+  {
+    struct utsname un;
+
+    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;
+
+    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";i    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(machine_string, sizeof(machine_string),
+               "%s %ld.%ld [%s]",
+               osname,
+               osvi.dwMajorVersion, osvi.dwMinorVersion,
+               cpuname);
+  }
+#else
+  my_snprintf(machine_string, sizeof(machine_string),
+              "unknown unknown [unknown]");
+#endif
+#endif /* HAVE_UNAME */
+
+  return machine_string;
+}
+
Index: utility/support.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/utility/support.h,v
retrieving revision 1.19
diff -u -r1.19 support.h
--- utility/support.h   17 May 2004 02:16:15 -0000      1.19
+++ utility/support.h   24 Nov 2004 00:38:18 -0000
@@ -66,4 +66,7 @@
 char my_toupper(char c);
 char my_tolower(char c);
 
+const char *my_uname(void);
+
 #endif  /* FC__SUPPORT_H */
+

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