added back in build version header.
[feisty_meow.git] / nucleus / library / versions / version_checker.cpp
index 24d06b69dbb78e77baf6125aeedf072e969464c8..70a8e2c47b8719cabd55ae8adb12d6b92cc0e47a 100644 (file)
@@ -33,7 +33,8 @@ using namespace structures;
 
 #ifndef BOOT_STRAPPING
   // pull in the version specified for this build.
-///hmmm: on hold!  #include <__build_version.h>
+  #include <__build_version.h>
+//why was this include "on hold"?
 #else
   // plug in a fake version for our bootstrapping process.
   #define __build_FILE_VERSION "108.420.1024.10008"
@@ -44,7 +45,8 @@ using namespace structures;
   #include <winver.h>
 #endif
 
-#ifdef __WIN32__
+#if defined(_MSC_VER)
+//#ifdef __WIN32__
   // ensures that we handle the data properly regardless of unicode settings.
   #ifdef UNICODE
     #define render_ptr(ptr) from_unicode_temp( (UTF16 *) ptr)
@@ -80,7 +82,7 @@ astring version_checker::text_form() const
 
 bool version_checker::good_version() const
 {
-  astring version_disabler = environment::get("TMP");
+  astring version_disabler = environment::TMP();
   version_disabler += "/no_version_check.txt";
   FILE *always_okay = fopen(version_disabler.s(), "r");
   if (always_okay) {
@@ -97,7 +99,8 @@ bool version_checker::good_version() const
 
 bool version_checker::loaded(const astring &library_file_name)
 {
-#ifdef __WIN32__
+//#ifdef __WIN32__
+#if defined(_MSC_VER)
   return bool(get_handle(library_file_name) != 0); 
 #else
 //temp code. 
@@ -107,21 +110,21 @@ bool version_checker::loaded(const astring &library_file_name)
 
 void *version_checker::get_handle(const astring &library_file_name)
 {
-#ifdef __WIN32__
+//#ifdef __WIN32__
+#if defined(_MSC_VER)
   return GetModuleHandle(to_unicode_temp(library_file_name));
 #else
-//hmmm: there really isn't this concept on OSes that i'm aware of.
-  return 0 && library_file_name.t();
+  if (library_file_name.t()) return NULL_POINTER; else return NULL_POINTER;
 #endif
 }
 
 astring version_checker::module_name(const void *module_handle)
 {
-#ifdef __UNIX__
-//hmmm: implement module name for linux if that makes sense.
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
   if (module_handle) {}
   return application_configuration::application_name();
-#elif defined(__WIN32__)
+#elif defined(_MSC_VER)
+//#elif defined(__WIN32__)
   flexichar low_buff[MAX_ABS_PATH + 1];
   GetModuleFileName((HMODULE)module_handle, low_buff, MAX_ABS_PATH - 1);
   astring buff = from_unicode_temp(low_buff);
@@ -129,7 +132,7 @@ astring version_checker::module_name(const void *module_handle)
   return buff;
 #else
   #pragma message("module_name unknown for this operating system.")
-  return application_name();
+  return application_configuration::application_name();
 #endif
 }
 
@@ -143,7 +146,8 @@ bool version_checker::retrieve_version_info(const astring &filename,
 
   // determine the required size of the version info buffer.
   int required_size;
-#ifdef __WIN32__
+#if defined(_MSC_VER)
+//#ifdef __WIN32__
   un_long module_handle;  // filled with the dll or exe handle.
   required_size = GetFileVersionInfoSize(to_unicode_temp(filename), &module_handle);
 #else
@@ -154,7 +158,8 @@ bool version_checker::retrieve_version_info(const astring &filename,
   
   // read the version info into our buffer.
   bool success = false;
-#ifdef __WIN32__
+#if defined(_MSC_VER)
+//#ifdef __WIN32__
   success = GetFileVersionInfo(to_unicode_temp(filename), module_handle,
       required_size, to_fill.access());
 #else
@@ -168,7 +173,8 @@ bool version_checker::get_language(byte_array &version_chunk,
 {
   high = 0;
   low = 0;
-#ifdef __WIN32__
+#if defined(_MSC_VER)
+//#ifdef __WIN32__
   // determine the language that the version's written in.
   basis::un_int data_size;
   void *pointer_to_language_structure;
@@ -190,7 +196,8 @@ bool version_checker::get_language(byte_array &version_chunk,
 
 version version_checker::retrieve_version(const astring &filename)
 {
-#ifdef UNIX
+//#ifdef UNIX
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
 
   // totally bogus stand-in; this just returns the version we were built with
   // rather than the version that's actually tagged on the file.
@@ -201,7 +208,7 @@ version version_checker::retrieve_version(const astring &filename)
 
 #endif
 
-  byte_array version_info_found(0, NIL);
+  byte_array version_info_found(0, NULL_POINTER);
   if (!retrieve_version_info(filename, version_info_found))
     return version(0, 0, 0, 0);
 
@@ -215,7 +222,7 @@ version version_checker::retrieve_version(const astring &filename)
   astring file_version_key(root_key + astring("\\FileVersion"));
 
   astring version_string;
-#ifdef __WIN32__
+#ifdef _MSC_VER
   abyte *file_version_pointer;
   basis::un_int data_size;
   if (!VerQueryValue(version_info_found.access(),
@@ -242,7 +249,7 @@ bool version_checker::get_record(const astring &filename,
     version_record &to_fill)
 {
   to_fill = version_record();
-  byte_array version_info_found(0, NIL);
+  byte_array version_info_found(0, NULL_POINTER);
   if (!retrieve_version_info(filename, version_info_found))
     return false;
 
@@ -258,7 +265,8 @@ bool version_checker::get_record(const astring &filename,
 
   // the various version pieces are retrieved...
 
-#ifdef __WIN32__
+//#ifdef __WIN32__
+#ifdef _MSC_VER
   basis::un_int data_size;
   void *data_pointer;
 
@@ -350,9 +358,10 @@ void version_checker::complain_wrong_version(const astring &library_file_name,
 
   to_show += astring("].  ");
   to_show += *_version_complaint;
-#ifdef __UNIX__
+//#ifdef __UNIX__
+#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
   continuable_error("version checking", "failure", to_show.s());
-#elif defined(__WIN32__)
+#elif defined(_MSC_VER)
   MessageBox(0, to_unicode_temp(to_show),
       to_unicode_temp("version_checking::failure"), MB_OK);
 #endif