From b7a1174511c3b7fad5b81a54bb4647662d94031c Mon Sep 17 00:00:00 2001 From: Piotr Piastucki Date: Thu, 14 May 2015 15:24:53 +0000 Subject: Updated for partial MSNP24 protocol support, for detailed changes see MSNP24 branch. git-svn-id: http://svn.miranda-ng.org/main/trunk@13589 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/MSN/src/msn_libstr.cpp | 96 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) (limited to 'protocols/MSN/src/msn_libstr.cpp') diff --git a/protocols/MSN/src/msn_libstr.cpp b/protocols/MSN/src/msn_libstr.cpp index 127328230e..a77a343a2d 100644 --- a/protocols/MSN/src/msn_libstr.cpp +++ b/protocols/MSN/src/msn_libstr.cpp @@ -88,6 +88,7 @@ void parseWLID(char* wlid, char** net, char** email, char** inst) if (net) *net = wlid; if (email) *email = col + 1; ++col; + wlid=col; } else { if (net) *net = NULL; @@ -266,6 +267,32 @@ void stripColorCode(char* src) *pd = 0; } +void stripHTML(char* str) +{ + char *p, *q; + + for ( p=q=str; *p!='\0'; p++,q++ ) + { + if ( *p == '<' ) + { + if ( !strnicmp( p, "

", 3 )) { strcpy(q, "\r\n\r\n"); q += 3; p += 2; } + else if ( !strnicmp( p, "

", 4 )) { strcpy(q, "\r\n\r\n"); q += 3; p += 3; } + else if ( !strnicmp( p, "
", 4 )) { strcpy(q, "\r\n"); ++q; p += 3; } + else if ( !strnicmp( p, "
", 6 )) { strcpy(q, "\r\n"); ++q; p += 5; } + else if ( !strnicmp( p, "
", 4 )) { strcpy(q, "\r\n"); ++q; p += 3; } + else if ( !strnicmp( p, "
", 6 )) { strcpy(q, "\r\n"); ++q; p += 5; } + else { + char *l = strchr(p, '>'); + if (l) { p = l; --q; } else *q = *p; + } + } + else + *q = *p; + } + *q = '\0'; +} + + // Process a string, and double all % characters, according to chat.dll's restrictions // Returns a pointer to the new string (old one is not freed) TCHAR* EscapeChatTags(const TCHAR* pszText) @@ -318,3 +345,72 @@ char* getNewUuid(void) RpcStringFreeA(&p); return result; } + +time_t IsoToUnixTime(const char *stamp) +{ + char date[9]; + int i, y; + + if (stamp == NULL) + return 0; + + char *p = NEWSTR_ALLOCA(stamp); + + // 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", ×tamp.tm_hour, ×tamp.tm_min, ×tamp.tm_sec) != 3) + return (time_t)0; + + timestamp.tm_isdst = 0; // DST is already present in _timezone below + time_t t = mktime(×tamp); + + _tzset(); + t -= _timezone; + return (t >= 0) ? t : 0; +} + +time_t MsnTSToUnixtime(const char *pszTS) +{ + char szTS[16]; + + if (!*pszTS) return time(NULL); + strncpy(szTS, pszTS, 10); + return (time_t)atoi(szTS); +} -- cgit v1.2.3