#!/bin/bash
#---------------------------------------------------------------------
##
##=head1 SYNOPSIS
## 
## Url handler functions for grabbing rsync urls.
##
##=head1 DESCRIPTION
##
## This file contains functions for I<downloading> files through rsync.
##
## In order for rsync urls to be downloaded, the I<rsync> spell must have been
## cast. This script first determines if rsync has been installed before 
## attempting to download a rsync url.
##
##=head1 RSYNC URL Format
##
##
##      rsync://SERVER::MODULE_NAME
##
## The above url will download the latest version of the specified
## module.
##
##=head1 EXAMPLES
##
## Suppose we want to download the latest version of the sorcery
## stable grimoire via rsync.  We'd use the following url:
##
##      rsync://codex.sourcemage.org::stable
##
##=head1 IMPLEMENTATION NOTE
##
## Downloading is supported but rsync url verification is not
## currently supported.
##
##=head1 COPYRIGHT
##
## Copyright 2003 by the Source Mage Team
##
##=head1 FUNCTIONS
##
##=over 4
##
#---------------------------------------------------------------------


#---------------------------------------------------------------------
##=item url_rsync_crack <url>
##
## No cracking is needed on these urls currently.
## Simply outputs the input.
##
#---------------------------------------------------------------------
function url_rsync_crack() {
  url_strip_prefix "$1" rsync
}


#---------------------------------------------------------------------
##=item url_rsync_hostname <url>
##
## Gets the hostname for this rsync type url
##
#---------------------------------------------------------------------
function url_rsync_hostname() {
  echo $1|sed 's|^.*//\(.*\)::.*$|\1|'
}

#---------------------------------------------------------------------
##=item url_rsync_netselect <url>
##
## run netselect on the url, this will also expand and rank when there
## are multiple A records
##
#---------------------------------------------------------------------
function url_rsync_netselect() {
  netselect -s 1000 $@ 2>/dev/null
}

#---------------------------------------------------------------------
##=back
##
##=head1 LICENSE
##
## This software is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This software is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this software; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
##
#---------------------------------------------------------------------

