summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_utils.h11
-rw-r--r--libs/win32/mir_core.libbin500680 -> 500916 bytes
-rw-r--r--libs/win64/mir_core.libbin506034 -> 506256 bytes
-rw-r--r--protocols/JabberG/src/jabber_util.cpp55
-rw-r--r--protocols/JabberG/src/stdafx.h1
-rw-r--r--protocols/SkypeWeb/src/skype_contacts.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h2
-rw-r--r--protocols/SkypeWeb/src/skype_utils.cpp60
-rw-r--r--src/mir_core/src/mir_core.def1
-rw-r--r--src/mir_core/src/mir_core64.def1
-rw-r--r--src/mir_core/src/utils.cpp51
11 files changed, 67 insertions, 117 deletions
diff --git a/include/m_utils.h b/include/m_utils.h
index d7dc704085..3ce8b68de3 100644
--- a/include/m_utils.h
+++ b/include/m_utils.h
@@ -435,6 +435,17 @@ EXTERN_C MIR_CORE_DLL(void) Utils_GetRandom(void *pszDest, size_t cbLen);
EXTERN_C MIR_CORE_DLL(bool) Utils_IsRtl(const wchar_t *pszwText);
/////////////////////////////////////////////////////////////////////////////////////////
+// Converts a timestamp in the ISO format to time_t
+
+EXTERN_C MIR_CORE_DLL(time_t) Utils_IsoToUnixTime(const char *pszIsoTimestamp);
+
+#ifdef _XSTRING_
+__forceinline time_t Utils_IsoToUnixTime(const std::string &str) {
+ return Utils_IsoToUnixTime(str.c_str());
+}
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////////
// UUID generator
MIR_CORE_DLL(CMStringA) Utils_GenerateUUID();
diff --git a/libs/win32/mir_core.lib b/libs/win32/mir_core.lib
index 5653157ab6..8ef33d6630 100644
--- a/libs/win32/mir_core.lib
+++ b/libs/win32/mir_core.lib
Binary files differ
diff --git a/libs/win64/mir_core.lib b/libs/win64/mir_core.lib
index 3cd02bfa08..0273f82db9 100644
--- a/libs/win64/mir_core.lib
+++ b/libs/win64/mir_core.lib
Binary files differ
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index 7d8e7bd322..b486219753 100644
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -390,57 +390,6 @@ void CJabberProto::SendVisibleInvisiblePresence(bool invisible)
}
}
-time_t JabberIsoToUnixTime(const char *stamp)
-{
- wchar_t date[9];
- int i, y;
-
- if (stamp == nullptr)
- return 0;
-
- auto *p = stamp;
-
- // Get the date part
- for (i = 0; *p != '\0' && i < 8 && isdigit(*p); p++, i++)
- date[i] = *p;
-
- // Parse year
- if (i == 6) {
- // 2-digit year (1970-2069)
- y = (date[0] - '0') * 10 + (date[1] - '0');
- if (y < 70) y += 100;
- }
- else if (i == 8) {
- // 4-digit year
- y = (date[0] - '0') * 1000 + (date[1] - '0') * 100 + (date[2] - '0') * 10 + date[3] - '0';
- y -= 1900;
- }
- else return 0;
-
- struct tm timestamp;
- timestamp.tm_year = y;
-
- // Parse month
- timestamp.tm_mon = (date[i - 4] - '0') * 10 + date[i - 3] - '0' - 1;
-
- // Parse date
- timestamp.tm_mday = (date[i - 2] - '0') * 10 + date[i - 1] - '0';
-
- // Skip any date/time delimiter
- for (; *p != '\0' && !isdigit(*p); p++);
-
- // Parse time
- if (sscanf(p, "%d:%d:%d", &timestamp.tm_hour, &timestamp.tm_min, &timestamp.tm_sec) != 3)
- return (time_t)0;
-
- timestamp.tm_isdst = 0; // DST is already present in _timezone below
- time_t t = mktime(&timestamp);
-
- _tzset();
- t -= _timezone;
- return (t >= 0) ? t : 0;
-}
-
void CJabberProto::SendPresenceTo(int status, const char *to, const TiXmlElement *extra, const char *msg)
{
if (!m_bJabberOnline) return;
@@ -826,13 +775,13 @@ const TiXmlElement* JabberProcessDelay(const TiXmlElement *node, time_t &msgTime
else if (!(szStamp[sj++] = szStamp[si++]))
break;
};
- msgTime = JabberIsoToUnixTime(szStamp);
+ msgTime = Utils_IsoToUnixTime(szStamp);
return (msgTime != 0) ? n : nullptr;
}
if (auto *n = XmlGetChildByTag(node, "x", "xmlns", JABBER_FEAT_DELAY))
if (auto *pszTimeStamp = XmlGetAttr(n, "stamp")) {
- msgTime = JabberIsoToUnixTime(pszTimeStamp);
+ msgTime = Utils_IsoToUnixTime(pszTimeStamp);
return (msgTime != 0) ? n : nullptr;
}
diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h
index b15f3962f8..ae3958750e 100644
--- a/protocols/JabberG/src/stdafx.h
+++ b/protocols/JabberG/src/stdafx.h
@@ -682,7 +682,6 @@ char* JabberPrepareJid(const char *jid);
char* JabberSha1(const char *str, JabberShaStrBuf buf);
void JabberHttpUrlDecode(wchar_t *str);
int JabberCombineStatus(int status1, int status2);
-time_t JabberIsoToUnixTime(const char *stamp);
char* JabberStripJid(const char *jid, char *dest, size_t destLen);
int JabberGetPacketID(const char*);
char* JabberId2string(int id);
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp
index c70a432005..034d5451ce 100644
--- a/protocols/SkypeWeb/src/skype_contacts.cpp
+++ b/protocols/SkypeWeb/src/skype_contacts.cpp
@@ -113,7 +113,7 @@ void CSkypeProto::LoadContactsAuth(MHttpResponse *response, AsyncHttpRequest*)
time_t eventTime = 0;
for (auto &it : item["invites"])
- eventTime = IsoToUnixTime(it["time"].as_string());
+ eventTime = Utils_IsoToUnixTime(it["time"].as_string().c_str());
std::string displayName = item["displayname"].as_string();
const char *szNick = (displayName.empty()) ? nullptr : displayName.c_str();
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index d6528c20d4..450b909a44 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -329,8 +329,6 @@ private:
CMStringW RemoveHtml(const CMStringW &src, bool bCheckSS = false);
- static time_t IsoToUnixTime(const std::string &stamp);
-
static int SkypeToMirandaStatus(const char *status);
static const char *MirandaToSkypeStatus(int status);
diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp
index 87a0863a4d..c0a2e568f9 100644
--- a/protocols/SkypeWeb/src/skype_utils.cpp
+++ b/protocols/SkypeWeb/src/skype_utils.cpp
@@ -19,66 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma warning(disable:4566)
-time_t CSkypeProto::IsoToUnixTime(const std::string &stamp)
-{
- char date[9];
- int i, y;
-
- if (stamp.empty())
- return 0;
-
- char *p = NEWSTR_ALLOCA(stamp.c_str());
-
- // skip '-' chars
- int si = 0, sj = 0;
- while (true) {
- if (p[si] == '-')
- si++;
- else if (!(p[sj++] = p[si++]))
- break;
- }
-
- // Get the date part
- for (i = 0; *p != '\0' && i < 8 && isdigit(*p); p++, i++)
- date[i] = *p;
-
- // Parse year
- if (i == 6) {
- // 2-digit year (1970-2069)
- y = (date[0] - '0') * 10 + (date[1] - '0');
- if (y < 70) y += 100;
- }
- else if (i == 8) {
- // 4-digit year
- y = (date[0] - '0') * 1000 + (date[1] - '0') * 100 + (date[2] - '0') * 10 + date[3] - '0';
- y -= 1900;
- }
- else return 0;
-
- struct tm timestamp;
- timestamp.tm_year = y;
-
- // Parse month
- timestamp.tm_mon = (date[i - 4] - '0') * 10 + date[i - 3] - '0' - 1;
-
- // Parse date
- timestamp.tm_mday = (date[i - 2] - '0') * 10 + date[i - 1] - '0';
-
- // Skip any date/time delimiter
- for (; *p != '\0' && !isdigit(*p); p++);
-
- // Parse time
- if (sscanf(p, "%d:%d:%d", &timestamp.tm_hour, &timestamp.tm_min, &timestamp.tm_sec) != 3)
- return (time_t)0;
-
- timestamp.tm_isdst = 0; // DST is already present in _timezone below
- time_t t = mktime(&timestamp);
-
- _tzset();
- t -= _timezone;
- return (t >= 0) ? t : 0;
-}
-
//////////////////////////////////////////////////////////////////////////////////////////
struct HtmlEntity
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index 47e6355063..4061511fb0 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -1587,3 +1587,4 @@ _db_event_delivered@8 @1806 NONAME
??6MBinBuffer@@QAEAAV0@G@Z @1812 NONAME
??6MBinBuffer@@QAEAAV0@I@Z @1813 NONAME
??6MBinBuffer@@QAEAAV0@_K@Z @1814 NONAME
+_Utils_IsoToUnixTime@4 @1815 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index 541b559b70..16e49f90b4 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -1587,3 +1587,4 @@ db_event_delivered @1806 NONAME
??6MBinBuffer@@QEAAAEAV0@G@Z @1812 NONAME
??6MBinBuffer@@QEAAAEAV0@I@Z @1813 NONAME
??6MBinBuffer@@QEAAAEAV0@_K@Z @1814 NONAME
+Utils_IsoToUnixTime @1815 NONAME
diff --git a/src/mir_core/src/utils.cpp b/src/mir_core/src/utils.cpp
index 630418cdab..d6f953fde0 100644
--- a/src/mir_core/src/utils.cpp
+++ b/src/mir_core/src/utils.cpp
@@ -584,3 +584,54 @@ MIR_CORE_DLL(bool) Utils_IsRtl(const wchar_t *pszwText)
return false;
}
+
+MIR_CORE_DLL(time_t) Utils_IsoToUnixTime(const char *stamp)
+{
+ wchar_t date[9];
+ int i, y;
+
+ if (stamp == nullptr)
+ return 0;
+
+ auto *p = stamp;
+
+ // Get the date part
+ for (i = 0; *p != '\0' && i < 8 && isdigit(*p); p++, i++)
+ date[i] = *p;
+
+ // Parse year
+ if (i == 6) {
+ // 2-digit year (1970-2069)
+ y = (date[0] - '0') * 10 + (date[1] - '0');
+ if (y < 70) y += 100;
+ }
+ else if (i == 8) {
+ // 4-digit year
+ y = (date[0] - '0') * 1000 + (date[1] - '0') * 100 + (date[2] - '0') * 10 + date[3] - '0';
+ y -= 1900;
+ }
+ else return 0;
+
+ struct tm timestamp;
+ timestamp.tm_year = y;
+
+ // Parse month
+ timestamp.tm_mon = (date[i - 4] - '0') * 10 + date[i - 3] - '0' - 1;
+
+ // Parse date
+ timestamp.tm_mday = (date[i - 2] - '0') * 10 + date[i - 1] - '0';
+
+ // Skip any date/time delimiter
+ for (; *p != '\0' && !isdigit(*p); p++);
+
+ // Parse time
+ if (sscanf(p, "%d:%d:%d", &timestamp.tm_hour, &timestamp.tm_min, &timestamp.tm_sec) != 3)
+ return (time_t)0;
+
+ timestamp.tm_isdst = 0; // DST is already present in _timezone below
+ time_t t = mktime(&timestamp);
+
+ _tzset();
+ t -= _timezone;
+ return (t >= 0) ? t : 0;
+}