X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=nucleus%2Flibrary%2Fapplication%2Fwindoze_helper.cpp;h=1dfbefad9c3715ede6f84ae3f96757b3d1bfb3f2;hb=1d2664df2dfb6d3d0786706ce397acd86c2fbb13;hp=c9c29109a4488791cca54c8d993a69abe75cd8ec;hpb=3ea085ec301ed1399dfa1e9f3a240312dc95410b;p=feisty_meow.git diff --git a/nucleus/library/application/windoze_helper.cpp b/nucleus/library/application/windoze_helper.cpp index c9c29109..1dfbefad 100644 --- a/nucleus/library/application/windoze_helper.cpp +++ b/nucleus/library/application/windoze_helper.cpp @@ -13,15 +13,8 @@ \*****************************************************************************/ #include "windoze_helper.h" -///#include "array.h" -///#include "build_configuration.h" -///#include "convert_utf.h" -///#include "function.h" -///#include "mutex.h" -///#include "portable.h" -///#include "set.h" -///#include "version_record.h" #include +#include ///#include ///#include @@ -50,12 +43,15 @@ */ using namespace basis; +using namespace loggers; using namespace structures; using namespace configuration; #undef static_class_name #define static_class_name() "windoze_helper" +#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s) + /* //#define DEBUG_PORTABLE // uncomment for noisy debugging. @@ -312,7 +308,7 @@ bool event_poll(MSG &message) message.message = 0; message.wParam = 0; message.lParam = 0; - if (!PeekMessage(&message, NIL, 0, 0, PM_REMOVE)) + if (!PeekMessage(&message, NULL_POINTER, 0, 0, PM_REMOVE)) return false; TranslateMessage(&message); DispatchMessage(&message); @@ -406,45 +402,6 @@ istring query_for_process_info() } #endif -// used as a return value when the name cannot be determined. -#ifndef EMBEDDED_BUILD - #define SET_BOGUS_NAME(error) { \ - COMPLAIN(error); \ - if (output) { \ - fclose(output); \ - unlink(tmpfile.s()); \ - } \ - istring home_dir = env_string("HOME"); \ - to_return = home_dir + "/failed_to_determine.exe"; \ - } -#else - #define SET_BOGUS_NAME(error) { \ - COMPLAIN(error); \ - to_return = "unknown"; \ - } -#endif - -istring application_name() -{ - FUNCDEF("application_name"); - istring to_return; -#ifdef __UNIX__ - to_return = get_cmdline_from_proc(); -#elif defined(__WIN32__) - flexichar low_buff[MAX_ABS_PATH + 1]; - GetModuleFileName(NIL, low_buff, MAX_ABS_PATH - 1); - istring buff = from_unicode_temp(low_buff); - buff.to_lower(); // we lower-case the name since windows seems to UC it. - to_return = buff; -#elif defined(EMBEDDED_BUILD) - SET_BOGUS_NAME("embedded_exe"); -#else - #pragma error("hmmm: no means of finding app name is implemented.") - SET_BOGUS_NAME("not_implemented_for_this_OS"); -#endif - return to_return; -} - istring module_name(const void *module_handle) { #ifdef __UNIX__ @@ -481,9 +438,9 @@ istring system_error_text(u_int to_name) return strerror(to_name); #elif defined(__WIN32__) char error_text[1000]; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NIL, to_name, + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL_POINTER, to_name, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)error_text, - sizeof(error_text) - 1, NIL); + sizeof(error_text) - 1, NULL_POINTER); istring to_return = error_text; // trim off the ridiculous carriage return they add. while ( (to_return[to_return.end()] == '\r') @@ -554,32 +511,6 @@ istring current_directory() return to_return; } -istring env_string(const istring &variable_name) -{ -#ifdef __WIN32__ - char *value = getenv(variable_name.upper().observe()); - // dos & os/2 require upper case for the name, so we just do it that way. -#else - char *value = getenv(variable_name.observe()); - // reasonable OSes support mixed-case environment variables. -#endif - istring to_return; - if (value) - to_return = istring(value); - return to_return; -} - -bool set_environ(const istring &variable_name, const istring &value) -{ - int ret = 0; -#ifdef __WIN32__ - ret = putenv((variable_name + "=" + value).s()); -#else - ret = setenv(variable_name.s(), value.s(), true); -#endif - return !ret; -} - timeval fill_timeval_ms(int duration) { timeval time_out; // timeval has tv_sec=seconds, tv_usec=microseconds. @@ -638,7 +569,7 @@ basis::char_star_array break_line(istring &app, const istring ¶meters) .stuff(to_return[to_return.last()], len); } // add the sentinel to the list of strings. - to_return += NIL; + to_return += NULL_POINTER; #ifdef DEBUG_PORTABLE for (int q = 0; to_return[q]; q++) { printf("%d: %s\n", q, to_return[q]); @@ -809,8 +740,8 @@ u_int launch_process(const istring &app_name_in, const istring &command_line, // } } istring parms = app_name + " " + command_line; - bool success = CreateProcess(NIL, to_unicode_temp(parms), NIL, NIL, false, - create_flag, NIL, NIL, &startup_info, &process_info); + bool success = CreateProcess(NULL_POINTER, to_unicode_temp(parms), NULL_POINTER, NULL_POINTER, false, + create_flag, NULL_POINTER, NULL_POINTER, &startup_info, &process_info); if (!success) return system_error(); // success then, merge back into stream. @@ -901,13 +832,16 @@ const char *opsystem_name(known_operating_systems which) case WIN_XP: return "WIN_XP"; case WIN_SRV2K3: return "WIN_SRV2K3"; case WIN_VISTA: return "WIN_VISTA"; - case WIN_SRV2K8: return "WIN_SRV2K8"; + case WIN_7: return "WIN_7"; + case WIN_8: return "WIN_8"; + case WIN_10: return "WIN_10"; default: return "UNKNOWN_OS"; } } known_operating_systems determine_OS() { + FUNCDEF("determine_OS"); version osver = application_configuration::get_OS_version(); if ( (osver.v_major() == 4) && (osver.v_minor() == 0) ) { if (osver.v_revision() == VER_PLATFORM_WIN32_WINDOWS) return WIN_95; @@ -920,9 +854,19 @@ known_operating_systems determine_OS() return WIN_SRV2K3; } else if ( (osver.v_major() == 6) && (osver.v_minor() == 0) ) { return WIN_VISTA; +// } else if ( (osver.v_major() == 6) && (osver.v_minor() == 1) ) { +// return WIN_SRV2K8; } else if ( (osver.v_major() == 6) && (osver.v_minor() == 1) ) { - return WIN_SRV2K8; + return WIN_7; + } else if ( (osver.v_major() == 6) && (osver.v_minor() == 2) ) { + return WIN_8; + } else if ( (osver.v_major() == 10) && (osver.v_minor() == 0) ) { + return WIN_10; } + +//temp +LOG(a_sprintf("got a major OS of %d and minor OS of %d", osver.v_major(), osver.v_minor())); + return UNKNOWN_OS; }