+# --embedded implies --binarylimit
+case $opt_embedded in
+yes) use_embedded=true ;;
+*) use_embedded=false ;;
+esac
+$use_embedded && opt_binarylimit=yes
+
+# Test for binarylimit command in MPD server. We want to minimize data
+# transfer in order to make cache hits as fast as possible.
+#
+# On older servers we can set a ridiculously large offset which causes the
+# server to send no data, but this is rejected by new servers. On new servers
+# we can limit the data transferred explicitly, but not less than 64 bytes
+# for some reason (probably not a big problem).
+
+use_binarylimit=true
+case $opt_binarylimit in
+auto) $MPDEXEC binarylimit 64 2>/dev/null || use_binarylimit=false ;;
+no) use_binarylimit=false ;;
+yes) :;;
+*)
+ print_usage 'invalid --binarylimit argument; must be yes, no or auto' 1>&2
+ exit 1
+esac
+
+if $use_binarylimit; then
+ printf 'binarylimit 64\n' >&3
+ binarylimit_offset=0
+else
+ binarylimit_offset=2147483647
+fi
+
+for file; do
+ case $file in
+ */*) dir=${file%/*}/ ;;
+ *) dir=/ ;;
+ esac
+
+ if $use_embedded; then
+ shift; set x "$@" "$file" "$dir"; shift
+ else
+ file=
+ fi