version.cc

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) 2001  The Exult Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #ifdef HAVE_CONFIG_H
00020 #  include <config.h>
00021 #endif
00022 
00023 #include <iostream>
00024 
00025 #ifdef WIN32
00026 #ifndef WIN32_LEAN_AND_MEAN 
00027 #define WIN32_LEAN_AND_MEAN
00028 #endif
00029 #include <windows.h>
00030 #endif
00031 
00032 #if (defined(__linux__) || defined(__linux) || defined(linux))
00033 #include <fstream>
00034 #include <string>
00035 #endif
00036 
00037 void getVersionInfo(std::ostream& out)
00038 {
00039   /*
00040    * 1. Exult version
00041    */
00042    
00043   out << "Exult version " << VERSION << std::endl;
00044 
00045   /*
00046    * 2. Build time
00047    */
00048    
00049 
00050 #if (defined(__TIME__) || defined(__DATE__))
00051   out << "Built at: ";
00052 #ifdef __DATE__
00053   out << __DATE__ << " ";
00054 #endif
00055 #ifdef __TIME__
00056   out << __TIME__;
00057 #endif
00058   out << std::endl;
00059 #endif
00060   
00061   /*
00062    * 3. Various important build options in effect
00063    */
00064    
00065   out << "Compile-time options: ";
00066   bool firstoption = true;
00067 
00068 #ifdef DEBUG
00069   if (!firstoption) out << ", "; 
00070   firstoption = false;
00071   out << "DEBUG";
00072 #endif
00073 
00074 #ifdef HAVE_TIMIDITY_BIN
00075   if (!firstoption) out << ", "; 
00076   firstoption = false;
00077   out << "HAVE_TIMIDITY_BIN";
00078 #endif
00079 
00080 #ifdef USE_EXULTSTUDIO
00081   if (!firstoption) out << ", "; 
00082   firstoption = false;
00083   out << "USE_EXULTSTUDIO";
00084 #endif
00085 
00086 #ifdef USECODE_DEBUGGER
00087   if (!firstoption) out << ", "; 
00088   firstoption = false;
00089   out << "USECODE_DEBUGGER";
00090 #endif
00091 
00092 #ifdef WANT_ALTERNATE_ALLOCATOR
00093   if (!firstoption) out << ", "; 
00094   firstoption = false;
00095   out << "WANT_ALTERNATE_ALLOCATOR";
00096 #endif
00097 
00098 #ifdef INITIALISE_ALLOCATED_BLOCKS
00099   if (!firstoption) out << ", "; 
00100   firstoption = false;
00101   out << "INITIALISE_ALLOCATED_BLOCKS";
00102 #endif
00103 
00104 #ifdef POISON_ALLOCATED_BLOCKS
00105   if (!firstoption) out << ", "; 
00106   firstoption = false;
00107   out << "POISON_ALLOCATED_BLOCKS";
00108 #endif
00109 
00110 #ifdef NO_SDL_PARACHUTE
00111   if (!firstoption) out << ", "; 
00112   firstoption = false;
00113   out << "NO_SDL_PARACHUTE";
00114 #endif
00115 
00116 #ifdef HAVE_ZIP_SUPPORT
00117   if (!firstoption) out << ", "; 
00118   firstoption = false;
00119   out << "HAVE_ZIP_SUPPORT";
00120 #endif
00121 
00122 #ifdef HAVE_OPENGL
00123   if (!firstoption) out << ", ";
00124   firstoption = false;
00125   out << "HAVE_OPENGL";
00126 #endif
00127 
00128   out << std::endl;
00129 
00130 
00131   /*
00132    * 4. Compiler used to create this binary
00133    */
00134    
00135   out << "Compiler: ";
00136   // GCC
00137 #if (defined(__GNUC__))
00138   out << "gcc";
00139  #if defined(__VERSION__)
00140   out << ", version: " << __VERSION__;
00141  #elif (defined(__GNUC_MINOR__))
00142   out << ", version " << __GNUC__ << "." << __GNUC_MINOR__;
00143   #if (defined(__GNUC_PATCHLEVEL__))
00144   out << "." << __GNUC_PATCHLEVEL__;
00145   #endif
00146  #endif
00147 
00148   // Microsoft C/C++ Compiler (used by MSVC)
00149 #elif (defined(_MSC_FULL_VER))
00150   out << "Microsoft C/C++ Compiler, version: " << (_MSC_FULL_VER/1000000) << "."
00151         << ((_MSC_FULL_VER/10000)%100) << "."
00152         << (_MSC_FULL_VER%10000);
00153 #elif (defined(_MSC_VER))
00154   out << "Microsoft C/C++ Compiler, version: " << (_MSC_VER/100) << "." << (_MSC_VER%100);
00155 
00156   // Metrowerks CodeWarrior
00157 #elif (defined(__MWERKS__))
00158   out << "Metrowerks CodeWarrior, version: ";
00159   out << ((__MWERKS__&0xf000)>>12) << ".";
00160   out << ((__MWERKS__&0x0f00)>>8) << ".";
00161   out << (__MWERKS__&0xff);
00162 #else
00163   out << "Unknown";
00164 #endif
00165 
00166   out << std::endl;
00167 
00168 
00169   /*
00170    * 5. Platform
00171    */
00172    
00173   out << std::endl << "Platform: ";
00174 
00175 #if (defined(__linux__) || defined(__linux) || defined(linux))
00176   std::string ver;
00177 
00178   try {
00179     std::ifstream procversion("/proc/version");
00180     if (!procversion) {
00181       ver = "Linux";
00182     } else {
00183       std::getline(procversion, ver);
00184       procversion.close();
00185       ver = ver.substr(0, ver.find('('));
00186     }
00187   } catch(...) {
00188     ver = "Linux";
00189   }
00190   out << ver;
00191 #elif (defined(BEOS))
00192   out << "BeOS";
00193 #elif (defined(__sun__) || defined(__sun))
00194   out << "Solaris";
00195 #elif (defined(WIN32))
00196   out << "Windows ";
00197   {
00198     // Get the version
00199     OSVERSIONINFO info;
00200     info.dwOSVersionInfoSize = sizeof (info);
00201     GetVersionEx (&info);
00202 
00203     // Platform is NT
00204     if (info.dwPlatformId == VER_PLATFORM_WIN32_NT)
00205     {
00206       if (info.dwMajorVersion < 4) out << "NT";
00207       else if (info.dwMajorVersion == 4) out << "NT4";
00208       else if (info.dwMajorVersion == 5 && info.dwMinorVersion == 0) out << 2000;
00209       else if (info.dwMajorVersion == 5 && info.dwMinorVersion == 1) out << "XP";
00210       else if (info.dwMajorVersion == 5 && info.dwMinorVersion == 2) out << 2003;
00211       else out << "Unknown NT";
00212 
00213       if (info.szCSDVersion[0]) out << " " << info.szCSDVersion;
00214     }
00215 #ifdef VER_PLATFORM_WIN32_CE
00216     else if (info.dwPlatformId == VER_PLATFORM_WIN32_CE)
00217     {
00218       out << "CE";
00219     }
00220 #endif
00221     else if (info.dwMajorVersion == 4 && info.dwMinorVersion == 0)
00222     {
00223       out << 95;
00224       if (info.szCSDVersion[1] != ' ') out << info.szCSDVersion;
00225     }
00226     else if (info.dwMajorVersion == 4 && info.dwMinorVersion == 10)
00227     {
00228       out << 98;
00229       if ( info.szCSDVersion[1] == 'A' ) out << " SE";
00230       else if (info.szCSDVersion[1] != ' ') out << info.szCSDVersion;
00231     }
00232     else if (info.dwMajorVersion == 4 && info.dwMinorVersion == 90)
00233       out << "Me";
00234 
00235     out << " Version " << info.dwMajorVersion << "." << info.dwMinorVersion << " Build " << LOWORD(info.dwBuildNumber&0xFFFF);
00236   }
00237 #elif (defined(MACOSX))
00238   out << "Mac OS X";
00239 #elif (defined(MACOS))
00240   out << "MacOS";
00241 #elif (defined(__MORPHOS__))
00242   out << "MorphOS";
00243 #elif (defined(AMIGA))
00244   out << "Amiga";
00245 #else
00246   out << "Unknown";
00247 #endif
00248 
00249   out << std::endl;
00250 
00251 }

Generated on Mon Jul 9 14:42:52 2007 for ExultEngine by  doxygen 1.5.1