#!/bin/bash
# Bash is required for the base 10 conversion

# Don't eject if flag in place
if [ -f /etc/udev/nokia-zerocd-noeject ]; then
   exit 1
fi

# Compare with device versions from table - treat bcd device as forced base 10,
# to avoid octal interpretation
while read idvendor idproduct bcddevice; do
   if [ "x$2" = "x$idvendor" -a "x$3" = "x$idproduct" -a $((10#0$4)) -le $((10#0$bcddevice)) ]; then
      eject $5
      exit 0
   fi
done < /lib/udev/nokia-testcd.dat

# No match
exit 1
