|
|
eb0e14 |
#!/bin/bash
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# render_doIdentityImageDm.sh -- This function standardize the way of
|
|
|
1b89c2 |
# retrive action values from pre-rendering configuration files. Use
|
|
|
1b89c2 |
# this function whenever you need to retrive action values from
|
|
|
eb0e14 |
# pre-rendering configuration script.
|
|
|
eb0e14 |
#
|
|
|
7cd8e9 |
# Usage:
|
|
|
eb0e14 |
#
|
|
|
7cd8e9 |
# VAR=$(render_getConfOption "ACTION" "FIELD")
|
|
|
eb0e14 |
#
|
|
|
7cd8e9 |
# Where:
|
|
|
eb0e14 |
#
|
|
|
7cd8e9 |
# VAR is the name of the variable you want to store the option
|
|
|
7cd8e9 |
# value retrived from your specification, using
|
|
|
7cd8e9 |
# render_getConfOption's ACTION and FIELD arguments. If there is
|
|
|
1b89c2 |
# no variable assignment, the function outputs the action value
|
|
|
7cd8e9 |
# to standard output without trailing newline.
|
|
|
eb0e14 |
#
|
|
|
7cd8e9 |
# ACTION is the string definition set in the pre-rendering
|
|
|
7cd8e9 |
# configuration script holding the action name and its options
|
|
|
7cd8e9 |
# fields.
|
|
|
eb0e14 |
#
|
|
|
7cd8e9 |
# FIELD is field number in the action string you want to
|
|
|
7cd8e9 |
# retrive option from. By default options start from third field
|
|
|
7cd8e9 |
# on. The first field is reserved for the action type (i.e.,
|
|
|
7cd8e9 |
# BASE, POST, LAST), and the second field is reserved for the
|
|
|
7cd8e9 |
# action itself (e.g., renderImage, renderFormats, etc.). Note
|
|
|
7cd8e9 |
# that this convenction can be altered if the action string has
|
|
|
7cd8e9 |
# been modified (e.g., you stript the BASE field from action
|
|
|
7cd8e9 |
# string) and passed the modified action string to another
|
|
|
7cd8e9 |
# function for processing.
|
|
|
eb0e14 |
#
|
|
|
9f5f2e |
# Copyright (C) 2009-2011 Alain Reguera Delgado
|
|
|
eb0e14 |
#
|
|
|
7cd8e9 |
# This program is free software; you can redistribute it and/or
|
|
|
7cd8e9 |
# modify it under the terms of the GNU General Public License as
|
|
|
7cd8e9 |
# published by the Free Software Foundation; either version 2 of the
|
|
|
7cd8e9 |
# License, or (at your option) any later version.
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# This program is distributed in the hope that it will be useful, but
|
|
|
eb0e14 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
eb0e14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
eb0e14 |
# General Public License for more details.
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# You should have received a copy of the GNU General Public License
|
|
|
eb0e14 |
# along with this program; if not, write to the Free Software
|
|
|
eb0e14 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
eb0e14 |
# USA.
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# ----------------------------------------------------------------------
|
|
|
eb0e14 |
# $Id$
|
|
|
eb0e14 |
# ----------------------------------------------------------------------
|
|
|
eb0e14 |
|
|
|
eb0e14 |
function render_getConfOption {
|
|
|
eb0e14 |
|
|
|
eb0e14 |
local ACTION="$1"
|
|
|
eb0e14 |
local FIELD="$2"
|
|
|
eb0e14 |
local VALUE=''
|
|
|
eb0e14 |
|
|
|
eb0e14 |
# Check action value. The action's value must be present in order
|
|
|
eb0e14 |
# for this function to work. It provides the string needed to
|
|
|
eb0e14 |
# retrive options from.
|
|
|
eb0e14 |
if [[ "$ACTION" == '' ]];then
|
|
|
eb0e14 |
cli_printMessage "`gettext "There is no action to work with."`"
|
|
|
eb0e14 |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
eb0e14 |
fi
|
|
|
eb0e14 |
|
|
|
eb0e14 |
# Check field value. The field's value must match the cut's
|
|
|
eb0e14 |
# command specification of its -f option.
|
|
|
eb0e14 |
if [[ ! "$FIELD" =~ '^([0-9]+|[0-9]+-|-[0-9]+|[0-9]+-[0-9]+)$' ]];then
|
|
|
eb0e14 |
cli_printMessage "`gettext "The field specified is not valid."`"
|
|
|
eb0e14 |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
eb0e14 |
fi
|
|
|
eb0e14 |
|
|
|
eb0e14 |
# Get option from pre-rendering configuration action definition.
|
|
|
eb0e14 |
VALUE=$(echo -n "$ACTION" | cut -d: -f${FIELD})
|
|
|
eb0e14 |
|
|
|
1b89c2 |
# Sanitate action value passed from pre-rendering configuration
|
|
|
eb0e14 |
# action definition.
|
|
|
eb0e14 |
VALUE=$(echo -n "${VALUE}" \
|
|
|
eb0e14 |
| sed -r 's!^ *!!g' \
|
|
|
eb0e14 |
| sed -r 's!( |,|;) *! !g' \
|
|
|
eb0e14 |
| sed -r 's! *$!!g')
|
|
|
eb0e14 |
|
|
|
1b89c2 |
# Output action value without trailing newline.
|
|
|
eb0e14 |
echo -n "$VALUE"
|
|
|
eb0e14 |
|
|
|
eb0e14 |
}
|