#!/bin/sh

#printf "Content-Type: text/plain\r\n\r\n"

request=server-request
port=4000

list="$QUERY_STRING"

count=0

while [ "$list" != "" ]
do
        item=${list%%&*}
        list=${list#*&}

        if [ "$item" = "$list" ]; then list=""; fi

        case "$item" in
		dev=* ) device[${count}]="${item#*=}" ;;
		val=* ) value[${count}]="${item#*=}" ; count=$((count + 1));;
        esac
done

if [ ${count} -eq 0 ]; then exit 1; fi


string=""
n=0
while [ ${n} -lt ${count} ]
do
        string="${string}${device[${n}]} ${value[${n}]} "
        n=$((n + 1))
done

if [ "${string}" != "" ]
then
        ${request} ${port} "SET-DEVICES-VALUES-NO-LOCK ${string}" nowait
fi
