Lolly 1.4.27
Loading...
Searching...
No Matches
url.cpp
Go to the documentation of this file.
1
2/******************************************************************************
3 * MODULE : url.cpp
4 * DESCRIPTION: unified resource location handling
5 * COPYRIGHT : (C) 1999 Joris van der Hoeven
6 *******************************************************************************
7 * This software falls under the GNU general public license version 3 or later.
8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ******************************************************************************/
11
12#include "url.hpp"
13#include "analyze.hpp"
14#include "sys_utils.hpp"
15#include "tbox/tbox.h"
16#include <ctype.h>
17
18#if defined(OS_MINGW) || defined(OS_WIN)
19#define WINPATHS
20#endif
21
22static url_tree
23url_tuple (string label) {
24 return url_tree (URL_TUPLE, url_tree (label));
25}
26
27static url_tree
28url_tuple (string label, string value) {
29 return url_tree (URL_TUPLE, url_tree (label), url_tree (value));
30}
31
32static url_tree
33url_tuple (string label, string value, string content) {
34 return url_tree (URL_TUPLE, url_tree (label), url_tree (value),
36}
37
38static url_tree
39url_tuple (string label, url_tree t1, url_tree t2) {
40 return url_tree (URL_TUPLE, url_tree (label), t1, t2);
41}
42
43static inline bool
44is_tuple (url_tree t, string s) {
45 return (t->op == URL_TUPLE) && (N (t) >= 1) && (t[0] == s);
46}
47static inline bool
48is_tuple (url_tree t, const char* s) {
49 return (t->op == URL_TUPLE) && (N (t) >= 1) && (t[0] == s);
50}
51static inline bool
52is_tuple (url_tree t, string s, int n) {
53 return (t->op == URL_TUPLE) && (N (t) == (n + 1)) && (t[0] == s);
54}
55static inline bool
56is_tuple (url_tree t, const char* s, int n) {
57 return (t->op == URL_TUPLE) && (N (t) == (n + 1)) && (t[0] == s);
58}
59
60url::url () : rep (tm_new<url_rep> (url_tuple ("none"))) {}
61url::url (const char* name) : rep (tm_new<url_rep> (url_system (name)->t)) {}
63url::url (string path_name, string name)
65
66string
68 string url_label= this->label ();
69 if (url_label == "root") {
70 return rep->t[1]->label;
71 }
72 else if (url_label == "concat") {
73 return as_url (rep->t[1]).protocol ();
74 }
75 else if (url_label == "or") {
76 // For mutiple urls, the protocol must be consistent
77 // otherwise, it is in empty protocol
78 string p1= as_url (rep->t[1]).protocol ();
79 if (p1 == "") return ""; // if empty protocol, return empty protocol fast
80
81 string p2= as_url (rep->t[2]).protocol ();
82 if (p1 == p2) return p1;
83 else return ""; // if the protocol does not match, return empty protocol
84 }
85 else {
86 return "default";
87 }
88}
89
90url
92 return as_url (url_tuple ("none"));
93}
94
95url
96url_root (string protocol) {
97 return as_url (url_tuple ("root", protocol));
98}
99
100url
101url_wildcard () { // any url
102 return as_url (url_tuple ("wildcard"));
103}
104
105url
106url_wildcard (string name) { // string with * wildcards
107 return as_url (url_tuple ("wildcard", name));
108}
109
110/******************************************************************************
111 * Generic url constructor
112 ******************************************************************************/
113void
114skip_ipv6 (string s, int& i) {
115 i++;
116 while (i < N (s) &&
117 (s[i] == ':' || (s[i] >= '0' && s[i] <= '9') ||
118 (s[i] >= 'a' && s[i] <= 'f') || (s[i] >= 'A' && s[i] <= 'F')))
119 i++;
120 if (i < N (s) && s[i] == ']') i++;
121}
122
123static bool
125 char sep= (type == 0) ? URL_SEPARATOR : ':';
126 int i= 0, n= N (name);
127 while (i < n)
128 if (name[i] == '[') skip_ipv6 (name, i);
129 else if (name[i] == sep) return true;
130 else i++;
131 return false;
132}
133
134static bool
136#ifdef WINPATHS
137 // FIXME: we probably should take into account 'type' too
138 if (N (name) < 2) return false;
139 if ((name[0] == '\\') && (name[1] == '\\')) return true;
140 return isalpha (name[0]) && (name[1] == ':') &&
141 ((N (name) == 2) || (name[2] == '\\') || (name[2] == '/'));
142#else
143 char sep= (type == 0) ? URL_CONCATER : '/';
144 return (name != "") && (name[0] == sep);
145#endif
146}
147
148static bool
150 return starts (name, "www.");
151 // FIXME: we might want to recognize some other ones like google.com too
152}
153
154static bool
156 return starts (name, "ftp.");
157}
158
159static bool
161#ifdef WINPATHS
162 return type != URL_SYSTEM && N (name) >= 2 && name[0] == '/' &&
163 is_alpha (name[1]) && (N (name) == 2 || name[2] == '/');
164#else
165 (void) name;
166 (void) type;
167 return false;
168#endif
169}
170
171static url
172url_get_atom (string s, int type) {
173 if (type < URL_STANDARD) {
174 if (s == "~") return url_system (get_env ("HOME"));
175 if (starts (s, "$")) {
176 string val= get_env (s (1, N (s)));
177 if (val == "") return url_none ();
178 return unblank (url_system (val));
179 }
180 }
181 if (contains (s, '*')) return url_wildcard (s);
182#ifdef WINPATHS
183 if (N (s) == 2 && ends (s, ":"))
184 s->resize (1); // remove the ':' after unit letter
185#endif
186 return as_url (url_tree (s));
187}
188
189url
190url_get_name (string s, int type, int i) {
191 char sep = (type == URL_SYSTEM) ? URL_CONCATER : '/';
192 int n = N (s);
194 while (i < n) {
195 int start= i;
196 while ((i < n) && (s[i] != sep) && (s[i] != '/')) {
197 if (s[i] == '[') skip_ipv6 (s, i);
198 else i++;
199 }
200 if (i > start) {
201 url u = url_get_atom (s (start, i), type);
202 u_list= list (u, u_list);
203 }
204 else if (i == start) {
205 i++;
206 if (i == n) {
207 u_list= list (as_url (url_tree ("")), u_list);
208 }
209 }
210 }
211
212 if (is_nil (u_list)) return as_url (url_tree (""));
213 url ret= u_list->item;
214 u_list = u_list->next;
215 while (!is_nil (u_list)) {
216 url u= u_list->item;
217 if (is_here (u) || (u->t == "")) {
218 // do nothing
219 }
220 else if (is_atomic (u)) {
221 ret= as_url (url_tuple ("concat", u->t, ret->t));
222 }
223 else {
224 ret= u * ret;
225 }
226 u_list= u_list->next;
227 }
228 return ret;
229}
230
231static url
232url_get_path (string s, int type= URL_STANDARD, int i= 0) {
233 char sep = (type == URL_SYSTEM) ? URL_SEPARATOR : ':';
234 int start= i, n= N (s);
235 if (i == n) return url_none ();
236 while ((i < n) && (s[i] != sep)) {
237 if (s[i] == '[') skip_ipv6 (s, i);
238 else i++;
239 }
240 url u= url_general (s (start, i), type);
241 if (i == n) return u;
242 if (start == i) return url_get_path (s, type, i + 1);
243 return u | url_get_path (s, type, i + 1);
244}
245
246url
247url_path (string s, int type) {
248 url u= url_get_path (s, type);
249 return u;
250}
251
252static url
254 string s= name (0, 2) * ":" * name (2, N (name));
255 return url_root ("default") * url_get_name (s, type);
256}
257
258static url
261#ifdef WINPATHS
262 // FIXME: this hack seems a bit too simple
263 if (is_concat (u) && (u[2]->t == "")) u= u[1];
264 // cout << name << " -> " << url_root ("default") * u << "\n";
265 return url_root ("default") * u;
266#else
267 if (u->t == "") return url_root ("default");
268 return url_root ("default") * u;
269#endif
270}
271
272url
274 if (contains (name, "://")) {
276 string protocol= tokens[0];
277 string path = tokens[1];
278 if (N (tokens) == 2 && is_alphanum (protocol) && N (protocol) >= 2) {
279 if (protocol == "file") return file_url (path);
280 if (protocol == "http") return http_url (path);
281 if (protocol == "https") return https_url (path);
282 if (protocol == "ftp") return ftp_url (path);
283 return url_root (tokens[0]) * url_get_name (tokens[1], type);
284 }
285 }
286 if (starts (name, "local:")) {
287 return file_url (name (6, N (name)));
288 }
289 if (starts (name, "//")) {
290 return blank_url (name (2, N (name)));
291 }
292 if (heuristic_is_path (name, type)) {
293 return url_path (name, type);
294 }
297 return url_mingw_default (name, type);
298 if (type != URL_CLEAN_UNIX) {
299 if (heuristic_is_http (name)) return http_url (name);
300 if (heuristic_is_ftp (name)) return ftp_url (name);
301 }
302 return url_get_name (name, type);
303}
304
305url
306url_system (string name) {
307 return url_general (name, URL_SYSTEM);
308}
309
310url
311url_system (string dir, string name) {
312 return url_system (dir) * url_system (name);
313}
314
315url
317 return url_general (name, URL_STANDARD);
318}
319
320url
321url_standard (string dir, string name) {
322 return url_standard (dir) * url_standard (name);
323}
324
325url
327 char path[TB_PATH_MAXN];
329 return url_system (path);
330 }
331 else {
332 TM_FAILED ("FAILED to get pwd");
333 return url_none ();
334 }
335}
336
337/******************************************************************************
338 * Rooted url constructors
339 ******************************************************************************/
340url
342 return as_url (url_tuple ("root", "ramdisc", contents));
343}
344
345/******************************************************************************
346 * Operations on urls
347 ******************************************************************************/
348
349static bool
351#ifdef WINPATHS
352 return is_root (u);
353#else
354 return is_root_web (u);
355#endif
356}
357
358static bool
360 // url u such that u/.. == u (website or windows drive name)
361 return is_concat (u) && is_special_root (u[1]) && is_atomic (u[2]);
362}
363
364url
366 return u * url_parent ();
367}
368
369url
371 if (is_concat (u)) {
372 if (is_root_web (u[1]) && is_atomic (u[2])) return url_here ();
373 return tail (u[2]);
374 }
375 if (is_or (u)) return tail (u[1]) | tail (u[2]);
376 if (is_root (u)) return url_here ();
377 return u;
378}
379
380string
382 u= tail (u);
383 if (!is_atomic (u)) return "";
384 string s= as_string (u);
385 int i, n= N (s);
386 for (i= n - 1; i >= 0; i--)
387 if (s[i] == '.') break;
388 if ((i > 0) && (i < n - 1)) {
389 string r= s (i + 1, n);
390 while ((N (r) > 0) && (r[N (r) - 1] == '~' || r[N (r) - 1] == '#'))
391 r= r (0, N (r) - 1);
392 int found= index_of (r, '?');
393 if (found != -1) r= r (0, found);
394 if (use_locase) return locase_all (r);
395 else return r;
396 }
397 return "";
398}
399
400string
402 return suffix (u, true);
403}
404
405string
406basename (url u, string suf) {
407 string s = as_string (tail (u));
408 int found= index_of (s, '?');
409 if (found != -1) s= s (0, found);
410 return remove_suffix (s, suf);
411}
412
413string
415 string s= suffix (u, false);
416 if (!is_empty (s)) s= "." * s;
417 return basename (u, s);
418}
419
420url
421glue (url u, string s) {
422 if (is_atomic (u)) return as_url (url_tree (u->t->label * s));
423 if (is_concat (u)) return u[1] * glue (u[2], s);
424 if (is_or (u)) return glue (u[1], s) | glue (u[2], s);
425 if (is_none (u)) return u;
426 TM_FAILED ("can't glue string to url");
427 return u;
428}
429
430url
431unglue (url u, int nr) {
432 if (is_atomic (u))
433 return as_url (url_tree (u->t->label (0, max (N (u->t->label) - nr, 0))));
434 if (is_concat (u)) return u[1] * unglue (u[2], nr);
435 if (is_or (u)) return unglue (u[1], nr) | unglue (u[2], nr);
436 if (is_none (u)) return u;
437 TM_FAILED ("can't unglue from url");
438 return u;
439}
440
441url
443 if (is_concat (u) && (u[2]->t == "")) return u[1];
444 if (is_concat (u)) return u[1] * unblank (u[2]);
445 if (is_or (u)) return unblank (u[1]) | unblank (u[2]);
446 return u;
447}
448
449url
451 return head (base) * u;
452}
453
454url
456 if (is_atomic (base)) return u;
457 if (is_concat (base) && is_concat (u) && (base[1] == u[1])) {
458 if (is_special_root (base[1]) && is_concat (base[2]) && is_concat (u[2]) &&
459 base[2][1] != u[2][1])
460 return url_none ();
461 return delta_sub (base[2], u[2]);
462 }
463 if (is_concat (base) && !is_semi_root (base))
464 return url_parent () * delta_sub (head (base), u);
465 return url_none ();
466}
467
468url
470 if (is_or (u)) return delta (base, u[1]) | delta (base, u[2]);
471 url res= delta_sub (base, u);
472 if (is_none (res)) return u;
473 return res;
474}
475
476string
478 return u.protocol ();
479}
480
481url
483 if (is_concat (u)) return unroot (u[1]) * u[2];
484 if (is_or (u)) return unroot (u[1]) | unroot (u[2]);
485 if (is_root (u)) return url_here ();
486 return u;
487}
488
489url
490reroot (url u, string protocol) {
491 if (is_concat (u)) return reroot (u[1], protocol) * u[2];
492 if (is_or (u)) return reroot (u[1], protocol) | reroot (u[2], protocol);
493 if (is_root (u)) return url_root (protocol);
494 return u;
495}
496
497static url
499 if (is_or (u1)) return expand (u1[1], u2) | expand (u1[2], u2);
500 if (is_or (u2)) return expand (u1, u2[1]) | expand (u1, u2[2]);
501 if (is_ancestor (u2)) {
502 if (is_concat (u1)) return u1 | expand (u1[1], u2);
503 if (is_special_root (u1)) return u2;
504 return u1 | u2;
505 }
506 if (is_concat (u2) && is_ancestor (u2[1]))
507 return expand (expand (u1, u2[1]), u2[2]);
508 return u1 * u2;
509}
510
511url
513 if (is_or (u)) return expand (u[1]) | expand (u[2]);
514 if (is_concat (u)) return expand (expand (u[1]), expand (u[2]));
515 return u;
516}
517
518static bool
520 if (is_atomic (u1) && is_atomic (u2)) return u1->t->label <= u2->t->label;
521 if (is_atomic (u1)) return true;
522 if (is_atomic (u2)) return false;
523 if (is_concat (u1) && is_concat (u2)) {
524 if (u1[1] == u2[1]) return u1[2] <= u2[2];
525 else return u1[1] <= u2[1];
526 }
527 if (is_concat (u1)) return true;
528 if (is_concat (u2)) return false;
529 return true; // does not matter for sorting
530}
531
532static url
534 if (is_or (to)) {
535 if (add <= to[1]) return add | to;
536 return to[1] | sort_sub (add, to[2]);
537 }
538 if (add <= to) return add | to;
539 else return to | add;
540}
541
542url
544 if (is_or (u)) return sort_sub (u[1], sort (u[2]));
545 else return u;
546}
547
548static url
550 if (!is_or (u)) return u;
551 url v= factor_sorted (u[2]);
552 if (is_concat (u[1])) {
553 if (is_concat (v) && (u[1][1] == v[1])) return u[1][1] * (u[1][2] | v[2]);
554 if (is_or (v) && is_concat (v[1]) && (u[1][1] == v[1][1]))
555 return (u[1][1] * (u[1][2] | v[1][2])) | v[2];
556 }
557 return u[1] | v;
558}
559
560static url
562 if (is_concat (u)) return u[1] * factor (u[2]);
563 if (is_or (u)) return factor_sub (u[1]) | factor_sub (u[2]);
564 return u;
565}
566
567url
569 return factor_sub (factor_sorted (sort (u)));
570}
571
572bool
574 if (u == base) return true;
575 if (is_concat (u) && is_atomic (base)) return u[1] == base;
576 if (is_concat (u) && is_concat (base)) {
578 while (iter_u[1] == iter_base[1]) {
579 iter_u = iter_u[2];
581 if (is_concat (iter_u) && is_concat (iter_base)) {
582 continue;
583 }
584 else {
585 return descends (iter_u, iter_base);
586 }
587 }
588 return false;
589 }
590 if (is_or (u)) return descends (u[1], base) && descends (u[2], base);
591 if (is_or (base)) return descends (u, base[1]) || descends (u, base[2]);
592 return false;
593}
594
595url
597 if (is_root (u2) || (is_concat (u2) && is_root (u2[1]))) {
598 if (is_concat (u1) && is_root_web (u1[1])) {
599 if (is_root (u2, "default") ||
600 (is_concat (u2) && is_root (u2[1], "default"))) {
601 url v= u1[2];
602 while (is_concat (v))
603 v= v[1];
604 if (is_root (u2)) return u1[1] * v;
605 return u1[1] * v * u2[2];
606 }
607 if (is_root (u2, "blank") || (is_concat (u2) && is_root (u2[1], "blank")))
608 return reroot (u2, u1[1][1]->t->label);
609 }
610 if (is_root (u1) && is_rooted (u1, "file")) {
611 return u1 * u2[2];
612 }
613 return u2;
614 }
615 if (is_here (u1) || (u1->t == "")) return u2;
616 if (is_here (u2)) return u1;
617 if (is_none (u1)) return url_none ();
618 if (is_none (u2)) return url_none ();
619 if (u2 == url_parent ()) {
620 if (is_root (u1)) return u1;
621 if (is_pseudo_atomic (u1) && (!is_parent (u1))) return url_here ();
622 if (is_semi_root (u1)) return u1;
623 }
624 if (is_concat (u2) && (u2[1] == url_parent ())) {
625 if (is_root (u1)) return u1 * u2[2];
626 if (is_pseudo_atomic (u1) && (!is_parent (u1))) return u2[2];
627 if (is_semi_root (u1)) return u1 * u2[2];
628 }
629 if (is_concat (u1)) return u1[1] * (u1[2] * u2);
630 return as_url (url_tuple ("concat", u1->t, u2->t));
631}
632
633url
634operator* (url u1, const char* name) {
635 return u1 * url (name);
636}
637
638url
640 return u1 * url (name);
641}
642
643url
645 return u1 * u2;
646}
647
648url
650 if (is_none (u1)) return u2;
651 if (is_none (u2)) return u1;
652 if (is_or (u1)) return u1[1] | (u1[2] | u2);
653 if (u1 == u2) return u2;
654 if (is_or (u2) && (u1 == u2[1])) return u2;
655 return as_url (url_tuple ("or", u1->t, u2->t));
656}
657
658url
660 return u1 | u2;
661}
662
663bool
665 return is_atomic (u->t);
666}
667bool
668is_root (url u, string s) {
669 return is_root (u) && (u[1]->t->label == s);
670}
671bool
673 return is_root (u, "http") || is_root (u, "https") || is_root (u, "ftp") ||
674 is_root (u, "blank");
675}
676bool
677is_wildcard (url u, int n) {
678 return is_tuple (u->t, "wildcard", n);
679}
680bool
682 return is_atomic (u->t) || is_tuple (u->t, "wildcard", 1);
683}
684
685bool
687 return is_root (u) || (is_concat (u) && is_rooted (u[1])) ||
688 (is_or (u) && is_rooted (u[1]) && is_rooted (u[2]));
689}
690
691bool
692is_rooted (url u, string protocol) {
693 return is_root (u, protocol) ||
694 (is_concat (u) && is_rooted (u[1], protocol)) ||
695 (is_or (u) && is_rooted (u[1], protocol) &&
696 is_rooted (u[2], protocol));
697}
698
699bool
701 return is_root_web (u) || (is_concat (u) && is_rooted_web (u[1])) ||
702 (is_or (u) && is_rooted_web (u[1]) && is_rooted_web (u[2]));
703}
704
705bool
707 if (is_atomic (u)) return true;
708 if (!is_concat (u)) return false;
709 return is_name (u[1]) && is_name (u[2]);
710}
711
712bool
714 return is_concat (u) && is_root (u[1]) && is_name (u[2]);
715}
716
717bool
719 if (is_name (u)) return true;
720 return is_concat (u) && is_root (u[1], "default") && is_name (u[2]);
721}
722
723bool
725 return is_concat (u) && is_root (u[1], "ramdisc");
726}
727
728string
730 // This routine pretty prints an url as a string.
731 // FIXME: the current algorithm is quadratic in time.
732 if (is_none (u)) return "{}";
733 if (is_atomic (u)) return u->t->label;
734 if (is_concat (u)) {
735 int stype= type;
736 if (is_root (u[1]) &&
737 !(is_root (u[1], "default") || is_root (u[1], "file"))) {
739 }
740 string sep= (stype == URL_SYSTEM ? string (URL_CONCATER) : string ("/"));
741 string s1 = as_string (u[1], type);
742 string s2 = as_string (u[2], stype);
743 if (is_root (u[1], "default")) s1= "";
744 if ((!is_name (u[1])) && (!is_root (u[1]))) s1= "{" * s1 * "}";
745 if ((!is_concat (u[2])) && (!is_atomic (u[2])) && (!is_wildcard (u[2], 1)))
746 s2= "{" * s2 * "}";
747 if (os_win () && // have to return the windows format
748 ((is_root (u[1], "default") && type == URL_SYSTEM) ||
749 is_root (u[1], "file"))) {
750 string root, remain;
751 if (is_concat (u[2])) {
752 root= as_string (u[2][1], type);
753 // root might be unit letter or hostname. It depends on the length
754 remain= as_string (u[2][2], type);
755 }
756 else {
757 root = s2;
758 remain= "";
759 }
760 if (is_root (u[1], "default")) {
761 if (N (root) == 1) return root * ":" * sep * remain; // drive letter
762 else return "\\\\" * root * "\\" * remain;
763 }
764 else {
765 if (N (root) == 1)
766 return s1 * "/" * root * ":" * sep * remain; // local file
767 else return s1 * root * "/" * remain; // remote
768 }
769 }
770 return s1 * sep * s2;
771 }
772 if (is_or (u)) {
773 string s1= as_string (u[1], type);
774 string s2= as_string (u[2], type);
775 if (!is_name_in_path (u[1])) s1= "{" * s1 * "}";
776 if ((!is_or (u[2])) && (!is_name_in_path (u[2]))) s2= "{" * s2 * "}";
777 if (os_win ()) {
778 if (type == URL_STANDARD) return s1 * ":" * s2;
779 else return s1 * string (URL_SEPARATOR) * s2;
780 }
781 else {
782 return s1 * string (URL_SEPARATOR) * s2;
783 }
784 }
785 if (os_win ()) {
786 if (is_root (u, "default")) {
787 int stype= type;
788 if (is_root (u[1]) && (!is_root (u[1], "default"))) stype= URL_STANDARD;
789 if (stype == URL_SYSTEM) return "";
790 else return "/";
791 }
792 }
793 else {
794 if (is_root (u, "default")) return "/";
795 }
796 if (is_root (u, "blank")) return "/";
797 if (is_root (u, "file")) return u[1]->t->label * "://";
798 if (is_root (u)) return u[1]->t->label * ":/";
799 if (is_wildcard (u, 0)) return "**";
800 if (is_wildcard (u, 1)) return u->t[1]->label;
801 TM_FAILED ("bad url");
802 return "";
803}
804
807 return out << as_string (u, URL_SYSTEM);
808}
bool starts(string s, const char *what)
Definition analyze.cpp:566
bool is_alphanum(string s)
Definition analyze.cpp:55
string locase_all(string s)
Converts all uppercase characters in a string to lowercase.
Definition analyze.cpp:137
array< string > tokenize(string s, string sep)
Definition analyze.cpp:948
bool ends(string s, const char *what)
Definition analyze.cpp:576
bool is_alpha(string s)
Checks if a string contains only alphabetic characters.
Definition analyze.cpp:46
int index_of(string s, char c)
Definition analyze.cpp:800
string remove_suffix(string s, string suffix)
Remove the suffix from s if matches.
Definition analyze.cpp:175
int N(array< T > a)
Get the length of the array.
Definition array.hpp:170
bool contains(T a, array< T > b)
Check if an array contains a specified element.
#define TM_FAILED(msg)
Macro used to throw an exception with a specified error message.
Definition basic.hpp:93
bool is_nil(blackbox x)
Definition blackbox.hpp:29
blackbox t1
blackbox t2
blackbox t[13]
The list class represents a linked list.
Definition list.hpp:48
Definition url.hpp:37
string label()
Definition url.hpp:51
url()
Definition url.cpp:60
string protocol()
Definition url.cpp:67
friend url as_url(url_tree t)
Definition url.hpp:61
C * tm_new()
SI max(SI i, SI j)
Returns the maximum of two signed integers.
Definition minmax.hpp:40
bool is_empty(string s)
Definition string.cpp:354
base class of resources
Definition resource.hpp:23
bool os_mingw()
bool os_win()
Definition sys_utils.cpp:94
string get_env(string var)
Definition sys_utils.cpp:25
#define URL_SEPARATOR
Definition sys_utils.hpp:23
#define URL_CONCATER
Definition sys_utils.hpp:22
static url_tree url_tuple(string label)
Definition url.cpp:23
bool is_root_web(url u)
Definition url.cpp:672
url tail(url u)
Definition url.cpp:370
url url_or(url u1, url u2)
Definition url.cpp:659
url url_none()
Definition url.cpp:91
bool is_atomic(url u)
Definition url.cpp:664
static url url_get_atom(string s, int type)
Definition url.cpp:172
string suffix(url u, bool use_locase)
Definition url.cpp:381
static bool is_tuple(url_tree t, string s)
Definition url.cpp:44
static bool is_special_root(url u)
Definition url.cpp:350
bool is_rooted_name(url u)
Definition url.cpp:713
url url_system(string name)
Definition url.cpp:306
url url_concat(url u1, url u2)
Definition url.cpp:644
url url_standard(string name)
Definition url.cpp:316
static bool heuristic_is_ftp(string name)
Definition url.cpp:155
static bool heuristic_is_path(string name, int type)
Definition url.cpp:124
static url sort_sub(url add, url to)
Definition url.cpp:533
url operator*(url u1, url u2)
Definition url.cpp:596
string basename(url u, string suf)
Definition url.cpp:406
static bool heuristic_is_default(string name, int type)
Definition url.cpp:135
tm_ostream & operator<<(tm_ostream &out, url u)
Definition url.cpp:806
url operator|(url u1, url u2)
Definition url.cpp:649
static url factor_sorted(url u)
Definition url.cpp:549
static url url_mingw_default(string name, int type)
Definition url.cpp:253
url url_root(string protocol)
Definition url.cpp:96
bool is_name_in_path(url u)
Definition url.cpp:718
static url url_get_path(string s, int type=URL_STANDARD, int i=0)
Definition url.cpp:232
url head(url u)
Definition url.cpp:365
url relative(url base, url u)
Definition url.cpp:450
bool is_pseudo_atomic(url u)
Definition url.cpp:681
static url url_default(string name, int type=URL_SYSTEM)
Definition url.cpp:259
url reroot(url u, string protocol)
Definition url.cpp:490
bool descends(url u, url base)
Definition url.cpp:573
url url_get_name(string s, int type, int i)
Definition url.cpp:190
bool is_rooted(url u)
Definition url.cpp:686
url delta_sub(url base, url u)
Definition url.cpp:455
bool is_ramdisc(url u)
Definition url.cpp:724
static bool heuristic_is_http(string name)
Definition url.cpp:149
url factor(url u)
Definition url.cpp:568
url url_path(string s, int type)
Definition url.cpp:247
bool is_name(url u)
Definition url.cpp:706
url url_ramdisc(string contents)
Definition url.cpp:341
url unroot(url u)
Definition url.cpp:482
static url factor_sub(url u)
Definition url.cpp:561
string get_root(url u)
Definition url.cpp:477
url delta(url base, url u)
Definition url.cpp:469
static bool operator<=(url u1, url u2)
Definition url.cpp:519
url sort(url u)
Definition url.cpp:543
url url_wildcard()
Definition url.cpp:101
static url expand(url u1, url u2)
Definition url.cpp:498
url unblank(url u)
Definition url.cpp:442
static bool heuristic_is_mingw_default(string name, int type)
Definition url.cpp:160
bool is_rooted_web(url u)
Definition url.cpp:700
url unglue(url u, int nr)
Definition url.cpp:431
url url_pwd()
Definition url.cpp:326
url glue(url u, string s)
Definition url.cpp:421
url url_general(string name, int type=URL_SYSTEM)
Definition url.cpp:273
string as_string(url u, int type)
Definition url.cpp:729
bool is_wildcard(url u, int n)
Definition url.cpp:677
void skip_ipv6(string s, int &i)
Definition url.cpp:114
bool is_root(url u, string s)
Definition url.cpp:668
static bool is_semi_root(url u)
Definition url.cpp:359
#define URL_STANDARD
Definition url.hpp:17
bool is_parent(url u)
Definition url.hpp:158
bool is_or(url u)
Definition url.hpp:178
bool is_here(url u)
Definition url.hpp:154
url url_here()
Definition url.hpp:122
#define URL_SYSTEM
Definition url.hpp:15
bool is_none(url u)
Definition url.hpp:166
lolly_tree< int > url_tree
Definition url.hpp:26
bool is_ancestor(url u)
Definition url.hpp:162
#define URL_CLEAN_UNIX
Definition url.hpp:18
#define URL_TUPLE
Definition url.hpp:20
url url_parent()
Definition url.hpp:127
bool is_concat(url u)
Definition url.hpp:174
url as_url(url_tree t)
Definition url.hpp:61