cfg: updated yapb.cfg to reflect changes.

cfg: made yb_quota 9 by default.
linux: fixed bots connection times remains static on linux or osx.
crlib: fix security issues.
This commit is contained in:
ds 2020-10-04 00:54:34 +03:00
commit 30a112fd71
10 changed files with 110 additions and 54 deletions

View file

@ -43,19 +43,16 @@ private:
return;
}
time_t ticks = time (&ticks);
tm *timeinfo = nullptr;
tm timeinfo {};
#if defined (CR_WINDOWS)
tm get;
localtime_s (&get, &ticks);
timeinfo = &get;
localtime_s (&timeinfo, &ticks);
#else
timeinfo = localtime (&ticks);
localtime_r (&ticks, &timeinfo);
#endif
auto timebuf = strings.chars ();
strftime (timebuf, StringBuffer::StaticBufferSize, "%Y-%m-%d %H:%M:%S", timeinfo);
strftime (timebuf, StringBuffer::StaticBufferSize, "%Y-%m-%d %H:%M:%S", &timeinfo);
handle_.puts ("%s (%s): %s\n", timebuf, level, msg);
}

View file

@ -139,6 +139,8 @@ CR_NAMESPACE_END
# include <android/log.h>
#endif
#include <time.h>
CR_NAMESPACE_BEGIN
// helper struct for platform detection
@ -151,6 +153,8 @@ struct Platform : public Singleton <Platform> {
bool x64 = false;
bool arm = false;
char appName[64] = {};
Platform () {
#if defined(CR_WINDOWS)
win32 = true;
@ -182,6 +186,11 @@ struct Platform : public Singleton <Platform> {
#endif
}
// set the app name
void setAppName (const char *name) {
snprintf (appName, cr::bufsize (appName), "%s", name);
}
// helper platform-dependant functions
template <typename U> bool checkPointer (U *ptr) {
#if defined(CR_WINDOWS)
@ -232,12 +241,14 @@ struct Platform : public Singleton <Platform> {
QueryPerformanceFrequency (&freq);
QueryPerformanceCounter (&count);
return static_cast <float> (count.QuadPart) / static_cast <float> (freq.QuadPart);
return static_cast <float> (count.QuadPart / freq.QuadPart);
#else
timeval tv;
gettimeofday (&tv, NULL);
gettimeofday (&tv, nullptr);
return static_cast <float> (tv.tv_sec) + (static_cast <float> (tv.tv_usec)) / 1000000.0;
static auto startTime = tv.tv_sec;
return static_cast <float> (tv.tv_sec - startTime);
#endif
}
@ -245,12 +256,12 @@ struct Platform : public Singleton <Platform> {
fprintf (stderr, "%s\n", msg);
#if defined (CR_ANDROID)
__android_log_write (ANDROID_LOG_ERROR, "crlib.fatal", msg);
__android_log_write (ANDROID_LOG_ERROR, appName, msg);
#endif
#if defined(CR_WINDOWS)
DestroyWindow (GetForegroundWindow ());
MessageBoxA (GetActiveWindow (), msg, "crlib.fatal", MB_ICONSTOP);
MessageBoxA (GetActiveWindow (), msg, appName, MB_ICONSTOP);
#endif
::abort ();
}

View file

@ -15,7 +15,6 @@
#pragma once
#include <time.h>
#include <crlib/cr-basic.h>
CR_NAMESPACE_BEGIN