refcodes-batch.1.0.2.source-code.lib-website-config.inc Maven / Gradle / Ivy
#!/bin/bash
# ------------------------------------------------------------------------------
# This lib relies on the "apply.sh" shell script.
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Gets the top-level-domain from a given domain name and sets it in $TLD:
# $1: The domain name.
# ------------------------------------------------------------------------------
function toTLD {
if [ -z "$1" ] ; then
showError "Argument missing: The function \"toTLD\" expects an argument !!!" >&2
exit $EXIT_BUG
fi
sentence=$1
sentence=${sentence//./$'\n'}
i=1
for word in $sentence
do
case $i in
3) TLD="$word"
;;
4) showError "You provided a wrong format for the passed domain name!"
exit $EXIT_ERROR
;;
esac
i=`expr $i + 1`
done
}
# ------------------------------------------------------------------------------
# Gets the second-level-label from a given domain name and sets it in $SLL:
# $1: The domain name.
# ------------------------------------------------------------------------------
function toSLL {
if [ -z "$1" ] ; then
showError "Argument missing: The function \"toSLL\" expects an argument !!!" >&2
exit $EXIT_BUG
fi
sentence=$1
sentence=${sentence//./$'\n'}
i=1
for word in $sentence
do
case $i in
2) SLL="$word"
;;
4) showError "You provided a wrong format for the passed domain name!"
exit $EXIT_ERROR
;;
esac
i=`expr $i + 1`
done
}
# ------------------------------------------------------------------------------
# Gets the third-level-label from a given domain name:
# $1: The domain name.
# ------------------------------------------------------------------------------
function toTLL {
if [ -z "$1" ] ; then
showError "Argument missing: The function \"toTLL\" expects an argument !!!" >&2
exit $EXIT_BUG
fi
sentence=$1
sentence=${sentence//./$'\n'}
i=1
for word in $sentence
do
case $i in
1) TLL="$word"
;;
4) showError "You provided a wrong format for the passed domain name!"
exit $EXIT_ERROR
;;
esac
i=`expr $i + 1`
done
}