summaryrefslogtreecommitdiff
path: root/src/bin/utils.c
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2019-09-15 17:47:07 +0200
committerBoris Faure <billiob@gmail.com>2019-09-15 17:47:07 +0200
commit259722a3f325972a38065583dbfd62e10ca7b300 (patch)
tree006858d98190984734d1a1e2cb50e95ba7cbc24e /src/bin/utils.c
parent7bfef215b0305d04579d98ba14c59f953163512c (diff)
move link_is_* to termiolink.c
Diffstat (limited to 'src/bin/utils.c')
-rw-r--r--src/bin/utils.c47
1 files changed, 0 insertions, 47 deletions
diff --git a/src/bin/utils.c b/src/bin/utils.c
index 9232676..3c5c2d6 100644
--- a/src/bin/utils.c
+++ b/src/bin/utils.c
@@ -180,50 +180,3 @@ utils_need_scale_wizard(void)
180 180
181 return EINA_TRUE; 181 return EINA_TRUE;
182} 182}
183
184Eina_Bool
185link_is_protocol(const char *str)
186{
187 const char *p = str;
188 int c = *p;
189
190 if (!isalpha(c))
191 return EINA_FALSE;
192
193 /* Try to follow RFC3986 a bit
194 * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
195 * hier-part = "//" authority path-abempty
196 * [...] other stuff not taken into account
197 * scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
198 */
199
200 do
201 {
202 p++;
203 c = *p;
204 }
205 while (isalpha(c) || (c == '.') || (c == '-') || (c == '+'));
206
207 return (p[0] == ':') && (p[1] == '/') && (p[2] == '/');
208}
209
210Eina_Bool
211link_is_url(const char *str)
212{
213 if (link_is_protocol(str) ||
214 casestartswith(str, "www.") ||
215 casestartswith(str, "ftp."))
216 return EINA_TRUE;
217 return EINA_FALSE;
218}
219
220Eina_Bool
221link_is_email(const char *str)
222{
223 const char *at = strchr(str, '@');
224 if (at && strchr(at + 1, '.'))
225 return EINA_TRUE;
226 if (casestartswith(str, "mailto:"))
227 return EINA_TRUE;
228 return EINA_FALSE;
229}