1ab2043b8SDevin Teskeif [ ! "$_TIMEZONE_CONTINENTS_SUBR" ]; then _TIMEZONE_CONTINENTS_SUBR=1 2ab2043b8SDevin Teske# 3*fb1f1beeSDevin Teske# Copyright (c) 2011-2015 Devin Teske 4f8ea072aSDevin Teske# All rights reserved. 5ab2043b8SDevin Teske# 6ab2043b8SDevin Teske# Redistribution and use in source and binary forms, with or without 7ab2043b8SDevin Teske# modification, are permitted provided that the following conditions 8ab2043b8SDevin Teske# are met: 9ab2043b8SDevin Teske# 1. Redistributions of source code must retain the above copyright 10ab2043b8SDevin Teske# notice, this list of conditions and the following disclaimer. 11ab2043b8SDevin Teske# 2. Redistributions in binary form must reproduce the above copyright 12ab2043b8SDevin Teske# notice, this list of conditions and the following disclaimer in the 13ab2043b8SDevin Teske# documentation and/or other materials provided with the distribution. 14ab2043b8SDevin Teske# 15ab2043b8SDevin Teske# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 168e37a7c8SDevin Teske# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17ab2043b8SDevin Teske# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18ab2043b8SDevin Teske# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19ab2043b8SDevin Teske# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 208e37a7c8SDevin Teske# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21ab2043b8SDevin Teske# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22ab2043b8SDevin Teske# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23ab2043b8SDevin Teske# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24ab2043b8SDevin Teske# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25ab2043b8SDevin Teske# SUCH DAMAGE. 26ab2043b8SDevin Teske# 27ab2043b8SDevin Teske# 28ab2043b8SDevin Teske############################################################ INCLUDES 29ab2043b8SDevin Teske 30ab2043b8SDevin TeskeBSDCFG_SHARE="/usr/share/bsdconfig" 31ab2043b8SDevin Teske. $BSDCFG_SHARE/common.subr || exit 1 3256961fd7SDevin Teskef_dprintf "%s: loading includes..." timezone/continents.subr 33ab2043b8SDevin Teske 34ab2043b8SDevin TeskeBSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="090.timezone" 35ab2043b8SDevin Teskef_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr 36ab2043b8SDevin Teske 37ab2043b8SDevin Teske############################################################ CONFIGURATION 38ab2043b8SDevin Teske 39ab2043b8SDevin Teske# 40ab2043b8SDevin Teske# List of worldly continents/oceans (export'ed for awk(1) ENVIRON visibility) 41ab2043b8SDevin Teske# 42ab2043b8SDevin Teskeexport CONTINENTS=" 43ab2043b8SDevin Teske africa 44ab2043b8SDevin Teske america 45ab2043b8SDevin Teske antarctica 46ab2043b8SDevin Teske arctic 47ab2043b8SDevin Teske asia 48ab2043b8SDevin Teske atlantic 49ab2043b8SDevin Teske australia 50ab2043b8SDevin Teske europe 51ab2043b8SDevin Teske indian 52ab2043b8SDevin Teske pacific 53ab2043b8SDevin Teske utc 54ab2043b8SDevin Teske" 55ab2043b8SDevin Teske 56ab2043b8SDevin Teske# 57ab2043b8SDevin Teske# Directory name of each continent/ocean (in _PATH_ZONEINFO) 58ab2043b8SDevin Teske# 59ab2043b8SDevin Teskeexport continent_africa_name="Africa" 60ab2043b8SDevin Teskeexport continent_america_name="America" 61ab2043b8SDevin Teskeexport continent_antarctica_name="Antarctica" 62ab2043b8SDevin Teskeexport continent_arctic_name="Arctic" 63ab2043b8SDevin Teskeexport continent_asia_name="Asia" 64ab2043b8SDevin Teskeexport continent_atlantic_name="Atlantic" 65ab2043b8SDevin Teskeexport continent_australia_name="Australia" 66ab2043b8SDevin Teskeexport continent_europe_name="Europe" 67ab2043b8SDevin Teskeexport continent_indian_name="Indian" 68ab2043b8SDevin Teskeexport continent_pacific_name="Pacific" 69ab2043b8SDevin Teskeexport continent_utc_name="UTC" 70ab2043b8SDevin Teske 71ab2043b8SDevin Teske# 72ab2043b8SDevin Teske# Export i18n menu texts of continents/oceans for awk(1) ENVIRON visibility 73ab2043b8SDevin Teske# NOTE: These are defined in messages.subr included above. 74ab2043b8SDevin Teske# 75ab2043b8SDevin Teskeexport continent_africa_title 76ab2043b8SDevin Teskeexport continent_america_title 77ab2043b8SDevin Teskeexport continent_antarctica_title 78ab2043b8SDevin Teskeexport continent_arctic_title 79ab2043b8SDevin Teskeexport continent_asia_title 80ab2043b8SDevin Teskeexport continent_atlantic_title 81ab2043b8SDevin Teskeexport continent_australia_title 82ab2043b8SDevin Teskeexport continent_europe_title 83ab2043b8SDevin Teskeexport continent_indian_title 84ab2043b8SDevin Teskeexport continent_pacific_title 85ab2043b8SDevin Teskeexport continent_utc_title 86ab2043b8SDevin Teske 87ab2043b8SDevin Teske############################################################ FUNCTIONS 88ab2043b8SDevin Teske 89*fb1f1beeSDevin Teske# f_continent $cont $property [$var_to_set] 90ab2043b8SDevin Teske# 91ab2043b8SDevin Teske# Returns a single property of a given continent. Available properties are: 92ab2043b8SDevin Teske# 93ab2043b8SDevin Teske# name Directory name of continent/ocean as it appears in 94ab2043b8SDevin Teske# _PATH_ZONEINFO. 95ab2043b8SDevin Teske# title Menu text of this continent/ocean to be displayed in the 96ab2043b8SDevin Teske# continent-selection menu. 97ab2043b8SDevin Teske# nitems Number of submenu items associated with this 98ab2043b8SDevin Teske# continent/ocean. 99ab2043b8SDevin Teske# tlc_N 2-character country code of the Nth submenu item associated 100ab2043b8SDevin Teske# with this continent displayed in the country-selection menu 101ab2043b8SDevin Teske# (which appears after continent selection). 102ab2043b8SDevin Teske# menu_list Menu-list of regions for this continent. 103ab2043b8SDevin Teske# 104*fb1f1beeSDevin Teske# If $var_to_set is missing or NULL, the value of $var_to_get is printed to 105*fb1f1beeSDevin Teske# standard output for capturing in a sub-shell (which is less-recommended 106*fb1f1beeSDevin Teske# because of performance degredation; for example, when called in a loop). 107*fb1f1beeSDevin Teske# 108ab2043b8SDevin Teskef_continent() 109ab2043b8SDevin Teske{ 110*fb1f1beeSDevin Teske f_getvar "continent_${1}_$2" $3 111ab2043b8SDevin Teske} 112ab2043b8SDevin Teske 113*fb1f1beeSDevin Teske# f_find_continent $title [$var_to_set] 114ab2043b8SDevin Teske# 115ab2043b8SDevin Teske# Returns continent identifier given continent title. 116ab2043b8SDevin Teske# 117*fb1f1beeSDevin Teske# If $var_to_set is missing or NULL, the value of $var_to_get is printed to 118*fb1f1beeSDevin Teske# standard output for capturing in a sub-shell (which is less-recommended 119*fb1f1beeSDevin Teske# because of performance degredation; for example, when called in a loop). 120*fb1f1beeSDevin Teske# 121ab2043b8SDevin Teskef_find_continent() 122ab2043b8SDevin Teske{ 123*fb1f1beeSDevin Teske local __cont __title 124*fb1f1beeSDevin Teske for __cont in $CONTINENTS; do 125*fb1f1beeSDevin Teske f_continent $__cont title __title 126*fb1f1beeSDevin Teske if [ "$1" = "$__title" ]; then 127*fb1f1beeSDevin Teske if [ "$2" ]; then 128*fb1f1beeSDevin Teske setvar "$2" $__cont 129*fb1f1beeSDevin Teske else 130*fb1f1beeSDevin Teske echo "$__cont" 131*fb1f1beeSDevin Teske fi 132ab2043b8SDevin Teske return $SUCCESS 133ab2043b8SDevin Teske fi 134ab2043b8SDevin Teske done 135ab2043b8SDevin Teske return $FAILURE 136ab2043b8SDevin Teske} 137ab2043b8SDevin Teske 138*fb1f1beeSDevin Teske# f_OCEANP $cont [$var_to_set] 139ab2043b8SDevin Teske# 140ab2043b8SDevin Teske# Returns "1" if the first argument is an ocean, otherwise NULL. 141ab2043b8SDevin Teske# 142*fb1f1beeSDevin Teske# If $var_to_set is missing or NULL, the value of $var_to_get is printed to 143*fb1f1beeSDevin Teske# standard output for capturing in a sub-shell (which is less-recommended 144*fb1f1beeSDevin Teske# because of performance degredation; for example, when called in a loop). 145*fb1f1beeSDevin Teske# 146ab2043b8SDevin Teskef_OCEANP() 147ab2043b8SDevin Teske{ 148ab2043b8SDevin Teske case "$1" in 149ab2043b8SDevin Teske arctic|atlantic|indian|pacific) 150*fb1f1beeSDevin Teske if [ "$2" ]; then 151*fb1f1beeSDevin Teske setvar "$2" 1 152*fb1f1beeSDevin Teske else 153ab2043b8SDevin Teske echo 1 154*fb1f1beeSDevin Teske fi 155*fb1f1beeSDevin Teske ;; 156*fb1f1beeSDevin Teske *) 157*fb1f1beeSDevin Teske [ "$2" ] && setvar "$2" "" 158ab2043b8SDevin Teske esac 159ab2043b8SDevin Teske} 160ab2043b8SDevin Teske 16156961fd7SDevin Teske############################################################ MAIN 16256961fd7SDevin Teske 16356961fd7SDevin Teskef_dprintf "%s: Successfully loaded." timezone/continents.subr 16456961fd7SDevin Teske 165ab2043b8SDevin Teskefi # ! $_TIMEZONE_CONTINENTS_SUBR 166