summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/SkypeWeb/src/skype_utils.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_utils.cpp84
1 files changed, 17 insertions, 67 deletions
diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp
index d7e119874c..38ca985b24 100644
--- a/protocols/SkypeWeb/src/skype_utils.cpp
+++ b/protocols/SkypeWeb/src/skype_utils.cpp
@@ -153,86 +153,36 @@ bool CSkypeProto::IsFileExists(std::tstring path)
return _taccess(path.c_str(), 0) == 0;
}
-char *CSkypeProto::ContactUrlToName(const char *url)
-{
- char *tempname = NULL;
- const char *start, *end;
- start = strstr(url, "/8:");
+// url parsing
- if (!start)
+char *ParseUrl(const char *url, const char *token)
+{
+ const char *start = strstr(url, token);
+ if (start == NULL)
return NULL;
- start = start + 3;
- if ((end = strchr(start, '/')))
- {
- mir_free(tempname);
- tempname = mir_strndup(start, end - start);
- return tempname;
- }
- mir_free(tempname);
- tempname = mir_strdup(start);
+ start = start + mir_strlen(token);
+ const char *end = strchr(start, '/');
+ if (start == NULL)
+ return mir_strdup(start);
+ return mir_strndup(start, end - start);
+}
- return tempname;
+char *CSkypeProto::ContactUrlToName(const char *url)
+{
+ return ParseUrl(url, "/8:");
}
char *CSkypeProto::SelfUrlToName(const char *url)
{
- char *tempname = NULL;
- const char *start, *end;
- start = strstr(url, "/1:");
-
- if (!start)
- return NULL;
- start = start + 3;
- if ((end = strchr(start, '/')))
- {
- mir_free(tempname);
- tempname = mir_strndup(start, end - start);
- return tempname;
- }
- mir_free(tempname);
- tempname = mir_strdup(start);
-
- return tempname;
+ return ParseUrl(url, "/1:");
}
char *CSkypeProto::ChatUrlToName(const char *url)
{
- char *tempname = NULL;
- const char *start, *end;
- start = strstr(url, "/19:");
-
- if (!start)
- return NULL;
- start = start + 4;
- if ((end = strchr(start, '/')))
- {
- mir_free(tempname);
- tempname = mir_strndup(start, end - start);
- return tempname;
- }
- mir_free(tempname);
- tempname = mir_strdup(start);
-
- return tempname;
+ return ParseUrl(url, "/19:");
}
char *CSkypeProto::GetServerFromUrl(const char *url)
{
- char *tempname = NULL;
- const char *start, *end;
- start = strstr(url, "://");
-
- if (!start)
- return NULL;
- start = start + 3;
- if ((end = strchr(start, '/')))
- {
- mir_free(tempname);
- tempname = mir_strndup(start, end - start);
- return tempname;
- }
- mir_free(tempname);
- tempname = mir_strdup(start);
-
- return tempname;
+ return ParseUrl(url, "://");
} \ No newline at end of file