wok-current rev 21768

sane-backends/sane.cgi: do not limit parameters
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Jun 30 11:35:08 2019 +0200 (2019-06-30)
parents 4d023db68233
children 5b7852dbf3f4
files fake-sane/stuff/sane-fake.log sane-backends/stuff/tazpanel/sane.cgi xscavenger/receipt
line diff
     1.1 --- a/fake-sane/stuff/sane-fake.log	Sat Jun 29 09:29:50 2019 +0100
     1.2 +++ b/fake-sane/stuff/sane-fake.log	Sun Jun 30 11:35:08 2019 +0200
     1.3 @@ -1,1 +1,1 @@
     1.4 -fake-sane/fake:brother:bus1;dev2,[fake] Brother MFC-8420|fake-sane/fake:hpoj:mlc:usb:psc_1200_series,[fake] Hewlett-Packard psc 1200 series|fake-sane/fake:hpaio::usb:PSC_1600_series:serial=MY5CJF3044L0,[fake] hp PSC_1600_series|fake-sane/fake:brother:bus1;dev2.patched,[fake+patched] Brother MFC-8420|fake-sane/fake:hpoj:mlc:usb:psc_1200_series.patched,[fake+patched] Hewlett-Packard psc 1200 series|fake-sane/fake:pixma:04A91709,[fake] PIXMA MP150|
     1.5 +fake-sane/fake:brother:bus1;dev2,[fake] Brother MFC-8420|fake-sane/fake:hpoj:mlc:usb:psc_1200_series,[fake] Hewlett-Packard psc 1200 series|fake-sane/fake:hpaio::usb:PSC_1600_series:serial=MY5CJF3044L0,[fake] hp PSC_1600_series|fake-sane/fake:brother:bus1;dev2.patched,[fake+patched] Brother MFC-8420|fake-sane/fake:hpoj:mlc:usb:psc_1200_series.patched,[fake+patched] Hewlett-Packard psc 1200 series|fake-sane/fake:pixma:04A91709,[fake] CANON PIXMA MP150|
     2.1 --- a/sane-backends/stuff/tazpanel/sane.cgi	Sat Jun 29 09:29:50 2019 +0100
     2.2 +++ b/sane-backends/stuff/tazpanel/sane.cgi	Sun Jun 30 11:35:08 2019 +0200
     2.3 @@ -44,8 +44,18 @@
     2.4  		CMD="$CMD -$i $j"
     2.5  		ARGS="$ARGS $j"
     2.6  	done
     2.7 -	for i in mode source contrast brightness ; do
     2.8 -		[ "$(xPOST $i)" ] && CMD="$CMD --$i '$(xPOST $i)'"
     2.9 +	for i in $(POST) ; do
    2.10 +		case $i in
    2.11 +		preview|format|resolution|res_min|res_max|l_min|l_max);;
    2.12 +		geometry_l|t_min|t_max|geometry_t|x_min|x_max|geometry_x);;
    2.13 +		y_min|y_max|geometry_y|tmpreview|device|params);;
    2.14 +		*)  v="$(xPOST $i)"; i="--${i//_/-}"
    2.15 +		    case "$v" in
    2.16 +			'')	;;
    2.17 +			yes|no) CMD="$CMD $i=$v" ;;
    2.18 +			*)	CMD="$CMD $i '$v'" ;;
    2.19 +		    esac
    2.20 +		esac
    2.21  	done
    2.22  	resolution=${1:-0}
    2.23  	if [ $resolution -eq 0 ]; then
    2.24 @@ -72,12 +82,12 @@
    2.25  ')"
    2.26  		suf="png"; [ "$1" ] && suf="pnm"
    2.27  		cat <<EOT
    2.28 -if convert -crop $c $mode $f /tmp/sane$$.$suf 2> /dev/null ; then
    2.29 +if convert -crop $c $mode $f /tmp/sane$$.$suf ; then
    2.30  	cat /tmp/sane$$.$suf
    2.31  	rm -f /tmp/sane$$.$suf
    2.32  else
    2.33  	cat $f
    2.34 -fi
    2.35 +fi 2> /dev/null
    2.36  EOT
    2.37  		;;
    2.38  	*)	echo -n "scanimage -d '$(echo $device | sed 's/,.*//')' --resolution '$(inrange $resolution $(xPOST res_min) $(xPOST res_max))dpi'$CMD"
    2.39 @@ -165,6 +175,7 @@
    2.40  	eval "$(getgeometry)" > $tmp.pnm 2> $tmp.err
    2.41  	if [ -s "$tmp.pnm" ]; then
    2.42  		convert $tmp.pnm $tmpreview > /dev/null 2>&1 ||
    2.43 +		pnm2png < $tmp.pnm > $tmpreview ||
    2.44  		cp $tmp.pnm $tmpreview
    2.45  	else
    2.46  		error="$(sed 's|$|<br />|' $tmp.err)"
    2.47 @@ -180,6 +191,18 @@
    2.48  [ -n "$error" ] && msg warn "$error"
    2.49  [ -n "$info" ] && msg tip "$info"
    2.50  if [ -z "$device" ]; then
    2.51 +	suggested=""
    2.52 +	while read exe pkg msg; do
    2.53 +		[ "$(which $exe 2> /dev/null)" ] && continue
    2.54 +		suggested="$suggested
    2.55 +<li><a href=\"/user/pkgs.cgi?info=$pkg\">$pkg</a>&nbsp;$msg</li>"
    2.56 +	done <<EOT
    2.57 +convert		imagemagick	$(_ "to preview images and support more image formats (recommended)")
    2.58 +gocr		gocr		$(_ "a basic optical character recognition")
    2.59 +tesseract	tesseract-ocr	$(_ "a better optical character recognition")
    2.60 +EOT
    2.61 +	[ "$suggested" ] &&
    2.62 +	msg tip "$(_ "You may need to install:") <ol>$suggested</ol>"
    2.63  	all="$(scanimage -f '%d,%v %m|'|\
    2.64  		cat - sane-fake.log fake-sane/sane-fake.log |sed 's/|/\n/g')"
    2.65  	case "$(echo "$all" | wc -l)" in
    2.66 @@ -190,20 +213,23 @@
    2.67  			xhtml_footer
    2.68  			exit 0
    2.69  		fi
    2.70 +		if [ "$suggested" ]; then
    2.71 +			cat <<EOT
    2.72 +<section>
    2.73 +	<header>
    2.74 +		<form name="scanner" method="post">
    2.75 +			<input type="hidden" name="device" value="$all">
    2.76 +			Scanner ${all#*,}
    2.77 +			<button data-icon="start">Continue</button>
    2.78 +		</form>
    2.79 +	</header>
    2.80 +</section>
    2.81 +EOT
    2.82 +			xhtml_footer
    2.83 +		exit 0
    2.84 +		fi
    2.85  		device="${all%|}" ;;
    2.86  	*)
    2.87 -		suggested=""
    2.88 -		while read exe pkg msg; do
    2.89 -			[ "$(which $exe 2> /dev/null)" ] && continue
    2.90 -			suggested="$suggested
    2.91 -<li><a href=\"/user/pkgs.cgi?info=$pkg\">$pkg</a>&nbsp;$msg</li>"
    2.92 -		done <<EOT
    2.93 -convert		imagemagick	$(_ "to preview images and support more image formats")
    2.94 -gocr		gocr		$(_ "a basic optical character recognition")
    2.95 -tesseract	tesseract-ocr	$(_ "a better optical character recognition")
    2.96 -EOT
    2.97 -		[ "$suggested" ] &&
    2.98 -		msg tip "$(_ "You may need to install:") <ol>$suggested</ol>"
    2.99  		cat <<EOT
   2.100  <section>
   2.101  	<header>
   2.102 @@ -239,7 +265,7 @@
   2.103  
   2.104  <table style="width:100%">
   2.105  <tr>
   2.106 -<td>
   2.107 +<td title="Sets the file format for the scanned image">
   2.108  <fieldset><legend>$(_ 'Format')</legend>
   2.109  <select name="format" size=1>
   2.110  $(imgformat list)
   2.111 @@ -254,48 +280,63 @@
   2.112  	params="$({
   2.113  cat "$(echo $device | sed 's/,.*//').log" 2> /dev/null ||
   2.114  scanimage --help -d "$(echo $device | sed 's/,.*//')"
   2.115 -} | awk '
   2.116 +} | dos2unix | sed 's|\[=| [|;s/||/|/g' | awk '
   2.117  function minmax()
   2.118  {
   2.119 +	inactive=1
   2.120  	if (match($2,"[0-9]")) {
   2.121  		i=$2; sub(/\.\..*/,"",i)
   2.122  		j=$2; sub(/.*\.\./,"",j)
   2.123  		sub(/\..*/,"",j); sub(/[dm%].*/,"",j)
   2.124  		k=$0; sub(/.* \[/,"",k); sub(/\].*/,"",k)
   2.125 -		print $1 " " int(k) " " int(i) " " int(j)
   2.126 +		printf("\n%s",$1 " " int(k) " " int(i) " " int(j))
   2.127 +		inactive=0
   2.128  	}
   2.129  }
   2.130  
   2.131  function enum()
   2.132  {
   2.133  	i=$0
   2.134 +	inactive=1
   2.135  	if (index(i,"|")) {
   2.136 -		sub(/^ *--*[a-z]* */,"",i)
   2.137 +		sub(/^ *--*[a-z-]* */,"",i)
   2.138 +		sub(/\[\(/,"",i); sub(/\)\]/,"",i)
   2.139  		sub(/dpi .*/,"",i); gsub(/ \[.*\].*/,"",i)
   2.140  		k=$0; sub(/.* \[/,"",k); sub(/\].*/,"",k)
   2.141  		gsub(/ /,"=",k)
   2.142 -		print $1 " " k " enum " i
   2.143 +		gsub(/ /,"=",i)
   2.144 +		printf("\n%s",$1 " " k " enum " i)
   2.145 +		inactive=0
   2.146  	}
   2.147  	else minmax()
   2.148  }
   2.149  
   2.150 -/Options specific to device/ { parse=1 }
   2.151  {
   2.152 +	if (/scanimage --help/) end=1
   2.153 +	if (end != 0) next
   2.154 +	if (/:$/) parse=0
   2.155 +	if (/Scan mode/ || /Mode/ || /Advanced/ || /Geometry/) parse=1
   2.156  	if (parse != 1) next
   2.157 -	if (/\[inactive\]/) next
   2.158 +	if (/\[inactive\]/) { inactive=1; next }
   2.159  	if (match("-l-t-x-y", $1)) minmax()
   2.160 -	if (match("--resolution--brightness--contrast--source--mode", $1)) enum()
   2.161 -}
   2.162 -' | sed 's/||/|/g')"
   2.163 +	else if (/^    --/) enum()
   2.164 +	else if (!/:$/ && inactive == 0) printf(" %s",$0)
   2.165 +} END { print "" }
   2.166 +' | sed 1d)"
   2.167  fi
   2.168 +echo "<!-- $params -->"
   2.169  output="$(n=$(echo "$params" | wc -l); echo "$params" | \
   2.170 -while read name def min max ; do
   2.171 -	name="${name##*-}"
   2.172 +while read name def min max help; do
   2.173 +	name="${name#-}"
   2.174 +	name="${name#-}"
   2.175 +	name="${name//-/_}"
   2.176 +	help="$(echo $help | sed 's|  | |g;s|"|\&#34|g')"
   2.177  	def="${def//=/ }"
   2.178 +	max="${max//=/ }"
   2.179  	if [ "$min" == "enum" ]; then
   2.180  		res_min=1000000
   2.181  		res_max=0
   2.182 -		echo "<td><fieldset><legend>$name</legend>"
   2.183 +		echo "<td title=\"$help\"><fieldset><legend>$name</legend>"
   2.184  		echo -n "<select name=\"$name\" size=1"
   2.185  		[ "$name" == "resolution" ] && echo -n " onchange=showGeometry()"
   2.186  		echo ">"
   2.187 @@ -339,7 +380,7 @@
   2.188  EOT
   2.189  		esac
   2.190  		[ "$name" == "resolution" ] && f="$f onchange=showGeometry()"
   2.191 -		echo "<td>$f type=\"text\" title=\"$min .. $max\" size=4 maxlength=4>$u"
   2.192 +		echo "<td>$f type=\"text\" title=\"$min .. $max. $help\" size=4 maxlength=4>$u"
   2.193  		res_min=$min
   2.194  		res_max=$max
   2.195  	fi
     3.1 --- a/xscavenger/receipt	Sat Jun 29 09:29:50 2019 +0100
     3.2 +++ b/xscavenger/receipt	Sun Jun 30 11:35:08 2019 +0200
     3.3 @@ -6,7 +6,7 @@
     3.4  SHORT_DESC="Lode Runner rewritten for X11."
     3.5  MAINTAINER="pascal.bellard@slitaz.org"
     3.6  LICENSE="GPL2"
     3.7 -WEB_SITE="http://www.xdr.com/dash/scavenger.html"
     3.8 +WEB_SITE="http://www.linuxmotors.com/scavenger/"
     3.9  TARBALL="$PACKAGE-$VERSION.tgz"
    3.10  ARCHIVE="https://web.archive.org/web/20120609005153if_/"
    3.11  WGET_URL="${ARCHIVE}$(dirname $WEB_SITE)/$TARBALL"