|
|
|
|
@@ -19,15 +19,15 @@
|
|
|
|
|
|
|
|
|
|
#include "piincludes_p.h"
|
|
|
|
|
#include "piinit.h"
|
|
|
|
|
#ifndef MICRO_PIP
|
|
|
|
|
|
|
|
|
|
#include "pitime.h"
|
|
|
|
|
#include "pisignals.h"
|
|
|
|
|
#include "piobject.h"
|
|
|
|
|
#include "pisysteminfo.h"
|
|
|
|
|
#include "piresourcesstorage.h"
|
|
|
|
|
#include "pidir.h"
|
|
|
|
|
#ifndef MICRO_PIP
|
|
|
|
|
# include "piprocess.h"
|
|
|
|
|
#endif
|
|
|
|
|
#include "piprocess.h"
|
|
|
|
|
#ifdef ESP_PLATFORM
|
|
|
|
|
# include "esp_system.h"
|
|
|
|
|
#endif
|
|
|
|
|
@@ -49,9 +49,7 @@ void __PISetTimerResolution() {
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
# include <pwd.h>
|
|
|
|
|
# ifndef MICRO_PIP
|
|
|
|
|
# include <sys/utsname.h>
|
|
|
|
|
# endif
|
|
|
|
|
# include <sys/utsname.h>
|
|
|
|
|
# include <pthread.h>
|
|
|
|
|
# ifdef BLACKBERRY
|
|
|
|
|
# include <signal.h>
|
|
|
|
|
@@ -84,7 +82,6 @@ ULONG prev_res;
|
|
|
|
|
bool delete_locs;
|
|
|
|
|
PRIVATE_DEFINITION_END(PIInit)
|
|
|
|
|
|
|
|
|
|
#ifndef MICRO_PIP
|
|
|
|
|
void __sighandler__(PISignals::Signal s) {
|
|
|
|
|
//piCout << Hex << int(s);
|
|
|
|
|
if (s == PISignals::StopTTYInput || s == PISignals::StopTTYOutput)
|
|
|
|
|
@@ -92,7 +89,6 @@ void __sighandler__(PISignals::Signal s) {
|
|
|
|
|
if (s == PISignals::UserDefined1)
|
|
|
|
|
dumpApplicationToFile(PIDir::home().path() + PIDir::separator + PIStringAscii("_PIP_DUMP_") + PIString::fromNumber(PIProcess::currentPID()));
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
|
@@ -106,12 +102,11 @@ PIInit::PIInit() {
|
|
|
|
|
file_charset = 0;
|
|
|
|
|
PISystemInfo * sinfo = PISystemInfo::instance();
|
|
|
|
|
sinfo->execDateTime = PIDateTime::current();
|
|
|
|
|
#ifndef MICRO_PIP
|
|
|
|
|
setFileCharset("UTF-8");
|
|
|
|
|
# ifndef ANDROID
|
|
|
|
|
#ifndef ANDROID
|
|
|
|
|
PISignals::setSlot(__sighandler__);
|
|
|
|
|
PISignals::grabSignals(PISignals::UserDefined1);
|
|
|
|
|
# ifndef WINDOWS
|
|
|
|
|
# ifndef WINDOWS
|
|
|
|
|
PISignals::grabSignals(PISignals::StopTTYInput | PISignals::StopTTYOutput);
|
|
|
|
|
sigset_t ss;
|
|
|
|
|
sigemptyset(&ss);
|
|
|
|
|
@@ -128,7 +123,7 @@ PIInit::PIInit() {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
# else //WINDOWS
|
|
|
|
|
# else //WINDOWS
|
|
|
|
|
// OS version
|
|
|
|
|
DWORD dwVersion = GetVersion();
|
|
|
|
|
DWORD dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
|
|
|
|
@@ -154,33 +149,33 @@ PIInit::PIInit() {
|
|
|
|
|
setTimerResolutionAddr = (PINtSetTimerResolution)GetProcAddress(PRIVATE->ntlib, "NtSetTimerResolution");
|
|
|
|
|
__PISetTimerResolution();
|
|
|
|
|
}
|
|
|
|
|
# endif //WINDOWS
|
|
|
|
|
# ifdef HAS_LOCALE
|
|
|
|
|
# endif //WINDOWS
|
|
|
|
|
# ifdef HAS_LOCALE
|
|
|
|
|
//cout << "has locale" << endl;
|
|
|
|
|
if (currentLocale_t != 0) {
|
|
|
|
|
freelocale(currentLocale_t);
|
|
|
|
|
currentLocale_t = 0;
|
|
|
|
|
}
|
|
|
|
|
currentLocale_t = newlocale(LC_ALL, setlocale(LC_ALL, ""), 0);
|
|
|
|
|
# else //HAS_LOCALE
|
|
|
|
|
# else //HAS_LOCALE
|
|
|
|
|
setlocale(LC_ALL, "");
|
|
|
|
|
setlocale(LC_NUMERIC, "C");
|
|
|
|
|
# endif //HAS_LOCALE
|
|
|
|
|
# else //ANDROID
|
|
|
|
|
# endif //HAS_LOCALE
|
|
|
|
|
#else //ANDROID
|
|
|
|
|
struct sigaction actions;
|
|
|
|
|
memset(&actions, 0, sizeof(actions));
|
|
|
|
|
sigemptyset(&actions.sa_mask);
|
|
|
|
|
actions.sa_flags = 0;
|
|
|
|
|
actions.sa_handler = android_thread_exit_handler;
|
|
|
|
|
sigaction(SIGTERM, &actions, 0);
|
|
|
|
|
# endif //ANDROID
|
|
|
|
|
#endif //ANDROID
|
|
|
|
|
PRIVATE->delete_locs = false;
|
|
|
|
|
__syslocname__ = __sysoemname__ = 0;
|
|
|
|
|
__utf8name__ = const_cast<char*>("UTF-8");
|
|
|
|
|
# ifdef PIP_ICU
|
|
|
|
|
#ifdef PIP_ICU
|
|
|
|
|
UErrorCode e((UErrorCode)0);
|
|
|
|
|
u_init(&e);
|
|
|
|
|
# ifdef WINDOWS
|
|
|
|
|
# ifdef WINDOWS
|
|
|
|
|
PRIVATE->delete_locs = true;
|
|
|
|
|
CPINFOEX cpinfo;
|
|
|
|
|
int l = 0;
|
|
|
|
|
@@ -192,30 +187,30 @@ PIInit::PIInit() {
|
|
|
|
|
memset(__sysoemname__, 0, 256);
|
|
|
|
|
memcpy(__sysoemname__, "ibm-", 4);
|
|
|
|
|
memcpy(&(__sysoemname__[4]), cpinfo.CodePageName, l);
|
|
|
|
|
# else
|
|
|
|
|
# else
|
|
|
|
|
/*PIString en(getenv("LANG"));
|
|
|
|
|
if (!en.isEmpty())
|
|
|
|
|
en = en.mid(en.find(".") + 1);
|
|
|
|
|
PIByteArray enba = en.toByteArray();
|
|
|
|
|
memcpy(__syslocname__, enba.data(), enba.size_s());*/
|
|
|
|
|
# endif
|
|
|
|
|
# endif
|
|
|
|
|
//piCout << __syslocname__;
|
|
|
|
|
//piCout << __sysoemname__;
|
|
|
|
|
# else //PIP_ICU
|
|
|
|
|
# ifdef WINDOWS
|
|
|
|
|
#else //PIP_ICU
|
|
|
|
|
# ifdef WINDOWS
|
|
|
|
|
__syslocname__ = (char *)CP_ACP;
|
|
|
|
|
__sysoemname__ = (char *)CP_OEMCP;
|
|
|
|
|
__utf8name__ = (char *)CP_UTF8;
|
|
|
|
|
# endif
|
|
|
|
|
# endif //PIP_ICU
|
|
|
|
|
# ifdef MAC_OS
|
|
|
|
|
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &__pi_mac_clock);
|
|
|
|
|
# endif
|
|
|
|
|
#endif //PIP_ICU
|
|
|
|
|
#ifdef MAC_OS
|
|
|
|
|
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &__pi_mac_clock);
|
|
|
|
|
#endif
|
|
|
|
|
char cbuff[1024];
|
|
|
|
|
memset(cbuff, 0, 1024);
|
|
|
|
|
if (gethostname(cbuff, 1023) == 0)
|
|
|
|
|
sinfo->hostname = cbuff;
|
|
|
|
|
# ifdef WINDOWS
|
|
|
|
|
#ifdef WINDOWS
|
|
|
|
|
SYSTEM_INFO sysinfo;
|
|
|
|
|
GetSystemInfo(&sysinfo);
|
|
|
|
|
sinfo->processorsCount = sysinfo.dwNumberOfProcessors;
|
|
|
|
|
@@ -236,7 +231,7 @@ PIInit::PIInit() {
|
|
|
|
|
ulong unlen = 1023;
|
|
|
|
|
if (GetUserName(cbuff, &unlen) != 0)
|
|
|
|
|
sinfo->user = cbuff;
|
|
|
|
|
# else //WINDOWS
|
|
|
|
|
#else //WINDOWS
|
|
|
|
|
sinfo->processorsCount = piMaxi(1, int(sysconf(_SC_NPROCESSORS_ONLN)));
|
|
|
|
|
passwd * ps = getpwuid(getuid());
|
|
|
|
|
if (ps)
|
|
|
|
|
@@ -252,8 +247,7 @@ PIInit::PIInit() {
|
|
|
|
|
sinfo->OS_version = uns.release;
|
|
|
|
|
sinfo->architecture = uns.machine;
|
|
|
|
|
}
|
|
|
|
|
# endif //WINDOWS
|
|
|
|
|
#endif // MICRO_PIP
|
|
|
|
|
#endif //WINDOWS
|
|
|
|
|
|
|
|
|
|
#ifdef ESP_PLATFORM
|
|
|
|
|
esp_chip_info_t chip_info;
|
|
|
|
|
@@ -266,21 +260,21 @@ PIInit::PIInit() {
|
|
|
|
|
sinfo->OS_name =
|
|
|
|
|
#ifdef WINDOWS
|
|
|
|
|
PIStringAscii("Windows");
|
|
|
|
|
# elif defined(QNX)
|
|
|
|
|
#elif defined(QNX)
|
|
|
|
|
PIStringAscii("QNX");
|
|
|
|
|
# elif defined(MAC_OS)
|
|
|
|
|
#elif defined(MAC_OS)
|
|
|
|
|
PIStringAscii("MacOS");
|
|
|
|
|
# elif defined(ANDROID)
|
|
|
|
|
#elif defined(ANDROID)
|
|
|
|
|
PIStringAscii("Android");
|
|
|
|
|
# elif defined(FREE_BSD)
|
|
|
|
|
#elif defined(FREE_BSD)
|
|
|
|
|
PIStringAscii("FreeBSD");
|
|
|
|
|
# elif defined(FREERTOS)
|
|
|
|
|
#elif defined(FREERTOS)
|
|
|
|
|
PIStringAscii("FreeRTOS");
|
|
|
|
|
# elif defined(MICRO_PIP)
|
|
|
|
|
#elif defined(MICRO_PIP)
|
|
|
|
|
PIStringAscii("MicroPIP");
|
|
|
|
|
# else
|
|
|
|
|
#else
|
|
|
|
|
uns.sysname;
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -418,3 +412,6 @@ __PIInit_Initializer__::~__PIInit_Initializer__() {
|
|
|
|
|
__instance__ = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // MICRO_PIP
|
|
|
|
|
|
|
|
|
|
|