The ha_get_multi_fields() function obtains the field values from a string, where $1 is the string and $2 is the field name. The string format is a series of name-value field pairs, where a name field is followed by the value of the name, separated by whitespace.
This function is typically used to extract dependency information. There may be multiple fields with the same name so the string returned in HA_FIELD_VALUE may contain multiple values separated by white space. This appears as follows:
ha_get_multi_fields()
{
HA_STR=$1
HA_FIELD_NAME=$2
ha_found=0;
ha_field=1;
for ha_i in $HA_STR
do
if [ $ha_field -eq 1 ]; then
ha_field=0;
if [ $ha_i = $HA_FIELD_NAME ]; then
ha_found=1;
fi
else
ha_field=1;
if [ $ha_found -eq 1 ]; then
if [ -z "$HA_FIELD_VALUE" ]; then
HA_FIELD_VALUE=$ha_i;
else
HA_FIELD_VALUE="$HA_FIELD_VALUE $ha_i";
fi;
ha_found=0;
fi
fi
done
if [ -z "$HA_FIELD_VALUE" ]; then
return 1;
else
return 0;
fi
} |