efreet_uri.c | efreet_uri.c | |||
---|---|---|---|---|
skipping to change at line 29 | skipping to change at line 29 | |||
#include "efreet_private.h" | #include "efreet_private.h" | |||
EAPI Efreet_Uri * | EAPI Efreet_Uri * | |||
efreet_uri_decode(const char *full_uri) | efreet_uri_decode(const char *full_uri) | |||
{ | { | |||
Efreet_Uri *uri; | Efreet_Uri *uri; | |||
const char *p; | const char *p; | |||
char protocol[64], hostname[_POSIX_HOST_NAME_MAX], path[PATH_MAX]; | char protocol[64], hostname[_POSIX_HOST_NAME_MAX], path[PATH_MAX]; | |||
int i = 0; | int i = 0; | |||
EINA_SAFETY_ON_NULL_RETURN_VAL(full_uri, NULL); | ||||
/* An uri should be in the form <protocol>://<hostname>/<path> */ | /* An uri should be in the form <protocol>://<hostname>/<path> */ | |||
if (!strstr(full_uri, "://")) return NULL; | if (!strstr(full_uri, "://")) return NULL; | |||
memset(protocol, 0, 64); | memset(protocol, 0, 64); | |||
memset(hostname, 0, _POSIX_HOST_NAME_MAX); | memset(hostname, 0, _POSIX_HOST_NAME_MAX); | |||
memset(path, 0, PATH_MAX); | memset(path, 0, PATH_MAX); | |||
/* parse protocol */ | /* parse protocol */ | |||
p = full_uri; | p = full_uri; | |||
for (i = 0; *p != ':' && *p != '\0' && i < 64; p++, i++) | for (i = 0; *p != ':' && *p != '\0' && i < 64; p++, i++) | |||
skipping to change at line 85 | skipping to change at line 87 | |||
return uri; | return uri; | |||
} | } | |||
EAPI const char * | EAPI const char * | |||
efreet_uri_encode(Efreet_Uri *uri) | efreet_uri_encode(Efreet_Uri *uri) | |||
{ | { | |||
char dest[PATH_MAX * 3 + 4]; | char dest[PATH_MAX * 3 + 4]; | |||
const char *p; | const char *p; | |||
int i; | int i; | |||
if (!uri || !uri->path || !uri->protocol) return NULL; | EINA_SAFETY_ON_NULL_RETURN_VAL(uri, NULL); | |||
EINA_SAFETY_ON_NULL_RETURN_VAL(uri->path, NULL); | ||||
EINA_SAFETY_ON_NULL_RETURN_VAL(uri->protocol, NULL); | ||||
memset(dest, 0, PATH_MAX * 3 + 4); | memset(dest, 0, PATH_MAX * 3 + 4); | |||
snprintf(dest, strlen(uri->protocol) + 4, "%s://", uri->protocol); | snprintf(dest, strlen(uri->protocol) + 4, "%s://", uri->protocol); | |||
/* Most app doesn't handle the hostname in the uri so it's put to NULL */ | /* Most app doesn't handle the hostname in the uri so it's put to NULL */ | |||
for (i = strlen(uri->protocol) + 3, p = uri->path; *p != '\0'; p++, i++ ) | for (i = strlen(uri->protocol) + 3, p = uri->path; *p != '\0'; p++, i++ ) | |||
{ | { | |||
if (isalnum(*p) || strchr("/$-_.+!*'()", *p)) | if (isalnum(*p) || strchr("/$-_.+!*'()", *p)) | |||
dest[i] = *p; | dest[i] = *p; | |||
else | else | |||
{ | { | |||
skipping to change at line 108 | skipping to change at line 113 | |||
} | } | |||
} | } | |||
return eina_stringshare_add(dest); | return eina_stringshare_add(dest); | |||
} | } | |||
EAPI void | EAPI void | |||
efreet_uri_free(Efreet_Uri *uri) | efreet_uri_free(Efreet_Uri *uri) | |||
{ | { | |||
if (!uri) return; | if (!uri) return; | |||
IF_RELEASE(uri->protocol); | IF_RELEASE(uri->protocol); | |||
IF_RELEASE(uri->path); | IF_RELEASE(uri->path); | |||
IF_RELEASE(uri->hostname); | IF_RELEASE(uri->hostname); | |||
FREE(uri); | FREE(uri); | |||
} | } | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 7 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |