int gettimeofday(struct timeval *_tv, struct timezone *_tz) { FILETIME ft; LARGE_INTEGER li; __int64 t; static int tzflag; if (_tv) { GetSystemTimeAsFileTime(&ft); li.LowPart = ft.dwLowDateTime; li.HighPart = ft.dwHighDateTime; t = li.QuadPart; /* In 100-nanosecond intervals */ t -= EPOCHFILETIME; /* Offset to the Epoch time */ t /= 10; /* In microseconds */ _tv->tv_sec = (long)(t / 1000000); _tv->tv_usec = (long)(t % 1000000); } if (_tz) { if (!tzflag) { _tzset(); tzflag++; } _get_timezone(&_tz->tz_minuteswest); _tz->tz_minuteswest /= 60; _get_daylight(&_tz->tz_dsttime); } return 0; }
int gettimeofday(struct timeval *tv, struct timezone *tz) { FILETIME ft; unsigned __int64 t = 0; ULARGE_INTEGER li; static int tzflag; if (NULL != tv) { GetSystemTimeAsFileTime(&ft); li.LowPart = ft.dwLowDateTime; li.HighPart = ft.dwHighDateTime; t = li.QuadPart; /* In 100-nanosecond intervals */ t /= 10; /* In microseconds */ t -= DELTA_EPOCH_IN_MICROSECS; /* Offset to the Epoch time */ tv->tv_sec = (long)(t / 1000000UL); tv->tv_usec = (long)(t % 1000000UL); } if (NULL != tz) { if (!tzflag) { _tzset(); tzflag++; } tz->tz_minuteswest = _get_timezone(NULL) / 60; tz->tz_dsttime = _get_daylight(NULL); } return 0; }
void ossimLocalTm::setTimezoneOffsetFromGmt() { m_mutex.lock(); // struct tm gmt = *this; #if !defined(_MSC_VER) tzset(); #else _tzset(); #endif #if ( defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) ) //gmt.tm_sec -= tm_gmtoff; // Seconds east of UTC m_timezoneOffset = tm_gmtoff; #elif (defined(WIN32)) long timezoneOffset=0; _get_timezone(&timezoneOffset); //m_timezoneOffset = timezone; // Seconds west of UTC if ( tm_isdst ) { timezoneOffset -= 3600; // Subtract an hour. } m_timezoneOffset = -timezoneOffset; #else m_timezoneOffset = timezone; // Seconds west of UTC if ( tm_isdst ) { m_timezoneOffset -= 3600; // Subtract an hour. } m_timezoneOffset = -m_timezoneOffset; #endif m_mutex.unlock(); m_timezoneOffset = m_timezoneOffset/3600; }
_CRTIMP errno_t __cdecl _ftime64_s ( struct __timeb64 *tp ) { FT nt_time; __time64_t t; TIME_ZONE_INFORMATION tzinfo; DWORD tzstate; long timezone = 0; _VALIDATE_RETURN_ERRCODE( ( tp != NULL ), EINVAL ) __tzset(); _ERRCHECK(_get_timezone(&timezone)); tp->timezone = (short)(timezone / 60); GetSystemTimeAsFileTime( &(nt_time.ft_struct) ); /* * Obtain the current DST status. Note the status is cached and only * updated once per minute, if necessary. */ if ( (t = (__time64_t)(nt_time.ft_scalar / 600000000i64)) != elapsed_minutes_cache ) { if ( (tzstate = GetTimeZoneInformation( &tzinfo )) != 0xFFFFFFFF ) { /* * Must be very careful in determining whether or not DST is * really in effect. */ if ( (tzstate == TIME_ZONE_ID_DAYLIGHT) && (tzinfo.DaylightDate.wMonth != 0) && (tzinfo.DaylightBias != 0) ) dstflag_cache = DAYLIGHT_TIME; else /* * When in doubt, assume standard time */ dstflag_cache = STANDARD_TIME; } else dstflag_cache = UNKNOWN_TIME; elapsed_minutes_cache = t; } tp->dstflag = (short)dstflag_cache; tp->millitm = (unsigned short)((nt_time.ft_scalar / 10000i64) % 1000i64); tp->time = (__time64_t)((nt_time.ft_scalar - EPOCH_BIAS) / 10000000i64); return 0; }
int gettimeofday(struct timeval * tv, struct timezone * tz) { FILETIME ft; unsigned __int64 tmpres(0); static int tzflag; if (NULL != tv) { GetSystemTimeAsFileTime(&ft); tmpres |= ft.dwHighDateTime; tmpres <<= 32; tmpres |= ft.dwLowDateTime; /*converting file time to unix epoch*/ tmpres -= DELTA_EPOCH_IN_MICROSECS; tmpres /= 10; /*convert into microseconds*/ tv->tv_sec = (long)(tmpres / 1000000UL); tv->tv_usec = (long)(tmpres % 1000000UL); } if (NULL != tz) { if (!tzflag) { _tzset(); tzflag++; } long time_zone(0); errno_t err(_get_timezone(&time_zone)); if (err == NO_ERROR) { tz->tz_minuteswest = time_zone / 60; } else { return -1; } int day_light(0); err = (_get_daylight(&day_light)); if (err == NO_ERROR) { tz->tz_dsttime = day_light; return 0; } else { return -1; } } return -1; }
/** * Get the current UNIX time * * @param tv the output timeval structure (or NULL) * @param tz the output timezone structure (or NULL) * @return 0 on success or -1 on error */ int gettimeofday(struct timeval *tv, struct timezone *tz) { // From: http://suacommunity.com/dictionary/gettimeofday-entry.php // Define a structure to receive the current Windows filetime FILETIME ft; // Initialize the present time to 0 and the timezone to UTC unsigned __int64 tmpres = 0; static int tzflag = 0; if (NULL != tv) { GetSystemTimeAsFileTime(&ft); // The GetSystemTimeAsFileTime returns the number of 100 nanosecond // intervals since Jan 1, 1601 in a structure. Copy the high bits to // the 64 bit tmpres, shift it left by 32 then or in the low 32 bits. tmpres |= ft.dwHighDateTime; tmpres <<= 32; tmpres |= ft.dwLowDateTime; // Convert to microseconds by dividing by 10 tmpres /= 10; // The Unix epoch starts on Jan 1 1970. Need to subtract the difference // in seconds from Jan 1 1601. tmpres -= DELTA_EPOCH_IN_MICROSECS; // Finally change microseconds to seconds and place in the seconds value. // The modulus picks up the microseconds. tv->tv_sec = (long)(tmpres / 1000000UL); tv->tv_usec = (long)(tmpres % 1000000UL); } if (NULL != tz) { if (!tzflag) { _tzset(); tzflag++; } // Adjust for the timezone west of Greenwich long t = 0; int d = 0; _get_timezone(&t); _get_daylight(&d); tz->tz_minuteswest = t / 60; tz->tz_dsttime = d; } return 0; }
const long TimeF::utcOffset() { long tz; #ifdef __GNUC__ tz = timezone; #else // __GNUC__ _get_timezone(&tz); #endif // __GNUC__ return tz; }
static void NeutralizeTimezone(tm& t) { static bool initialized = false; static long timezone_difference = 0; if (!initialized) { _tzset(); _get_timezone(&timezone_difference); initialized = true; } t.tm_sec -= timezone_difference; // mktime uses the current time zone }
inline static int timezone() { static bool set; if (!set) { _tzset(); set = true; } #if defined(_MSC_VER) && (_MSC_VER >= 1600) long timezone; _get_timezone(&timezone); return timezone; #else return ::timezone; #endif }
double _getLocalTZA() { if(!FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) return 0; time_t t = 0; time(&t); localtime(&t); #if _MSC_VER >= 1900 // In gcc and in Visual Studio prior to VS 2015 'timezone' is a global // variable declared in time.h. That variable was deprecated and in VS 2015 // is removed, with _get_timezone replacing it. long timezone = 0; _get_timezone(&timezone); #endif return (double)(-(timezone * 1000)); }
long DateTime::GetTimeZoneSeconds() { #ifdef MEDUSA_WINDOWS //return _timezone; long timezone; _get_timezone(&timezone); return timezone; #else return timezone; /*time_t rawtime; time ( &rawtime ); tm localDate = localtime(&rawtime); tm gmDate = gmtime( &rawtime ); return (localDate.tm_hour - gmDate->tm_hour)*3600;*/ #endif }
CTimeStamp::CTimeStamp(const FILETIME& FileTime) { Reset(); SYSTEMTIME FileSystemTime; FileTimeToSystemTime(&FileTime, &FileSystemTime); struct tm Tm; Tm.tm_sec = FileSystemTime.wSecond; Tm.tm_min = FileSystemTime.wMinute; Tm.tm_hour = FileSystemTime.wHour; Tm.tm_mday = FileSystemTime.wDay; Tm.tm_mon = FileSystemTime.wMonth - 1; // tm_mon is 0 based Tm.tm_year = FileSystemTime.wYear - 1900; // tm_year is 1900 based Tm.tm_isdst = 0; long timezone; Verify (_get_timezone(&timezone) == 0); m_TimeB.time = mktime(&Tm) - timezone; m_TimeB.millitm = 0; }
int gettimeofday(struct timeval *tv, struct timezone *tz) { FILETIME ft; UINT64 tmpres = 0; static int tzflag; if (NULL != tv) { GetSystemTimeAsFileTime(&ft); tmpres |= ft.dwHighDateTime; tmpres <<= 32; tmpres |= ft.dwLowDateTime; /*convert into microseconds*/ tmpres /= 10; /*converting file time to unix epoch*/ tmpres -= DELTA_EPOCH_IN_MICROSECS; tv->tv_sec = (long)(tmpres / 1000000UL); tv->tv_usec = (long)(tmpres % 1000000UL); } if (NULL != tz) { long ttz; int tdl; if (!tzflag) { _tzset(); tzflag++; } _get_timezone(&ttz); _get_daylight(&tdl); tz->tz_minuteswest = ttz / 60; tz->tz_dsttime = tdl; } return 0; }
int gettimeofday (struct timeval *tv, struct timezone *tz) { struct timespec ts; static int tzflag; if (tv) { clock_gettime (0, &ts); tv->tv_sec = (long) ts.tv_sec; tv->tv_usec = ts.tv_nsec / 1000; } if (tz) { if (!tzflag) { _tzset (); tzflag++; } _get_timezone (&tz->tz_minuteswest); tz->tz_minuteswest /= 60; _get_daylight (&tz->tz_dsttime); } return (0); }
String Apollo::TimeValue::toRFC2822() { // "Thu, 19 Nov 1981 08:52:00 GMT" // "Thu, 19 Nov 1981 08:52:00 +0100 time_t tSec = Sec(); struct tm tms = *(::localtime(&tSec)); int nMaxSize = 1000; Flexbuf<TCHAR> buf(nMaxSize); _tcsftime((TCHAR*) buf, nMaxSize-1, _T("%a, %d %b %Y %H:%M:%S"), &tms); String s = (TCHAR*) buf; long gmtoff = 0; if (_get_timezone(&gmtoff) == 0) { gmtoff -= tms.tm_isdst ? 3600 : 0; s.appendf(" %+03d%02d", -(gmtoff / (60 * 60)), (gmtoff % (60 * 60))); } return s; }
void SG_time__decode__local(SG_context* pCtx, SG_int64 iTime, SG_time* pTime) { // iTime contains time in milliseconds since epoch in UTC. // convert this to a SG_time expressed in localtime. time_t t1 = iTime / MILLISECONDS_PER_SECOND; #if defined(MAC) || defined(LINUX) struct tm* ptm = localtime(&t1); #endif #if defined(WINDOWS) struct tm tBuf; struct tm* ptm = &tBuf; long tzBiasSec, dstBiasSec; (void)_localtime64_s(&tBuf,&t1); (void)_get_dstbias(&dstBiasSec); (void)_get_timezone(&tzBiasSec); #endif SG_NULLARGCHECK_RETURN(pTime); pTime->year = ptm->tm_year + 1900; pTime->month = ptm->tm_mon + 1; pTime->mday = ptm->tm_mday; pTime->hour = ptm->tm_hour; pTime->min = ptm->tm_min; pTime->sec = ptm->tm_sec; pTime->msec = (SG_uint32)(iTime % MILLISECONDS_PER_SECOND); pTime->wday = ptm->tm_wday; pTime->yday = ptm->tm_yday; #if defined(MAC) || defined(LINUX) pTime->offsetUTC = (SG_int32)ptm->tm_gmtoff; #endif #if defined(WINDOWS) pTime->offsetUTC = -(SG_int32)(tzBiasSec + ((ptm->tm_isdst > 0) ? dstBiasSec : 0)); #endif }
int gettimeofday64(struct timeval64*tv, struct timezone*tz) { static int tzflag; if (tv != nullptr) { // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); SYSTEMTIME system_time; FILETIME file_time; uint64_t time; GetSystemTime(&system_time); SystemTimeToFileTime(&system_time, &file_time); time = ((uint64_t)file_time.dwLowDateTime); time += ((uint64_t)file_time.dwHighDateTime) << 32; tv->tv_sec = (long long) ((time - EPOCH) / 10000000L); tv->tv_usec = (long) (system_time.wMilliseconds * 1000); } if (tz != nullptr) { if (!tzflag) { _tzset(); tzflag++; } long timezoneseconds = 0; _get_timezone(&timezoneseconds); tz->tz_minuteswest = (int)(timezoneseconds / 60); int dsthours = 0; _get_daylight(&dsthours); tz->tz_dsttime = dsthours; } return 0; }
int gettimeofday(struct timeval *tv, struct timezone *tz) { FILETIME ft; unsigned __int64 tmpres = 0; static int tzflag = 0; if (NULL != tv) { GetSystemTimeAsFileTime(&ft); tmpres |= ft.dwHighDateTime; tmpres <<= 32; tmpres |= ft.dwLowDateTime; ULARGE_INTEGER test = { ft.dwLowDateTime, ft.dwHighDateTime }; /*converting file time to unix epoch*/ tmpres -= DELTA_EPOCH_IN_MICROSECS; tmpres /= 10; /*convert into microseconds*/ tv->tv_sec = (long)(tmpres / 1000000UL); tv->tv_usec = (long)(tmpres % 1000000UL); } if (NULL != tz) { if (!tzflag) { _tzset(); tzflag++; } long tztmp = 0; _get_timezone(&tztmp); tz->tz_minuteswest = tztmp / 60; _get_daylight(&tz->tz_dsttime); } return 0; }
int gettimeofday(struct timeval*tv, struct timezone*tz) { FILETIME ft; unsigned __int64 tmpres = 0; static int tzflag; if (tv != nullptr) { GetSystemTimeAsFileTime(&ft); tmpres |= ft.dwHighDateTime; tmpres <<= 32; tmpres |= ft.dwLowDateTime; /*converting file time to unix epoch*/ tmpres -= DELTA_EPOCH_IN_MICROSECS; tmpres /= 10; /*convert into microseconds*/ tv->tv_sec = (long)(tmpres / 1000000UL); tv->tv_usec = (long)(tmpres % 1000000UL); } if (tz != nullptr) { if (!tzflag) { _tzset(); tzflag++; } long timezoneseconds = 0; _get_timezone(&timezoneseconds); tz->tz_minuteswest = (int)(timezoneseconds / 60); int dsthours = 0; _get_daylight(&dsthours); tz->tz_dsttime = dsthours; } return 0; }
ossimLocalTm ossimLocalTm::convertToGmt()const { m_mutex.lock(); struct tm gmt = *this; #if !defined(_MSC_VER) tzset(); #else _tzset(); #endif #if ( defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) ) gmt.tm_sec -= tm_gmtoff; // Seconds east of UTC #elif (defined(WIN32)) long timezoneOffset=0; _get_timezone(&timezoneOffset); //m_timezoneOffset = timezone; // Seconds west of UTC if ( tm_isdst ) { timezoneOffset -= 3600; // Subtract an hour. } m_timezoneOffset = -timezoneOffset; #else m_timezoneOffset = timezone; // Seconds west of UTC if ( tm_isdst ) { m_timezoneOffset -= 3600; // Subtract an hour. } m_timezoneOffset = -m_timezoneOffset; #endif time_t t = mktime(&gmt); std::tm localTime = *localtime(&t); m_mutex.unlock(); ossimLocalTm result(localTime); return result; }
/* *---------------------------------------------------------------------- * * TimeUtil_SecondsSinceEpoch -- * * Converts a date into the the number of seconds since the unix epoch in UTC. * * Parameters: * date to be converted. * * Results: * Returns the numbers of seconds since the unix epoch. * * Side effects: * None. * *---------------------------------------------------------------------- */ time_t TimeUtil_SecondsSinceEpoch(TimeUtil_Date *d) // IN { struct tm tmval = {0}; /* * We can't handle negative time. */ if (d->year < 1970) { ASSERT(0); return -1; } tmval.tm_year = d->year - 1900; tmval.tm_mon = d->month - 1; tmval.tm_mday = d->day; tmval.tm_hour = d->hour; tmval.tm_min = d->minute; tmval.tm_sec = d->second; #if defined(_WIN32) /* * Workaround since Win32 doesn't have timegm(). Use the win32 * _get_timezone to adjust to UTC. */ { int utcSeconds = 0; _get_timezone(&utcSeconds); return mktime(&tmval) - utcSeconds; } #elif (defined(__linux__) || defined(__APPLE__)) && !defined(__ANDROID__) return timegm(&tmval); #else NOT_IMPLEMENTED(); return -1; #endif }
static int sceRtcConvertUtcToLocalTime(u32 tickUTCPtr,u32 tickLocalPtr) { DEBUG_LOG(SCERTC, "sceRtcConvertLocalTimeToUTC(%d, %d)", tickLocalPtr, tickUTCPtr); if (Memory::IsValidAddress(tickLocalPtr) && Memory::IsValidAddress(tickUTCPtr)) { u64 srcTick = Memory::Read_U64(tickUTCPtr); // TODO : Let the user select his timezone / daylight saving instead of taking system param ? #ifdef _WIN32 long timezone_val; _get_timezone(&timezone_val); srcTick += -timezone_val * 1000000ULL; #elif !defined(_AIX) && !defined(__sgi) && !defined(__hpux) time_t timezone = 0; tm *time = localtime(&timezone); srcTick += time->tm_gmtoff*1000000ULL; #endif Memory::Write_U64(srcTick, tickLocalPtr); } else { return 1; } return 0; }
long int gnc_timezone (const struct tm *tm) { g_return_val_if_fail (tm != NULL, 0); #ifdef HAVE_STRUCT_TM_GMTOFF /* tm_gmtoff is seconds *east* of UTC and is * already adjusted for daylight savings time. */ return -(tm->tm_gmtoff); #else { long tz_seconds; /* timezone is seconds *west* of UTC and is * not adjusted for daylight savings time. * In Spring, we spring forward, wheee! */ # if COMPILER(MSVC) _get_timezone(&tz_seconds); # else tz_seconds = timezone; # endif return (long int)(tz_seconds - (tm->tm_isdst > 0 ? 3600 : 0)); } #endif }
int gettimeofday(struct timeval * tv, struct timezone * tz) { //define a structure to receive the current Windows filetime FILETIME ft; //initialize the present time to 0 and the timezone to UTC unsigned __int64 tmpres = 0; static int tzflag = 0; if(NULL != tv) { GetSystemTimeAsFileTime(&ft); tmpres |= ft.dwHighDateTime; tmpres <<= 32; tmpres |= ft.dwLowDateTime; tmpres /= 10; tmpres -= DELTA_EPOCH_IN_MICROSECS; tv->tv_sec = (long)(tmpres / 1000000UL); tv->tv_usec = (long)(tmpres % 1000000UL); } if(NULL != tz) { long tzdiff; int tzdaylight; if(!tzflag) { _tzset(); tzflag++; } //Adjust for the timezone west of Greenwich _get_timezone(&tzdiff); _get_daylight(&tzdaylight); //tz->tz_minuteswest = _timezone / 60; //tz->tz_dsttime = _daylight; tz->tz_minuteswest = tzdiff / 60; tz->tz_dsttime = tzdaylight; } return 0; }
void O2ReportMaker:: GetReport(string &out, bool pub) { double ptime; double ptimeavg; int handle_c; int thread_c; PerformanceCounter->GetValue(ptime, ptimeavg, handle_c, thread_c); long tzoffset; _get_timezone(&tzoffset); // start time time_t starttime = PerformanceCounter->GetStartTime(); wchar_t starttime_str[32]; if (starttime != 0) { time_t t = starttime - tzoffset; struct tm tm; gmtime_s(&tm, &t); wcsftime(starttime_str, 32, L"%Y/%m/%d %H:%M:%S", &tm); } else wcscpy_s(starttime_str, 32, L"-"); // uptime uint64 uptime = PerformanceCounter->GetUptime(); wchar_t uptime_str[32]; if (uptime != 0) { swprintf_s(uptime_str, 32, L"%I64dd %02I64d:%02I64d:%02I64d", uptime/86400, (uptime%86400)/3600, (uptime%3600)/60, uptime%60); } else wcscpy_s(uptime_str, 32, L"-"); // uptime (累計) uint64 total_uptime = PerformanceCounter->GetTotalUptime() + uptime; wchar_t total_uptime_str[32]; swprintf_s(total_uptime_str, 32, L"%I64dd %02I64d:%02I64d:%02I64d", total_uptime/86400, (total_uptime%86400)/3600, (total_uptime%3600)/60, total_uptime%60); wchar_t ptime_str[32]; swprintf_s(ptime_str, 32, L"%.1f%% (%.1f%%)", ptime, ptimeavg); // 送受信バイト数 (現在のセッション) uint64 total_u = Server_P2P->GetSendByte() + Client->GetSendByte(); uint64 total_d = Server_P2P->GetRecvByte() + Client->GetRecvByte(); wchar_t traffic_u[32]; swprintf_s(traffic_u, 32, L"%.1f(%.1f)", (uptime == 0 ? 0 : (double)total_u/1024/uptime), (uptime == 0 ? 0 : (double)total_u/uptime*8)); wchar_t traffic_d[32]; swprintf_s(traffic_d, 32, L"%.1f(%.1f)", (uptime == 0 ? 0 : (double)total_d/1024/uptime), (uptime == 0 ? 0 : (double)total_d/uptime*8)); wchar_t traffic_ud[32]; swprintf_s(traffic_ud, 32, L"%.1f(%.1f)", (uptime == 0 ? 0 : (double)(total_u+total_d)/1024/uptime), (uptime == 0 ? 0 : (double)(total_u+total_d)/uptime*8)); // 送受信バイト数 (累計) uint64 accum_total_u = PerformanceCounter->GetTotalSend() + total_u; uint64 accum_total_d = PerformanceCounter->GetTotalRecv() + total_d; wchar_t a_traffic_u[32]; swprintf_s(a_traffic_u, 32, L"%.1f(%.1f)", (total_uptime == 0 ? 0 : (double)accum_total_u/1024/total_uptime), (total_uptime == 0 ? 0 : (double)accum_total_u/total_uptime*8)); wchar_t a_traffic_d[32]; swprintf_s(a_traffic_d, 32, L"%.1f(%.1f)", (total_uptime == 0 ? 0 : (double)accum_total_d/1024/total_uptime), (total_uptime == 0 ? 0 : (double)accum_total_d/total_uptime*8)); wchar_t a_traffic_ud[32]; swprintf_s(a_traffic_ud, 32, L"%.1f(%.1f)", (total_uptime == 0 ? 0 : (double)(accum_total_u+accum_total_d)/1024/total_uptime), (total_uptime == 0 ? 0 : (double)(accum_total_u+accum_total_d)/total_uptime*8)); //dat数、サイズ uint64 datnum = 0; uint64 datsize = 0; uint64 pubnum = 0; DatDB->select_report(PUBLISH_ORIGINAL_TT, datnum, datsize, pubnum); //publish率 wchar_t publishper[32]; if (datnum == 0) wcscpy_s(publishper, 32, L"0.0%"); else { swprintf(publishper, 32, L"%.1f%% (%I64u)", (double)pubnum/datnum*100.0, pubnum); } wstring tmpstr; wstring xml; xml += L"<?xml version=\"1.0\" encoding=\""; xml += _T(DEFAULT_XML_CHARSET); xml += L"\"?>"EOL; if (pub) xml += L"<?xml-stylesheet type=\"text/xsl\" href=\"/profile.xsl\"?>"; xml += L"<report>"EOL; // // 名前、コメント、閲覧履歴 // if (pub) { makeCDATA(Profile->GetNodeNameW(), tmpstr); xml += L"<name>"; xml += tmpstr; xml += L"</name>"EOL; xml += L"<category>"EOL; xml += L"<table>"EOL; // xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"ID"); hashT hash; Profile->GetID(hash); wstring hashstr; hash.to_string(hashstr); xml_AddElement(xml, L"td", L"class=\"L\"", hashstr.c_str()); xml += L"</tr>"EOL; // xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"コメント"); makeCDATA(Profile->GetComment(), tmpstr); xml += L" <pre>"; xml += tmpstr; xml += L"</pre>"EOL; xml += L"</tr>"EOL; // if (Profile->IsPublicRecentDat()) { xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"閲覧履歴"); xml += L"<pre>"; O2KeyList recent; Server_Proxy->GetRecentDatList(recent); tmpstr.erase(); for (O2KeyListIt it = recent.begin(); it != recent.end(); it++) { wchar_t timestr[TIMESTR_BUFF_SIZE]; struct tm tm; localtime_s(&tm, &it->date); wcsftime(timestr, TIMESTR_BUFF_SIZE, L"%Y/%m/%d %H:%M:%S", &tm); tmpstr += timestr; tmpstr += L" [ "; tmpstr += it->url; tmpstr += L" ] "; tmpstr += it->title; tmpstr += L"\r\n"; } makeCDATA(tmpstr, tmpstr); xml += tmpstr; xml += L"</pre>"EOL; xml += L"</tr>"EOL; } xml += L"</table>"EOL; xml += L"</category>"EOL; } // // 概要 // if (!pub || Profile->IsPublicReport()) { xml += L"<category>"EOL; xml_AddElement(xml, L"caption", NULL, L"概要"); xml += L"<table>"EOL; xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"状態"); xml_AddElement(xml, L"td", L"type=\"h\"", L"CPU(平均)"); xml_AddElement(xml, L"td", L"type=\"h\"", L"ハンドル"); xml_AddElement(xml, L"td", L"type=\"h\"", L"スレッド"); xml_AddElement(xml, L"td", L"type=\"h\"", L"総dat数"); xml_AddElement(xml, L"td", L"type=\"h\"", L"総datサイズ"); xml_AddElement(xml, L"td", L"type=\"h\"", L"publish率"); xml += L"</tr>"EOL; xml += L"<tr>"EOL; if (PerformanceCounter->IsActive()) xml_AddElement(xml, L"td", L"class=\"active\"", L"稼動中"); else xml_AddElement(xml, L"td", L"class=\"deactive\"", L"停止中"); xml_AddElement(xml, L"td", L"class=\"C\"", ptime_str); xml_AddElement(xml, L"td", L"class=\"N\"", handle_c); xml_AddElement(xml, L"td", L"class=\"N\"", thread_c); xml_AddElement(xml, L"td", L"class=\"N\"", datnum); xml_AddElement(xml, L"td", L"class=\"N\"", datsize); xml_AddElement(xml, L"td", L"class=\"R\"", publishper); xml += L"</tr>"EOL; xml += L"</table>"EOL; // xml += L"<table>"EOL; xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"起動日時"); xml_AddElement(xml, L"td", L"type=\"h\"", L"グローバルIP"); xml_AddElement(xml, L"td", (Server_P2P->IsActive() ? L"type=\"h\" class=\"active\"" : L"type=\"h\" class=\"deactive\""), L"P2P"); xml_AddElement(xml, L"td", (Server_Proxy->IsActive() ? L"type=\"h\" class=\"active\"" : L"type=\"h\" class=\"deactive\""), L"Proxy"); xml_AddElement(xml, L"td", (Server_Admin->IsActive() ? L"type=\"h\" class=\"active\"" : L"type=\"h\" class=\"deactive\""), L"Admin"); xml_AddElement(xml, L"td", L"type=\"h\"", L"Ver"); xml += L"</tr>"EOL; xml += L"<tr>"EOL; wstring ipstr; ulong2ipstr(Profile->GetIP(), ipstr); xml_AddElement(xml, L"td", L"class=\"C\"", starttime_str); xml_AddElement(xml, L"td", L"class=\"C\"", ipstr.c_str()); xml_AddElement(xml, L"td", L"class=\"C\"", Profile->GetP2PPort()); xml_AddElement(xml, L"td", L"class=\"C\"", Profile->GetProxyPort()); xml_AddElement(xml, L"td", L"class=\"C\"", Profile->GetAdminPort()); xml_AddElement(xml, L"td", L"class=\"C\"", Profile->GetUserAgentW()); xml += L"</tr>"EOL; xml += L"</table>"EOL; // xml += L"<table>"EOL; xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L""); xml_AddElement(xml, L"td", L"type=\"h\"", L"稼働時間"); xml_AddElement(xml, L"td", L"type=\"h\"", L"上り"); xml_AddElement(xml, L"td", L"type=\"h\"", L"下り"); xml_AddElement(xml, L"td", L"type=\"h\"", L"合計"); xml_AddElement(xml, L"td", L"type=\"h\"", L""); xml_AddElement(xml, L"td", L"type=\"h\"", L"上りKB/s(bps)"); xml_AddElement(xml, L"td", L"type=\"h\"", L"下りKB/s(bps)"); xml_AddElement(xml, L"td", L"type=\"h\"", L"合計KB/s(bps)"); xml += L"</tr>"EOL; xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"今回"); xml_AddElement(xml, L"td", L"class=\"C\"", uptime_str); xml_AddElement(xml, L"td", L"class=\"N\"", total_u); xml_AddElement(xml, L"td", L"class=\"N\"", total_d); xml_AddElement(xml, L"td", L"class=\"N\"", total_u+total_d); xml_AddElement(xml, L"td", L"", L""); xml_AddElement(xml, L"td", L"class=\"R\"", traffic_u); xml_AddElement(xml, L"td", L"class=\"R\"", traffic_d); xml_AddElement(xml, L"td", L"class=\"R\"", traffic_ud); xml += L"</tr>"EOL; xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"累計"); xml_AddElement(xml, L"td", L"class=\"C\"", total_uptime_str); xml_AddElement(xml, L"td", L"class=\"N\"", accum_total_u); xml_AddElement(xml, L"td", L"class=\"N\"", accum_total_d); xml_AddElement(xml, L"td", L"class=\"N\"", accum_total_u+accum_total_d); xml_AddElement(xml, L"td", L"", L""); xml_AddElement(xml, L"td", L"class=\"R\"", a_traffic_u); xml_AddElement(xml, L"td", L"class=\"R\"", a_traffic_d); xml_AddElement(xml, L"td", L"class=\"R\"", a_traffic_ud); xml += L"</tr>"EOL; xml += L"</table>"EOL; xml += L"</category>"EOL; // // DB // xml += L"<category>"EOL; xml_AddElement(xml, L"caption", NULL, L"DB"); xml += L"<table>"EOL; xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L""); xml_AddElement(xml, L"td", L"type=\"h\"", L"Node"); xml_AddElement(xml, L"td", L"type=\"h\"", L"Friend"); xml_AddElement(xml, L"td", L"type=\"h\"", L"Key"); xml_AddElement(xml, L"td", L"type=\"h\"", L"SakuKey"); xml_AddElement(xml, L"td", L"type=\"h\"", L"Query"); xml_AddElement(xml, L"td", L"type=\"h\"", L"Saku"); xml_AddElement(xml, L"td", L"type=\"h\"", L"IM"); xml_AddElement(xml, L"td", L"type=\"h\"", L"Broadcast"); xml_AddElement(xml, L"td", L"type=\"h\"", L"BCQueue"); xml_AddElement(xml, L"td", L"type=\"h\"", L"Logger"); xml_AddElement(xml, L"td", L"type=\"h\"", L"IPFilter"); xml_AddElement(xml, L"td", L"type=\"h\"", L"DatRequest"); xml += L"</tr>"EOL; xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"保持数"); xml_AddElement(xml, L"td", L"class=\"N\"", NodeDB->count()); xml_AddElement(xml, L"td", L"class=\"N\"", FriendDB->Count()); xml_AddElement(xml, L"td", L"class=\"N\"", KeyDB->Count()); xml_AddElement(xml, L"td", L"class=\"N\"", SakuKeyDB->Count()); xml_AddElement(xml, L"td", L"class=\"N\"", QueryDB->Count()); xml_AddElement(xml, L"td", L"class=\"N\"", SakuDB->Count()); xml_AddElement(xml, L"td", L"class=\"N\"", IMDB->Count()); xml_AddElement(xml, L"td", L"class=\"N\"", BroadcastDB->Count()); xml_AddElement(xml, L"td", L"class=\"N\"", Job_Broadcast->GetQueueCount()); xml_AddElement(xml, L"td", L"class=\"N\"", Logger->Count()); xml_AddElement(xml, L"td", L"class=\"N\"", IPFilter_P2P->Count()+IPFilter_Proxy->Count()+IPFilter_Admin->Count()); xml_AddElement(xml, L"td", L"class=\"N\"", Job_QueryDat->GetRequestQueueCount()); xml += L"</tr>"EOL; xml += L"</table>"EOL; xml += L"</category>"EOL; // // Server // xml += L"<category>"EOL; xml_AddElement(xml, L"caption", NULL, L"Server"); xml += L"<table>"EOL; xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L""); xml_AddElement(xml, L"td", L"type=\"h\"", L"dat"); xml_AddElement(xml, L"td", L"type=\"h\"", L"collection"); xml_AddElement(xml, L"td", L"type=\"h\"", L"im"); xml_AddElement(xml, L"td", L"type=\"h\"", L"broadcast"); xml_AddElement(xml, L"td", L"type=\"h\"", L"profile"); xml_AddElement(xml, L"td", L"type=\"h\"", L"ping"); xml_AddElement(xml, L"td", L"type=\"h\"", L"store"); xml_AddElement(xml, L"td", L"type=\"h\"", L"findnode"); xml_AddElement(xml, L"td", L"type=\"h\"", L"findvalue"); xml_AddElement(xml, L"td", L"type=\"h\"", L"ERROR"); xml_AddElement(xml, L"td", L"type=\"h\"", L"?"); xml_AddElement(xml, L"td", L"type=\"h\"", L"計"); xml_AddElement(xml, L"td", L"type=\"h\"", L""); xml_AddElement(xml, L"td", L"type=\"h\"", L"Proxy"); xml_AddElement(xml, L"td", L"type=\"h\"", L"Admin"); xml += L"</tr>"EOL; xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"接続回数"); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSessionCountByPath("dat")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSessionCountByPath("collection")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSessionCountByPath("im")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSessionCountByPath("broadcast")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSessionCountByPath("profile")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSessionCountByPath("ping")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSessionCountByPath("store")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSessionCountByPath("findnode")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSessionCountByPath("findvalue")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSessionCountByPath("ERROR")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSessionCountByPath("?")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSessionCountByPath(NULL)); xml_AddElement(xml, L"td", L"type=\"h\"", L""); xml_AddElement(xml, L"td", L"class=\"N\"", Server_Proxy->GetTotalSessionCount()); xml_AddElement(xml, L"td", L"class=\"N\"", Server_Admin->GetTotalSessionCount()); xml += L"</tr>"EOL; xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"up"); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("dat")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("collection")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("im")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("broadcast")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("profile")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("ping")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("store")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("findnode")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("findvalue")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("ERROR")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("?")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath(NULL)); xml_AddElement(xml, L"td", L"type=\"h\"", L""); xml_AddElement(xml, L"td", L"class=\"N\"", Server_Proxy->GetSendByte()); xml_AddElement(xml, L"td", L"class=\"N\"", Server_Admin->GetSendByte()); xml += L"</tr>"EOL; xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"down"); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetRecvByteByPath("dat")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetRecvByteByPath("collection")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetRecvByteByPath("im")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetRecvByteByPath("broadcast")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetRecvByteByPath("profile")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetRecvByteByPath("ping")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetRecvByteByPath("store")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetRecvByteByPath("findnode")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetRecvByteByPath("findvalue")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetRecvByteByPath("ERROR")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetRecvByteByPath("?")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetRecvByteByPath(NULL)); xml_AddElement(xml, L"td", L"type=\"h\"", L""); xml_AddElement(xml, L"td", L"class=\"N\"", Server_Proxy->GetRecvByte()); xml_AddElement(xml, L"td", L"class=\"N\"", Server_Admin->GetRecvByte()); xml += L"</tr>"EOL; xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"up + down"); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("dat") + Server_P2P->GetRecvByteByPath("dat")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("collection") + Server_P2P->GetRecvByteByPath("collection")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("im") + Server_P2P->GetRecvByteByPath("im")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("broadcast") + Server_P2P->GetRecvByteByPath("broadcast")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("profile") + Server_P2P->GetRecvByteByPath("profile")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("ping") + Server_P2P->GetRecvByteByPath("ping")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("store") + Server_P2P->GetRecvByteByPath("store")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("findnode") + Server_P2P->GetRecvByteByPath("findnode")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("findvalue") + Server_P2P->GetRecvByteByPath("findvalue")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("ERROR") + Server_P2P->GetRecvByteByPath("ERROR")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath("UNKNOWN") + Server_P2P->GetRecvByteByPath("UNKNOWN")); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSendByteByPath(NULL) + Server_P2P->GetRecvByteByPath(NULL)); xml_AddElement(xml, L"td", L"type=\"h\"", L""); xml_AddElement(xml, L"td", L"class=\"N\"", Server_Proxy->GetSendByte() + Server_Proxy->GetRecvByte()); xml_AddElement(xml, L"td", L"class=\"N\"", Server_Admin->GetRecvByte() + Server_Admin->GetRecvByte()); xml += L"</tr>"EOL; xml += L"</table>"EOL; xml += L"<table>"EOL; xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"同時接続数ピーク"); xml_AddElement(xml, L"td", L"class=\"N\"", Server_P2P->GetSessionPeak()); xml += L"</tr>"EOL; xml += L"</table>"EOL; xml += L"</category>"EOL; // // Agent // xml += L"<category>"EOL; xml_AddElement(xml, L"caption", NULL, L"Agent"); xml += L"<table>"EOL; // xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L""); size_t i; for (i = 0; i < Jobs.size(); i++) { if (Jobs[i]->IsActive()) xml_AddElement(xml, L"td", L"type=\"h\" class=\"active\"", Jobs[i]->GetName()); else xml_AddElement(xml, L"td", L"type=\"h\" class=\"deactive\"", Jobs[i]->GetName()); } xml += L"</tr>"EOL; // xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"実行"); for (i = 0; i < Jobs.size(); i++) { if (!Jobs[i]->IsActive()) xml_AddElement(xml, L"td", L"class=\"C\"", L"-"); else if (Jobs[i]->IsWorking()) xml_AddElement(xml, L"td", L"class=\"active\"", L"実行中"); else xml_AddElement(xml, L"td", L"class=\"wait\"", L"待機"); } xml += L"</tr>"EOL; // xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"間隔(s)"); for (i = 0; i < Jobs.size(); i++) { if (!Jobs[i]->IsActive()) xml_AddElement(xml, L"td", L"class=\"C\"", L"-"); else xml_AddElement(xml, L"td", L"class=\"C\"", Jobs[i]->GetInterval()); } xml += L"</tr>"EOL; // xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"起動まで"); for (i = 0; i < Jobs.size(); i++) { if (!Jobs[i]->IsActive() || Jobs[i]->IsWorking()) xml_AddElement(xml, L"td", L"class=\"C\"", L"-"); else xml_AddElement(xml, L"td", L"class=\"C\"", Jobs[i]->GetRemain()); } xml += L"</tr>"EOL; // xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"接続回数"); for (i = 0; i < Jobs.size(); i++) { if (!Jobs[i]->IsActive()) xml_AddElement(xml, L"td", L"class=\"R\"", L"-"); else xml_AddElement(xml, L"td", L"class=\"N\"", Jobs[i]->GetTotalSessionCount()); } xml += L"</tr>"EOL; // xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"up"); for (i = 0; i < Jobs.size(); i++) { if (!Jobs[i]->IsActive()) xml_AddElement(xml, L"td", L"class=\"R\"", L"-"); else xml_AddElement(xml, L"td", L"class=\"N\"", Jobs[i]->GetSendByte()); } xml += L"</tr>"EOL; // xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"down"); for (i = 0; i < Jobs.size(); i++) { if (!Jobs[i]->IsActive()) xml_AddElement(xml, L"td", L"class=\"R\"", L"-"); else xml_AddElement(xml, L"td", L"class=\"N\"", Jobs[i]->GetRecvByte()); } xml += L"</tr>"EOL; // xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"up+down"); for (i = 0; i < Jobs.size(); i++) { if (!Jobs[i]->IsActive()) xml_AddElement(xml, L"td", L"class=\"R\"", L"-"); else xml_AddElement(xml, L"td", L"class=\"N\"", Jobs[i]->GetSendByte()+Jobs[i]->GetRecvByte()); } xml += L"</tr>"EOL; xml += L"</table>"EOL; xml += L"<table>"EOL; xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L"同時接続数ピーク"); xml_AddElement(xml, L"td", L"class=\"N\"", Client->GetSessionPeak()); xml += L"</tr>"EOL; xml += L"</table>"EOL; xml += L"</category>"EOL; if (O2DEBUG && TRACE_CONNECTIONS && !pub) { // // Connections // xml += L"<category>"EOL; xml_AddElement(xml, L"caption", NULL, L"Connections"); xml += L"<table>"EOL; xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"type=\"h\"", L""); xml_AddElement(xml, L"td", L"type=\"h\"", L"IP"); xml_AddElement(xml, L"td", L"type=\"h\"", L"Port"); xml_AddElement(xml, L"td", L"type=\"h\"", L"接続時間(s)"); xml_AddElement(xml, L"td", L"type=\"h\"", L"recv"); xml_AddElement(xml, L"td", L"type=\"h\"", L"send"); xml_AddElement(xml, L"td", L"type=\"h\"", L"rbuff"); xml += L"</tr>"EOL; O2SocketSessionPList lst; time_t now = time(NULL); Server_P2P->GetSessionList(lst); for (O2SocketSessionPListIt it = lst.begin(); it != lst.end(); it++) { O2SocketSession *ss = *it; wstring e_ip; ip2e(ss->ip, e_ip); xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"class=\"C\"", L"Server"); xml_AddElement(xml, L"td", L"class=\"C\"", e_ip.c_str()); xml_AddElement(xml, L"td", L"class=\"C\"", ss->port); xml_AddElement(xml, L"td", L"class=\"R\"", now - ss->connect_t); xml_AddElement(xml, L"td", L"class=\"N\"", ss->rbuffoffset); xml_AddElement(xml, L"td", L"class=\"N\"", ss->sbuffoffset); wstring rbuff; ascii2unicode(ss->rbuff, rbuff); xml_AddElement(xml, L"td", L"class=\"L\"", rbuff.c_str(), true); xml += L"</tr>"EOL; delete *it; } lst.clear(); Client->GetSessionList(lst); for (O2SocketSessionPListIt it = lst.begin(); it != lst.end(); it++) { O2SocketSession *ss = *it; wstring e_ip; ip2e(ss->ip, e_ip); xml += L"<tr>"EOL; xml_AddElement(xml, L"td", L"class=\"C\"", L"Agent"); xml_AddElement(xml, L"td", L"class=\"C\"", e_ip.c_str()); xml_AddElement(xml, L"td", L"class=\"C\"", ss->port); xml_AddElement(xml, L"td", L"class=\"R\"", now - ss->connect_t); xml_AddElement(xml, L"td", L"class=\"N\"", ss->rbuffoffset); xml_AddElement(xml, L"td", L"class=\"N\"", ss->sbuffoffset); wstring rbuff; ascii2unicode(ss->rbuff, rbuff); xml_AddElement(xml, L"td", L"class=\"L\"", rbuff.c_str(), true); xml += L"</tr>"EOL; delete *it; } xml += L"</table>"EOL; xml += L"</category>"EOL; } } xml += L"</report>"EOL; FromUnicode(_T(DEFAULT_XML_CHARSET), xml, out); }
void rfc822::mkdate_cst(time_t t, char *buf, size_t size) { struct tm *p; int offset = 0; #ifdef WIN32 # if _MSC_VER >= 1500 struct tm tm_buf; long s; p = &tm_buf; if (localtime_s(p, &t) != 0) p = NULL; # else p = localtime(&t); # endif #else struct tm tm_buf; p = localtime_r(&t, &tm_buf); #endif buf[0] = 0; if (p == NULL) return; #if USE_TIME_ALTZONE offset = -_timezone; if (p->tm_isdst > 0) offset = -altzone; if (offset % 60) { offset = 0; #ifdef WIN32 # if _MSC_VER >= 1500 p = &tm_buf; if (gmtime_s(p, &t) != 0) p = NULL; # else p = gmtime(&t); # endif #else p = gmtime_r(&t, &tm_buf); #endif } offset /= 60; #else #if USE_TIME_DAYLIGHT #ifdef WIN32 # if _MSC_VER >= 1500 if ( _get_timezone(&s) != 0) s = 0; offset =- s; # else offset = - _timezone; # endif #elif !defined(ACL_FREEBSD) // XXX -zsx offset = - timezone; #endif if (p == NULL) return; if (p->tm_isdst > 0) offset += 60 * 60; if (offset % 60) { offset = 0; #ifdef WIN32 # if _MSC_VER >= 1500 p = &tm_buf; if (gmtime_s(p, &t) != 0) p = NULL; # else p = gmtime(&t); # endif #else p = gmtime_r(&t, &tm_buf); #endif } offset /= 60; #else #if USE_TIME_GMTOFF offset = p->tm_gmtoff; if (offset % 60) { offset = 0; #ifdef WIN32 # if _MSC_VER >= 1500 p = &tm_buf; if (gmtime_s(p, &t) != 0) p = NULL; # else p = gmtime(&t); # endif #else p = gmtime_r(&t, &tm_buf); #endif } offset /= 60; #else #ifdef WIN32 # if _MSC_VER >= 1500 p = &tm_buf; if (gmtime_s(p, &t) != 0) p = NULL; # else p = gmtime(&t); # endif #else p = gmtime_r(&t, &tm_buf); #endif offset = 0; #endif #endif #endif offset = (offset % 60) + offset / 60 * 100; #if defined(WIN32) && _MSC_VER >= 1500 _snprintf_s(buf, size, size, "%s, %02d %s %04d %02d:%02d:%02d %+05d (CST)", wdays[p->tm_wday], p->tm_mday, months[p->tm_mon], p->tm_year + 1900, p->tm_hour, p->tm_min, p->tm_sec, offset); #else snprintf(buf, size, "%s, %02d %s %04d %02d:%02d:%02d %+05d (CST)", wdays[p->tm_wday], p->tm_mday, months[p->tm_mon], p->tm_year + 1900, p->tm_hour, p->tm_min, p->tm_sec, offset); #endif }
static __time64_t __cdecl _make__time64_t ( struct tm *tb, int ultflag ) { __time64_t tmptm1, tmptm2, tmptm3; struct tm tbtemp; long dstbias = 0; long timezone = 0; _VALIDATE_RETURN( ( tb != NULL ), EINVAL, ( ( __time64_t )( -1 ) ) ) /* * First, make sure tm_year is reasonably close to being in range. */ if ( ((tmptm1 = tb->tm_year) < _BASE_YEAR - 1) || (tmptm1 > _MAX_YEAR64 + 1) ) goto err_mktime; /* * Adjust month value so it is in the range 0 - 11. This is because * we don't know how many days are in months 12, 13, 14, etc. */ if ( (tb->tm_mon < 0) || (tb->tm_mon > 11) ) { tmptm1 += (tb->tm_mon / 12); if ( (tb->tm_mon %= 12) < 0 ) { tb->tm_mon += 12; tmptm1--; } /* * Make sure year count is still in range. */ if ( (tmptm1 < _BASE_YEAR - 1) || (tmptm1 > _MAX_YEAR64 + 1) ) goto err_mktime; } /***** HERE: tmptm1 holds number of elapsed years *****/ /* * Calculate days elapsed minus one, in the given year, to the given * month. Check for leap year and adjust if necessary. */ tmptm2 = _days[tb->tm_mon]; if ( _IS_LEAP_YEAR(tmptm1) && (tb->tm_mon > 1) ) tmptm2++; /* * Calculate elapsed days since base date (midnight, 1/1/70, UTC) * * * 365 days for each elapsed year since 1970, plus one more day for * each elapsed leap year. no danger of overflow because of the range * check (above) on tmptm1. */ tmptm3 = (tmptm1 - _BASE_YEAR) * 365 + _ELAPSED_LEAP_YEARS(tmptm1); /* * elapsed days to current month (still no possible overflow) */ tmptm3 += tmptm2; /* * elapsed days to current date. */ tmptm1 = tmptm3 + (tmptm2 = (__time64_t)(tb->tm_mday)); /***** HERE: tmptm1 holds number of elapsed days *****/ /* * Calculate elapsed hours since base date */ tmptm2 = tmptm1 * 24; tmptm1 = tmptm2 + (tmptm3 = (__time64_t)tb->tm_hour); /***** HERE: tmptm1 holds number of elapsed hours *****/ /* * Calculate elapsed minutes since base date */ tmptm2 = tmptm1 * 60; tmptm1 = tmptm2 + (tmptm3 = (__time64_t)tb->tm_min); /***** HERE: tmptm1 holds number of elapsed minutes *****/ /* * Calculate elapsed seconds since base date */ tmptm2 = tmptm1 * 60; tmptm1 = tmptm2 + (tmptm3 = (__time64_t)tb->tm_sec); /***** HERE: tmptm1 holds number of elapsed seconds *****/ if ( ultflag ) { /* * Adjust for timezone. No need to check for overflow since * localtime() will check its arg value */ __tzset(); _ERRCHECK(_get_dstbias(&dstbias)); _ERRCHECK(_get_timezone(&timezone)); tmptm1 += timezone; /* * Convert this second count back into a time block structure. * If localtime returns NULL, return an error. */ if ( _localtime64_s(&tbtemp, &tmptm1) != 0 ) goto err_mktime; /* * Now must compensate for DST. The ANSI rules are to use the * passed-in tm_isdst flag if it is non-negative. Otherwise, * compute if DST applies. Recall that tbtemp has the time without * DST compensation, but has set tm_isdst correctly. */ if ( (tb->tm_isdst > 0) || ((tb->tm_isdst < 0) && (tbtemp.tm_isdst > 0)) ) { tmptm1 += dstbias; if ( _localtime64_s(&tbtemp, &tmptm1) != 0 ) goto err_mktime; } } else { if ( _gmtime64_s(&tbtemp, &tmptm1) != 0) goto err_mktime; } /***** HERE: tmptm1 holds number of elapsed seconds, adjusted *****/ /***** for local time if requested *****/ *tb = tbtemp; return tmptm1; err_mktime: /* * All errors come to here */ errno = EINVAL; return (__time64_t)(-1); }
// returns the time zone in the C sense, i.e. the difference UTC - local // (in seconds) int wxGetTimeZone() { #ifdef WX_GMTOFF_IN_TM // set to true when the timezone is set static bool s_timezoneSet = false; static long gmtoffset = LONG_MAX; // invalid timezone // ensure that the timezone variable is set by calling wxLocaltime_r if ( !s_timezoneSet ) { // just call wxLocaltime_r() instead of figuring out whether this // system supports tzset(), _tzset() or something else time_t t = time(NULL); struct tm tm; wxLocaltime_r(&t, &tm); s_timezoneSet = true; // note that GMT offset is the opposite of time zone and so to return // consistent results in both WX_GMTOFF_IN_TM and !WX_GMTOFF_IN_TM // cases we have to negate it gmtoffset = -tm.tm_gmtoff; // this function is supposed to return the same value whether DST is // enabled or not, so we need to use an additional offset if DST is on // as tm_gmtoff already does include it if ( tm.tm_isdst ) gmtoffset += 3600; } return (int)gmtoffset; #elif defined(__DJGPP__) || defined(__WINE__) struct timeb tb; ftime(&tb); return tb.timezone*60; #elif defined(__VISUALC__) // We must initialize the time zone information before using it (this will // be done only once internally). _tzset(); // Starting with VC++ 8 timezone variable is deprecated and is not even // available in some standard library version so use the new function for // accessing it instead. #if wxCHECK_VISUALC_VERSION(8) long t; _get_timezone(&t); return t; #else // VC++ < 8 return timezone; #endif #else // Use some kind of time zone variable. // In any case we must initialize the time zone before using it. tzset(); #if defined(WX_TIMEZONE) // If WX_TIMEZONE was defined by configure, use it. return WX_TIMEZONE; #elif defined(__BORLANDC__) || defined(__MINGW32__) return _timezone; #else // unknown platform -- assume it has timezone return timezone; #endif // different time zone variables #endif // different ways to determine time zone }
void O2IMDB:: MakeIMElement(O2IMessage &im, O2IMSelectCondition &cond, wstring &xml) { wchar_t tmp[16]; wstring tmpstr; xml += L"<message>" EOL; if (cond.mask & IM_XMLELM_IP) { ip2e(im.ip, tmpstr); xml += L" <ip>"; xml += tmpstr; xml += L"</ip>" EOL; } if (cond.mask & IM_XMLELM_PORT) { swprintf_s(tmp, 16, L"%d", im.port); xml += L" <port>"; xml += tmp; xml += L"</port>" EOL; } if (cond.mask & IM_XMLELM_ID) { im.id.to_string(tmpstr); xml += L" <id>"; xml += tmpstr; xml += L"</id>" EOL; } if (cond.mask & IM_XMLELM_PUBKEY) { im.pubkey.to_string(tmpstr); xml += L" <pubkey>"; xml += tmpstr; xml += L"</pubkey>" EOL; } if (cond.mask & IM_XMLELM_NAME) { xml += L" <name>"; xml += im.name; xml += L"</name>" EOL; } if (cond.mask & IM_XMLELM_DATE) { if (im.date == 0) xml += L" <date></date>" EOL; else { long tzoffset; #ifdef _WIN32 /** windows */ _get_timezone(&tzoffset); #else /** unix */ tzoffset = getGmtOffset(); #endif if (!cond.timeformat.empty()) { time_t t = im.date - tzoffset; wchar_t timestr[TIMESTR_BUFF_SIZE]; struct tm tm; #ifdef _WIN32 /** windows */ gmtime_s(&tm, &t); #else /** unix */ gmtime_r(&t, &tm); #endif wcsftime(timestr, TIMESTR_BUFF_SIZE, cond.timeformat.c_str(), &tm); xml += L" <date>"; xml += timestr; xml += L"</date>" EOL; } else { time_t2datetime(im.date, - tzoffset, tmpstr); xml += L" <date>"; xml += tmpstr; xml += L"</date>" EOL; } } } if (cond.mask & IM_XMLELM_MSG) { makeCDATA(im.msg, tmpstr); xml += L" <msg>"; xml += tmpstr; xml += L"</msg>" EOL; } if (cond.mask & IM_XMLELM_KEY) { im.key.to_string(tmpstr); xml += L" <key>"; xml += tmpstr; xml += L"</key>" EOL; } if (cond.mask & IM_XMLELM_MINE) { xml += L" <mine>"; xml += im.mine ? L"1" : L"0"; xml += L"</mine>" EOL; } xml += L"</message>" EOL; }
void date_toString( UThread* ut, const UCell* cell, UBuffer* str, int depth ) { char tmp[ 30 ]; struct tm st; time_t tt; long timeZone; int hour; char* cp = tmp; double sec = ur_double(cell); //double frac; (void) ut; (void) depth; tt = (time_t) sec; #if defined(_WIN32) #if _MSC_VER >= 1400 localtime_s( &st, &tt ); #else st = *localtime( &tt ); #endif #else localtime_r( &tt, &st ); //gmtime_r( &tt, &st ); #endif #if defined(_WIN32) #if _MSC_VER >= 1400 _get_timezone( &timeZone ); timeZone = -timeZone; #else timeZone = -timezone; #endif #elif defined(__sun__) { struct tm gt; int days, hours; gmtime_r( &tt, > ); days = st.tm_yday - gt.tm_yday; hours = (days < -1 ? 24 : days > 1 ? -24 : days * 24) + st.tm_hour - gt.tm_hour; timeZone = (hours * 60 + st.tm_min - gt.tm_min) * 60; } #else timeZone = st.tm_gmtoff; #endif //printf( "KR gmtoff %ld %ld\n", st.tm_gmtoff, timezone ); { int year = st.tm_year + 1900; cp = append02d( cp, year / 100 ); cp = append02d( cp, year % 100 ); } *cp++ = '-'; cp = append02d( cp, st.tm_mon + 1 ); *cp++ = '-'; cp = append02d( cp, st.tm_mday ); if( st.tm_hour || st.tm_min || st.tm_sec ) { *cp++ = 'T'; cp = append02d( cp, st.tm_hour ); *cp++ = ':'; cp = append02d( cp, st.tm_min ); if( st.tm_sec ) { *cp++ = ':'; cp = append02d( cp, st.tm_sec ); /* if( st.tm_sec < 10 ) *cp++ = '0'; frac = sec - floor(sec); if( frac ) appendDecimal( out, frac ); */ } } if( timeZone ) { if( timeZone < 0 ) { *cp++ = '-'; timeZone = -timeZone; } else { *cp++ = '+'; } hour = timeZone / 3600; cp = append02d( cp, hour ); *cp++ = ':'; cp = append02d( cp, (timeZone / 60) - (hour * 60) ); } else { *cp++ = 'Z'; } *cp = '\0'; ur_strAppendCStr( str, tmp ); }