From 87b1da592111c6b30775edcb0a84e38ee26cd520 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 26 Oct 2014 10:04:24 +0000 Subject: Use nsurl to extract scheme. --- amiga/launch.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'amiga') diff --git a/amiga/launch.c b/amiga/launch.c index d3c9ff11e..e8b64f65b 100755 --- a/amiga/launch.c +++ b/amiga/launch.c @@ -42,17 +42,25 @@ struct MinList ami_unsupportedprotocols; struct ami_protocol { struct MinNode node; - char *protocol; + lwc_string *protocol; }; struct ami_protocol *ami_openurl_add_protocol(const char *url) { + nsurl *ns_url struct ami_protocol *ami_p = (struct ami_protocol *)AllocVecTagList(sizeof(struct ami_protocol), NULL); - if(url_scheme(url, &ami_p->protocol) != NSERROR_OK) + if (nsurl_create(url, &ns_url) != NSERROR_OK) { + FreeVec(ami_p); + return NULL; + } + + ami_p->protocol = nsurl_get_component(ns_url, NSURL_SCHEME); + if (ami_p->protocol == NULL) { FreeVec(ami_p); + nsurl_unref(ns_url); return NULL; } @@ -73,7 +81,7 @@ void ami_openurl_free_list(struct MinList *list) nnode=(struct ami_protocol *)GetSucc((struct Node *)node); Remove((struct Node *)node); - if(node->protocol) free(node->protocol); + if (node->protocol) lwc_string_unref(node->protocol); FreeVec(node); node = NULL; }while(node=nnode); @@ -91,7 +99,8 @@ BOOL ami_openurl_check_list(struct MinList *list, const char *url) { nnode=(struct ami_protocol *)GetSucc((struct Node *)node); - if(!strncasecmp(url, node->protocol, strlen(node->protocol))) + if (!strncasecmp(url, lwc_string_data(node->protocol), + lwc_string_length(node->protocol))) return TRUE; }while(node=nnode); -- cgit v1.2.3