[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Audiodo-develop] Speed up command line parsing
From: |
Stefano |
Subject: |
[Audiodo-develop] Speed up command line parsing |
Date: |
Wed, 20 Feb 2002 22:27:15 +0100 |
User-agent: |
Mutt/1.2.5i |
I'm thinking about this code to speed up command line parsing in MP3do.
ConfigMP3do will make a variable called ALL_PARAMETERS_PLUGINS containing
all parameters obtained from PARAMETERS variable of used config plugins.
Unfortunately I must change structure of config plugins, adding a function
called control_variables_<plugin-name> to setup variables needed in
parameter overwriting check (now checking is done for general plugins
too...)
Here is some code:
# This function fill ALL_PARAMETERS_PLUGINS variable and ARR_PLUG_PARAM
# array to use like a pointer to plugin name
make_param () {
IFS="|"
for P in $PARAMETERS; do
IFS=
ALL_PARAMETERS_PLUGINS="$ALL_PARAMETERS_PLUGINS|$P"
indice=${#ALL_PARAMETERS_PLUGINS}
ARR_PLUG_PARAM[$indice]="$1"
done
}
# This function use ARR_PLUG_PARAM array searching for parameter $1 in
# ALL_PARAMETERS_PLUGINS
find_param () {
# To handle short, long and parameters containing ":"
if [ $(expr "$1" : ".*:.*") -eq ${#1} ]; then
f_param="$(echo "$1"|cut -d':' -f1):"
else
f_param=$1
fi
indice=$(expr "$ALL_PARAMETERS_PLUGINS|" : ".*|$f_param|")
if [ $indice -ne 0 ]; then
indice=$[ indice - 1 ]
echo "check_param_${ARR_PLUG_PARAM[$indice]}"
fi
}
# Example of new function to be inserted in cdda2wav config plugin
control_variables_cdda2wav () {
if [ -z "$1" ]; then
EXTENSIONS="CDA"
OUTPUT_FORMATS_cdda2wav="wav cdr au aiff aifc sun raw"
PARAMETERS="cdda:|--cdda-device"
else
unset EXTENSIONS
unset OUTPUT_FORMATS_cdda2wav
unset PARAMETERS
fi
}
# Example of new function to be inserted in atip config plugin
control_variables_atip () {
if [ -z "$1" ]; then
PARAMETERS="-a|--atip"
else
unset PARAMETERS
fi
}
# How to call these functions...
control_variables_cdda2wav
make_param cdda2wav
control_variables_atip
make_param atip
# Now parameter $1 will be VERY quickly found! :-)
find_param "$1"
Some hint?
--
__ _
(__'|_ _ |_'_ _ _
,__)(_,(-'| (_(| )(_)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Audiodo-develop] Speed up command line parsing,
Stefano <=