diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-04-08 20:34:40 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-04-08 20:34:40 +0000 |
commit | 97cdf4cf1a9bdf132477708c0cb150ce1b6e118f (patch) | |
tree | 283f998d6a7212c6d48872aa049e4a420c03f1d2 /protocols/SkypeWeb/src/skype_utils.cpp | |
parent | 6148761669741440a617e27f03c9eaf0e9038818 (diff) |
SkypeWeb: cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@12683 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_utils.cpp')
-rw-r--r-- | protocols/SkypeWeb/src/skype_utils.cpp | 84 |
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 |