All Downloads are FREE. Search and download functionalities are using the official Maven repository.

refcodes-batch.1.0.2.source-code.lib-website-config.inc Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
#!/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
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy