diff y4-funcs.sh @ 8:3db7524d3dea

Add default images
author HIROSE Yuuji <yuuji@gentei.org>
date Mon, 20 Jul 2015 11:30:39 +0900
parents 7ccd9c2eb97e
children 3565d93c2fb1
line wrap: on
line diff
--- a/y4-funcs.sh	Sun Jul 19 17:02:46 2015 +0900
+++ b/y4-funcs.sh	Mon Jul 20 11:30:39 2015 +0900
@@ -6,7 +6,7 @@
 myargs="$@"
 #bindir=`(cd $mydir/bin; pwd)`
 # :$bindir
-PATH=/usr/local/sqlite3/bin:/usr/local/vim7/bin:/usr/local/ImageMagick/bin:$PATH
+PATH=/usr/local/sqlite3/bin:/usr/local/vim7/bin:/usr/iekei/ImageMagick/bin:/usr/local/ImageMagick/bin:$PATH
 tmpdir=${TMPDIR:-tmp}
 dbdir=${DBDIR:-db}
 tmpfiles=""
@@ -517,7 +517,7 @@
 		 #file=$td/$val
 		 file=$td/`query "select val from $cond $slice;"`
 ####tmp		 [ -s $file -a -s $td/$fn.rowid ] && continue
-		 sq $db<<EOF | xxd -r -p > $file
+		 sq $db<<EOF | unhexize > $file
 .output $td/$fn.rowid
 select rowid from $cond $slice;
 .output $td/$fn
@@ -559,7 +559,7 @@
 		       if [ ! -s $file ]; then
 			## sq $db "select quote(bin) from $cond and val=\"$fn\"" \
 			 query "select quote(bin) from $cond and val=\"$fn\";" \
-			     | xxd -r -p > $file
+			     | unhexize > $file
 			 echo ${type#file:} > $file.content-type
 # err TTTTTTTTTTTTTTTT: $type
 			 case $type in
@@ -631,11 +631,31 @@
     if type xxd >/dev/null 2>&1; then
       hexize="xxd -p"
     else
-      hexize="hexdump -ve '1/1 \"%.2x\"'"
+      hexize_hd() {
+	hexdump -ve '1/1 "%.2x"'
+      }
+      hexize="hexize_hd"
     fi
   fi
   cat $1 | $hexize | tr -d '\n'
 }
+unhexize() {
+  if [ -z "$unhex" ]; then
+    if type xxd >/dev/null 2>&1; then
+      unhex="xxd -p -r"
+    elif type perl >/dev/null 2>&1; then
+      cat >$tmpd/unhex.pl<<EOF
+s/([0-9a-f]{2})/print chr hex \$1/gie
+EOF
+      # Perl refuses -e in setuid circumstances, which can be absurdly
+      # avoided by creating scripts in a file where its parent directory is
+      # world writable...:)
+      unhex="perl -n $tmpd/unhex.pl"
+    fi
+  fi
+  cat $1 | $unhex
+#  cat $1 | tee /tmp/uh.in| $unhex | tee /tmp/uh.out
+}
 percenthex() {
   hexize $1 | sed 's/\(..\)/%\1/g'
 }
@@ -1400,6 +1420,7 @@
   # $1=definition-file
   # Using $user and $session
   rowid=`getpar rowid`
+err ...........rowid=$rowid
   if [ ! -e $1 ]; then
     echo "<p>テーブル定義ファイルが見付かりません</p>"
     exit 1
@@ -1785,7 +1806,7 @@
  <table class="b $2">
 $forms
  </table>$hiddens
- ${rowid:+<input type=\"hidden\" name=\"rowid\" value=\"$rowid\">}
+ ${rowid:+<input type="hidden" name="rowid" value="$rowid">}
 EOF
   if [ -z $GF_VIEWONLY ]; then
     cat<<EOF

yatex.org