/var/lib/sorcery/modules/url_handlers/url_default
1 #!/bin/bash
2 #---------------------------------------------------------------------
3 ##
4 ## @Synopsis
5 ##
6 ## Default implementations of url_handler api.
7 ##
8 ## @Copyright Copyright 2005 by the Source Mage Team
9 ##
10 #---------------------------------------------------------------------
11
12 #---------------------------------------------------------------------
13 ##=item url_default_bucketize
14 ## @param url
15 ##
16 ## Outputs file as that is the dl handler for file:// urls
17 ##
18 #---------------------------------------------------------------------
19 function url_default_bucketize() {
20 url_get_prefix $1
21 }
22
23 #---------------------------------------------------------------------
24 ##=item url_default_crack
25 ##
26 ## Outputs the url with the prefix removed
27 ##
28 #---------------------------------------------------------------------
29 function url_default_crack() {
30 local prefix=$(url_get_prefix $1)
31 [[ $prefix ]] || return 1
32 url_strip_prefix "$1" $prefix
33 }
34
35 #---------------------------------------------------------------------
36 ##=item url_default_expand
37 #---------------------------------------------------------------------
38 function url_default_expand() {
39 echo "$@"
40 }
41
42 #---------------------------------------------------------------------
43 ##=item url_default_is_valid
44 ## @param url
45 ##
46 ## True if url_crack returns true
47 ##
48 #---------------------------------------------------------------------
49 function url_default_is_valid() {
50 url_crack $1 >/dev/null
51 }
52
53 #---------------------------------------------------------------------
54 ##=url_default_verify
55 ##
56 ## Always returns true
57 ##
58 #---------------------------------------------------------------------
59 function url_default_verify() {
60 true
61 }
62
63 #---------------------------------------------------------------------
64 ##=item url_default_hostname
65 ##
66 ## Outputs localhost
67 ##
68 #---------------------------------------------------------------------
69 function url_default_hostname() {
70 echo localhost
71 }
72
73 #---------------------------------------------------------------------
74 ##=item url_default_netselect
75 ##
76 ## Fake netselect return 0 for each url
77 ##
78 #---------------------------------------------------------------------
79 function url_default_netselect() {
80 local each
81 for each in $@ ; do
82 echo "0 $each"
83 done
84 }
85
86
87 #---------------------------------------------------------------------
88 ##=back
89 ##
90 ##=head1 LICENSE
91 ##
92 ## This software is free software; you can redistribute it and/or modify
93 ## it under the terms of the GNU General Public License as published by
94 ## the Free Software Foundation; either version 2 of the License, or
95 ## (at your option) any later version.
96 ##
97 ## This software is distributed in the hope that it will be useful,
98 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
99 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
100 ## GNU General Public License for more details.
101 ##
102 ## You should have received a copy of the GNU General Public License
103 ## along with this software; if not, write to the Free Software
104 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
105 ##
106 #---------------------------------------------------------------------