Scheduler: Added EventId documentation
[senf.git] / doclib / dot
index fca62c8..ba31692 100755 (executable)
@@ -2,4 +2,43 @@
 
 topdir="`dirname "$0"`"; topdir="`cd "$topdir/.."; pwd`"
 "$topdir/doclib/dot-munge.pl" "$1"
-exec dot "$@"
+
+case "$2" in
+    -Tpng:gd)
+       first="$1"; shift; shift
+       set -- "$first" "-Tpng" "$@"
+       ;;
+    *)
+esac
+
+set -e
+
+dot "$@"
+
+case "$4" in
+    *.png)
+       if [ -r "$4" ]; then
+           size="`pngtopnm "$4" | sed -n -e '2p'`"
+           width_a="${size% *}"
+           height_a="${size#* }"
+           if [ $width_a -gt 800 ]; then
+               for file in "${1%.dot}".*; do
+                   cp "$file" "$file.a"
+               done
+               sed -e 's/rankdir=LR/rankdir=TB/' -e t -e 's/rankdir=TB/rankdir=LR/' "$1.a" > "$1"
+               dot "$@"
+               size="`pngtopnm "$4" | sed -n -e '2p'`"
+               width_b="${size% *}"
+               height_b="${size#* }"
+               if [ $width_a -lt $width_b ]; then
+                   for file in "${1%.dot}".*.a; do
+                       mv "$file" "${file%.a}"
+                   done
+               else
+                   rm "${1%.dot}".*.a
+               fi
+           fi
+       fi
+       ;;
+    *)  ;;
+esac